#include "GyverPortal.h"
bool m1, m2;
String V_220 = "on";
float t_out = 17.45;
float t_in = -13.66;
float t_bat = 10.45;
float v_bat = 13.45;
float proc_bat = 147;
void build() {
String s;
BUILD_BEGIN(s);
add.THEME(GP_DARK);
add.AJAX_UPDATE(PSTR("t_out,t_in,t_bat,220v,v_bat,proc_bat"));
add.TITLE("Cam_Control");
add.HR();
add.LABEL("Outside="); add.LABEL("", "t_out");
add.LABEL("Inside="); add.LABEL("", "t_in");
add.LABEL("Battery="); add.LABEL("", "t_bat");
add.HR();
add.LABEL("220v="); add.LABEL("", "220v");
add.LABEL("v_bat="); add.LABEL("", "v_bat");
add.LABEL("%_bat="); add.LABEL("", "proc_bat");
add.HR();
add.FORM_SUBMIT("/menu1", "Control");
if (m1) {
add.BUTTON_MINI( "btn1", "LED_1");
add.BUTTON_MINI( "btn2", "LED_2");
}
BUILD_END();
}
GyverPortal portal;
void setup() {
Serial.begin(9600);
WiFi.mode(WIFI_STA);
WiFi.begin("Zzz", "goodrrr");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println(WiFi.localIP());
portal.attachBuild(build);
portal.start();
}
void loop() {
portal.tick();
if (portal.form()) {
if (portal.form("/menu1")) m1 = !m1;
}
if (portal.update()) {
if (portal.update("t_out")) portal.answer(t_out);
if (portal.update("t_in")) portal.answer(t_in);
if (portal.update("t_bat")) portal.answer(t_bat);
if (portal.update("220v")) portal.answer(V_220);
if (portal.update("v_bat")) portal.answer(v_bat);
if (portal.update("proc_bat")) portal.answer(proc_bat);
}
if (portal.click()) {
}
}