nicer configuration of button/touch in web interface; autoconfig enhanced
This commit is contained in:
parent
2928b41270
commit
ff035eabd4
|
|
@ -423,8 +423,8 @@ struct st_configitems config_list[] = {
|
|||
{"oled_sda", "OLED SDA (needs reboot)", 0, &sonde.config.oled_sda},
|
||||
{"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},
|
||||
{"button_pin", "Button input port (needs reboot)", -4, &sonde.config.button_pin},
|
||||
{"button2_pin", "Button 2 input port (needs reboot)", -4, &sonde.config.button2_pin},
|
||||
{"touch_thresh", "Touch button threshold (needs reboot)", 0, &sonde.config.touch_thresh},
|
||||
{"led_pout", "LED output port (needs reboot)", 0, &sonde.config.led_pout},
|
||||
{"gps_rxd", "GPS RXD pin (-1 to disable)", 0, &sonde.config.gps_rxd},
|
||||
|
|
@ -440,6 +440,11 @@ void addConfigNumEntry(char *ptr, int idx, const char *label, int *value) {
|
|||
sprintf(ptr + strlen(ptr), "<tr><td>%s</td><td><input name=\"CFG%d\" type=\"text\" value=\"%d\"/></td></tr>\n",
|
||||
label, idx, *value);
|
||||
}
|
||||
void addConfigButtonEntry(char *ptr, int idx, const char *label, int *value) {
|
||||
sprintf(ptr + strlen(ptr), "<tr><td>%s</td><td><input name=\"CFG%d\" type=\"text\" size=\"3\" value=\"%d\"/>",
|
||||
label, idx, 127 & *value);
|
||||
sprintf(ptr + strlen(ptr), "<input type=\"checkbox\" name=\"TO%d\"%s> Touch </td></tr>\n", idx, 128 & *value ? " checked" : "");
|
||||
}
|
||||
void addConfigTypeEntry(char *ptr, int idx, const char *label, int *value) {
|
||||
// TODO
|
||||
}
|
||||
|
|
@ -467,6 +472,9 @@ const char *createConfigForm() {
|
|||
case 0:
|
||||
addConfigNumEntry(ptr, i, config_list[i].label, (int *)config_list[i].data);
|
||||
break;
|
||||
case -4:
|
||||
addConfigButtonEntry(ptr, i, config_list[i].label, (int *)config_list[i].data);
|
||||
break;
|
||||
default:
|
||||
addConfigStringEntry(ptr, i, config_list[i].label, config_list[i].type, (char *)config_list[i].data);
|
||||
break;
|
||||
|
|
@ -504,6 +512,15 @@ const char *handleConfigPost(AsyncWebServerRequest *request) {
|
|||
AsyncWebParameter *value = request->getParam(label, true);
|
||||
if (!value) continue;
|
||||
String strvalue = value->value();
|
||||
if (config_list[idx].type == -4) { // input button port with "touch" checkbox
|
||||
char tmp[10];
|
||||
snprintf(tmp, 10, "TO%d", idx);
|
||||
AsyncWebParameter *touch = request->getParam(tmp, true);
|
||||
if (touch) {
|
||||
int i = atoi(strvalue.c_str()) + 128;
|
||||
strvalue = String(i);
|
||||
}
|
||||
}
|
||||
Serial.printf("Processing %s=%s\n", config_list[idx].name, strvalue.c_str());
|
||||
f.printf("%s=%s\n", config_list[idx].name, strvalue.c_str());
|
||||
}
|
||||
|
|
@ -885,14 +902,17 @@ void sx1278Task(void *parameter) {
|
|||
(2) set output flag receiveResult (success/error/timeout and keybord events)
|
||||
|
||||
*/
|
||||
Serial.printf("rx task: activate=%d mainstate=%d\n", rxtask.activate, rxtask.mainState);
|
||||
while (1) {
|
||||
if (rxtask.activate >= 128) {
|
||||
// activating sx1278 background task...
|
||||
Serial.printf("rx task: activate=%d mainstate=%d\n", rxtask.activate, rxtask.mainState);
|
||||
rxtask.mainState = ST_DECODER;
|
||||
rxtask.currentSonde = rxtask.activate & 0x7F;
|
||||
Serial.println("rx task: calling sonde.setup()");
|
||||
sonde.setup();
|
||||
} else if (rxtask.activate != -1) {
|
||||
Serial.printf("rx task: activate=%d mainstate=%d\n", rxtask.activate, rxtask.mainState);
|
||||
rxtask.mainState = rxtask.activate;
|
||||
}
|
||||
rxtask.activate = -1;
|
||||
/* only if mainState is ST_DECODER */
|
||||
|
|
@ -900,13 +920,6 @@ void sx1278Task(void *parameter) {
|
|||
delay(100);
|
||||
continue;
|
||||
}
|
||||
#if 0
|
||||
if (resetup) {
|
||||
resetup = false;
|
||||
sonde.setup();
|
||||
}
|
||||
//Serial.println("rx task: calling sonde.receive()");
|
||||
#endif
|
||||
sonde.receive();
|
||||
delay(20);
|
||||
}
|
||||
|
|
@ -933,7 +946,7 @@ void IRAM_ATTR touchISR2() {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: touchRead in ISR is also a bad idea.
|
||||
// touchRead in ISR is also a bad idea. Now moved to Ticker task
|
||||
void checkTouchButton(Button & button) {
|
||||
if (button.isTouched) {
|
||||
int tmp = touchRead(button.pin & 0x7f);
|
||||
|
|
|
|||
|
|
@ -38,24 +38,33 @@ int getKeyPressEvent(); /* in RX_FSK.ino */
|
|||
Sonde::Sonde() {
|
||||
sondeList = (SondeInfo *)malloc((MAXSONDE+1)*sizeof(SondeInfo));
|
||||
memset(sondeList, 0, (MAXSONDE+1)*sizeof(SondeInfo));
|
||||
config.button_pin = 0;
|
||||
config.button2_pin = T4 + 128; // T4 == GPIO13, should be ok for v1 and v2
|
||||
config.touch_thresh = 60;
|
||||
config.touch_thresh = 70;
|
||||
config.led_pout = 9;
|
||||
// Try autodetecting board type
|
||||
// Seems like on startup, GPIO4 is 1 on v1 boards, 0 on v2.1 boards?
|
||||
int autodetect = gpio_get_level((gpio_num_t)4);
|
||||
if(autodetect==1) {
|
||||
int autodetect = gpio_get_level((gpio_num_t)16);
|
||||
config.gps_rxd = -1;
|
||||
config.gps_txd = -1;
|
||||
if(autodetect==0) {
|
||||
config.oled_sda = 4;
|
||||
config.oled_scl = 15;
|
||||
config.button_pin = 0;
|
||||
config.button2_pin = T4 + 128; // T4 == GPIO13
|
||||
} else {
|
||||
config.oled_sda = 21;
|
||||
config.oled_scl = 22;
|
||||
autodetect = gpio_get_level((gpio_num_t)17);
|
||||
if(autodetect==0) { // T-Beam
|
||||
config.button_pin = 39;
|
||||
config.button2_pin = T4 + 128; // T4 == GPIO13
|
||||
config.gps_rxd = 12;
|
||||
} else {
|
||||
config.button_pin = 2 + 128; // GPIO2 / T2
|
||||
config.button2_pin = 14 + 128; // GPIO14 / T6
|
||||
}
|
||||
}
|
||||
//
|
||||
config.oled_rst = 16;
|
||||
config.gps_rxd = -1;
|
||||
config.gps_txd = -1;
|
||||
config.noisefloor = -125;
|
||||
strcpy(config.call,"NOCALL");
|
||||
strcpy(config.passcode, "---");
|
||||
|
|
@ -322,8 +331,11 @@ void Sonde::receive() {
|
|||
// handled here...
|
||||
nextRxSonde();
|
||||
action = ACT_SONDE(rxtask.currentSonde);
|
||||
if(rxtask.activate==-1) {
|
||||
// race condition here. maybe better use mutex. TODO
|
||||
rxtask.activate = action;
|
||||
}
|
||||
}
|
||||
res = (action<<8) | (res&0xff);
|
||||
Serial.printf("receive Result is %04x\n", res);
|
||||
// let waitRXcomplete resume...
|
||||
|
|
@ -471,23 +483,10 @@ void Sonde::updateDisplayIP() {
|
|||
disp.updateDisplayIP();
|
||||
}
|
||||
|
||||
// Probing RS41
|
||||
// 40x.xxx MHz
|
||||
void Sonde::updateDisplayScanner() {
|
||||
disp.setLayout(0);
|
||||
disp.updateDisplay();
|
||||
disp.setLayout(config.display);
|
||||
#if 0
|
||||
char buf[16];
|
||||
u8x8->setFont(u8x8_font_7x14_1x2_r);
|
||||
u8x8->drawString(0, 0, "Scan:");
|
||||
u8x8->drawString(8, 0, sondeTypeStr[si()->type]);
|
||||
snprintf(buf, 16, "%3.3f MHz", si()->freq);
|
||||
u8x8->drawString(0,3, buf);
|
||||
snprintf(buf, 16, "%s", si()->launchsite);
|
||||
u8x8->drawString(0,5, buf);
|
||||
updateDisplayIP();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Sonde::updateDisplay()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
Heltec board
|
||||
(sda,scl: 4,15) (same as LORA v1.0)
|
||||
0:1 1:0 2:0 3:1 4:0 5:1 6:0 7:1 8:0 9:1 10:1 11:1 12:0 13:0 14:1 15:0 16:0 17:0 18:0 19:0 20:0 21:1 22:0 23:0 24:0 25:0 26:0 27:0 28:0 29:0 30:0 31:0 32:0 33:0 34:0 35:0 36:0 37:0 38:0
|
||||
|
||||
TTGO LORA32 v2.1_1.6 (button1: touch gpio 2 => 130; button2: touch gpio14 => 142)
|
||||
(sda,scl: 21,22)
|
||||
0:1 1:0 2:0 3:1 4:0 5:1 6:0 7:1 8:0 9:1 10:1 11:1 12:0 13:0 14:1 15*1 16*1 17*1 18:0 19:0 20:0 21:1 22*1 23*1 24:0 25:0 26:0 27:0 28:0 29:0 30:0 31:0 32:0 33:0 34:0 35:0 36:0 37:0 38:0
|
||||
|
||||
TTGO LORA v1.0
|
||||
(sda,scl: 4,15) (button1: 0) (button2: touch gpio13 = 141)
|
||||
0:1 1:0 2:0 3:1 4*1 5:1 6:0 7:1 8:0 9:1 10:1 11:1 12:0 13:0 14:1 15*1 16*0 17*0 18:0 19:0 20:0 21:0 22*0 23*0 24:0 25:0 26:0 27:0 28:0 29:0 30:0 31:0 32:0 33:0 34:0 35:0 36:0 37:0 38:0
|
||||
|
||||
TTGO T-Beam
|
||||
(sda,scl: 21,22) (button1: 39) (button2: touch gpio13 = 141) (gps rx: 12)
|
||||
0:1 1:0 2:0 3:1 4:0 5:1 6:0 7:1 8:0 9:1 10:1 11:1 12:0 13:0 14:1 15:1 16:1 17:0 18:0 19:0 20:0 21:1 22:1 23:1 24:0 25:0 26:0 27:0 28:0 29:0 30:0 31:0 32:0 33:0 34:0 35:0 36:0 37:0 38:0
|
||||
|
||||
|
||||
|
||||
Current autodetect strategy:
|
||||
RST always set to 16
|
||||
|
||||
GPIO16=0 (GPio22,23 would also work):
|
||||
==Heltec or TTGO LORA v1.0==
|
||||
SDA,SCL set to (4,15)
|
||||
Button 1 set to GPIO 0
|
||||
Button 2 set to Touch in GPIO 13 (141)
|
||||
|
||||
|
||||
otherwise
|
||||
==LORA32 v2.1 or T-Beam==
|
||||
SDA,SCL set to (21,22)
|
||||
GPIO17=0:
|
||||
== T-BEAM =
|
||||
GPS RX set to 12
|
||||
Button 1 set to GPIO39
|
||||
Button 2 set to Touch GPIO13 (141)
|
||||
otherweise:
|
||||
GPS disabled
|
||||
Button 1 set to Touch GPIO2 (130)
|
||||
Button 2 set to Touch GPIO14 (142)
|
||||
|
||||
Loading…
Reference in New Issue