...
 
Commits (4)
#define MODE_OFF 0
#define DEBUG_WITH_BUILTIN_LED false
#define DEBUG_WITH_BUILTIN_LED true
#define PIN_OUT_BUILTIN_LED 7
// Foreground Modes
......@@ -23,16 +23,46 @@
// Blue - 5V Left handlebar grip tactile switch
// Blue striped - 5V Right handlebar grip tactile switch
// 12V
// ===
//
// 1 - Hot 12V Red
// 2.- Negative Blinker L Green
// 3 - Negative Blinker R Yellow
// 4 - Negative Horn Brown
// 5 - Negative ____ White
//
// 3.3V
// ====
//
// 1 - Log Ground
// 2 - In 0
// 3 - In 1
// 4 - In 2
// 5 - Out 3
// 6 - _____
// LLC
// ===
//
// Solid green = 4
// Striped green = 5
// Solid blue = 6
// Striped blue = 7
// Inputs
#define PIN_IN_LEFT_GRIP_BUTTON 0
#define PIN_IN_RIGHT_GRIP_BUTTON 1
#define PIN_IN_HORN_BUTTON 2
#define PIN_IN_EXTRA_BUTTON 3
// Outputs
#define PIN_OUT_SPEAKER 3
#define PIN_OUT_BLINKER_L 4
#define PIN_OUT_BLINKER_R 5
#define PIN_OUT_HORN 6
#define PIN_OUT_EXTRA 7
// Config
#define BLINK_RATE 150
......@@ -78,13 +108,19 @@ void setup()
// Initialize a serial connection for reporting values to the host
Serial.begin(9600);
pinMode(PIN_IN_LEFT_GRIP_BUTTON, INPUT_PULLUP);
pinMode(PIN_IN_LEFT_GRIP_BUTTON, INPUT);
pinMode(PIN_IN_RIGHT_GRIP_BUTTON, INPUT);
pinMode(PIN_IN_HORN_BUTTON, INPUT_PULLUP);
pinMode(PIN_IN_HORN_BUTTON, INPUT);
pinMode(PIN_IN_EXTRA_BUTTON, INPUT);
pinMode(PIN_OUT_SPEAKER, OUTPUT);
pinMode(PIN_OUT_BLINKER_L, OUTPUT);
pinMode(PIN_OUT_BLINKER_R, OUTPUT);
pinMode(PIN_OUT_HORN, OUTPUT);
pinMode(PIN_OUT_EXTRA, OUTPUT);
digitalWrite(PIN_OUT_BLINKER_L, LOW);
digitalWrite(PIN_OUT_BLINKER_R, LOW);
digitalWrite(PIN_OUT_HORN, LOW);
if (digitalRead(PIN_IN_LEFT_GRIP_BUTTON) == LOW) {
firmware_mode = true;
......@@ -104,8 +140,8 @@ void blink_frame(bool left, bool right, int tone_divisor = 2)
blinker_light_state = !blinker_light_state;
}
if (cycle_time == 1 && !blinker_light_state)
blink_speaker_frame(tone_divisor);
/* if (cycle_time == 1 && !blinker_light_state) */
/* blink_speaker_frame(tone_divisor); */
// Actual light
if (left)
......@@ -151,7 +187,7 @@ void blink_speaker_frame(int divisor)
/* if (!blinker_light_state && cycle_time < 40) { */
/* digitalWrite(PIN_OUT_SPEAKER, !(cycle_time % divisor) ? HIGH : LOW); */
/* } */
tone(PIN_OUT_SPEAKER, 2000, 20);
/* tone(PIN_OUT_SPEAKER, 2000, 20); */
}
// Each frame, this increments L/R/B hold time variables while the user is holding a button (or both) down.
......@@ -236,6 +272,7 @@ void reset_all()
digitalWrite(PIN_OUT_BLINKER_L, LOW);
digitalWrite(PIN_OUT_BLINKER_R, LOW);
digitalWrite(PIN_OUT_HORN, LOW);
digitalWrite(PIN_OUT_EXTRA, LOW);
}
void loop()
......@@ -275,7 +312,10 @@ void loop()
// Horn is driven asynchronously from the rest of the blinking logic
if (hold_time[btn_horn] > 0)
{
digitalWrite(PIN_OUT_HORN, HIGH); // TOOOOOOT
digitalWrite(PIN_OUT_BUILTIN_LED, HIGH);
}
else
digitalWrite(PIN_OUT_HORN, LOW);
......