mirror of
https://github.com/brendanhaines/Hohm-Phone.git
synced 2024-12-26 10:57:36 -07:00
adds charging handling logic
This commit is contained in:
parent
d01b9fd99c
commit
6c35e0f594
|
@ -22,6 +22,11 @@
|
||||||
// TIMEOUT_SLEEP is the time to stay awake from last activity until sleep (milliseconds)
|
// TIMEOUT_SLEEP is the time to stay awake from last activity until sleep (milliseconds)
|
||||||
#define TIMEOUT_SLEEP 6000
|
#define TIMEOUT_SLEEP 6000
|
||||||
|
|
||||||
|
// Charging voltage thresholds. Will turn on charging at CHG_VLO and turn off charging at CHG_VHI (millivolts)
|
||||||
|
#define CHG_VLO 3900
|
||||||
|
#define CHG_VHI 4100
|
||||||
|
#define CHG_PIN A0
|
||||||
|
|
||||||
// Comment the following line to use HW serial for Fona and disable debugging information
|
// Comment the following line to use HW serial for Fona and disable debugging information
|
||||||
#define USB_DEBUG
|
#define USB_DEBUG
|
||||||
|
|
||||||
|
@ -144,9 +149,11 @@ void setup() {
|
||||||
pinMode( GSM_RST, OUTPUT );
|
pinMode( GSM_RST, OUTPUT );
|
||||||
pinMode( GSM_RING, INPUT_PULLUP );
|
pinMode( GSM_RING, INPUT_PULLUP );
|
||||||
pinMode( GSM_KEY, OUTPUT );
|
pinMode( GSM_KEY, OUTPUT );
|
||||||
|
pinMode( CHG_PIN, OUTPUT );
|
||||||
|
|
||||||
digitalWrite( GSM_KEY, LOW );
|
digitalWrite( GSM_KEY, LOW );
|
||||||
digitalWrite( GSM_RST, HIGH );
|
digitalWrite( GSM_RST, HIGH );
|
||||||
|
digitalWrite( CHG_PIN, HIGH );
|
||||||
|
|
||||||
fonaSerial->begin(4800);
|
fonaSerial->begin(4800);
|
||||||
if (! fona.begin(*fonaSerial)) {
|
if (! fona.begin(*fonaSerial)) {
|
||||||
|
@ -222,6 +229,14 @@ void loop() {
|
||||||
resumeDialtone();
|
resumeDialtone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t vbat;
|
||||||
|
fona.getBattVoltage(&vbat);
|
||||||
|
if ( vbat < CHG_VLO ) {
|
||||||
|
digitalWrite( CHG_PIN, HIGH );
|
||||||
|
} else if ( vbat > CHG_VHI ) {
|
||||||
|
digitalWrite( CHG_PIN, LOW );
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef SLEEP
|
#ifdef SLEEP
|
||||||
// Autoshutdown if inactive for extended period
|
// Autoshutdown if inactive for extended period
|
||||||
// Typecast to long avoids "rollover" issues
|
// Typecast to long avoids "rollover" issues
|
||||||
|
|
Loading…
Reference in New Issue
Block a user