can set idle_pwm from webserver, but not working properly
This commit is contained in:
parent
2754bd5247
commit
66d220cdb0
@ -13,8 +13,7 @@
|
||||
<div class="param_block">
|
||||
Active Brightness: <output id="out_act_pwm" class="val_range">50</output> %
|
||||
<div class="slider">
|
||||
<input type="range" class="regler" id="range_act_pwm" min="0" max="100" value="50"
|
||||
oninput="amount1.value=helligkeit.value">
|
||||
<input type="range" class="regler" id="range_act_pwm" min="0" max="100" value="50">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -22,8 +21,7 @@
|
||||
<div class="param_block">
|
||||
Idle Brightness: <output id="out_idl_pwm" class="val_range">50</output> %
|
||||
<div class="slider">
|
||||
<input type="range" class="regler" id="range_idl_pwm" min="0" max="100" value="50"
|
||||
oninput="amount2.value=helligkeit_dunkel.value">
|
||||
<input type="range" class="regler" id="range_idl_pwm" min="0" max="100" value="50">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -31,16 +29,14 @@
|
||||
Time per stair: <output id="out_tim_sta" class="val_range">50</output> %
|
||||
|
||||
<div class="slider">
|
||||
<input type="range" class="regler" id="range_tim_sta" min="0" max="100" value="50"
|
||||
oninput="amount3.value=geschwindigkeit.value">
|
||||
<input type="range" class="regler" id="range_tim_sta" min="0" max="100" value="50">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="param_block">
|
||||
On Time: <output id="out_tim_on" class="val_range">50</output> %
|
||||
<div class="slider">
|
||||
<input type="range" class="regler" id="range_tim_on" min="0" max="100" value="50"
|
||||
oninput="amount4.value=time.value">
|
||||
<input type="range" class="regler" id="range_tim_on" min="0" max="100" value="50">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
@ -19,7 +19,7 @@ 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');
|
||||
@ -28,7 +28,7 @@ function reloadRangeValues() {
|
||||
rangeValues = {};
|
||||
}
|
||||
|
||||
setTimeout(reloadRangeValues, 500);
|
||||
setTimeout(reloadRangeValues, 1000);
|
||||
};
|
||||
reloadRangeValues();
|
||||
|
||||
|
@ -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; i<args(); i++) {
|
||||
if(args()) {
|
||||
for(int i=0; i<args()-1; i++) {
|
||||
Serial.printf("%s=%s\n", argName(i).c_str(), arg(i).c_str());
|
||||
if(argName(i).equals("range_idl_pwm")) {
|
||||
treppe->set_idle_prozent(arg(i).toInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
send(200, "text/plain", "accepted");
|
||||
});
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <ESP8266WebServer.h>
|
||||
#include <stdarg.h>
|
||||
#include "filesys.h"
|
||||
#include "treppe.h"
|
||||
|
||||
// debug log <ESP8266WebServer.h>
|
||||
// #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()
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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")
|
||||
|
Loading…
x
Reference in New Issue
Block a user