Skip to content

Commit

Permalink
update web interface
Browse files Browse the repository at this point in the history
  • Loading branch information
SK21 committed Feb 24, 2024
1 parent e5a83fb commit 9ac049d
Show file tree
Hide file tree
Showing 10 changed files with 346 additions and 46 deletions.
Binary file modified Modules/ESP32 Rate/RC_ESP32.ino.bin
Binary file not shown.
13 changes: 7 additions & 6 deletions Modules/ESP32 Rate/RC_ESP32/Begin.ino
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,12 @@ void DoSetup()
// web server
Serial.println();
Serial.println("Starting Web Server");
server.on("/", HandlePage1);
server.on("/", HandleRoot);
server.on("/page1", HandlePage1);
server.on("/page2", HandlePage2);
server.on("/ButtonPressed", ButtonPressed);
server.onNotFound(HandlePage1);
server.onNotFound(HandleRoot);
server.begin();

// OTA
server.on("/myurl", HTTP_GET, []() {
Expand All @@ -357,8 +360,6 @@ void DoSetup()
/* INITIALIZE ESP2SOTA LIBRARY */
ESP2SOTA.begin(&server);

server.begin();

Serial.println("OTA started.");

// wifi client mode
Expand All @@ -369,12 +370,12 @@ void DoSetup()
WiFi.onEvent(WiFiStationConnected, WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_CONNECTED);
WiFi.onEvent(WiFiGotIP, WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_GOT_IP);
WiFi.onEvent(WiFiStationDisconnected, WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_DISCONNECTED);
WiFi.begin(MDL.NetName, MDL.NetPassword);
WiFi.begin(MDL.SSID, MDL.Password);
Serial.println();
Serial.println("Connecting to wifi network ...");
}

delay(1000);
delay(1500);
Serial.println("");
Serial.println("Finished setup.");
Serial.println("");
Expand Down
63 changes: 63 additions & 0 deletions Modules/ESP32 Rate/RC_ESP32/GUI.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
void HandleRoot()
{
if (server.hasArg("prop1"))
{
handleCredentials();
}
else
{
server.send(200, "text/html", GetPage0());
}
}

void HandlePage1()
{
// switches
server.send(200, "text/html", GetPage1());
}

void HandlePage2()
{
// network
server.send(200, "text/html", GetPage2());
}

void handleCredentials()
{
int NewID;
int Interval;

server.arg("prop1").toCharArray(MDL.SSID, sizeof(MDL.SSID) - 1);
server.arg("prop2").toCharArray(MDL.Password, sizeof(MDL.Password) - 1);
MDL.WifiMode = 1;

server.send(200, "text/html", GetPage0());

SaveData();

delay(3000);

ESP.restart();
}

void ButtonPressed()
{
if (server.arg("Btn") == "Master")
{
WifiMasterOn = !WifiMasterOn;
WifiSwitchesTimer = millis();
HandlePage1();
}
else
{
int ID = server.arg("Btn").toInt() - 1;
if (ID >= 0 && ID < 16)
{
Button[ID] = !Button[ID];
WifiSwitchesTimer = millis();
HandlePage1();
}
}
}


125 changes: 125 additions & 0 deletions Modules/ESP32 Rate/RC_ESP32/PgNetwork.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@

String GetPage2()
{
String st = "<HTML>";
st += "";
st += " <head>";
st += " <META content='text/html; charset=utf-8' http-equiv=Content-Type>";
st += " <meta name=vs_targetSchema content='HTML 4.0'>";
st += " <meta name='viewport' content='width=device-width, initial-scale=1.0'>";
st += " <title>Wifi AOG</title>";
st += " <style>";
st += " html {";
st += " font-family: Helvetica;";
st += " display: inline-block;";
st += " margin: 0px auto;";
st += " text-align: center;";
st += "";
st += " }";
st += "";
st += " h1 {";
st += " color: #444444;";
st += " margin: 50px auto 30px;";
st += " }";
st += "";
st += " table.center {";
st += " margin-left: auto;";
st += " margin-right: auto;";
st += " }";
st += "";
st += " .button-72 {";
st += " align-items: center;";
st += " background-color: initial;";
st += " background-image: linear-gradient(rgba(179, 132, 201, .84), rgba(57, 31, 91, .84) 50%);";
st += " border-radius: 42px;";
st += " border-width: 0;";
st += " box-shadow: rgba(57, 31, 91, 0.24) 0 2px 2px, rgba(179, 132, 201, 0.4) 0 8px 12px;";
st += " color: #FFFFFF;";
st += " cursor: pointer;";
st += " display: flex;";
st += " font-family: Quicksand, sans-serif;";
st += " font-size: 18px;";
st += " font-weight: 700;";
st += " justify-content: center;";
st += " letter-spacing: .04em;";
st += " line-height: 16px;";
st += " margin: auto;";
st += " padding: 18px 18px;";
st += " text-align: center;";
st += " text-decoration: none;";
st += " text-shadow: rgba(255, 255, 255, 0.4) 0 0 4px, rgba(255, 255, 255, 0.2) 0 0 12px, rgba(57, 31, 91, 0.6) 1px 1px 4px, rgba(57, 31, 91, 0.32) 4px 4px 16px;";
st += " user-select: none;";
st += " -webkit-user-select: none;";
st += " touch-action: manipulation;";
st += " vertical-align: baseline;";
st += " width: 40%";
st += " }";
st += "";
st += " .InputCell {";
st += " text-align: center;";
st += " font-size: 18px;";
st += " font-weight: 700;";
st += " }";
st += "";
st += " a:link {";
st += " font-size: 150%;";
st += " }";
st += "";
st += " </style>";
st += " </head>";
st += "";
st += " <BODY>";
st += " <style>";
st += " body {";
st += " margin-top: 50px;";
st += " background-color: wheat";
st += " }";
st += "";
st += " font-family: Arial,";
st += " Helvetica,";
st += " Sans-Serif;";
st += "";
st += " </style>";
st += "";
st += " <h1 align=center>Wifi Network </h1>";
st += " <form id=FORM1 method=post action='/'>&nbsp;";
st += " <table class='center'>";
st += "";
st += " <tr>";
st += " <td align='left'>Network</td>";
st += " <td><input class='InputCell' size='20' name='prop1' value='" + String(MDL.SSID) + "' ID=Text1></td>";
st += " </tr>";
st += "";
st += " <tr>";
st += " <td align='left'>Password</td>";
st += " <td><input class='InputCell' size='20' name='prop2' value='" + String(MDL.Password) + "' ID=Text2></td>";
st += " </tr>";
st += " </table>";
st += "";
st += " <p> <input class='button-72' id=Submit1 type=submit value='Save/Restart'></p>";
st += " <p> <a href='/page0'>Back</a> </p>";
st += " </form>";
if (WiFi.isConnected())
{
st += "<p>Wifi Connected to " + String(MDL.SSID) + "</p>";
}
else
{
st += "<p>Wifi Not Connected</p>";
}
//st += "<P>Debug</p>";
//st += "<p>" + String(debug1) + "</p>";
//st += "<p>" + String(debug2) + "</p>";
//st += "<p>" + String(debug3) + "</p>";
st += "</body>";
st += "";
st += "</HTML>";

return st;
}






120 changes: 120 additions & 0 deletions Modules/ESP32 Rate/RC_ESP32/PgStart.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@

String GetPage0()
{
String st = "<HTML>";
st += "";
st += " <head>";
st += " <META content='text/html; charset=utf-8' http-equiv=Content-Type>";
st += " <meta name=vs_targetSchema content='HTML 4.0'>";
st += " <meta name='viewport' content='width=device-width, initial-scale=1.0'>";
st += " <title>Wifi AOG</title>";
st += " <style>";
st += " html {";
st += " font-family: Helvetica;";
st += " display: inline-block;";
st += " margin: 0px auto;";
st += " text-align: center;";
st += "";
st += " }";
st += "";
st += " h1 {";
st += " color: #444444;";
st += " margin: 50px auto 30px;";
st += " }";
st += "";
st += " table.center {";
st += " margin-left: auto;";
st += " margin-right: auto;";
st += " }";
st += "";
st += " .buttonOn {";
st += " background-color: #00ff00;";
st += " border: none;";
st += " color: white;";
st += " padding: 15px 32px;";
st += " text-align: center;";
st += " text-decoration: none;";
st += " display: inline-block;";
st += " margin: 4px 2px;";
st += " cursor: pointer;";
st += " font-size: 15px;";
st += " width: 30%;";
st += " }";
st += "";
st += " .buttonOff {";
st += " background-color: #ff0000;";
st += " border: none;";
st += " color: white;";
st += " padding: 15px 32px;";
st += " text-align: center;";
st += " text-decoration: none;";
st += " display: inline-block;";
st += " margin: 4px 2px;";
st += " cursor: pointer;";
st += " font-size: 15px;";
st += " width: 30%;";
st += " }";
st += "";
st += " .button-72 {";
st += " align-items: center;";
st += " background-color: initial;";
st += " background-image: linear-gradient(rgba(179, 132, 201, .84), rgba(57, 31, 91, .84) 50%);";
st += " border-radius: 42px;";
st += " border-width: 0;";
st += " box-shadow: rgba(57, 31, 91, 0.24) 0 2px 2px, rgba(179, 132, 201, 0.4) 0 8px 12px;";
st += " color: #FFFFFF;";
st += " cursor: pointer;";
st += " display: flex;";
st += " font-family: Quicksand, sans-serif;";
st += " font-size: 18px;";
st += " font-weight: 700;";
st += " justify-content: center;";
st += " letter-spacing: .04em;";
st += " line-height: 16px;";
st += " margin: auto;";
st += " padding: 18px 18px;";
st += " text-align: center;";
st += " text-decoration: none;";
st += " text-shadow: rgba(255, 255, 255, 0.4) 0 0 4px, rgba(255, 255, 255, 0.2) 0 0 12px, rgba(57, 31, 91, 0.6) 1px 1px 4px, rgba(57, 31, 91, 0.32) 4px 4px 16px;";
st += " user-select: none;";
st += " -webkit-user-select: none;";
st += " touch-action: manipulation;";
st += " vertical-align: baseline;";
st += " width:30%";
st += " }";
st += "";
st += " .InputCell {";
st += " text-align: center;";
st += " }";
st += "";
st += " </style>";
st += " </head>";
st += "";
st += " <BODY>";
st += " <style>";
st += " body {";
st += " margin-top: 50px;";
st += " background-color: wheat";
st += " }";
st += "";
st += " font-family: Arial,";
st += " Helvetica,";
st += " Sans-Serif;";
st += "";
st += " </style>";
st += "";
st += " <h1 align=center>RC_ESP32";
st += " </h1>";
st += " <form id=FORM1 method=post action='/'>&nbsp;";
st += "";
st += "";
st += " <p> <a class='button-72' href='/page1' >Switches</a> </p>";
st += " <p> <a class='button-72' href='/page2' >Network</a> </p>";
st += "";
st += " </form>";
st += "";
st += "</HTML>";

return st;
}

Loading

0 comments on commit 9ac049d

Please sign in to comment.