Skip to content

Commit

Permalink
add button interrupt
Browse files Browse the repository at this point in the history
  • Loading branch information
cameron-goddard committed Nov 18, 2024
1 parent e263215 commit 32152ac
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define SD_PIN 4

#define LATCH_PIN A4
#define SWITCH_PIN 5
#define BUTTON_PIN 5

#define RED_LED_PIN A0
#define GREEN_LED_PIN A1
Expand Down
8 changes: 8 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,21 @@ IRControlTask ir_control_task;
MotorControlTask motor_control_task;
SDControlTask sd_control_task;

void set_automated() {
sfr::test::automated = true;
set_purple();
}

void setup() {
Serial.begin(9600);

pinMode(RED_LED_PIN, OUTPUT);
pinMode(GREEN_LED_PIN, OUTPUT);
pinMode(BLUE_LED_PIN, OUTPUT);

pinMode(BUTTON_PIN, INPUT);
attachInterrupt(BUTTON_PIN, set_automated, FALLING);

set_white();

imu_monitor.begin();
Expand Down
3 changes: 3 additions & 0 deletions src/sfr.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include "sfr.hpp"

namespace sfr {
namespace test {
volatile bool automated = false;
} // namespace test
namespace ir {
bool is_armed = false;
unsigned long armed_start = 0;
Expand Down
3 changes: 3 additions & 0 deletions src/sfr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#define SFR_HPP

namespace sfr {
namespace test {
extern volatile bool automated;
} // namespace test
namespace ir {
extern bool is_armed;
extern unsigned long armed_start;
Expand Down

0 comments on commit 32152ac

Please sign in to comment.