feat: save more power by disabling timer, and use gps time for tx interval instead
This commit is contained in:
parent
913ecf3f3f
commit
486715dd5f
1 changed files with 23 additions and 31 deletions
54
src/main.cpp
54
src/main.cpp
|
@ -606,8 +606,15 @@ void readNmeaRmc() {
|
|||
}
|
||||
}
|
||||
}
|
||||
uint32_t now = millis();
|
||||
if ((rmc.valid || SEND_INVALID) && ((now - lastBroadcast) / 1000 > config.interval || lastBroadcast == 0)) {
|
||||
if (rmc.valid || SEND_INVALID) {
|
||||
uint32_t now;
|
||||
now = ((rmc.time[0] - '0') * 10 + (rmc.time[1] - '0')) * 3600; // h
|
||||
now += ((rmc.time[2] - '0') * 10 + (rmc.time[3] - '0')) * 60; // m
|
||||
now += ((rmc.time[4] - '0') * 10 + (rmc.time[5] - '0')); // s
|
||||
uint32_t interval = (((now - lastBroadcast) % 86400) + 86400) % 86400;
|
||||
if (interval < config.interval) {
|
||||
return;
|
||||
}
|
||||
lastBroadcast = now;
|
||||
char aprs[256];
|
||||
if (rmc.valid) {
|
||||
|
@ -695,34 +702,6 @@ void setup() {
|
|||
|
||||
void loop() {
|
||||
readNmeaRmc();
|
||||
uint32_t now = millis();
|
||||
#ifdef GPSM_L80R
|
||||
// L80-R: Wake up the module if config.interval has expired - wakeup happens on any serial activity
|
||||
if ((now - lastBroadcast) > config.interval) {
|
||||
Serial.print("\r");
|
||||
Serial.flush();
|
||||
}
|
||||
#endif
|
||||
if (abcPressed || setPressed) {
|
||||
lastPressed = now;
|
||||
}
|
||||
if (off) {
|
||||
if (abcPressed || setPressed) {
|
||||
off = false;
|
||||
abcPressed = false;
|
||||
setPressed = false;
|
||||
if (editingConfig || editingComment) {
|
||||
lcd.blink();
|
||||
}
|
||||
lcd.backlight();
|
||||
lcd.display();
|
||||
}
|
||||
} else {
|
||||
if (now - lastPressed > 30000) {
|
||||
off = true;
|
||||
lcd.noDisplay();
|
||||
lcd.noBacklight();
|
||||
}
|
||||
if (editingConfig) {
|
||||
editConfig();
|
||||
return;
|
||||
|
@ -756,6 +735,19 @@ void loop() {
|
|||
} else if (page == 3) {
|
||||
printDateTime();
|
||||
}
|
||||
LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
|
||||
if (!abcPressed && !setPressed) {
|
||||
off = true;
|
||||
lcd.noDisplay();
|
||||
lcd.noBacklight();
|
||||
} else if (off) {
|
||||
off = false;
|
||||
abcPressed = false;
|
||||
setPressed = false;
|
||||
if (editingConfig || editingComment) {
|
||||
lcd.blink();
|
||||
}
|
||||
lcd.backlight();
|
||||
lcd.display();
|
||||
}
|
||||
LowPower.idle(SLEEP_FOREVER, ADC_OFF, TIMER2_OFF, TIMER1_OFF, TIMER0_ON, SPI_OFF, USART0_ON, TWI_OFF);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue