Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix buttons, fix typo in cameras #92

Merged
merged 4 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 34 additions & 32 deletions console/arduino/buttons_2025/Sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion console/arduino/buttons_2025/buttons_2025.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion raspberry_pi/app/config/identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down