Update MightyHat example

This commit is contained in:
LowPowerLab 2015-12-17 10:01:00 -05:00
parent 5387bcd167
commit 301a56ac00
1 changed files with 14 additions and 2 deletions

View File

@ -47,6 +47,7 @@
#define ENCRYPTKEY "sampleEncryptKey" //has to be same 16 characters/bytes on all nodes, not more not less! #define ENCRYPTKEY "sampleEncryptKey" //has to be same 16 characters/bytes on all nodes, not more not less!
#define IS_RFM69HW //uncomment only for RFM69HW! Leave out if you have RFM69W! #define IS_RFM69HW //uncomment only for RFM69HW! Leave out if you have RFM69W!
//#define ENABLE_ATC //comment out this line to disable AUTO TRANSMISSION CONTROL //#define ENABLE_ATC //comment out this line to disable AUTO TRANSMISSION CONTROL
//#define ENABLE_WIRELESS_PROGRAMMING //comment out this line to disable Wireless Programming of this gateway
//***************************************************************************************************************************** //*****************************************************************************************************************************
#define ACK_TIME 30 // # of ms to wait for an ack #define ACK_TIME 30 // # of ms to wait for an ack
#define SERIAL_BAUD 115200 #define SERIAL_BAUD 115200
@ -79,7 +80,7 @@
// trigger a shutdown to the target device once voltage is around 3.4v to allow 30sec safe shutdown // trigger a shutdown to the target device once voltage is around 3.4v to allow 30sec safe shutdown
#define BATTERY_VOLTS(analog_reading) analog_reading * 0.00322 * 1.51 // 100/66 is the inverse ratio of the voltage divider ( Batt > 1MEG > A7 > 2MEG > GND ) #define BATTERY_VOLTS(analog_reading) analog_reading * 0.00322 * 1.51 // 100/66 is the inverse ratio of the voltage divider ( Batt > 1MEG > A7 > 2MEG > GND )
#define LOWBATTERYTHRESHOLD 3.65 // a shutdown will be triggered to the target device when battery voltage drops below this (Volts) #define LOWBATTERYTHRESHOLD 3.5 // a shutdown will be triggered to the target device when battery voltage drops below this (Volts)
#define CHARGINGTHRESHOLD 4.3 #define CHARGINGTHRESHOLD 4.3
#define RESETHOLDTIME 500 // Button must be hold this many mseconds before a reset is issued (should be much less than SHUTDOWNHOLDTIME) #define RESETHOLDTIME 500 // Button must be hold this many mseconds before a reset is issued (should be much less than SHUTDOWNHOLDTIME)
#define SHUTDOWNHOLDTIME 2000 // Button must be hold this many mseconds before a shutdown sequence is started (should be much less than ForcedShutoffDelay) #define SHUTDOWNHOLDTIME 2000 // Button must be hold this many mseconds before a shutdown sequence is started (should be much less than ForcedShutoffDelay)
@ -473,6 +474,12 @@ void handlePowerControl() {
POWER(PowerState); POWER(PowerState);
} }
if (PowerState == OFF)
{
sprintf(lcdbuff, "Pi is now OFF");
refreshLCD();
}
digitalWrite(SIG_SHUTOFF, LOW); digitalWrite(SIG_SHUTOFF, LOW);
//DEBUGln("SIG_SHUTOFF - LOW"); //DEBUGln("SIG_SHUTOFF - LOW");
} }
@ -496,6 +503,8 @@ void handlePowerControl() {
//TODO: add blinking here to signal final shutdown delay //TODO: add blinking here to signal final shutdown delay
PowerState = OFF; PowerState = OFF;
POWER(PowerState); POWER(PowerState);
sprintf(lcdbuff, "Pi is now OFF");
refreshLCD();
break; break;
} }
} }
@ -612,7 +621,10 @@ void loop() {
} }
//check if the packet is a wireless programming request //check if the packet is a wireless programming request
//removing this line will save 3kb+ of flash space
#ifdef ENABLE_WIRELESS_PROGRAMMING
CheckForWirelessHEX(radio, flash, false); //non verbose DEBUG CheckForWirelessHEX(radio, flash, false); //non verbose DEBUG
#endif
//respond to any ACK if requested //respond to any ACK if requested
if (radio.ACKRequested()) if (radio.ACKRequested())
@ -627,4 +639,4 @@ void loop() {
} }
if (readBattery() || newPacketReceived) refreshLCD(); if (readBattery() || newPacketReceived) refreshLCD();
//LCD_BACKLIGHT(batteryLow ? 0 : 1); //LCD_BACKLIGHT(batteryLow ? 0 : 1);
} }