From 0158fcf352ab209f15166c70478898acc3cd12d7 Mon Sep 17 00:00:00 2001 From: geeksville Date: Sat, 8 Feb 2020 07:55:12 -0800 Subject: [PATCH] get ttgo building again --- src/NodeDB.cpp | 2 +- src/configuration.h | 4 ++-- src/main.ino | 21 +++++++++++++++++++ src/screen.cpp | 51 +++++++++++++-------------------------------- 4 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/NodeDB.cpp b/src/NodeDB.cpp index d0d393dd7..26a20afdd 100644 --- a/src/NodeDB.cpp +++ b/src/NodeDB.cpp @@ -100,7 +100,7 @@ void NodeDB::loadFromDisk() DEBUG_MSG("Loading saved preferences\n"); pb_istream_t stream = {&readcb, &f, DeviceState_size}; - scratch = DeviceState_init_zero; + memset(&scratch, 0, sizeof(scratch)); if (!pb_decode(&stream, DeviceState_fields, &scratch)) { DEBUG_MSG("Error: can't decode protobuf %s\n", PB_GET_ERROR(&stream)); diff --git a/src/configuration.h b/src/configuration.h index f562ae77c..320b500b2 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -38,11 +38,11 @@ along with this program. If not, see . // Select which T-Beam board is being used. Only uncomment one. Note: these options now come from platformio standard build file flags //#ifdef ARDUINO_T_Beam -//#define T_BEAM_V10 // AKA Rev1 (second board released) +#define T_BEAM_V10 // AKA Rev1 (second board released) //#endif //#ifdef ARDUINO_HELTEC_WIFI_LORA_32_V2 -#define HELTEC_LORA32 +// #define HELTEC_LORA32 //#endif // If we are using the JTAG port for debugging, some pins must be left free for that (and things like GPS have to be disabled) diff --git a/src/main.ino b/src/main.ino index 0cf962173..cc5353ce3 100644 --- a/src/main.ino +++ b/src/main.ino @@ -390,6 +390,27 @@ void loop() { // blink the axp led axp.setChgLEDMode(ledon ? AXP20X_LED_LOW_LEVEL : AXP20X_LED_OFF); + + if (pmu_irq) + { + pmu_irq = false; + axp.readIRQ(); + if (axp.isChargingIRQ()) + { + baChStatus = "Charging"; + } + else + { + baChStatus = "No Charging"; + } + if (axp.isVbusRemoveIRQ()) + { + baChStatus = "No Charging"; + } + // This is not a GPIO actually connected on the tbeam board + // digitalWrite(2, !digitalRead(2)); + axp.clearIRQ(); + } } #endif diff --git a/src/screen.cpp b/src/screen.cpp index 1400fbc54..716b7c12d 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -280,8 +280,6 @@ static void screen_print(const char *text, uint8_t x, uint8_t y, uint8_t alignme dispdev.drawString(x, y, text); } - - void screen_print(const char *text) { DEBUG_MSG("Screen: %s\n", text); @@ -345,33 +343,11 @@ uint32_t screen_loop() if (!disp) return 30 * 1000; -#ifdef T_BEAM_V10 - if (axp192_found && pmu_irq) + if (wakeScreen) { - pmu_irq = false; - axp.readIRQ(); - if (axp.isChargingIRQ()) - { - baChStatus = "Charging"; - } - else - { - baChStatus = "No Charging"; - } - if (axp.isVbusRemoveIRQ()) - { - baChStatus = "No Charging"; - } - // This is not a GPIO actually connected on the tbeam board - // digitalWrite(2, !digitalRead(2)); - axp.clearIRQ(); + screen_on(); // make sure the screen is not asleep + wakeScreen = false; } -#endif - -if(wakeScreen) { - screen_on(); // make sure the screen is not asleep - wakeScreen = false; -} static bool showingBootScreen = true; @@ -389,33 +365,36 @@ if(wakeScreen) { } // Show the bluetooth PIN screen -void screen_start_bluetooth(uint32_t pin) { - static FrameCallback btFrames[] = { drawFrameBluetooth }; +void screen_start_bluetooth(uint32_t pin) +{ + static FrameCallback btFrames[] = {drawFrameBluetooth}; snprintf(btPIN, sizeof(btPIN), "%06d", pin); DEBUG_MSG("showing bluetooth screen\n"); showingBluetooth = true; - wakeScreen = true; + wakeScreen = true; - ui.disableAutoTransition(); // we now require presses - ui.setFrames(btFrames, 1); // Just show the bluetooth frame + ui.disableAutoTransition(); // we now require presses + ui.setFrames(btFrames, 1); // Just show the bluetooth frame // we rely on our main loop to show this screen (because we are invoked deep inside of bluetooth callbacks) // ui.update(); // manually draw once, because I'm not sure if loop is getting called } // restore our regular frame list -void screen_set_frames() { +void screen_set_frames() +{ DEBUG_MSG("showing standard frames\n"); - ui.setFrames(nonBootFrames, frameCount - 1); + ui.setFrames(nonBootFrames, frameCount - 1); showingBluetooth = false; } /// handle press of the button -void screen_press() { +void screen_press() +{ // screen_start_bluetooth(123456); // Once the user presses a button, stop auto scrolling between screens - ui.disableAutoTransition(); // we now require presses + ui.disableAutoTransition(); // we now require presses ui.nextFrame(); } \ No newline at end of file