add reboot to control buttons (#111)

This commit is contained in:
Michael Carter 2021-07-26 20:09:03 +01:00 committed by GitHub
parent 7f2b9ef611
commit 4dc3ea6974
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 4 deletions

View File

@ -783,23 +783,24 @@ const char *handleConfigPost(AsyncWebServerRequest *request) {
return ""; return "";
} }
const char *ctrlid[] = {"rx", "scan", "spec", "wifi", "rx2", "scan2", "spec2", "wifi2"}; const char *ctrlid[] = {"rx", "scan", "spec", "wifi", "rx2", "scan2", "spec2", "wifi2", "reboot"};
const char *ctrllabel[] = {"Receiver/next freq. (short keypress)", "Scanner (double keypress)", "Spectrum (medium keypress)", "WiFi (long keypress)", const char *ctrllabel[] = {"Receiver/next freq. (short keypress)", "Scanner (double keypress)", "Spectrum (medium keypress)", "WiFi (long keypress)",
"Button 2/next screen (short keypress)", "Button 2 (double keypress)", "Button 2 (medium keypress)", "Button 2 (long keypress)" "Button 2/next screen (short keypress)", "Button 2 (double keypress)", "Button 2 (medium keypress)", "Button 2 (long keypress)",
"Reboot"
}; };
const char *createControlForm() { const char *createControlForm() {
char *ptr = message; char *ptr = message;
strcpy(ptr, HTMLHEAD); strcat(ptr, "</head>"); strcpy(ptr, HTMLHEAD); strcat(ptr, "</head>");
HTMLBODY(ptr, "control.html"); HTMLBODY(ptr, "control.html");
for (int i = 0; i < 8; i++) { for (int i = 0; i < 9; i++) {
strcat(ptr, "<input class=\"ctlbtn\" type=\"submit\" name=\""); strcat(ptr, "<input class=\"ctlbtn\" type=\"submit\" name=\"");
strcat(ptr, ctrlid[i]); strcat(ptr, ctrlid[i]);
strcat(ptr, "\" value=\""); strcat(ptr, "\" value=\"");
strcat(ptr, ctrllabel[i]); strcat(ptr, ctrllabel[i]);
strcat(ptr, "\"></input>"); strcat(ptr, "\"></input>");
if (i == 3) { if (i == 3 || i == 7 ) {
strcat(ptr, "<p></p>"); strcat(ptr, "<p></p>");
} }
} }
@ -847,6 +848,10 @@ const char *handleControlPost(AsyncWebServerRequest *request) {
Serial.println("equals wifi2"); Serial.println("equals wifi2");
button2.pressed = KP_LONG; button2.pressed = KP_LONG;
} }
else if (param.equals("reboot")) {
Serial.println("equals reboot");
ESP.restart();
}
} }
return ""; return "";
} }