mirror of
https://github.com/openshwprojects/OpenBK7231T_App.git
synced 2026-02-12 11:45:29 +00:00
add support for TuyaMCU dimmers
* add Tuya_SendState (and typed variants) to set value of a data point * add tuy sendQueryState command to query state of TuyaMCU's data points * add a new channel type "dimmer" (normalized value from 0..100) * run TuyaMCU_OnChannelChanged, whenever a Channel is set to a new value: This updates TuyaMCU's data point linked to the channel * map normalized dimmer value (0..100) to TuyaMCU's dimmer range (tuyaMcu_setDimmerRange)
This commit is contained in:
@ -136,6 +136,13 @@ int http_fn_index(http_request_t *request) {
|
||||
hprintf128(request,"<h3>Changed pwm %i to %i!</h3>",j,newPWMValue);
|
||||
CHANNEL_Set(j,newPWMValue,1);
|
||||
}
|
||||
if(http_getArg(request->url,"dim",tmpA,sizeof(tmpA))) {
|
||||
int newDimmerValue = atoi(tmpA);
|
||||
http_getArg(request->url,"dimIndex",tmpA,sizeof(tmpA));
|
||||
j = atoi(tmpA);
|
||||
hprintf128(request,"<h3>Changed dimmer %i to %i!</h3>",j,newDimmerValue);
|
||||
CHANNEL_Set(j,newDimmerValue,1);
|
||||
}
|
||||
|
||||
|
||||
for(i = 0; i < CHANNEL_MAX; i++) {
|
||||
@ -186,13 +193,15 @@ int http_fn_index(http_request_t *request) {
|
||||
hprintf128(request,"<input type=\"hidden\" name=\"tgl\" value=\"%i\">",i);
|
||||
hprintf128(request,"<input class=\"%s\" type=\"submit\" value=\"Toggle %i\"/></form>",c,i);
|
||||
}
|
||||
else if(h_isChannelPWM(i)) {
|
||||
else if(h_isChannelPWM(i) || (channelType == ChType_Dimmer)) {
|
||||
// PWM and dimmer both use a slider control
|
||||
const char *inputName = h_isChannelPWM(i) ? "pwm" : "dim";
|
||||
int pwmValue;
|
||||
|
||||
pwmValue = CHANNEL_Get(i);
|
||||
hprintf128(request,"<form action=\"index\" id=\"form%i\">",i);
|
||||
hprintf128(request,"<input type=\"range\" min=\"0\" max=\"100\" name=\"pwm\" id=\"slider%i\" value=\"%i\">",i,pwmValue);
|
||||
hprintf128(request,"<input type=\"hidden\" name=\"pwmIndex\" value=\"%i\">",i);
|
||||
hprintf128(request,"<input type=\"range\" min=\"0\" max=\"100\" name=\"%s\" id=\"slider%i\" value=\"%i\">",inputName,i,pwmValue);
|
||||
hprintf128(request,"<input type=\"hidden\" name=\"%sIndex\" value=\"%i\">",inputName,i);
|
||||
hprintf128(request,"<input type=\"submit\" style=\"display:none;\" value=\"Toggle %i\"/></form>",i);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user