diff --git a/RX_FSK/RX_FSK.ino b/RX_FSK/RX_FSK.ino index 34ea72b..1200b7a 100644 --- a/RX_FSK/RX_FSK.ino +++ b/RX_FSK/RX_FSK.ino @@ -46,14 +46,21 @@ enum KeyPress { KP_NONE = 0, KP_SHORT, KP_DOUBLE, KP_MID, KP_LONG }; struct Button { uint8_t pin; + uint32_t numberKeyPresses; KeyPress pressed; unsigned long press_ts; boolean doublepress; + + bool isTouched; + long touchTime; }; -Button button1 = {0, 0, KP_NONE, 0, false}; +Button button1 = {0, 0, KP_NONE, 0, false, false, 0}; +Button button2 = {0, 0, KP_NONE, 0, false, false, 0}; +static int lastDisplay = 1; +static int currentDisplay = 1; // Set LED GPIO int ledPin = 1; @@ -117,7 +124,7 @@ void setupChannelList() { return; } int i = 0; - char launchsite[17]=" "; + char launchsite[17] = " "; sonde.clearSonde(); Serial.println("Reading channel config:"); while (file.available()) { @@ -143,8 +150,8 @@ void setupChannelList() { int active = space[3] == '+' ? 1 : 0; if (space[4] == ' ') { memset(launchsite, ' ', 16); - int str_len = strlen(space+5); - strncpy(launchsite, space+5, str_len>16?16:str_len); + int str_len = strlen(space + 5); + strncpy(launchsite, space + 5, str_len > 16 ? 16 : str_len); if (sonde.config.debug == 1) { Serial.printf("Add %f - sondetype: %d (on/off: %d) - site #%d - name: %s\n ", freq, type, active, i, launchsite); } @@ -367,7 +374,7 @@ struct st_configitems config_list[] = { /* General config settings */ {"wifi", "Wifi mode (0/1/2/3)", 0, &sonde.config.wifi}, {"debug", "Debug mode (0/1)", 0, &sonde.config.debug}, - {"maxsonde", "Maxsonde (requires reboot?)", 0, &sonde.config.maxsonde}, + {"maxsonde", "Maxsonde", 0, &sonde.config.maxsonde}, {"display", "Display mode (1/2/3)", 0, &sonde.config.display}, {"---", "---", -1, NULL}, /* Spectrum display settings */ @@ -407,6 +414,7 @@ struct st_configitems config_list[] = { {"oled_scl", "OLED SCL (needs reboot)", 0, &sonde.config.oled_scl}, {"oled_rst", "OLED RST (needs reboot)", 0, &sonde.config.oled_rst}, {"button_pin", "Button input port (needs reboot)", 0, &sonde.config.button_pin}, + {"button2_pin", "Button 2 input port (needs reboot)", 0, &sonde.config.button2_pin}, {"led_pout", "LED output port (needs reboot)", 0, &sonde.config.led_pout}, }; const static int N_CONFIG = (sizeof(config_list) / sizeof(struct st_configitems)); @@ -489,16 +497,20 @@ const char *handleConfigPost(AsyncWebServerRequest *request) { f.printf("%s=%s\n", config_list[idx].name, strvalue.c_str()); } f.close(); + currentDisplay = sonde.config.display; setupConfigData(); } -const char *ctrlid[] = {"rx", "scan", "spec", "wifi"}; -const char *ctrllabel[] = {"Receiver (short keypress)", "Scanner (double keypress)", "Spectrum (medium keypress)", "WiFi (long keypress)"}; +const char *ctrlid[] = {"rx", "scan", "spec", "wifi", "rx2", "scan2", "spec2", "wifi2"}; + +const char *ctrllabel[] = {"Receiver (short keypress)", "Scanner (double keypress)", "Spectrum (medium keypress)", "WiFi (long keypress)", + "Button 2 (short keypress)", "Button 2 (double keypress)", "Button 2 (medium keypress)", "Button 2 (long keypress)" + }; + const char *createControlForm() { char *ptr = message; - char tmp[4]; strcpy(ptr, "