Disable sleep temporarily, swap to SPST switches, update to do, tweak sleep logic
This commit is contained in:
parent
ac9fbda27d
commit
29f1048ec7
2
TODO.md
2
TODO.md
|
@ -3,4 +3,6 @@
|
||||||
* Need to add support for Adafruit Trinket Pro
|
* Need to add support for Adafruit Trinket Pro
|
||||||
* Add note about adjusting values for distance
|
* Add note about adjusting values for distance
|
||||||
* Finish Fritzing documentation (breadboard / schematic)
|
* Finish Fritzing documentation (breadboard / schematic)
|
||||||
|
* Switch to SPST switches
|
||||||
|
* Add door sensor (NO reed switch as a fallback)
|
||||||
* Bill of Materials for all pieces/parts/etc
|
* Bill of Materials for all pieces/parts/etc
|
||||||
|
|
12
src/src.ino
12
src/src.ino
|
@ -11,7 +11,7 @@
|
||||||
// Various defines / pins / etc
|
// Various defines / pins / etc
|
||||||
#define DEBUG true
|
#define DEBUG true
|
||||||
#define INTERACTIVE_DEBUG false
|
#define INTERACTIVE_DEBUG false
|
||||||
#define USE_SLEEP true
|
#define USE_SLEEP false
|
||||||
#define SLEEP_INTERVAL 1000 // miliseconds
|
#define SLEEP_INTERVAL 1000 // miliseconds
|
||||||
#define ALERT_LEVEL 15 // battery alert level (%)
|
#define ALERT_LEVEL 15 // battery alert level (%)
|
||||||
#define POT_BRIGHT A0
|
#define POT_BRIGHT A0
|
||||||
|
@ -52,8 +52,8 @@ void setup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup various digital/analog inputs
|
// Setup various digital/analog inputs
|
||||||
pinMode(PIN_ALWAYS_ON, INPUT);
|
pinMode(PIN_ALWAYS_ON, INPUT_PULLUP);
|
||||||
pinMode(PIN_WHITE, INPUT);
|
pinMode(PIN_WHITE, INPUT_PULLUP);
|
||||||
pinMode(PIN_DOOR, INPUT_PULLUP);
|
pinMode(PIN_DOOR, INPUT_PULLUP);
|
||||||
pinMode(POT_BRIGHT, INPUT);
|
pinMode(POT_BRIGHT, INPUT);
|
||||||
pinMode(POT_COLOR, INPUT);
|
pinMode(POT_COLOR, INPUT);
|
||||||
|
@ -96,8 +96,8 @@ void loop() {
|
||||||
}
|
}
|
||||||
brightness = map(analogRead(POT_BRIGHT), 0, 1024, 0, 255); // Brightness (0-1023) mapped to 0-255
|
brightness = map(analogRead(POT_BRIGHT), 0, 1024, 0, 255); // Brightness (0-1023) mapped to 0-255
|
||||||
raw_color = analogRead(POT_COLOR); // Color (0-1024)
|
raw_color = analogRead(POT_COLOR); // Color (0-1024)
|
||||||
always_on = (digitalRead(PIN_ALWAYS_ON) == HIGH); // Toggle button pressed == ALWAYS ON
|
always_on = (digitalRead(PIN_ALWAYS_ON) == LOW); // Toggle button pressed == ALWAYS ON
|
||||||
white = (digitalRead(PIN_WHITE) == HIGH); // Shorted pin to enable white color for LEDs
|
white = (digitalRead(PIN_WHITE) == LOW); // Shorted pin to enable white color for LEDs
|
||||||
door_open = (digitalRead(PIN_DOOR) == HIGH); // SparkFun door sensor is indicating door is open (NO for door closed state, set as input_pullup so the logic is inverted)
|
door_open = (digitalRead(PIN_DOOR) == HIGH); // SparkFun door sensor is indicating door is open (NO for door closed state, set as input_pullup so the logic is inverted)
|
||||||
|
|
||||||
// Set RGB array to values as appropriate
|
// Set RGB array to values as appropriate
|
||||||
|
@ -151,7 +151,7 @@ void loop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sleep mode enabled
|
// Sleep mode enabled
|
||||||
if (USE_SLEEP && !always_on && !door_open) { // Don't enable sleep if always on toggle is set
|
if (USE_SLEEP && !always_on) { // Don't enable sleep if always on toggle is set
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Serial.println("SLEEPING!");
|
Serial.println("SLEEPING!");
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue