fix: idle mode was not always activated

This commit is contained in:
s3lph 2023-05-07 02:16:59 +02:00
parent 4ea4d52be0
commit f6fbc29fde
Signed by: s3lph
GPG key ID: 0AA29A52FB33CFB5
2 changed files with 59 additions and 35 deletions

View file

@ -15,6 +15,7 @@ framework = arduino
lib_deps = lib_deps =
https://github.com/marcoschwartz/LiquidCrystal_I2C https://github.com/marcoschwartz/LiquidCrystal_I2C
https://github.com/rocketscream/Low-Power https://github.com/rocketscream/Low-Power
build_flags = -DGPSM_UBLOX6
upload_protocol = custom upload_protocol = custom
upload_flags = upload_flags =
-C -C

View file

@ -529,6 +529,11 @@ void readNmeaRmc() {
} }
} }
if (nmeaState == 2) { 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 buf[16];
char *bptr = buf; char *bptr = buf;
uint8_t counter = 0; uint8_t counter = 0;
@ -642,6 +647,7 @@ void readNmeaRmc() {
} }
void setup() { void setup() {
#if defined(GPSM_UBLOX6)
Serial.begin(9600); Serial.begin(9600);
// ublox NEO-6M: Switch to low-power on-off mode with peak current limiting - not sure if this actually works // 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"); 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,VTG,0,0,0,0,0,0*5E");
Serial.println("$PUBX,40,GGA,0,0,0,0,0,0*5A"); Serial.println("$PUBX,40,GGA,0,0,0,0,0,0*5A");
Serial.flush(); 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; OUT_DDR |= 0x0f;
pinMode(PTT, OUTPUT); pinMode(PTT, OUTPUT);
digitalWrite(PTT, LOW); digitalWrite(PTT, LOW);
@ -675,6 +690,13 @@ void setup() {
void loop() { void loop() {
readNmeaRmc(); readNmeaRmc();
uint32_t now = millis(); 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) { if (abcPressed || setPressed) {
lastPressed = now; lastPressed = now;
} }
@ -689,8 +711,8 @@ void loop() {
lcd.backlight(); lcd.backlight();
lcd.display(); lcd.display();
} }
return; } else {
} else if (now - lastPressed > 30000) { if (now - lastPressed > 30000) {
off = true; off = true;
lcd.noDisplay(); lcd.noDisplay();
lcd.noBacklight(); lcd.noBacklight();
@ -728,5 +750,6 @@ void loop() {
} else if (page == 3) { } else if (page == 3) {
printDateTime(); printDateTime();
} }
}
LowPower.idle(SLEEP_FOREVER, ADC_OFF, TIMER2_OFF, TIMER1_OFF, TIMER0_ON, SPI_OFF, USART0_ON, TWI_OFF); LowPower.idle(SLEEP_FOREVER, ADC_OFF, TIMER2_OFF, TIMER1_OFF, TIMER0_ON, SPI_OFF, USART0_ON, TWI_OFF);
} }