diff --git a/console/arduino/buttons_2025/Sensor.h b/console/arduino/buttons_2025/Sensor.h index aec4789..ad7bd2d 100644 --- a/console/arduino/buttons_2025/Sensor.h +++ b/console/arduino/buttons_2025/Sensor.h @@ -54,42 +54,44 @@ class Sensor { /** * Reads the switch state and writes the values into reportTx. + * + * The GPIOs are pulled up so when the button is pressed, they go low. */ void sense(ReportTx& reportTx) { uint16_t gpio0 = mcp0.readGPIOAB(); uint16_t gpio1 = mcp1.readGPIOAB(); - reportTx.b1 = gpio0 & 0b0000000000000001; - reportTx.b2 = gpio0 & 0b0000000000000010; - reportTx.b3 = gpio0 & 0b0000000000000100; - reportTx.b4 = gpio0 & 0b0000000000001000; - reportTx.b5 = gpio0 & 0b0000000000010000; - reportTx.b6 = gpio0 & 0b0000000000100000; - reportTx.b7 = gpio0 & 0b0000000001000000; - reportTx.b8 = gpio0 & 0b0000000010000000; - reportTx.b9 = gpio0 & 0b0000000100000000; - reportTx.b10 = gpio0 & 0b0000001000000000; - reportTx.b11 = gpio0 & 0b0000010000000000; - reportTx.b12 = gpio0 & 0b0000100000000000; - reportTx.b13 = gpio0 & 0b0001000000000000; - reportTx.b14 = gpio0 & 0b0010000000000000; - reportTx.b15 = gpio0 & 0b0100000000000000; - reportTx.b16 = gpio0 & 0b1000000000000000; - reportTx.b17 = gpio1 & 0b0000000000000001; - reportTx.b18 = gpio1 & 0b0000000000000010; - reportTx.b19 = gpio1 & 0b0000000000000100; - reportTx.b20 = gpio1 & 0b0000000000001000; - reportTx.b21 = gpio1 & 0b0000000000010000; - reportTx.b22 = gpio1 & 0b0000000000100000; - reportTx.b23 = gpio1 & 0b0000000001000000; - reportTx.b24 = gpio1 & 0b0000000010000000; - reportTx.b25 = gpio1 & 0b0000000100000000; - reportTx.b26 = gpio1 & 0b0000001000000000; - reportTx.b27 = gpio1 & 0b0000010000000000; - reportTx.b28 = gpio1 & 0b0000100000000000; - reportTx.b29 = gpio1 & 0b0001000000000000; - reportTx.b30 = gpio1 & 0b0010000000000000; - reportTx.b31 = gpio1 & 0b0100000000000000; - reportTx.b32 = gpio1 & 0b1000000000000000; + reportTx.b1 = !(gpio0 & 0b0000000000000001); + reportTx.b2 = !(gpio0 & 0b0000000000000010); + reportTx.b3 = !(gpio0 & 0b0000000000000100); + reportTx.b4 = !(gpio0 & 0b0000000000001000); + reportTx.b5 = !(gpio0 & 0b0000000000010000); + reportTx.b6 = !(gpio0 & 0b0000000000100000); + reportTx.b7 = !(gpio0 & 0b0000000001000000); + reportTx.b8 = !(gpio0 & 0b0000000010000000); + reportTx.b9 = !(gpio0 & 0b0000000100000000); + reportTx.b10 = !(gpio0 & 0b0000001000000000); + reportTx.b11 = !(gpio0 & 0b0000010000000000); + reportTx.b12 = !(gpio0 & 0b0000100000000000); + reportTx.b13 = !(gpio0 & 0b0001000000000000); + reportTx.b14 = !(gpio0 & 0b0010000000000000); + reportTx.b15 = !(gpio0 & 0b0100000000000000); + reportTx.b16 = !(gpio0 & 0b1000000000000000); + reportTx.b17 = !(gpio1 & 0b0000000000000001); + reportTx.b18 = !(gpio1 & 0b0000000000000010); + reportTx.b19 = !(gpio1 & 0b0000000000000100); + reportTx.b20 = !(gpio1 & 0b0000000000001000); + reportTx.b21 = !(gpio1 & 0b0000000000010000); + reportTx.b22 = !(gpio1 & 0b0000000000100000); + reportTx.b23 = !(gpio1 & 0b0000000001000000); + reportTx.b24 = !(gpio1 & 0b0000000010000000); + reportTx.b25 = !(gpio1 & 0b0000000100000000); + reportTx.b26 = !(gpio1 & 0b0000001000000000); + reportTx.b27 = !(gpio1 & 0b0000010000000000); + reportTx.b28 = !(gpio1 & 0b0000100000000000); + reportTx.b29 = !(gpio1 & 0b0001000000000000); + reportTx.b30 = !(gpio1 & 0b0010000000000000); + reportTx.b31 = !(gpio1 & 0b0100000000000000); + reportTx.b32 = !(gpio1 & 0b1000000000000000); } private: diff --git a/console/arduino/buttons_2025/buttons_2025.ino b/console/arduino/buttons_2025/buttons_2025.ino index 160daae..6d958ac 100644 --- a/console/arduino/buttons_2025/buttons_2025.ino +++ b/console/arduino/buttons_2025/buttons_2025.ino @@ -17,5 +17,5 @@ void loop() { // The sensor has an issue triggered by state changes during I2C transmission: // https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library/issues/96 // To minimize the incidence of that bug, minimize the sample rate. - delay(100); + delay(50); } diff --git a/raspberry_pi/app/config/identity.py b/raspberry_pi/app/config/identity.py index 07a9864..506e9a5 100644 --- a/raspberry_pi/app/config/identity.py +++ b/raspberry_pi/app/config/identity.py @@ -45,7 +45,7 @@ class Identity(Enum): CORAL_LEFT = "8ddb2ed6c49a9bce" #32 CORAL_RIGHT = "364f07fb090a3bf7" #31 SWERVE_LEFT = "8132c256f63bbb4e" #33 - SWERVE_RIGHT = "06ece53b019a5c2e" *34 + SWERVE_RIGHT = "06ece53b019a5c2e" #34 # for testing DEV = "10000000a7c673d9" # rpi4 used for development