Added notes about values to tweak, fixed bug with fuel gauge implementation, added interactive debugging flag
This commit is contained in:
parent
7a69f68eb4
commit
76252f6f8d
|
@ -2,6 +2,13 @@ Overview
|
|||
=
|
||||
This project is a basic lighting system that can be used with smaller SentrySafe products such as the X125 model.
|
||||
|
||||
Config
|
||||
=
|
||||
In the code you'll find the following variables which may need tweaking
|
||||
|
||||
* SLEEP_INTERVAL : The amount of time (in miliseconds) that the device sleeps for between checks
|
||||
* ALERT_LEVEL : The battery level that generates an alert. This must be set between 1 and 32%, inclusive
|
||||
|
||||
Code License
|
||||
=
|
||||
All code is licensed under the Apache 2 License (http://www.apache.org/licenses/LICENSE-2.0) unless otherwise specified.
|
||||
|
|
2
TODO.md
2
TODO.md
|
@ -2,4 +2,4 @@
|
|||
* Need to implement "always on toggle"
|
||||
* Need to implement PIR distance sensor to verify door of safe closed
|
||||
* Need to add support for Adafruit Trinket Pro
|
||||
* Add note about adjusting values for distance, use sleep, alert threshold (if using fuel gauge)
|
||||
* Add note about adjusting values for distance
|
||||
|
|
|
@ -75,7 +75,6 @@ char MAX1704::version(){
|
|||
}
|
||||
|
||||
void MAX1704::setAlertThreshold(uint8_t level){
|
||||
|
||||
Wire.beginTransmission(MAX1704_ADDR);
|
||||
Wire.write(MAX1704_CONFIG);
|
||||
Wire.write(MAX1704_ALERT_LEVEL);
|
||||
|
|
19
src/src.ino
19
src/src.ino
|
@ -10,8 +10,10 @@
|
|||
|
||||
// Various defines / pins / etc
|
||||
#define DEBUG true
|
||||
#define INTERACTIVE_DEBUG true
|
||||
#define USE_SLEEP false
|
||||
#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
|
||||
|
@ -41,7 +43,9 @@ void setup() {
|
|||
|
||||
// Setup serial and wait for console
|
||||
if (DEBUG) {
|
||||
//while(!Serial);
|
||||
if (INTERACTIVE_DEBUG) {
|
||||
while(!Serial);
|
||||
}
|
||||
Serial.println("Starting up...");
|
||||
}
|
||||
|
||||
|
@ -54,9 +58,12 @@ void setup() {
|
|||
// Setup / config MAX1704
|
||||
Wire.beginTransmission(MAX1704_ADDR);
|
||||
max_found = (Wire.endTransmission() == 0);
|
||||
if (max_found == 0) {
|
||||
if (max_found) {
|
||||
fuelGauge.reset();
|
||||
fuelGauge.quickStart();
|
||||
fuelGauge.awake(); // In case it was turned off when sleep was enabled
|
||||
delay(250); // Wait for it to settle before writing config value
|
||||
fuelGauge.setAlertThreshold(ALERT_LEVEL);
|
||||
}
|
||||
|
||||
// AdaFruit NeoPixel init
|
||||
|
@ -73,7 +80,11 @@ void setup() {
|
|||
fuelGauge.showConfig();
|
||||
Serial.println("----------");
|
||||
}
|
||||
}
|
||||
|
||||
if (INTERACTIVE_DEBUG) {
|
||||
while(!Serial.available());
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Read various values needed
|
||||
|
@ -107,6 +118,8 @@ void loop() {
|
|||
if (max_found) {
|
||||
Serial.print("Battery %: ");
|
||||
Serial.println(charge_percent);
|
||||
Serial.print("Alert level: ");
|
||||
Serial.println(fuelGauge.alertThreshold());
|
||||
}
|
||||
else {
|
||||
Serial.println("MAX1704 not found!");
|
||||
|
|
Reference in a new issue