From 444ac37c01707236e77976b87934be27dea5af12 Mon Sep 17 00:00:00 2001 From: Endaf Jones Date: Wed, 25 Sep 2024 12:35:03 -0600 Subject: [PATCH 1/2] Added audio feedback of packets received with addition of a piezoe speaker on a free GPIO pin. --- RX_FSK/RX_FSK.ino | 18 ++++++++++++++++++ RX_FSK/data/cfg.js | 1 + RX_FSK/data/config.txt | 2 ++ RX_FSK/src/Sonde.cpp | 4 ++++ RX_FSK/src/Sonde.h | 1 + RX_FSK/version.h | 2 +- 6 files changed, 27 insertions(+), 1 deletion(-) diff --git a/RX_FSK/RX_FSK.ino b/RX_FSK/RX_FSK.ino index c026fe84..e22145b9 100644 --- a/RX_FSK/RX_FSK.ino +++ b/RX_FSK/RX_FSK.ino @@ -670,6 +670,7 @@ struct st_configitems config_list[] = { {"touch_thresh", 0, &sonde.config.touch_thresh}, {"power_pout", 0, &sonde.config.power_pout}, {"led_pout", 0, &sonde.config.led_pout}, + {"piezoe_pout", 0, &sonde.config.piezoe_pout}, {"gps_rxd", 0, &sonde.config.gps_rxd}, {"gps_txd", 0, &sonde.config.gps_txd}, {"batt_adc", 0, &sonde.config.batt_adc}, @@ -1380,6 +1381,7 @@ void touchISR2(); Ticker ticker; Ticker ledFlasher; +Ticker tone; #define IS_TOUCH(x) (((x)!=255)&&((x)!=-1)&&((x)&128)) void initTouch() { @@ -1502,6 +1504,17 @@ void flashLed(int ms) { } } +void toneOffCallback() { + ledcWriteTone(0,0); +} + +void toneOn(int ms) { + if (sonde.config.piezoe_pout >= 0) { + ledcWriteTone(0,440); // 440 Hz - Middle A + tone.once_ms(ms, toneOffCallback); + } +} + int doTouch = 0; void checkTouchStatus() { checkTouchButton(button1); @@ -1765,6 +1778,11 @@ void setup() flashLed(1000); // testing } + if (sonde.config.piezoe_pout >= 0) { + ledcAttachPin(sonde.config.piezoe_pout,0); + toneOn(1000); // testing + } + button1.pin = sonde.config.button_pin; button2.pin = sonde.config.button2_pin; if (button1.pin != 0xff) { diff --git a/RX_FSK/data/cfg.js b/RX_FSK/data/cfg.js index a0df69e7..c3da3df7 100644 --- a/RX_FSK/data/cfg.js +++ b/RX_FSK/data/cfg.js @@ -88,6 +88,7 @@ var cfgs = [ [ "touch_thresh", "Touch button threshold
(0 for calib mode)"], [ "power_pout", "Power control port"], [ "led_pout", "LED output port"], +[ "piezoe_pout", "Piezo output port"], [ "gps_rxd", "GPS RXD pin (-1 to disable)"], [ "gps_txd", "GPS TXD pin (not really needed)"], [ "batt_adc", "Battery measurement pin"], diff --git a/RX_FSK/data/config.txt b/RX_FSK/data/config.txt index 6d8e2543..da30a655 100644 --- a/RX_FSK/data/config.txt +++ b/RX_FSK/data/config.txt @@ -10,6 +10,8 @@ #button2_axp=0 # LED port #led_pout=-1 +# Piezoe Speaker +piezoe_pout=-1 # OLED Setup is depending on hardware of LoRa board # TTGO v1: SDA=4 SCL=15, RST=16 # TTGO v2: SDA=21 SCL=22, RST=16 diff --git a/RX_FSK/src/Sonde.cpp b/RX_FSK/src/Sonde.cpp index d3afe3b8..18bf8918 100644 --- a/RX_FSK/src/Sonde.cpp +++ b/RX_FSK/src/Sonde.cpp @@ -92,6 +92,7 @@ void Sonde::defaultConfig() { } config.touch_thresh = 70; config.led_pout = -1; + config.piezoe_pout = -1; config.power_pout = -1; config.spectrum=10; // Try autodetecting board type @@ -462,6 +463,8 @@ void Sonde::setup() { extern void flashLed(int ms); +extern void toneOn(int ms); + void Sonde::receive() { uint16_t res = 0; SondeInfo *si = &sondeList[rxtask.currentSonde]; @@ -490,6 +493,7 @@ void Sonde::receive() { // state information for RX_TIMER / NORX_TIMER events if(res==RX_OK || res==RX_ERROR) { // something was received... flashLed( (res==RX_OK)?700:100); + toneOn( (res==RX_OK)?200:50); if(si->lastState != 1) { si->rxStart = millis(); si->lastState = 1; diff --git a/RX_FSK/src/Sonde.h b/RX_FSK/src/Sonde.h index 422d5848..a2a87626 100644 --- a/RX_FSK/src/Sonde.h +++ b/RX_FSK/src/Sonde.h @@ -240,6 +240,7 @@ typedef struct st_rdzconfig { int button2_axp; // Use AXP192 power button as button2 int touch_thresh; // Threshold value (0..100) for touch input button int led_pout; // POUT port number of LED (used as serial monitor) + int piezoe_pout; // POUT port number of Piezoe Speaker int power_pout; // Power control pin (for Heltec v2) int disptype; // 0=OLED; 1=ILI9225 int oled_sda; // OLED/TFT data pin diff --git a/RX_FSK/version.h b/RX_FSK/version.h index 7df7fe7e..633aa5ca 100644 --- a/RX_FSK/version.h +++ b/RX_FSK/version.h @@ -1,4 +1,4 @@ const char *version_name = "rdzTTGOsonde"; const char *version_id = "devel20240530"; const int SPIFFS_MAJOR=2; -const int SPIFFS_MINOR=17; +const int SPIFFS_MINOR=18; From 2a97742db225735b8b3dcef7acbee726142b397e Mon Sep 17 00:00:00 2001 From: Endaf Jones Date: Wed, 2 Oct 2024 10:05:37 -0600 Subject: [PATCH 2/2] mqtt report uptime in a more usefull seconds instead of milliseconds --- RX_FSK/src/conn-mqtt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RX_FSK/src/conn-mqtt.cpp b/RX_FSK/src/conn-mqtt.cpp index e8149d91..4aafca78 100644 --- a/RX_FSK/src/conn-mqtt.cpp +++ b/RX_FSK/src/conn-mqtt.cpp @@ -112,7 +112,7 @@ void MQTT::publishUptime() char payload[256]; // maybe TODO: Use dynamic position if GPS is available? // rxlat, rxlon only if not empty - snprintf(payload, 256, "{\"uptime\": %lu, \"user\": \"%s\", ", millis(), sonde.config.mqtt.username); + snprintf(payload, 256, "{\"uptime\": %lu, \"user\": \"%s\", ", int (millis() / 1000, sonde.config.mqtt.username); if( !isnan(sonde.config.rxlat) && !isnan(sonde.config.rxlon) ) { snprintf(payload, 256, "%s\"rxlat\": %.5f, \"rxlon\": %.5f, ", payload, sonde.config.rxlat, sonde.config.rxlon); }