diff --git a/README.md b/README.md index ba89715..a5f87ed 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ The best success is to use PlatformIO (and it is the only platform where I can s ### Configuration * You can find all nessesary settings to change for your configuration in **data/tracker.json**. +* The `button_tx` setting enables manual triggering of the beacon using the middle button on the T-Beam. * To upload it to your board you have to do this via **Upload File System image** in PlatformIO! * To find the 'Upload File System image' click the PlatformIO symbol (the little alien) on the left side, choos your configuration, click on 'Platform' and search for 'Upload File System image'. diff --git a/data/tracker.json b/data/tracker.json index a6439ab..f439a10 100644 --- a/data/tracker.json +++ b/data/tracker.json @@ -6,6 +6,7 @@ { "message":"LoRa Tracker", "timeout": 1, + "button_tx": false, "symbol": "[", "overlay": "/" }, diff --git a/platformio.ini b/platformio.ini index 19fe00f..f9518ff 100644 --- a/platformio.ini +++ b/platformio.ini @@ -14,6 +14,7 @@ lib_deps = peterus/APRS-Decoder-Lib @ 0.0.5 mikalhart/TinyGPSPlus @ 1.0.2 paulstoffregen/Time @ 1.6 + shaggydog/OneButton @ 1.5.0 check_tool = cppcheck check_flags = cppcheck: --suppress=*:*.pio\* --inline-suppr -DCPPCHECK diff --git a/src/LoRa_APRS_Tracker.cpp b/src/LoRa_APRS_Tracker.cpp index a42a9c6..d5e67b7 100644 --- a/src/LoRa_APRS_Tracker.cpp +++ b/src/LoRa_APRS_Tracker.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "display.h" #include "pins.h" #include "power_management.h" @@ -12,6 +13,7 @@ Configuration Config; #include "power_management.h" PowerManagement powerManagement; +OneButton userButton = OneButton(BUTTON_PIN, true, true); #include "logger.h" @@ -32,6 +34,9 @@ String createTimeString(time_t t); String getSmartBeaconState(); String padding(unsigned int number, unsigned int width); +static bool send_update = true; +static void handle_tx_click(); + // cppcheck-suppress unusedFunction void setup() { @@ -73,6 +78,12 @@ void setup() WiFi.mode(WIFI_OFF); btStop(); + if (Config.beacon.button_tx) + { + // attach TX action to user button (defined by BUTTON_PIN) + userButton.attachClick(handle_tx_click); + } + logPrintlnI("Smart Beacon is " + getSmartBeaconState()); show_display("INFO", "Smart Beacon is " + getSmartBeaconState(), 1000); logPrintlnI("setup done..."); @@ -82,6 +93,8 @@ void setup() // cppcheck-suppress unusedFunction void loop() { + userButton.tick(); + if(Config.debug) { while(Serial.available() > 0) @@ -104,7 +117,6 @@ void loop() bool gps_time_update = gps.time.isUpdated(); bool gps_loc_update = gps.location.isUpdated(); static time_t nextBeaconTimeStamp = -1; - static bool send_update = true; static double currentHeading = 0; static double previousHeading = 0; @@ -415,6 +427,11 @@ char *s_min_nn(uint32_t min_nnnnn, int high_precision) return buf; } +static void handle_tx_click() +{ + send_update = true; +} + String create_lat_aprs(RawDegrees lat) { char str[20]; diff --git a/src/configuration.cpp b/src/configuration.cpp index 3aa226c..0b454c2 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -51,6 +51,8 @@ Configuration ConfigurationManagement::readConfiguration() conf.beacon.symbol = data["beacon"]["symbol"].as(); if(data.containsKey("beacon") && data["beacon"].containsKey("overlay")) conf.beacon.overlay = data["beacon"]["overlay"].as() ; + if(data.containsKey("beacon") && data["beacon"].containsKey("button_tx")) + conf.beacon.button_tx = data["beacon"]["button_tx"] | false; conf.smart_beacon.active = data["smart_beacon"]["active"] | false; conf.smart_beacon.turn_min = data["smart_beacon"]["turn_min"] | 25; @@ -95,6 +97,7 @@ void ConfigurationManagement::writeConfiguration(Configuration conf) data["beacon"]["timeout"] = conf.beacon.timeout; data["beacon"]["symbol"] = conf.beacon.symbol; data["beacon"]["overlay"] = conf.beacon.overlay; + data["beacon"]["button_tx"] = conf.beacon.button_tx; data["smart_beacon"]["active"] = conf.smart_beacon.active; data["smart_beacon"]["turn_min"] = conf.smart_beacon.turn_min; data["smart_beacon"]["slow_rate"] = conf.smart_beacon.slow_rate; diff --git a/src/configuration.h b/src/configuration.h index b39a687..cac3955 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -11,12 +11,13 @@ public: class Beacon { public: - Beacon() : message("LoRa Tracker, Info: github.com/lora-aprs/LoRa_APRS_Tracker"), timeout(1), symbol("["), overlay("/") {} + Beacon() : message("LoRa Tracker, Info: github.com/lora-aprs/LoRa_APRS_Tracker"), timeout(1), symbol("["), overlay("/"), button_tx(false) {} String message; int timeout; String symbol; String overlay; + bool button_tx; }; class Smart_Beacon diff --git a/src/pins.h b/src/pins.h index 1f848ca..1d8f15c 100644 --- a/src/pins.h +++ b/src/pins.h @@ -9,6 +9,8 @@ #define OLED_SCL 22 #define OLED_RST 16 +#define BUTTON_PIN 38 // The middle button GPIO on the T-Beam + #ifdef TTGO_T_Beam_V0_7 #define GPS_RX 15 #define GPS_TX 12