From 3e73e89d08c3ac6b2d0606dbbd888648bc97daaf Mon Sep 17 00:00:00 2001 From: richonguzman Date: Tue, 7 May 2024 11:19:48 -0400 Subject: [PATCH] new startupScreen --- src/LoRa_APRS_Tracker.cpp | 33 +++------------------------- src/display.cpp | 17 +++++++++++++++ src/display.h | 2 ++ src/power_utils.cpp | 45 +++++++++++++++++++++++++++++++++++++++ src/power_utils.h | 2 ++ 5 files changed, 69 insertions(+), 30 deletions(-) diff --git a/src/LoRa_APRS_Tracker.cpp b/src/LoRa_APRS_Tracker.cpp index f3749f2..ffe2236 100644 --- a/src/LoRa_APRS_Tracker.cpp +++ b/src/LoRa_APRS_Tracker.cpp @@ -149,40 +149,13 @@ void setup() { #endif POWER_Utils::setup(); - setup_display(); + POWER_Utils::externalPinSetup(); - if (Config.notification.buzzerActive) { - pinMode(Config.notification.buzzerPinTone, OUTPUT); - pinMode(Config.notification.buzzerPinVcc, OUTPUT); - if (Config.notification.bootUpBeep) NOTIFICATION_Utils::start(); - } - if (Config.notification.ledTx) pinMode(Config.notification.ledTxPin, OUTPUT); - if (Config.notification.ledMessage) pinMode(Config.notification.ledMessagePin, OUTPUT); - if (Config.notification.ledFlashlight) pinMode(Config.notification.ledFlashlightPin, OUTPUT); - STATION_Utils::loadIndex(0); STATION_Utils::loadIndex(1); - String workingFreq = " LoRa Freq ["; - if (loraIndex == 0) { - workingFreq += "Eu]"; - } else if (loraIndex == 1) { - workingFreq += "PL]"; - } else if (loraIndex == 2) { - workingFreq += "UK]"; - } - - show_display(" LoRa APRS", " (TRACKER)", workingFreq, "", "Richonguzman / CA2RXU", " " + versionDate, 4000); - #ifdef HAS_TFT - cleanTFT(); - #endif - logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "RichonGuzman (CA2RXU) --> LoRa APRS Tracker/Station"); - logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "Version: %s", versionDate); - - if (Config.ptt.active) { - pinMode(Config.ptt.io_pin, OUTPUT); - digitalWrite(Config.ptt.io_pin, Config.ptt.reverse ? HIGH : LOW); - } + startupScreen(loraIndex, versionDate); + MSG_Utils::loadNumMessages(); GPS_Utils::setup(); currentLoRaType = &Config.loraTypes[loraIndex]; diff --git a/src/display.cpp b/src/display.cpp index 5f39a53..26d4080 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -434,4 +434,21 @@ void show_display(String header, String line1, String line2, String line3, Strin display.display(); #endif delay(wait); +} + +void startupScreen(uint8_t index, String version) { + String workingFreq = " LoRa Freq ["; + if (index == 0) { + workingFreq += "Eu]"; + } else if (index == 1) { + workingFreq += "PL]"; + } else if (index == 2) { + workingFreq += "UK]"; + } + show_display(" LoRa APRS", " (TRACKER)", workingFreq, "", "Richonguzman / CA2RXU", " " + version, 4000); + #ifdef HAS_TFT + cleanTFT(); + #endif + logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "RichonGuzman (CA2RXU) --> LoRa APRS Tracker/Station"); + logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "Version: %s", version); } \ No newline at end of file diff --git a/src/display.h b/src/display.h index a4cd1f8..e5b5a93 100644 --- a/src/display.h +++ b/src/display.h @@ -12,4 +12,6 @@ void show_display(String header, String line1, String line2, String line3, int w void show_display(String header, String line1, String line2, String line3, String line4, int wait = 0); void show_display(String header, String line1, String line2, String line3, String line4, String line5, int wait = 0); +void startupScreen(uint8_t index, String version); + #endif \ No newline at end of file diff --git a/src/power_utils.cpp b/src/power_utils.cpp index cacaa28..d980484 100644 --- a/src/power_utils.cpp +++ b/src/power_utils.cpp @@ -232,6 +232,46 @@ namespace POWER_Utils { #endif } + void externalPinSetup() { + if (Config.notification.buzzerActive && Config.notification.buzzerPinTone >= 0 && Config.notification.buzzerPinVcc >= 0) { + pinMode(Config.notification.buzzerPinTone, OUTPUT); + pinMode(Config.notification.buzzerPinVcc, OUTPUT); + if (Config.notification.bootUpBeep) NOTIFICATION_Utils::start(); + } else if (Config.notification.buzzerActive && (Config.notification.buzzerPinTone < 0 || Config.notification.buzzerPinVcc < 0)) { + logger.log(logging::LoggerLevel::LOGGER_LEVEL_WARN, "PINOUT", "Buzzer Pins bad/not defined"); + while (1); + } + + if (Config.notification.ledTx && Config.notification.ledTxPin >= 0) { + pinMode(Config.notification.ledTxPin, OUTPUT); + } else if (Config.notification.ledTx && Config.notification.ledTxPin < 0) { + logger.log(logging::LoggerLevel::LOGGER_LEVEL_WARN, "PINOUT", "Led Tx Pin bad/not defined"); + while (1); + } + + if (Config.notification.ledMessage && Config.notification.ledMessagePin >= 0) { + pinMode(Config.notification.ledMessagePin, OUTPUT); + } else if (Config.notification.ledMessage && Config.notification.ledMessagePin < 0) { + logger.log(logging::LoggerLevel::LOGGER_LEVEL_WARN, "PINOUT", "Led Message Pin bad/not defined"); + while (1); + } + + if (Config.notification.ledFlashlight && Config.notification.ledFlashlightPin >= 0) { + pinMode(Config.notification.ledFlashlightPin, OUTPUT); + } else if (Config.notification.ledFlashlight && Config.notification.ledFlashlightPin < 0) { + logger.log(logging::LoggerLevel::LOGGER_LEVEL_WARN, "PINOUT", "Led Flashlight Pin bad/not defined"); + while (1); + } + + if (Config.ptt.active && Config.ptt.io_pin >= 0) { + pinMode(Config.ptt.io_pin, OUTPUT); + digitalWrite(Config.ptt.io_pin, Config.ptt.reverse ? HIGH : LOW); + } else if (Config.ptt.active && Config.ptt.io_pin < 0) { + logger.log(logging::LoggerLevel::LOGGER_LEVEL_WARN, "PINOUT", "PTT Pin bad/not defined"); + while (1); + } + } + bool begin(TwoWire &port) { #if defined(TTGO_T_Beam_V0_7) || defined(ESP32_DIY_LoRa_GPS) || defined(TTGO_T_LORA32_V2_1_GPS) || defined(TTGO_T_LORA32_V2_1_TNC) || defined(ESP32_DIY_1W_LoRa_GPS) || defined(HELTEC_V3_GPS) || defined(OE5HWN_MeshCom) || defined(ESP32_C3_DIY_LoRa_GPS) || defined(HELTEC_WIRELESS_TRACKER) || defined(TTGO_T_DECK_GPS) return true; // no powerManagment chip for this boards (only a few measure battery voltage). @@ -404,6 +444,11 @@ namespace POWER_Utils { #if defined(HAS_AXP192) || defined(HAS_AXP2101) if (Config.notification.shutDownBeep) NOTIFICATION_Utils::shutDownBeep(); PMU.shutdown(); + //#endif + #else + esp_sleep_enable_timer_wakeup(10 * 1000000); // 10 seconds + esp_deep_sleep_start(); + #endif } diff --git a/src/power_utils.h b/src/power_utils.h index 6bcf04f..e0e1de8 100644 --- a/src/power_utils.h +++ b/src/power_utils.h @@ -33,6 +33,8 @@ namespace POWER_Utils { void activateLoRa(); void deactivateLoRa(); + void externalPinSetup(); + bool begin(TwoWire &port); void setup();