diff --git a/RX_FSK/RX_FSK.ino b/RX_FSK/RX_FSK.ino index 3b8f5c6..917b807 100644 --- a/RX_FSK/RX_FSK.ino +++ b/RX_FSK/RX_FSK.ino @@ -1294,7 +1294,8 @@ int getKeyPress() { return p; } -int getKey2Press() { +// called by arduino main loop (from Sonde::waitRXcomplete) as soon as pmu_irq is set +void handlePMUirq() { if (sonde.config.button2_axp) { // Use AXP power button as second button if (pmu_irq) { @@ -1314,6 +1315,10 @@ int getKey2Press() { xSemaphoreGive( axpSemaphore ); } } +} + +int getKey2Press() { + // TODO: Should be atomic KeyPress p = button2.pressed; button2.pressed = KP_NONE; //Serial.printf("button2 press: %d at %ld (%d)\n", p, button2.keydownTime, button2.numberKeyPresses); diff --git a/RX_FSK/version.h b/RX_FSK/version.h index 2cc6a2b..5162342 100644 --- a/RX_FSK/version.h +++ b/RX_FSK/version.h @@ -1,4 +1,4 @@ const char *version_name = "rdzTTGOsonde"; -const char *version_id = "devel20201111"; +const char *version_id = "devel20201111b"; const int SPIFFS_MAJOR=2; const int SPIFFS_MINOR=4; diff --git a/libraries/SondeLib/Sonde.cpp b/libraries/SondeLib/Sonde.cpp index 01cc963..b140347 100644 --- a/libraries/SondeLib/Sonde.cpp +++ b/libraries/SondeLib/Sonde.cpp @@ -10,7 +10,6 @@ #include "Display.h" #include -extern SX1278FSK sx1278; RXTask rxtask = { -1, -1, -1, 0xFFFF, 0 }; @@ -31,7 +30,11 @@ const char *fingerprintText[]={ "TTGO T-Beam (new version 1.0), SPI TFT@4,13,14", }; -int getKeyPressEvent(); /* in RX_FSK.ino */ +/* global variables from RX_FSK.ino */ +int getKeyPressEvent(); +int handlePMUirq(); +extern bool pmu_irq; +extern SX1278FSK sx1278; /* Task model: * There is a background task for all SX1278 interaction. @@ -489,7 +492,11 @@ uint16_t Sonde::waitRXcomplete() { uint16_t res=0; uint32_t t0 = millis(); rxloop: - while( rxtask.receiveResult==0xFFFF && millis()-t0 < 3000) { delay(50); } + while( !pmu_irq && rxtask.receiveResult==0xFFFF && millis()-t0 < 3000) { delay(50); } + if( pmu_irq ) { + handlePMUirq(); + goto rxloop; + } if( rxtask.receiveResult == RX_UPDATERSSI ) { rxtask.receiveResult = 0xFFFF; Serial.print("RSSI update: ");