tentativ apx key fix

This commit is contained in:
Hansi, dl9rdz 2020-11-11 14:13:33 +01:00
parent 92edc5e04c
commit e0ad39b9f0
3 changed files with 17 additions and 5 deletions

View File

@ -1294,7 +1294,8 @@ int getKeyPress() {
return p; 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) { if (sonde.config.button2_axp) {
// Use AXP power button as second button // Use AXP power button as second button
if (pmu_irq) { if (pmu_irq) {
@ -1314,6 +1315,10 @@ int getKey2Press() {
xSemaphoreGive( axpSemaphore ); xSemaphoreGive( axpSemaphore );
} }
} }
}
int getKey2Press() {
// TODO: Should be atomic
KeyPress p = button2.pressed; KeyPress p = button2.pressed;
button2.pressed = KP_NONE; button2.pressed = KP_NONE;
//Serial.printf("button2 press: %d at %ld (%d)\n", p, button2.keydownTime, button2.numberKeyPresses); //Serial.printf("button2 press: %d at %ld (%d)\n", p, button2.keydownTime, button2.numberKeyPresses);

View File

@ -1,4 +1,4 @@
const char *version_name = "rdzTTGOsonde"; const char *version_name = "rdzTTGOsonde";
const char *version_id = "devel20201111"; const char *version_id = "devel20201111b";
const int SPIFFS_MAJOR=2; const int SPIFFS_MAJOR=2;
const int SPIFFS_MINOR=4; const int SPIFFS_MINOR=4;

View File

@ -10,7 +10,6 @@
#include "Display.h" #include "Display.h"
#include <Wire.h> #include <Wire.h>
extern SX1278FSK sx1278;
RXTask rxtask = { -1, -1, -1, 0xFFFF, 0 }; 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", "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: /* Task model:
* There is a background task for all SX1278 interaction. * There is a background task for all SX1278 interaction.
@ -489,7 +492,11 @@ uint16_t Sonde::waitRXcomplete() {
uint16_t res=0; uint16_t res=0;
uint32_t t0 = millis(); uint32_t t0 = millis();
rxloop: 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 ) { if( rxtask.receiveResult == RX_UPDATERSSI ) {
rxtask.receiveResult = 0xFFFF; rxtask.receiveResult = 0xFFFF;
Serial.print("RSSI update: "); Serial.print("RSSI update: ");