fix: idle mode was not always activated
This commit is contained in:
parent
4ea4d52be0
commit
f6fbc29fde
2 changed files with 59 additions and 35 deletions
|
@ -15,6 +15,7 @@ framework = arduino
|
|||
lib_deps =
|
||||
https://github.com/marcoschwartz/LiquidCrystal_I2C
|
||||
https://github.com/rocketscream/Low-Power
|
||||
build_flags = -DGPSM_UBLOX6
|
||||
upload_protocol = custom
|
||||
upload_flags =
|
||||
-C
|
||||
|
|
27
src/main.cpp
27
src/main.cpp
|
@ -529,6 +529,11 @@ void readNmeaRmc() {
|
|||
}
|
||||
}
|
||||
if (nmeaState == 2) {
|
||||
#ifdef GPSM_L80R
|
||||
// L80-R: Send GPS module into standby mode
|
||||
Serial.println("$PMTK161,0*28");
|
||||
Serial.flush();
|
||||
#endif
|
||||
char buf[16];
|
||||
char *bptr = buf;
|
||||
uint8_t counter = 0;
|
||||
|
@ -642,6 +647,7 @@ void readNmeaRmc() {
|
|||
}
|
||||
|
||||
void setup() {
|
||||
#if defined(GPSM_UBLOX6)
|
||||
Serial.begin(9600);
|
||||
// ublox NEO-6M: Switch to low-power on-off mode with peak current limiting - not sure if this actually works
|
||||
Serial.print("\xb5\x62\x06\x3b\x2c\x00\x01\x06\x00\x00\x0e\x81\x00\x00\x60\xea\x00\x00\x10\x27\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x2c\x01\x00\x00\x4f\xc1\x03\x00\x86\x02\x00\x00\xfe\x00\x00\x00\x64\x40\x01\x00\xf1\xd5");
|
||||
|
@ -653,6 +659,15 @@ void setup() {
|
|||
Serial.println("$PUBX,40,VTG,0,0,0,0,0,0*5E");
|
||||
Serial.println("$PUBX,40,GGA,0,0,0,0,0,0*5A");
|
||||
Serial.flush();
|
||||
#elif defined(GPSM_L80R)
|
||||
Serial.begin(9600);
|
||||
// L80-R: Disable all NMEA sentences except for GPRMC
|
||||
Serial.println("$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29");
|
||||
Serial.flush();
|
||||
#else
|
||||
// Assume NMEA-0183 default baud rate of 4800
|
||||
Serial.begin(4800);
|
||||
#endif
|
||||
OUT_DDR |= 0x0f;
|
||||
pinMode(PTT, OUTPUT);
|
||||
digitalWrite(PTT, LOW);
|
||||
|
@ -675,6 +690,13 @@ 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;
|
||||
}
|
||||
|
@ -689,8 +711,8 @@ void loop() {
|
|||
lcd.backlight();
|
||||
lcd.display();
|
||||
}
|
||||
return;
|
||||
} else if (now - lastPressed > 30000) {
|
||||
} else {
|
||||
if (now - lastPressed > 30000) {
|
||||
off = true;
|
||||
lcd.noDisplay();
|
||||
lcd.noBacklight();
|
||||
|
@ -728,5 +750,6 @@ void loop() {
|
|||
} else if (page == 3) {
|
||||
printDateTime();
|
||||
}
|
||||
}
|
||||
LowPower.idle(SLEEP_FOREVER, ADC_OFF, TIMER2_OFF, TIMER1_OFF, TIMER0_ON, SPI_OFF, USART0_ON, TWI_OFF);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue