Enable manual TX with the middle GPIO button

pull/42/head
Simonas Kareiva 2021-10-11 14:25:33 +03:00
rodzic d2aa0641c2
commit 1dca7bc5b2
7 zmienionych plików z 28 dodań i 2 usunięć

Wyświetl plik

@ -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'.

Wyświetl plik

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

Wyświetl plik

@ -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

Wyświetl plik

@ -4,6 +4,7 @@
#include <TinyGPS++.h>
#include <TimeLib.h>
#include <WiFi.h>
#include <OneButton.h>
#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];

Wyświetl plik

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

Wyświetl plik

@ -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

Wyświetl plik

@ -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