Minor variable name refactor, updated ToDo, added place holder definition for SparkFun door sensor
This commit is contained in:
parent
916da9d3af
commit
67e7c21fdf
1
TODO.md
1
TODO.md
|
@ -3,3 +3,4 @@
|
|||
* Need to add support for Adafruit Trinket Pro
|
||||
* Add note about adjusting values for distance
|
||||
* Finish Fritzing documentation (breadboard / schematic)
|
||||
* Bill of Materials for all pieces/parts/etc
|
||||
|
|
26
src/src.ino
26
src/src.ino
|
@ -9,17 +9,18 @@
|
|||
#endif
|
||||
|
||||
// Various defines / pins / etc
|
||||
#define DEBUG false
|
||||
#define DEBUG true
|
||||
#define INTERACTIVE_DEBUG false
|
||||
#define USE_SLEEP true
|
||||
#define SLEEP_INTERVAL 1000 // miliseconds
|
||||
#define ALERT_LEVEL 15 // battery alert level (%)
|
||||
#define BUTTON_CAP_TOGGLE 9
|
||||
#define POT_BRIGHT_PIN A0
|
||||
#define POT_COLOR_PIN A1
|
||||
#define NEO_PIN 6
|
||||
#define POT_BRIGHT A0
|
||||
#define POT_COLOR A1
|
||||
#define PIN_ALWAYS_ON 9 // Switch that enables always on/off of pixels
|
||||
#define PIN_NEO 6 // Pin with the pixel comm line
|
||||
#define NEO_PIX_NUM 2 // FIXME: this should be 5 for final build for safe lighting
|
||||
#define PIN_WHITE 12 // Short Vout to this pin to change color to white
|
||||
#define PIN_DOOR 11 // Door sensor pin
|
||||
|
||||
// Objects / values / etc
|
||||
MAX1704 fuelGauge;
|
||||
|
@ -28,7 +29,7 @@ uint8_t brightness;
|
|||
uint16_t raw_color;
|
||||
uint8_t color;
|
||||
bool always_on = false;
|
||||
Adafruit_NeoPixel neopix = Adafruit_NeoPixel(NEO_PIX_NUM, NEO_PIN, NEO_GRB + NEO_KHZ800);
|
||||
Adafruit_NeoPixel neopix = Adafruit_NeoPixel(NEO_PIX_NUM, PIN_NEO, NEO_GRB + NEO_KHZ800);
|
||||
uint8_t rgb[3]; // index 0 = red / index 1 = green / index 2 = blue
|
||||
bool white = false;
|
||||
bool max_found = false;
|
||||
|
@ -50,10 +51,11 @@ void setup() {
|
|||
}
|
||||
|
||||
// Setup various digital/analog inputs
|
||||
pinMode(BUTTON_CAP_TOGGLE, INPUT);
|
||||
pinMode(POT_BRIGHT_PIN, INPUT);
|
||||
pinMode(POT_COLOR_PIN, INPUT);
|
||||
pinMode(PIN_ALWAYS_ON, INPUT);
|
||||
pinMode(PIN_WHITE, INPUT);
|
||||
pinMode(PIN_DOOR, INPUT);
|
||||
pinMode(POT_BRIGHT, INPUT);
|
||||
pinMode(POT_COLOR, INPUT);
|
||||
|
||||
// Setup / config MAX1704
|
||||
Wire.beginTransmission(MAX1704_ADDR);
|
||||
|
@ -91,9 +93,9 @@ void loop() {
|
|||
if (max_found) {
|
||||
charge_percent = fuelGauge.stateOfCharge(); // Battery level
|
||||
}
|
||||
brightness = map(analogRead(POT_BRIGHT_PIN), 0, 1024, 0, 255); // Brightness (0-1023) mapped to 0-255
|
||||
raw_color = analogRead(POT_COLOR_PIN); // Color (0-1024)
|
||||
always_on = (digitalRead(BUTTON_CAP_TOGGLE) == HIGH); // Toggle button pressed == ALWAYS ON
|
||||
brightness = map(analogRead(POT_BRIGHT), 0, 1024, 0, 255); // Brightness (0-1023) mapped to 0-255
|
||||
raw_color = analogRead(POT_COLOR); // Color (0-1024)
|
||||
always_on = (digitalRead(PIN_ALWAYS_ON) == HIGH); // Toggle button pressed == ALWAYS ON
|
||||
white = (digitalRead(PIN_WHITE) == HIGH); // Shorted pin to enable white color for LEDs
|
||||
|
||||
// Set RGB array to values as appropriate
|
||||
|
|
Reference in a new issue