Enable manual TX with the middle GPIO button

This commit is contained in:
Simonas Kareiva 2021-10-11 14:25:33 +03:00
parent d2aa0641c2
commit 1dca7bc5b2
7 changed files with 28 additions and 2 deletions

View file

@ -33,6 +33,7 @@ The best success is to use PlatformIO (and it is the only platform where I can s
### Configuration ### Configuration
* You can find all nessesary settings to change for your configuration in **data/tracker.json**. * 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 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'. * 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'.

View file

@ -6,6 +6,7 @@
{ {
"message":"LoRa Tracker", "message":"LoRa Tracker",
"timeout": 1, "timeout": 1,
"button_tx": false,
"symbol": "[", "symbol": "[",
"overlay": "/" "overlay": "/"
}, },

View file

@ -14,6 +14,7 @@ lib_deps =
peterus/APRS-Decoder-Lib @ 0.0.5 peterus/APRS-Decoder-Lib @ 0.0.5
mikalhart/TinyGPSPlus @ 1.0.2 mikalhart/TinyGPSPlus @ 1.0.2
paulstoffregen/Time @ 1.6 paulstoffregen/Time @ 1.6
shaggydog/OneButton @ 1.5.0
check_tool = cppcheck check_tool = cppcheck
check_flags = check_flags =
cppcheck: --suppress=*:*.pio\* --inline-suppr -DCPPCHECK cppcheck: --suppress=*:*.pio\* --inline-suppr -DCPPCHECK

View file

@ -4,6 +4,7 @@
#include <TinyGPS++.h> #include <TinyGPS++.h>
#include <TimeLib.h> #include <TimeLib.h>
#include <WiFi.h> #include <WiFi.h>
#include <OneButton.h>
#include "display.h" #include "display.h"
#include "pins.h" #include "pins.h"
#include "power_management.h" #include "power_management.h"
@ -12,6 +13,7 @@ Configuration Config;
#include "power_management.h" #include "power_management.h"
PowerManagement powerManagement; PowerManagement powerManagement;
OneButton userButton = OneButton(BUTTON_PIN, true, true);
#include "logger.h" #include "logger.h"
@ -32,6 +34,9 @@ String createTimeString(time_t t);
String getSmartBeaconState(); String getSmartBeaconState();
String padding(unsigned int number, unsigned int width); String padding(unsigned int number, unsigned int width);
static bool send_update = true;
static void handle_tx_click();
// cppcheck-suppress unusedFunction // cppcheck-suppress unusedFunction
void setup() void setup()
{ {
@ -73,6 +78,12 @@ void setup()
WiFi.mode(WIFI_OFF); WiFi.mode(WIFI_OFF);
btStop(); 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()); logPrintlnI("Smart Beacon is " + getSmartBeaconState());
show_display("INFO", "Smart Beacon is " + getSmartBeaconState(), 1000); show_display("INFO", "Smart Beacon is " + getSmartBeaconState(), 1000);
logPrintlnI("setup done..."); logPrintlnI("setup done...");
@ -82,6 +93,8 @@ void setup()
// cppcheck-suppress unusedFunction // cppcheck-suppress unusedFunction
void loop() void loop()
{ {
userButton.tick();
if(Config.debug) if(Config.debug)
{ {
while(Serial.available() > 0) while(Serial.available() > 0)
@ -104,7 +117,6 @@ void loop()
bool gps_time_update = gps.time.isUpdated(); bool gps_time_update = gps.time.isUpdated();
bool gps_loc_update = gps.location.isUpdated(); bool gps_loc_update = gps.location.isUpdated();
static time_t nextBeaconTimeStamp = -1; static time_t nextBeaconTimeStamp = -1;
static bool send_update = true;
static double currentHeading = 0; static double currentHeading = 0;
static double previousHeading = 0; static double previousHeading = 0;
@ -415,6 +427,11 @@ char *s_min_nn(uint32_t min_nnnnn, int high_precision)
return buf; return buf;
} }
static void handle_tx_click()
{
send_update = true;
}
String create_lat_aprs(RawDegrees lat) String create_lat_aprs(RawDegrees lat)
{ {
char str[20]; char str[20];

View file

@ -51,6 +51,8 @@ Configuration ConfigurationManagement::readConfiguration()
conf.beacon.symbol = data["beacon"]["symbol"].as<String>(); conf.beacon.symbol = data["beacon"]["symbol"].as<String>();
if(data.containsKey("beacon") && data["beacon"].containsKey("overlay")) if(data.containsKey("beacon") && data["beacon"].containsKey("overlay"))
conf.beacon.overlay = data["beacon"]["overlay"].as<String>() ; conf.beacon.overlay = data["beacon"]["overlay"].as<String>() ;
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.active = data["smart_beacon"]["active"] | false;
conf.smart_beacon.turn_min = data["smart_beacon"]["turn_min"] | 25; 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"]["timeout"] = conf.beacon.timeout;
data["beacon"]["symbol"] = conf.beacon.symbol; data["beacon"]["symbol"] = conf.beacon.symbol;
data["beacon"]["overlay"] = conf.beacon.overlay; 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"]["active"] = conf.smart_beacon.active;
data["smart_beacon"]["turn_min"] = conf.smart_beacon.turn_min; data["smart_beacon"]["turn_min"] = conf.smart_beacon.turn_min;
data["smart_beacon"]["slow_rate"] = conf.smart_beacon.slow_rate; data["smart_beacon"]["slow_rate"] = conf.smart_beacon.slow_rate;

View file

@ -11,12 +11,13 @@ public:
class Beacon class Beacon
{ {
public: 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; String message;
int timeout; int timeout;
String symbol; String symbol;
String overlay; String overlay;
bool button_tx;
}; };
class Smart_Beacon class Smart_Beacon

View file

@ -9,6 +9,8 @@
#define OLED_SCL 22 #define OLED_SCL 22
#define OLED_RST 16 #define OLED_RST 16
#define BUTTON_PIN 38 // The middle button GPIO on the T-Beam
#ifdef TTGO_T_Beam_V0_7 #ifdef TTGO_T_Beam_V0_7
#define GPS_RX 15 #define GPS_RX 15
#define GPS_TX 12 #define GPS_TX 12