Compare commits
No commits in common. "dccd3d27f454e7625cdbb25455706a6006bbca47" and "08b1bdf3fd51e8b674e760c52266f68f7d7b5c36" have entirely different histories.
dccd3d27f4
...
08b1bdf3fd
@ -38,10 +38,10 @@ const int alarmPin = 4; // pin to monitor for RTC alarms
|
|||||||
const char* ssid = WIFI_SSID;
|
const char* ssid = WIFI_SSID;
|
||||||
const char* password = WIFI_PASSWORD;
|
const char* password = WIFI_PASSWORD;
|
||||||
|
|
||||||
|
const char* PARAM_STRING = "inputString";
|
||||||
const char* PARAM_SEND = "inputSend";
|
const char* PARAM_SEND = "inputSend";
|
||||||
const char* PARAM_WPM = "inputWPM";
|
const char* PARAM_WPM = "inputWPM";
|
||||||
const char* PARAM_MSG = "inputMsg";
|
const char* PARAM_MSG = "inputMsg";
|
||||||
const char* PARAM_CMSG = "inputCustomMsg";
|
|
||||||
const char* PARAM_FLOAT = "inputFloat";
|
const char* PARAM_FLOAT = "inputFloat";
|
||||||
const char* PARAM_TIME = "inputTimeUnix";
|
const char* PARAM_TIME = "inputTimeUnix";
|
||||||
const char* PARAM_START = "inputStartTimeUnix";
|
const char* PARAM_START = "inputStartTimeUnix";
|
||||||
@ -51,11 +51,11 @@ const char* PARAM_CYCLEID = "inputCycleID";
|
|||||||
const char* PARAM_NTRANS = "inputNtransmitters";
|
const char* PARAM_NTRANS = "inputNtransmitters";
|
||||||
|
|
||||||
// Global variables
|
// Global variables
|
||||||
|
String yourInputString;
|
||||||
int yourInputSend;
|
int yourInputSend;
|
||||||
int yourInputWPM;
|
int yourInputWPM;
|
||||||
int yourInputMsg;
|
int yourInputMsg;
|
||||||
int yourInputMsg_old; // to save previous state and check changes
|
int yourInputMsg_old; // to save previous state and check changes
|
||||||
String yourInputCustomMsg;
|
|
||||||
float yourInputFloat;
|
float yourInputFloat;
|
||||||
uint32_t yourInputTime; //to keep time
|
uint32_t yourInputTime; //to keep time
|
||||||
uint32_t yourInputStartTimeUnix;
|
uint32_t yourInputStartTimeUnix;
|
||||||
@ -68,7 +68,7 @@ long start_millis = 0;
|
|||||||
long stop_millis = 0;
|
long stop_millis = 0;
|
||||||
long pause_until_millis = 0;
|
long pause_until_millis = 0;
|
||||||
|
|
||||||
// HTML web page to handle input fields
|
// HTML web page to handle 3 input fields (inputString, inputSend, inputFloat)
|
||||||
const char index_html[] PROGMEM = R"rawliteral(
|
const char index_html[] PROGMEM = R"rawliteral(
|
||||||
<!DOCTYPE HTML><html><head>
|
<!DOCTYPE HTML><html><head>
|
||||||
<link rel="icon" href="data:,">
|
<link rel="icon" href="data:,">
|
||||||
@ -130,15 +130,13 @@ const char index_html[] PROGMEM = R"rawliteral(
|
|||||||
|
|
||||||
Message:
|
Message:
|
||||||
<select name="inputMsg" id="message">
|
<select name="inputMsg" id="message">
|
||||||
<option value="0">0 - Custom Message</option>
|
<option value="0">0 - TEST TEST TEST DE W1CDN</option>
|
||||||
<option value="1">1 - MOE</option>
|
<option value="1">1 - MOE</option>
|
||||||
<option value="2">2 - MOI</option>
|
<option value="2">2 - MOI</option>
|
||||||
<option value="3">3 - MOS</option>
|
<option value="3">3 - MOS</option>
|
||||||
<option value="4">4 - MOH</option>
|
<option value="4">4 - MOH</option>
|
||||||
<option value="5">5 - MO5</option>
|
<option value="5">5 - MO5</option>
|
||||||
</select><br>
|
</select><br>
|
||||||
|
|
||||||
Custom message: <input type="text" name="inputCustomMsg" value = "%inputCustomMsg%"><br>
|
|
||||||
|
|
||||||
Speed: <input type="number" name="inputWPM" value = %inputWPM%> WPM
|
Speed: <input type="number" name="inputWPM" value = %inputWPM%> WPM
|
||||||
</p>
|
</p>
|
||||||
@ -162,6 +160,7 @@ const char index_html[] PROGMEM = R"rawliteral(
|
|||||||
<input type="hidden" name="inputTimeUnix" id="js_time_unix">
|
<input type="hidden" name="inputTimeUnix" id="js_time_unix">
|
||||||
|
|
||||||
<!-- Extra fields just in case I need them -->
|
<!-- Extra fields just in case I need them -->
|
||||||
|
<input type="hidden" name="inputString" value = %inputString%>
|
||||||
<input type="hidden" name="inputFloat" value = %inputFloat%>
|
<input type="hidden" name="inputFloat" value = %inputFloat%>
|
||||||
|
|
||||||
<input type="submit" value="Submit"">
|
<input type="submit" value="Submit"">
|
||||||
@ -212,8 +211,8 @@ void writeFile(fs::FS &fs, const char * path, const char * message){
|
|||||||
// Replaces placeholder in web UI with stored values
|
// Replaces placeholder in web UI with stored values
|
||||||
String processor(const String& var){
|
String processor(const String& var){
|
||||||
//Serial.println(var);
|
//Serial.println(var);
|
||||||
if(var == "inputCustomMsg"){
|
if(var == "inputString"){
|
||||||
return readFile(SPIFFS, "/inputCustomMsg.txt");
|
return readFile(SPIFFS, "/inputString.txt");
|
||||||
}
|
}
|
||||||
else if(var == "inputSend"){
|
else if(var == "inputSend"){
|
||||||
return readFile(SPIFFS, "/inputSend.txt");
|
return readFile(SPIFFS, "/inputSend.txt");
|
||||||
@ -309,7 +308,7 @@ void setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read in existing data
|
// Read in existing data
|
||||||
yourInputCustomMsg = readFile(SPIFFS, "/inputCustomMsg.txt");
|
yourInputString = readFile(SPIFFS, "/inputString.txt");
|
||||||
yourInputSend = readFile(SPIFFS, "/inputSend.txt").toInt();
|
yourInputSend = readFile(SPIFFS, "/inputSend.txt").toInt();
|
||||||
yourInputWPM = readFile(SPIFFS, "/inputWPM.txt").toFloat();
|
yourInputWPM = readFile(SPIFFS, "/inputWPM.txt").toFloat();
|
||||||
yourInputMsg = readFile(SPIFFS, "/inputMsg.txt").toInt();
|
yourInputMsg = readFile(SPIFFS, "/inputMsg.txt").toInt();
|
||||||
@ -325,8 +324,8 @@ void setup() {
|
|||||||
// On restart, keep doing what you were doing before
|
// On restart, keep doing what you were doing before
|
||||||
yourInputMsg_old = yourInputMsg;
|
yourInputMsg_old = yourInputMsg;
|
||||||
if(yourInputMsg == 0){
|
if(yourInputMsg == 0){
|
||||||
sender_blink.setMessage(yourInputCustomMsg);
|
sender_blink.setMessage(String("test test test de w1cdn "));
|
||||||
sender_key.setMessage(yourInputCustomMsg);
|
sender_key.setMessage(String("test test test de w1cdn "));
|
||||||
} else if(yourInputMsg == 1){
|
} else if(yourInputMsg == 1){
|
||||||
sender_blink.setMessage(String("moe "));
|
sender_blink.setMessage(String("moe "));
|
||||||
sender_key.setMessage(String("moe "));
|
sender_key.setMessage(String("moe "));
|
||||||
@ -359,17 +358,14 @@ void setup() {
|
|||||||
request->send_P(200, "text/html", index_html, processor);
|
request->send_P(200, "text/html", index_html, processor);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Send a GET request to <ESP_IP>/get?inputCustomMsg=<inputMessage>
|
// Send a GET request to <ESP_IP>/get?inputString=<inputMessage>
|
||||||
server.on("/get", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
server.on("/get", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
||||||
String inputMessage;
|
String inputMessage;
|
||||||
// GET inputCustomMsg value on <ESP_IP>/get?inputCustomMsg=<inputMessage>
|
// GET inputString value on <ESP_IP>/get?inputString=<inputMessage>
|
||||||
if (request->hasParam(PARAM_CMSG)) {
|
if (request->hasParam(PARAM_STRING)) {
|
||||||
inputMessage = request->getParam(PARAM_CMSG)->value();
|
inputMessage = request->getParam(PARAM_STRING)->value();
|
||||||
// arduinomorse needs lowercase characters
|
writeFile(SPIFFS, "/inputString.txt", inputMessage.c_str());
|
||||||
std::transform(inputMessage.begin(), inputMessage.end(), inputMessage.begin(), ::tolower);
|
yourInputString = inputMessage;
|
||||||
writeFile(SPIFFS, "/inputCustomMsg.txt", inputMessage.c_str());
|
|
||||||
yourInputCustomMsg = inputMessage;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// GET inputSend value on <ESP_IP>/get?inputSend=<inputMessage>
|
// GET inputSend value on <ESP_IP>/get?inputSend=<inputMessage>
|
||||||
if (request->hasParam(PARAM_SEND)) {
|
if (request->hasParam(PARAM_SEND)) {
|
||||||
@ -401,8 +397,8 @@ void setup() {
|
|||||||
|
|
||||||
// Check the message every time the form is submitted.
|
// Check the message every time the form is submitted.
|
||||||
if(yourInputMsg == 0){
|
if(yourInputMsg == 0){
|
||||||
sender_blink.setMessage(yourInputCustomMsg);
|
sender_blink.setMessage(String("test test test de w1cdn "));
|
||||||
sender_key.setMessage(yourInputCustomMsg);
|
sender_key.setMessage(String("test test test de w1cdn "));
|
||||||
} else if(yourInputMsg == 1){
|
} else if(yourInputMsg == 1){
|
||||||
sender_blink.setMessage(String("moe "));
|
sender_blink.setMessage(String("moe "));
|
||||||
sender_key.setMessage(String("moe "));
|
sender_key.setMessage(String("moe "));
|
||||||
|
Loading…
Reference in New Issue
Block a user