From e8d13588353662365fb11a9c6a3520280e5c64d3 Mon Sep 17 00:00:00 2001 From: Michael Clemens // DK1MI Date: Thu, 4 May 2023 07:58:33 +0000 Subject: [PATCH] =?UTF-8?q?=E2=80=9Ewt32pamon.ino=E2=80=9C=20=C3=A4ndern?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wt32pamon.ino | 87 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 85 insertions(+), 2 deletions(-) diff --git a/wt32pamon.ino b/wt32pamon.ino index b24b35a..e1f13f6 100644 --- a/wt32pamon.ino +++ b/wt32pamon.ino @@ -6,7 +6,7 @@ Based on and modified from ESP8266 https://github.com/esp8266/Arduino/releases Based on Built by Khoi Hoang https://github.com/khoih-prog/WebServer_WT32_ETH01 - Adapted by Michael Clemens + Adapted by Michael Clemens, DK1MI Licensed under MIT license Copyright (c) 2015, Majenko Technologies @@ -46,7 +46,11 @@ #define YES 1 #include -#include "index.h" //Web page header file +#include "index.h" // Main Web page header file +#include "config.h" // Config Web page header file +#include + +Preferences preferences; #ifdef __cplusplus extern "C" { @@ -64,6 +68,10 @@ int voltage_fwd_peak =0,voltage_ref_peak =0, voltage_drv_peak =0; int fwd_power=0, ref_power=0; byte iii=0; +String conf_content; +String conf_translate_table; +String del_action = ""; + int IO2_FWD = 2; int IO4_REF = 4; int IO12_DRV = 12; @@ -172,9 +180,80 @@ void handleTEMP() { server.send(200, "text/plane", tempValue); //Send ADC value only to client ajax request } +void handleCONFIG() { + //String s = CONFIG_page; //Read HTML contents + String x = "10"; + unsigned int stored_val = preferences.getUInt(x.c_str(), 0); + conf_content = "\r\nWelcome to Wifi Credentials Update page"; + conf_content += "
"; + conf_content += "

"; + conf_content += "Action: " + del_action; + conf_content += "Added: " + String(stored_val); + conf_content += "

"; + conf_content += conf_translate_table; + conf_content += "

"; + conf_content += "

"; + conf_content += "

"; + conf_content += ""; + server.send(200, "text/html", conf_content); + //server.send(200, "text/html", s); //Send web page +} + +void handleLIST() { + del_action = server.arg("delete"); + if (del_action != "") + preferences.remove(del_action.c_str()); + + conf_translate_table = ""; + conf_translate_table += ""; + + for (int i=0; i<3400; i++) { + unsigned int stored_val = preferences. getUInt(String(i).c_str(), 0); + if (stored_val > 0) { + conf_translate_table += ""; + } + } + + + /* + for (int i=0; idelete"; + conf_translate_table += ""; + } + */ + + conf_translate_table += "
VoltWattDelete
"; + conf_translate_table += String(i); + conf_translate_table += ""; + conf_translate_table += String(stored_val); + conf_translate_table += ""; + conf_translate_table += ""; + conf_translate_table += "
"; + //server.send(200, "text/html", conf_translate_table); //Send web page + //conf_content = "\r\ngo back"; + //server.send(200, "text/html", conf_content); + handleCONFIG(); +} + +void handleADD() { + String volt = server.arg("volt"); + String watt = server.arg("watt"); + preferences.putUInt(volt.c_str(), watt.toInt()); + del_action = volt + "/" + watt; + handleLIST(); +} + + + void setup() { analogReadResolution(12); + preferences.begin("translation", false); Serial.begin(115200); while (!Serial); @@ -201,6 +280,10 @@ void setup() server.on("/readDRV", handleDRV); server.on("/readSWR", handleSWR); server.on("/readTEMP", handleTEMP); + server.on("/config", handleCONFIG); + server.on("/list", handleLIST); + server.on("/add", handleADD); + server.onNotFound(handleNotFound); server.begin();