Added notes about values to tweak, fixed bug with fuel gauge implementation, added interactive debugging flag

This commit is contained in:
Mike C 2015-08-04 23:32:41 -04:00
parent 7a69f68eb4
commit 76252f6f8d
4 changed files with 24 additions and 5 deletions

View file

@ -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.

View file

@ -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

View file

@ -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);

View file

@ -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!");