Skip to content

Commit

Permalink
Doc
Browse files Browse the repository at this point in the history
  • Loading branch information
pu2clr committed Oct 9, 2024
1 parent a807860 commit 6affb57
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
4 changes: 2 additions & 2 deletions examples/08_STM32/STM32_ENCODER_LCD/STM32_ENCODER_LCD.ino
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,8 @@ void setup() {
// recompile the code, and upload it again. This step prevents the clock from being reset each time the
// STM32 is restarted. By following these steps, the RTC will retain the correct time the next time you
// power on the STM32.
// rtc.setTime(9, 18, 0); // Set here the current Hour, Minute and Seconds
// rtc.setDate(2, 8, 10, 24); // Set here the current Week Day, Day, Month and Year
// rtc.setTime(10, 57, 0); // Set here the current Hour, Minute and Seconds
// rtc.setDate(3, 9, 10, 24); // Set here the current Week Day, Day, Month and Year
// END - STM32 RTC Setup

Wire.begin(STM32_I2C_SDA, STM32_I2C_SCL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ void doFormParameters() {
htmlPage += "function sendData(fieldId) {";
htmlPage += " var value = document.getElementById(fieldId).value;";
htmlPage += " var xhr = new XMLHttpRequest();";
htmlPage += " xhr.open('POST', '/update', true);";
htmlPage += " xhr.open('POST', '/setParameters', true);";
htmlPage += " xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');";
htmlPage += " xhr.onreadystatechange = function() {";
htmlPage += " if (xhr.readyState == 4 && xhr.status == 200) {";
Expand Down Expand Up @@ -293,6 +293,16 @@ String getValue(String data, String field) {
}


void doNothing() {

client.println("HTTP/1.1 200 OK");
client.println("Content-type:text/plain");
client.println();
client.println("Nothing!");
client.println();

}

void loop() {
// Check if there are any connected clients
client = server.available();
Expand All @@ -304,13 +314,18 @@ void loop() {
Serial.println(request);
client.readStringUntil('\n'); // Skip the remaining headers

// Check if it's a POST request
if (request.indexOf("POST") >= 0) {
processPostRequest();
} else {
// For other requests (like GET), serve the HTML form
Serial.println("Ok");
doFormParameters();
// Process the request manually based on URL
if (request.indexOf("GET / ") >= 0) {
doFormParameters(); // Route for the root page
}
else if (request.indexOf("POST /setParameters") >= 0) {
doFormParameters(); // Route for handling form submission
}
else if (request.indexOf("POST /update") >= 0) {
processPostRequest(); // Route for handling AJAX updates
}
else {
doNothing(); // Handle 404 - Not Found
}

// Close the connection with the client
Expand All @@ -319,3 +334,4 @@ void loop() {
}
}


0 comments on commit 6affb57

Please sign in to comment.