From 8c3473cc80f3343ca81ed28d40a5432d77120bd0 Mon Sep 17 00:00:00 2001
From: moon2 <moon2protonmail@protonmail.com>
Date: Sun, 21 May 2023 15:21:13 +0200
Subject: [PATCH] fixed rev1 button bug

---
 components/badge23/spio.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/components/badge23/spio.c b/components/badge23/spio.c
index 8858cf0ab0..0a2a4c387e 100644
--- a/components/badge23/spio.c
+++ b/components/badge23/spio.c
@@ -19,11 +19,11 @@ static int8_t rightbutton = 0;
 static void _init_buttons(){
     //configure all buttons as pullup
     uint64_t mask = 0;
-    mask |= (1 << RIGHT_BUTTON_LEFT);
-    mask |= (1 << RIGHT_BUTTON_RIGHT);
-    mask |= (1 << LEFT_BUTTON_LEFT);
-    mask |= (1 << LEFT_BUTTON_MID);
-    mask |= (1 << LEFT_BUTTON_RIGHT);
+    mask |= (1ULL << RIGHT_BUTTON_LEFT);
+    mask |= (1ULL << RIGHT_BUTTON_RIGHT);
+    mask |= (1ULL << LEFT_BUTTON_LEFT);
+    mask |= (1ULL << LEFT_BUTTON_MID);
+    mask |= (1ULL << LEFT_BUTTON_RIGHT);
     gpio_config_t cfg = {
         .pin_bit_mask = mask,
         .mode = GPIO_MODE_INPUT,
@@ -95,10 +95,10 @@ static void _init_buttons(){
 void update_button_state(){
     uint8_t port;
     esp_err_t ret = i2c_master_read_from_device(I2C_MASTER_NUM, 0b1101101, &port, sizeof(port), TIMEOUT_MS / portTICK_PERIOD_MS);
-    uint8_t rr = port & (1 << RIGHT_BUTTON_RIGHT);
-    uint8_t rm = port & (1 << RIGHT_BUTTON_MID);
-    uint8_t rl = port & (1 << RIGHT_BUTTON_LEFT);
-    uint8_t lr = port & (1 << LEFT_BUTTON_RIGHT);
+    uint8_t rr = port & (1ULL << RIGHT_BUTTON_RIGHT);
+    uint8_t rm = port & (1ULL << RIGHT_BUTTON_MID);
+    uint8_t rl = port & (1ULL << RIGHT_BUTTON_LEFT);
+    uint8_t lr = port & (1ULL << LEFT_BUTTON_RIGHT);
     uint8_t ll = gpio_get_level(LEFT_BUTTON_LEFT);
     uint8_t lm = gpio_get_level(LEFT_BUTTON_MID);
 
-- 
GitLab