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 =
|
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
|
||||||
|
|
93
src/main.cpp
93
src/main.cpp
|
@ -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,44 +711,45 @@ 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();
|
||||||
}
|
|
||||||
if (editingConfig) {
|
|
||||||
editConfig();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (editingComment) {
|
|
||||||
editComment();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (abcPressed) {
|
|
||||||
abcPressed = false;
|
|
||||||
page = (page + 1) % 4;
|
|
||||||
lcd.clear();
|
|
||||||
}
|
|
||||||
if (page == 0) {
|
|
||||||
printConfig();
|
|
||||||
if (setPressed) {
|
|
||||||
setPressed = false;
|
|
||||||
editingConfig = true;
|
|
||||||
lcd.blink();
|
|
||||||
}
|
}
|
||||||
} else if (page == 1) {
|
if (editingConfig) {
|
||||||
printComment();
|
editConfig();
|
||||||
if (setPressed) {
|
return;
|
||||||
setPressed = false;
|
}
|
||||||
editingComment = true;
|
if (editingComment) {
|
||||||
|
editComment();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (abcPressed) {
|
||||||
|
abcPressed = false;
|
||||||
|
page = (page + 1) % 4;
|
||||||
lcd.clear();
|
lcd.clear();
|
||||||
lcd.blink();
|
|
||||||
}
|
}
|
||||||
} else if (page == 2) {
|
if (page == 0) {
|
||||||
printLocation();
|
printConfig();
|
||||||
} else if (page == 3) {
|
if (setPressed) {
|
||||||
printDateTime();
|
setPressed = false;
|
||||||
|
editingConfig = true;
|
||||||
|
lcd.blink();
|
||||||
|
}
|
||||||
|
} else if (page == 1) {
|
||||||
|
printComment();
|
||||||
|
if (setPressed) {
|
||||||
|
setPressed = false;
|
||||||
|
editingComment = true;
|
||||||
|
lcd.clear();
|
||||||
|
lcd.blink();
|
||||||
|
}
|
||||||
|
} else if (page == 2) {
|
||||||
|
printLocation();
|
||||||
|
} else if (page == 3) {
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue