...
 
Commits (2)
#define MODE_OFF 0
#define DEBUG_WITH_BUILTIN_LED false
#define PIN_OUT_BUILTIN_LED 7
// Foreground Modes
#define FG_MODE_BLINK_L 1
......@@ -23,21 +24,21 @@
// Blue striped - 5V Right handlebar grip tactile switch
// Inputs
#define PIN_IN_LEFT_GRIP_BUTTON 1
#define PIN_IN_RIGHT_GRIP_BUTTON 2
#define PIN_IN_HORN_BUTTON 3
#define PIN_IN_LEFT_GRIP_BUTTON 0
#define PIN_IN_RIGHT_GRIP_BUTTON 1
#define PIN_IN_HORN_BUTTON 2
// Outputs
#define PIN_OUT_SPEAKER 4
#define PIN_OUT_BLINKER_L 7
#define PIN_OUT_BLINKER_R 6
#define PIN_OUT_HORN 5
#define PIN_OUT_SPEAKER 3
#define PIN_OUT_BLINKER_L 4
#define PIN_OUT_BLINKER_R 5
#define PIN_OUT_HORN 6
// Config
#define BLINK_RATE 250
#define RUNNING_LIGHT_BLINK_RATE 920
#define HOLD_DOWN_TIME 500
#define DEBOUNCE_COOLDOWN_TIME 200
#define BLINK_RATE 150
#define RUNNING_LIGHT_BLINK_RATE 820
#define HOLD_DOWN_TIME 400
#define DEBOUNCE_COOLDOWN_TIME 100
// State
int fg_mode = MODE_OFF;
......@@ -78,7 +79,7 @@ void setup()
Serial.begin(9600);
pinMode(PIN_IN_LEFT_GRIP_BUTTON, INPUT_PULLUP);
pinMode(PIN_IN_RIGHT_GRIP_BUTTON, INPUT_PULLUP);
pinMode(PIN_IN_RIGHT_GRIP_BUTTON, INPUT);
pinMode(PIN_IN_HORN_BUTTON, INPUT_PULLUP);
pinMode(PIN_OUT_SPEAKER, OUTPUT);
......@@ -114,7 +115,7 @@ void blink_frame(bool left, bool right, int tone_divisor = 2)
digitalWrite(PIN_OUT_BLINKER_R, blinker_light_state ? LOW : HIGH);
#if DEBUG_WITH_BUILTIN_LED
digitalWrite(LED_BUILTIN, blinker_light_state ? LOW : HIGH);
digitalWrite(PIN_OUT_BUILTIN_LED, blinker_light_state ? LOW : HIGH);
#endif
cycle_time++;
......@@ -129,7 +130,7 @@ void running_light_frame(bool with_blink = false)
digitalWrite(PIN_OUT_BLINKER_R, !(cycle_time % 20) || (with_blink && cycle_time < 70) ? HIGH : LOW);
#if DEBUG_WITH_BUILTIN_LED
digitalWrite(LED_BUILTIN, !(cycle_time % 20) || (with_blink && cycle_time < 70) ? HIGH : LOW);
digitalWrite(PIN_OUT_BUILTIN_LED, !(cycle_time % 20) || (with_blink && cycle_time < 70) ? HIGH : LOW);
#endif
cycle_time++;
......@@ -141,7 +142,7 @@ void auxiliary_light_frame()
digitalWrite(PIN_OUT_BLINKER_R, HIGH);
#if DEBUG_WITH_BUILTIN_LED
digitalWrite(LED_BUILTIN, HIGH);
digitalWrite(PIN_OUT_BUILTIN_LED, HIGH);
#endif
}
......@@ -229,7 +230,7 @@ void reset_all()
blinker_light_state = 0;
#if DEBUG_WITH_BUILTIN_LED
digitalWrite(LED_BUILTIN, LOW);
digitalWrite(PIN_OUT_BUILTIN_LED, LOW);
#endif
digitalWrite(PIN_OUT_BLINKER_L, LOW);
......