Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added audio feedback of packets received with addition of a piezoe sp… #466

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions RX_FSK/RX_FSK.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -1380,6 +1381,7 @@ void touchISR2();

Ticker ticker;
Ticker ledFlasher;
Ticker tone;

#define IS_TOUCH(x) (((x)!=255)&&((x)!=-1)&&((x)&128))
void initTouch() {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions RX_FSK/data/cfg.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ var cfgs = [
[ "touch_thresh", "Touch button threshold<br>(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"],
Expand Down
2 changes: 2 additions & 0 deletions RX_FSK/data/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions RX_FSK/src/Sonde.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions RX_FSK/src/Sonde.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion RX_FSK/src/conn-mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion RX_FSK/version.h
Original file line number Diff line number Diff line change
@@ -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;