diff --git a/platformio.ini b/platformio.ini index 3e4e34f..9086f13 100644 --- a/platformio.ini +++ b/platformio.ini @@ -14,6 +14,7 @@ board = nanoatmega328 framework = arduino lib_deps = https://github.com/marcoschwartz/LiquidCrystal_I2C + https://github.com/rocketscream/Low-Power upload_protocol = custom upload_flags = -C diff --git a/src/main.cpp b/src/main.cpp index 766ec25..64f6563 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #define OUT_PORT PORTC @@ -223,7 +224,7 @@ volatile bool setPressed = false; volatile bool abcPressed = false; uint8_t page = 0; uint32_t lastPressed = 0; -bool off = false; +bool off = true; bool editingConfig = false; bool editingComment = false; uint8_t configEditState = 0; @@ -525,8 +526,6 @@ void readNmeaRmc() { } else { nmeaState = 0; } - Serial.println(nmeaStr); - Serial.flush(); } } if (nmeaState == 2) { @@ -612,7 +611,6 @@ void readNmeaRmc() { } memcpy(aprs+34, config.comment, config.commentLen); aprs[34+config.commentLen] = 0; - Serial.println(aprs); // AX.25 3.8 - FCS is sent MSB first uint16_t fcs = 0xffff; for (size_t i = 0; i < sizeof(frame); ++i) { @@ -645,6 +643,9 @@ void readNmeaRmc() { void setup() { 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"); + Serial.flush(); // ublox NEO-6M: Disable all NMEA sentences except for GPTXT and GPRMC Serial.println("$PUBX,40,GLL,0,0,0,0,0,0*5C"); Serial.println("$PUBX,40,GSV,0,0,0,0,0,0*59"); @@ -652,9 +653,6 @@ 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(); - // 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\x91\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\x01\x45"); - Serial.flush(); OUT_DDR |= 0x0f; pinMode(PTT, OUTPUT); digitalWrite(PTT, LOW); @@ -668,7 +666,7 @@ void setup() { attachInterrupt(digitalPinToInterrupt(2), isrSet, FALLING); attachInterrupt(digitalPinToInterrupt(3), isrAbc, FALLING); lcd.init(); - lcd.backlight(); + lcd.noDisplay(); setPressed = false; abcPressed = false; } @@ -689,13 +687,12 @@ void loop() { lcd.blink(); } lcd.backlight(); - lcd.on(); + lcd.display(); } return; } else if (now - lastPressed > 30000) { off = true; - lcd.off(); - lcd.noBlink(); + lcd.noDisplay(); lcd.noBacklight(); } if (editingConfig) { @@ -731,4 +728,5 @@ 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); }