diff --git a/data/index.html b/data/index.html
index 1c435d4..6bc4b97 100644
--- a/data/index.html
+++ b/data/index.html
@@ -13,8 +13,7 @@
@@ -22,8 +21,7 @@
@@ -31,16 +29,14 @@
Time per stair: %
-
+
diff --git a/data/input.js b/data/input.js
index 53ed611..90f546a 100644
--- a/data/input.js
+++ b/data/input.js
@@ -19,8 +19,8 @@ function reloadRangeValues() {
let params = [];
for(let p in rangeValues)
params.push(encodeURIComponent(p) + "=" + encodeURIComponent(rangeValues[p]));
- params.join("&");
-
+ params = params.join("&");
+
xhrUpd.open("POST", url, true);
xhrUpd.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhrUpd.send(params);
@@ -28,7 +28,7 @@ function reloadRangeValues() {
rangeValues = {};
}
- setTimeout(reloadRangeValues, 500);
+ setTimeout(reloadRangeValues, 1000);
};
reloadRangeValues();
diff --git a/lib/httpserver/httpserver.cpp b/lib/httpserver/httpserver.cpp
index d4ae262..c9820a7 100644
--- a/lib/httpserver/httpserver.cpp
+++ b/lib/httpserver/httpserver.cpp
@@ -60,9 +60,13 @@ void HTTPServer::start_apps() {
// application handler
this->on("/update", HTTP_POST, [this]() {
- // Serial.printf("got /update with args()=%d\n", args());
- for(int i=0; iset_idle_prozent(arg(i).toInt());
+ }
+ }
}
send(200, "text/plain", "accepted");
});
diff --git a/lib/httpserver/httpserver.h b/lib/httpserver/httpserver.h
index e54bbb7..9eb3ca1 100644
--- a/lib/httpserver/httpserver.h
+++ b/lib/httpserver/httpserver.h
@@ -5,6 +5,7 @@
#include
#include
#include "filesys.h"
+#include "treppe.h"
// debug log
// #define DEBUGV(f,...) do { Serial.printf(PSTR(f), ##__VA_ARGS__); } while (0)
@@ -24,10 +25,11 @@ private:
void listRoot() {
ls(rootDir);
}
+ Treppe* treppe;
public:
- HTTPServer(const int _port, const char* _rootDir) :
- ESP8266WebServer(_port), rootDir(_rootDir)
+ HTTPServer(const int _port, const char* _rootDir, Treppe* _treppe) :
+ ESP8266WebServer(_port), rootDir(_rootDir), treppe(_treppe)
{ }
~HTTPServer()
{
diff --git a/lib/treppe/treppe.cpp b/lib/treppe/treppe.cpp
index d32662e..db56cd2 100644
--- a/lib/treppe/treppe.cpp
+++ b/lib/treppe/treppe.cpp
@@ -213,8 +213,11 @@ void Treppe::task()
if (fsm_outputs.status > ST_RUHEZUSTAND)
{
if (anim_beendet == true &&
- (fsm_outputs.status == ST_AUFDIMMEN_HOCH || fsm_outputs.status == ST_ABDIMMEN_HOCH ||
- fsm_outputs.status == ST_AUFDIMMEN_RUNTER || fsm_outputs.status == ST_ABDIMMEN_RUNTER))
+ (fsm_outputs.status == ST_AUFDIMMEN_HOCH ||
+ fsm_outputs.status == ST_ABDIMMEN_HOCH ||
+ fsm_outputs.status == ST_AUFDIMMEN_RUNTER ||
+ fsm_outputs.status == ST_ABDIMMEN_RUNTER)
+ )
{
start_animation();
}
@@ -226,7 +229,7 @@ void Treppe::task()
void Treppe::berechne_dimmer()
{
ticks_pro_stufe = time_per_stair / INT_TIME; // [ms]
- differenz_pwm_pro_tick = (float)(active_brightness - idle_brightness) / (float)ticks_pro_stufe;
+ differenz_pwm_pro_tick = (float)(active_brightness - idle_bright_internal) / (float)ticks_pro_stufe;
}
void Treppe::setup()
@@ -250,15 +253,27 @@ void Treppe::setup()
Serial.printf("Treppe: initial parameters: stufen=%d\n", stufen);
}
-// ###################################################################################################################
-// GEBUFFERT => Erst im Ruhezustand übernehmen !!!!
+
+
+void Treppe::set_idle_prozent(int prozent) {
+ uint16_t new_pwm = 0xFFF * prozent / 100;
+ set_idle_pwm(new_pwm);
+}
+
void Treppe::set_idle_pwm(uint16_t _idle_brightness)
{
- idle_brightness = _idle_brightness;
+ if(_idle_brightness > active_brightness) {
+ idle_bright_internal = active_brightness;
+ } else {
+ idle_bright_internal = _idle_brightness;
+ }
+ Serial.printf("Treppe: idle_bright_internal=%d\n", idle_bright_internal);
berechne_dimmer();
- Serial.printf("Treppe: idle_brightness=%d\n", idle_brightness);
+
+ pwmController.setAllChannelsPWM(idle_bright_internal);
}
+
void Treppe::activate_idle_pwm(bool active)
{
static uint8_t former_active = 0;
@@ -274,6 +289,7 @@ void Treppe::activate_idle_pwm(bool active)
}
}
}
+
void Treppe::set_active_pwm(uint16_t _active_brightness)
{
active_brightness = _active_brightness;
diff --git a/lib/treppe/treppe.h b/lib/treppe/treppe.h
index 124480d..042c0f6 100644
--- a/lib/treppe/treppe.h
+++ b/lib/treppe/treppe.h
@@ -82,6 +82,7 @@ public:
void task(); // call periodically
// Parameter section
+ void set_idle_prozent(int prozent);
void set_idle_pwm(uint16_t _idle_brightness);
void activate_idle_pwm(bool active);
void set_active_pwm(uint16_t _active_brightness);
diff --git a/src/main.cpp b/src/main.cpp
index dc5b5e5..fc5bf63 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -28,7 +28,7 @@ const char* ssid = STASSID;
const char* password = STAPSK;
// port 80, root directory of server '/'
-HTTPServer httpServer(80, "/");
+HTTPServer httpServer(80, "/", &stairs);
uint32_t _t=0;
#define SP_US(_str,_a) Serial.print(_str); Serial.print(" took: "); Serial.print(_a); Serial.println("us")