Merge pull request 'Group inputs into one webform' (#5) from share-webform into main
Reviewed-on: #5
This commit is contained in:
commit
17d8883f39
|
@ -37,6 +37,11 @@ const char* PARAM_STRING = "inputString";
|
||||||
const char* PARAM_INT = "inputInt";
|
const char* PARAM_INT = "inputInt";
|
||||||
const char* PARAM_FLOAT = "inputFloat";
|
const char* PARAM_FLOAT = "inputFloat";
|
||||||
|
|
||||||
|
// Global variables
|
||||||
|
String yourInputString;
|
||||||
|
int yourInputInt;
|
||||||
|
float yourInputFloat;
|
||||||
|
|
||||||
// HTML web page to handle 3 input fields (inputString, inputInt, inputFloat)
|
// HTML web page to handle 3 input fields (inputString, inputInt, inputFloat)
|
||||||
const char index_html[] PROGMEM = R"rawliteral(
|
const char index_html[] PROGMEM = R"rawliteral(
|
||||||
<!DOCTYPE HTML><html><head>
|
<!DOCTYPE HTML><html><head>
|
||||||
|
@ -49,15 +54,19 @@ const char index_html[] PROGMEM = R"rawliteral(
|
||||||
}
|
}
|
||||||
</script></head><body>
|
</script></head><body>
|
||||||
<form action="/get" target="hidden-form">
|
<form action="/get" target="hidden-form">
|
||||||
inputString (current value %inputString%): <input type="text" name="inputString" value=%inputString%>
|
inputString (current value %inputString%): <input type="text" name="inputString" value=%inputString%><br>
|
||||||
|
<!--
|
||||||
|
<input type="submit" value="Submit" onclick="submitMessage()">
|
||||||
|
</form><br>
|
||||||
|
<form action="/get" target="hidden-form">
|
||||||
|
-->
|
||||||
|
Seconds between flash (current value %inputInt%): <input type="number " name="inputInt" value = %inputInt%><br>
|
||||||
|
<!--
|
||||||
<input type="submit" value="Submit" onclick="submitMessage()">
|
<input type="submit" value="Submit" onclick="submitMessage()">
|
||||||
</form><br>
|
</form><br>
|
||||||
<form action="/get" target="hidden-form">
|
<form action="/get" target="hidden-form">
|
||||||
Seconds between flash (current value %inputInt%): <input type="number " name="inputInt" value = %inputInt%>
|
-->
|
||||||
<input type="submit" value="Submit" onclick="submitMessage()">
|
inputFloat (current value %inputFloat%): <input type="number " name="inputFloat" value = %inputFloat%><br>
|
||||||
</form><br>
|
|
||||||
<form action="/get" target="hidden-form">
|
|
||||||
inputFloat (current value %inputFloat%): <input type="number " name="inputFloat" value = %inputFloat%>
|
|
||||||
<input type="submit" value="Submit" onclick="submitMessage()">
|
<input type="submit" value="Submit" onclick="submitMessage()">
|
||||||
</form>
|
</form>
|
||||||
<iframe style="display:none" name="hidden-form"></iframe>
|
<iframe style="display:none" name="hidden-form"></iframe>
|
||||||
|
@ -263,22 +272,23 @@ void setup() {
|
||||||
digitalWrite(output27, LOW);
|
digitalWrite(output27, LOW);
|
||||||
|
|
||||||
// Initialize SPIFFS
|
// Initialize SPIFFS
|
||||||
#ifdef ESP32
|
SPIFFS.begin(true);
|
||||||
|
//#ifdef ESP32
|
||||||
if(!SPIFFS.begin(true)){
|
if(!SPIFFS.begin(true)){
|
||||||
Serial.println("An Error has occurred while mounting SPIFFS");
|
Serial.println("An Error has occurred while mounting SPIFFS");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#else
|
//#else
|
||||||
if(!SPIFFS.begin()){
|
if(!SPIFFS.begin()){
|
||||||
Serial.println("An Error has occurred while mounting SPIFFS");
|
Serial.println("An Error has occurred while mounting SPIFFS");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
// Read in existing data
|
// Read in existing data
|
||||||
// String yourInputString = readFile(SPIFFS, "/inputString.txt");
|
yourInputString = readFile(SPIFFS, "/inputString.txt");
|
||||||
// int yourInputInt = readFile(SPIFFS, "/inputInt.txt").toInt();
|
yourInputInt = readFile(SPIFFS, "/inputInt.txt").toInt();
|
||||||
// float yourInputFloat = readFile(SPIFFS, "/inputFloat.txt").toFloat();
|
yourInputFloat = readFile(SPIFFS, "/inputFloat.txt").toFloat();
|
||||||
|
|
||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
WiFi.begin(ssid, password);
|
WiFi.begin(ssid, password);
|
||||||
|
@ -302,21 +312,23 @@ void setup() {
|
||||||
if (request->hasParam(PARAM_STRING)) {
|
if (request->hasParam(PARAM_STRING)) {
|
||||||
inputMessage = request->getParam(PARAM_STRING)->value();
|
inputMessage = request->getParam(PARAM_STRING)->value();
|
||||||
writeFile(SPIFFS, "/inputString.txt", inputMessage.c_str());
|
writeFile(SPIFFS, "/inputString.txt", inputMessage.c_str());
|
||||||
|
yourInputString = inputMessage;
|
||||||
}
|
}
|
||||||
// GET inputInt value on <ESP_IP>/get?inputInt=<inputMessage>
|
// GET inputInt value on <ESP_IP>/get?inputInt=<inputMessage>
|
||||||
else if (request->hasParam(PARAM_INT)) {
|
if (request->hasParam(PARAM_INT)) {
|
||||||
inputMessage = request->getParam(PARAM_INT)->value();
|
inputMessage = request->getParam(PARAM_INT)->value();
|
||||||
writeFile(SPIFFS, "/inputInt.txt", inputMessage.c_str());
|
writeFile(SPIFFS, "/inputInt.txt", inputMessage.c_str());
|
||||||
|
yourInputInt = inputMessage.toInt();
|
||||||
}
|
}
|
||||||
// GET inputFloat value on <ESP_IP>/get?inputFloat=<inputMessage>
|
// GET inputFloat value on <ESP_IP>/get?inputFloat=<inputMessage>
|
||||||
else if (request->hasParam(PARAM_FLOAT)) {
|
if (request->hasParam(PARAM_FLOAT)) {
|
||||||
inputMessage = request->getParam(PARAM_FLOAT)->value();
|
inputMessage = request->getParam(PARAM_FLOAT)->value();
|
||||||
writeFile(SPIFFS, "/inputFloat.txt", inputMessage.c_str());
|
writeFile(SPIFFS, "/inputFloat.txt", inputMessage.c_str());
|
||||||
|
yourInputFloat = inputMessage.toFloat();
|
||||||
}
|
}
|
||||||
else {
|
// else {
|
||||||
inputMessage = "No message sent";
|
// inputMessage = "No message sent";
|
||||||
}
|
// }
|
||||||
Serial.println(inputMessage);
|
|
||||||
request->send(200, "text/plain", inputMessage);
|
request->send(200, "text/plain", inputMessage);
|
||||||
|
|
||||||
// // Update data from files
|
// // Update data from files
|
||||||
|
@ -348,25 +360,26 @@ void loop() {
|
||||||
//arduinomorse
|
//arduinomorse
|
||||||
//sender.continueSending();
|
//sender.continueSending();
|
||||||
|
|
||||||
String yourInputString = readFile(SPIFFS, "/inputString.txt");
|
//String yourInputString = readFile(SPIFFS, "/inputString.txt");
|
||||||
int yourInputInt = readFile(SPIFFS, "/inputInt.txt").toInt();
|
//int yourInputInt = readFile(SPIFFS, "/inputInt.txt").toInt();
|
||||||
// float yourInputFloat = readFile(SPIFFS, "/inputFloat.txt").toFloat();
|
// float yourInputFloat = readFile(SPIFFS, "/inputFloat.txt").toFloat();
|
||||||
|
|
||||||
// if you want to send code, and it's not sending, then start it up
|
// if you want to send code, and it's not sending, then start it up
|
||||||
if(yourInputInt != 0 & morseLed.IsRunning() == false){
|
if((yourInputInt != 0) & (morseLed.IsRunning() == false)){
|
||||||
//jled
|
//jled
|
||||||
morseLed.Reset().Update();
|
morseLed.Reset().Update();
|
||||||
//morse.send("CQ CQ CQ DE W1CDN K"); //etherkit morse
|
//morse.send("CQ CQ CQ DE W1CDN K"); //etherkit morse
|
||||||
//telegraph26.send("CQ CQ CQ DE W1CDN K"); //telegraph
|
//telegraph26.send("CQ CQ CQ DE W1CDN K"); //telegraph
|
||||||
|
|
||||||
// if you want to send code, and it is sending, keep sending
|
// if you want to send code, and it is sending, keep sending
|
||||||
} else if(yourInputInt != 0 & morseLed.IsRunning() == true){
|
} else if((yourInputInt != 0) & (morseLed.IsRunning() == true)){
|
||||||
morseLed.Update();
|
morseLed.Update();
|
||||||
// if you don't want to send code
|
// if you don't want to send code
|
||||||
} else {
|
} else {
|
||||||
// stop sending and make sure the pin is off
|
// stop sending and make sure the pin is off
|
||||||
morseLed.Stop(JLed::eStopMode::FULL_OFF).Update();
|
morseLed.Stop(JLed::eStopMode::FULL_OFF).Update();
|
||||||
}
|
}
|
||||||
|
morseLed.Update();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user