|
@@ -5,6 +5,7 @@ bool serverStarted = false;
|
|
|
HttpServer server;
|
|
|
|
|
|
extern float SensorT, SensorH, SensorHI, SensorCR;
|
|
|
+extern uint32_t SensorLux;
|
|
|
extern String StrCF;
|
|
|
extern time_t NTPLastUpdate;
|
|
|
|
|
@@ -18,7 +19,7 @@ void onIndex(HttpRequest& request, HttpResponse& response)
|
|
|
vars["HI"] = String(SensorHI, 0);
|
|
|
vars["CR"] = String(SensorCR, 0);
|
|
|
vars["CF"] = StrCF; // это первое место, где оно используется
|
|
|
- vars["ADC"] = String(system_adc_read ());
|
|
|
+ vars["LUX"] = String(SensorLux, 0);
|
|
|
vars["VDD"] = String(system_get_vdd33 ());
|
|
|
vars["LASTNTP"] = String (SystemClock.now () - NTPLastUpdate);
|
|
|
|
|
@@ -93,12 +94,12 @@ void onConfiguration(HttpRequest& request, HttpResponse& response)
|
|
|
TemplateFileStream* tmpl = new TemplateFileStream("config.html");
|
|
|
auto& vars = tmpl->variables();
|
|
|
vars["SSID"] = cfg.NetworkSSID;
|
|
|
- vars["TZ"] = String(cfg.AddTZ, 2);
|
|
|
- vars["LLow"] = String(cfg.LightTrhLow);
|
|
|
- vars["LHigh"] = String(cfg.LightTrhHigh);
|
|
|
- vars["BLow"] = String(cfg.BrightnessLow);
|
|
|
- vars["BMid"] = String(cfg.BrightnessMiddle);
|
|
|
- vars["BHigh"] = String(cfg.BrightnessHigh);
|
|
|
+ vars["TZ"] = String(cfg.AddTZ, 2);
|
|
|
+ vars["LLow"] = String(cfg.LightTrhLow);
|
|
|
+ vars["LHigh"] = String(cfg.LightTrhHigh);
|
|
|
+ vars["BLow"] = String(cfg.BrightnessLow);
|
|
|
+ vars["BMid"] = String(cfg.BrightnessMiddle);
|
|
|
+ vars["BHigh"] = String(cfg.BrightnessHigh);
|
|
|
response.sendNamedStream(tmpl);
|
|
|
}
|
|
|
|
|
@@ -138,16 +139,35 @@ void onApiSensors(HttpRequest& request, HttpResponse& response)
|
|
|
json["status"] = (bool)true;
|
|
|
JsonObject sensors = json.createNestedObject("sensors");
|
|
|
|
|
|
- sensors["temperature"] = String(SensorT, 2);
|
|
|
- sensors["humidity"] = String(SensorH, 2);
|
|
|
- sensors["heatindex"] = String(SensorHI, 2);
|
|
|
- sensors["comfortp"] = String(SensorCR, 2);
|
|
|
- sensors["comforts"] = StrCF.c_str (); //??? второе место
|
|
|
- sensors["adcvalue"] = String(system_adc_read ());
|
|
|
- sensors["vddvalue"] = String(system_get_vdd33 ());
|
|
|
- time_t now = SystemClock.now();
|
|
|
- sensors["datetime"] = String(now);
|
|
|
- sensors["lastntp"] = String(now - NTPLastUpdate);
|
|
|
+ sensors["temperature"] = String(SensorT, 2);
|
|
|
+ sensors["humidity"] = String(SensorH, 2);
|
|
|
+ sensors["heatindex"] = String(SensorHI, 2);
|
|
|
+ sensors["comfortp"] = String(SensorCR, 2);
|
|
|
+ sensors["comforts"] = StrCF.c_str (); //??? второе место
|
|
|
+ sensors["luxvalue"] = String(SensorLux, 0);
|
|
|
+ sensors["vddvalue"] = String(system_get_vdd33 ());
|
|
|
+ time_t now = SystemClock.now();
|
|
|
+ sensors["datetime"] = String(now);
|
|
|
+ sensors["lastntp"] = String(now - NTPLastUpdate);
|
|
|
+
|
|
|
+ response.sendDataStream(stream, MIME_JSON);
|
|
|
+}
|
|
|
+
|
|
|
+#include "led_spi.h"
|
|
|
+#include "tm1650.h"
|
|
|
+void onApiControl (HttpRequest &request, HttpResponse &response)
|
|
|
+{
|
|
|
+ int val = request.getQueryParameter ("bright", "-1").toInt ();
|
|
|
+ if (val < LedBrightMin) { val = LedBrightMin; }
|
|
|
+ if (val > LedBrightMax) { val = LedBrightMax; }
|
|
|
+
|
|
|
+ LED_SetBright(val);
|
|
|
+ TM1650_Bright(val);
|
|
|
+
|
|
|
+ JsonObjectStream* stream = new JsonObjectStream();
|
|
|
+ JsonObject json = stream->getRoot();
|
|
|
+
|
|
|
+ json["status"] = val;
|
|
|
|
|
|
response.sendDataStream(stream, MIME_JSON);
|
|
|
}
|