mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 03:39:49 +03:00
HSV & RGB mixed control, starting with PID
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
-DCONTROLLINO
|
-DCONTROLLINO
|
||||||
-DCUSTOM_FIRMWARE_MAC=de:ad:be:ef:fe:07
|
-DCUSTOM_FIRMWARE_MAC=de:ad:be:ef:fe:07
|
||||||
-DWiz5100
|
-DWiz5100
|
||||||
|
-DPID_DISABLE
|
||||||
|
|||||||
@@ -5,4 +5,5 @@
|
|||||||
-DARTNET_ENABLE
|
-DARTNET_ENABLE
|
||||||
-DOTA
|
-DOTA
|
||||||
-DSTATUSLED
|
-DSTATUSLED
|
||||||
|
-DPID_DISABLE
|
||||||
|
|
||||||
|
|||||||
@@ -3,3 +3,4 @@
|
|||||||
-DSTATUSLED
|
-DSTATUSLED
|
||||||
-DSYSLOG_ENABLE
|
-DSYSLOG_ENABLE
|
||||||
-DWiz5100
|
-DWiz5100
|
||||||
|
-DPID_DISABLE
|
||||||
|
|||||||
@@ -3,3 +3,4 @@
|
|||||||
-DDMX_SMOOTH
|
-DDMX_SMOOTH
|
||||||
-DSTATUSLED
|
-DSTATUSLED
|
||||||
-DSYSLOG_ENABLE
|
-DSYSLOG_ENABLE
|
||||||
|
-DPID_DISABLE
|
||||||
|
|||||||
@@ -13,3 +13,4 @@
|
|||||||
#-DARTNET_ENABLE - udp rx errors ((
|
#-DARTNET_ENABLE - udp rx errors ((
|
||||||
#-DUSE_1W_PIN=16
|
#-DUSE_1W_PIN=16
|
||||||
#-DW5500_CS_PIN=15
|
#-DW5500_CS_PIN=15
|
||||||
|
-DPID_DISABLE
|
||||||
|
|||||||
@@ -7,3 +7,4 @@
|
|||||||
-DARTNET_ENABLE
|
-DARTNET_ENABLE
|
||||||
-DUSE_1W_PIN=16
|
-DUSE_1W_PIN=16
|
||||||
-DW5500_CS_PIN=15
|
-DW5500_CS_PIN=15
|
||||||
|
-DPID_DISABLE
|
||||||
|
|||||||
@@ -8,3 +8,4 @@
|
|||||||
#-DWiz5500
|
#-DWiz5500
|
||||||
-DSTATUSLED
|
-DSTATUSLED
|
||||||
-DMCP23017
|
-DMCP23017
|
||||||
|
-DPID_DISABLE
|
||||||
|
|||||||
@@ -9,3 +9,4 @@
|
|||||||
-DM5STACK
|
-DM5STACK
|
||||||
#-DSYSLOG_ENABLE
|
#-DSYSLOG_ENABLE
|
||||||
-DUSE_1W_PIN=16
|
-DUSE_1W_PIN=16
|
||||||
|
-DPID_DISABLE
|
||||||
|
|||||||
@@ -2,3 +2,4 @@
|
|||||||
-DAVR_DMXOUT_PIN=18
|
-DAVR_DMXOUT_PIN=18
|
||||||
-DSYSLOG_ENABLE
|
-DSYSLOG_ENABLE
|
||||||
-DWiz5100
|
-DWiz5100
|
||||||
|
-DPID_DISABLE
|
||||||
|
|||||||
@@ -2,3 +2,4 @@
|
|||||||
-DMODBUS_DIMMER_PARAM=SERIAL_8E1
|
-DMODBUS_DIMMER_PARAM=SERIAL_8E1
|
||||||
-DAVR_DMXOUT_PIN=18
|
-DAVR_DMXOUT_PIN=18
|
||||||
-DSYSLOG_ENABLE
|
-DSYSLOG_ENABLE
|
||||||
|
-DPID_DISABLE
|
||||||
@@ -12,3 +12,4 @@
|
|||||||
-DSPILED_DISABLE
|
-DSPILED_DISABLE
|
||||||
-DAC_DISABLE
|
-DAC_DISABLE
|
||||||
-DSYSLOG_ENABLE
|
-DSYSLOG_ENABLE
|
||||||
|
-DPID_DISABLE
|
||||||
|
|||||||
@@ -11,3 +11,4 @@
|
|||||||
-DAC_DISABLE
|
-DAC_DISABLE
|
||||||
-DSYSLOG_ENABLE
|
-DSYSLOG_ENABLE
|
||||||
-DMBUS_DISABLE
|
-DMBUS_DISABLE
|
||||||
|
-DPID_DISABLE
|
||||||
|
|||||||
@@ -8,3 +8,4 @@
|
|||||||
-DCSSHDC_DISABLE
|
-DCSSHDC_DISABLE
|
||||||
-DSPILED_DISABLE
|
-DSPILED_DISABLE
|
||||||
-DAC_DISABLE
|
-DAC_DISABLE
|
||||||
|
-DPID_DISABLE
|
||||||
|
|||||||
BIN
compiled/esp32-wifi/StartCounter.ino.bin
Normal file
BIN
compiled/esp32-wifi/StartCounter.ino.bin
Normal file
Binary file not shown.
1
compiled/esp32-wifi/uploadCounter.sh
Executable file
1
compiled/esp32-wifi/uploadCounter.sh
Executable file
@@ -0,0 +1 @@
|
|||||||
|
../tools/mac/arduinoOTA -address 192.168.8.58 -port 65280 -username arduino -password password -sketch StartCounter.ino.bin -b -upload /sketch
|
||||||
1
compiled/esp32-wifi/uploadOTA.sh
Executable file
1
compiled/esp32-wifi/uploadOTA.sh
Executable file
@@ -0,0 +1 @@
|
|||||||
|
../tools/mac/arduinoOTA -address 192.168.88.45 -port 65280 -username arduino -password password -sketch firmware.bin -upload /sketch -b
|
||||||
302
config-examples/12-12-12-12-12-12.config.json
Normal file
302
config-examples/12-12-12-12-12-12.config.json
Normal file
@@ -0,0 +1,302 @@
|
|||||||
|
{
|
||||||
|
"mqtt":["abc3","192.168.88.2"],
|
||||||
|
"syslog":["192.168.88.2"],
|
||||||
|
"dmx":[3,80],
|
||||||
|
"topics":{"root":"abc"},
|
||||||
|
"modbus":[],
|
||||||
|
"items":
|
||||||
|
{
|
||||||
|
"lightall":[7,[
|
||||||
|
"lampbedr3",
|
||||||
|
"lampcab31",
|
||||||
|
"lampcab32",
|
||||||
|
"lampsauna3",
|
||||||
|
"lampbath33",
|
||||||
|
"lampktc3",
|
||||||
|
"lampwc3",
|
||||||
|
"lamp4",
|
||||||
|
"lampext4",
|
||||||
|
"lamphall3",
|
||||||
|
"lampstw3",
|
||||||
|
"fasadeast",
|
||||||
|
"bra31",
|
||||||
|
"lampgst3",
|
||||||
|
"lampkln3",
|
||||||
|
"lampbalk3",
|
||||||
|
"fasadsouth",
|
||||||
|
"bra32"]],
|
||||||
|
"gr_hall3":[7,["lamphall3","lampstw3"]],
|
||||||
|
"gr_gost3":[7,["lampgst3","lampktc3"]],
|
||||||
|
"relays":[7,["pout0","thermostat","pout2","pout3","pout4","pout5","pout6"]],
|
||||||
|
"uouts":[7,["unprot0","unprot1","unprot2","unprot3","unprot4","unprot5","unprot6","unprot7"]],
|
||||||
|
|
||||||
|
"mb1":[44,[1,0,3,100]],
|
||||||
|
"mb2":[44,[1,1,3,100]],
|
||||||
|
"mb3":[44,[1,2,3,100]],
|
||||||
|
"mb4":[44,[1,3,3,100]],
|
||||||
|
"mba":[44,[96,0,0]],
|
||||||
|
|
||||||
|
"lampbedr3":[0,1],
|
||||||
|
"lampcab31":[0,2],
|
||||||
|
"lampcab32":[0,3],
|
||||||
|
|
||||||
|
"lampsauna3":[0,4],
|
||||||
|
"lampbath3":[0,5],
|
||||||
|
"lampwc3":[0,6],
|
||||||
|
|
||||||
|
"lampktc3":[0,7],
|
||||||
|
"lamp4":[0,8],
|
||||||
|
"lamphall3":[0,9],
|
||||||
|
|
||||||
|
"lampext4":[0,10],
|
||||||
|
"lampstw3":[0,11],
|
||||||
|
"fasadeast":[0,12],
|
||||||
|
|
||||||
|
"lampgst3":[0,13],
|
||||||
|
"bra31":[0,14],
|
||||||
|
"bra32":[0,15],
|
||||||
|
|
||||||
|
"lampbalk3":[0,16],
|
||||||
|
"fasadsouth":[0,17],
|
||||||
|
"lampkln3":[0,18],
|
||||||
|
"lampbar3":[0,21],
|
||||||
|
|
||||||
|
"ledbedr3":[1,22],
|
||||||
|
"ledcab31":[1,26],
|
||||||
|
"ledcab32":[1,30],
|
||||||
|
"ledkab":[7,["ledcab31","ledcab32"]],
|
||||||
|
"ledsauna31":[1,34],
|
||||||
|
"ledsauna32":[1,38],
|
||||||
|
"ledsauna":[7,["ledsauna31","ledsauna32"]],
|
||||||
|
"led4":[1,42],
|
||||||
|
|
||||||
|
"ledktc31":[1,48],
|
||||||
|
"ledktc31w":[0,52],
|
||||||
|
"ledktc32":[1,53],
|
||||||
|
"ledktc32w":[0,57],
|
||||||
|
"ledgst31":[1,58],
|
||||||
|
"ledgst31w":[0,62],
|
||||||
|
"ledgst32":[1,63],
|
||||||
|
"ledgst32w":[0,67],
|
||||||
|
"ledktc3w":[7,["ledktc31w","ledktc32w","ledgst31w","ledgst32w"]],
|
||||||
|
"ledktc3":[7,["ledktc31","ledktc32","ledgst31","ledgst32"]],
|
||||||
|
|
||||||
|
"fanbath3":[0,68],
|
||||||
|
"fanwc3":[0,69],
|
||||||
|
|
||||||
|
"pout0":[6,22],
|
||||||
|
"thermostat":[5,23,33],
|
||||||
|
"pout2":[6,24],
|
||||||
|
"water3":[6,25],
|
||||||
|
"pout4":[3,9],
|
||||||
|
"pout5":[3,8],
|
||||||
|
"pout6":[3,11],
|
||||||
|
"pout7":[6,12],
|
||||||
|
|
||||||
|
|
||||||
|
"pwm0" :[3,4],
|
||||||
|
"pwm1" :[3,5],
|
||||||
|
"pwm2" :[3,6],
|
||||||
|
"pwm3" :[3,7],
|
||||||
|
"pwm10":[3,10],
|
||||||
|
|
||||||
|
|
||||||
|
"unprot0":[6,33],
|
||||||
|
"unprot1":[6,32],
|
||||||
|
"unprot2":[6,31],
|
||||||
|
"unprot3":[6,30],
|
||||||
|
"unprot4":[6,29],
|
||||||
|
"unprot5":[6,28],
|
||||||
|
"unprot6":[6,27],
|
||||||
|
"unprot7":[6,26]
|
||||||
|
},
|
||||||
|
|
||||||
|
"in":
|
||||||
|
[ {"#":42,"emit":"power3","item":"fanwc3"},
|
||||||
|
{"#":44,"emit":"in1"},
|
||||||
|
{"#":46,"emit":"in2"},
|
||||||
|
{"#":49,"emit":"in3"},
|
||||||
|
{"#":43,"emit":"in4"},
|
||||||
|
{"#":45,"emit":"in5"},
|
||||||
|
{"#":47,"emit":"in6"},
|
||||||
|
{"#":48,"emit":"in7"},
|
||||||
|
{"#":34,"emit":"in8"},
|
||||||
|
{"#":36,"emit":"in9"},
|
||||||
|
|
||||||
|
{"#":38,"T":0,
|
||||||
|
"click":{"item":"gr_hall3","icmd":"ON"},
|
||||||
|
"dclick":{"item":"lampbedr3","icmd":"ON"},
|
||||||
|
"tclick":{"item":"lightall","icmd":"REST"},
|
||||||
|
"rpcmd":{"item":"gr_hall3","icmd":"%+2"}
|
||||||
|
},
|
||||||
|
{"#":40,"T":0,
|
||||||
|
"click":{"item":"gr_hall3","icmd":"OFF"},
|
||||||
|
"dclick":{"item":"lampbedr3","icmd":"OFF"},
|
||||||
|
"tclick":{"item":"lightall","icmd":"HALT"},
|
||||||
|
"rpcmd":{"item":"gr_hall3","icmd":"%-2"}
|
||||||
|
},
|
||||||
|
{"#":35,"T":0,
|
||||||
|
"click":{"item":"gr_gost3","icmd":"ON"},
|
||||||
|
"dclick":{"item":"lampwc3","icmd":"ON"},
|
||||||
|
"tclick":{"item":"lampbath3","icmd":"ON"},
|
||||||
|
"rpcmd":{"item":"gr_gost3","icmd":"%+2"}
|
||||||
|
},
|
||||||
|
{"#":37,"T":0,
|
||||||
|
"click":{"item":"gr_gost3","icmd":"OFF"},
|
||||||
|
"dclick":{"item":"lampwc3","icmd":"OFF"},
|
||||||
|
"tclick":{"item":"lampbath3","icmd":"OFF"},
|
||||||
|
"rpcmd":{"item":"gr_gost3","icmd":"%-2"}
|
||||||
|
},
|
||||||
|
|
||||||
|
{"#":39,"emit":"in14"},
|
||||||
|
{"#":41,"emit":"in15"},
|
||||||
|
|
||||||
|
{"#":54,"T":0,"act":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"map":[128,640],
|
||||||
|
"click":{"item":"gr_gost3","icmd":"ON"},
|
||||||
|
"dclick":{"item":"lampwc3","icmd":"ON"},
|
||||||
|
"tclick":{"item":"lampbath3","icmd":"ON"},
|
||||||
|
"rpcmd":{"item":"gr_gost3","icmd":"%+2"}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"map":[641,1024],
|
||||||
|
"click":{"item":"gr_gost3","icmd":"OFF"},
|
||||||
|
"dclick":{"item":"lampwc3","icmd":"OFF"},
|
||||||
|
"tclick":{"item":"lampbath3","icmd":"OFF"},
|
||||||
|
"rpcmd":{"item":"gr_gost3","icmd":"%-2"}
|
||||||
|
}
|
||||||
|
]},
|
||||||
|
{"#":55,"T":66,"emit":"a01","map":[0,1024,0,1024,10]},
|
||||||
|
|
||||||
|
{"#":56,"T":66,"emit":"a02","map":[0,1024,0,1024,10]},
|
||||||
|
{"#":57,"T":66,"emit":"a03","map":[0,1024,0,1024,10]},
|
||||||
|
|
||||||
|
{"#":58,"T":66,"emit":"a04","map":[0,1024,0,1024,10]},
|
||||||
|
{"#":59,"T":66,"emit":"a05","map":[0,1024,0,1024,10]},
|
||||||
|
|
||||||
|
{"#":60,"T":0,"act":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"map":[128,640],
|
||||||
|
"click":{"item":"gr_hall3","icmd":"ON"},
|
||||||
|
"dclick":{"item":"lampbedr3","icmd":"ON"},
|
||||||
|
"tclick":{"item":"lightall","icmd":"REST"},
|
||||||
|
"rpcmd":{"item":"gr_hall3","icmd":"%+2"}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"map":[641,1024],
|
||||||
|
"click":{"item":"gr_hall3","icmd":"OFF"},
|
||||||
|
"dclick":{"item":"lampbedr3","icmd":"OFF"},
|
||||||
|
"tclick":{"item":"lightall","icmd":"HALT"},
|
||||||
|
"rpcmd":{"item":"gr_hall3","icmd":"%-2"}
|
||||||
|
}
|
||||||
|
]},
|
||||||
|
{"#":61,"T":0,"act":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"map":[128,640],
|
||||||
|
"click":{"item":"gr_gost3","icmd":"ON"},
|
||||||
|
"dclick":{"item":"lampwc3","icmd":"ON"},
|
||||||
|
"tclick":{"item":"lampbath3","icmd":"ON"},
|
||||||
|
"rpcmd":{"item":"gr_gost3","icmd":"%+2"}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"map":[641,1024],
|
||||||
|
"click":{"item":"gr_gost3","icmd":"OFF"},
|
||||||
|
"dclick":{"item":"lampwc3","icmd":"OFF"},
|
||||||
|
"tclick":{"item":"lampbath3","icmd":"OFF"},
|
||||||
|
"rpcmd":{"item":"gr_gost3","icmd":"%-2"}
|
||||||
|
}
|
||||||
|
]},
|
||||||
|
|
||||||
|
{"#":62,"T":66,"emit":"a08","map":[0,1024,0,1024,10]},
|
||||||
|
{"#":63,"T":66,"emit":"a09","map":[0,1024,0,1024,10]},
|
||||||
|
|
||||||
|
{"#":64,"T":66,"emit":"a10","map":[0,1024,0,1024,10]},
|
||||||
|
{"#":65,"T":66,"emit":"a11","map":[0,1024,0,1024,10]},
|
||||||
|
{"#":66,"T":0,"emit":"leak31","item":"water3","scmd":"OFF","rcmd":"ON"},
|
||||||
|
{"#":67,"T":2,"emit":"leak32","item":"water3","scmd":"OFF","rcmd":"ON"},
|
||||||
|
{"#":68,"T":0,"emit":"leak33","item":"water3","scmd":"OFF","rcmd":"ON"},
|
||||||
|
{"#":69,"T":0,"emit":"a15"}
|
||||||
|
],
|
||||||
|
|
||||||
|
"in2":
|
||||||
|
{ "42":{"emit":"power3","item":"fanwc3"},
|
||||||
|
"44":{"emit":"in1"},
|
||||||
|
"46":{"emit":"in2"},
|
||||||
|
"49":{"emit":"in3"},
|
||||||
|
"43":{"emit":"in4"},
|
||||||
|
"45":{"emit":"in5"},
|
||||||
|
"47":{"emit":"in6"},
|
||||||
|
"48":{"emit":"in7"},
|
||||||
|
"34":{"emit":"in8"},
|
||||||
|
"36":{"emit":"in9"},
|
||||||
|
|
||||||
|
"38":{"T":0,
|
||||||
|
"click":{"item":"gr_hall3","icmd":"ON"},
|
||||||
|
"dclick":{"item":"lampbedr3","icmd":"ON"},
|
||||||
|
"tclick":{"item":"lightall","icmd":"REST"},
|
||||||
|
"rpcmd":{"item":"gr_hall3","icmd":"%+2"}
|
||||||
|
},
|
||||||
|
"40":{"T":0,
|
||||||
|
"click":{"item":"gr_hall3","icmd":"OFF"},
|
||||||
|
"dclick":{"item":"lampbedr3","icmd":"OFF"},
|
||||||
|
"tclick":{"item":"lightall","icmd":"HALT"},
|
||||||
|
"rpcmd":{"item":"gr_hall3","icmd":"%-2"}
|
||||||
|
},
|
||||||
|
"35":{"T":0,
|
||||||
|
"click":{"item":"gr_gost3","icmd":"ON"},
|
||||||
|
"dclick":{"item":"lampwc3","icmd":"ON"},
|
||||||
|
"tclick":{"item":"lampbath3","icmd":"ON"},
|
||||||
|
"rpcmd":{"item":"gr_gost3","icmd":"%+2"}
|
||||||
|
},
|
||||||
|
"37":{"T":0,
|
||||||
|
"click":{"item":"gr_gost3","icmd":"OFF"},
|
||||||
|
"dclick":{"item":"lampwc3","icmd":"OFF"},
|
||||||
|
"tclick":{"item":"lampbath3","icmd":"OFF"},
|
||||||
|
"rpcmd":{"item":"gr_gost3","icmd":"%-2"}
|
||||||
|
},
|
||||||
|
|
||||||
|
"39":{"emit":"in14"},
|
||||||
|
"41":{"emit":"in15"},
|
||||||
|
|
||||||
|
"54":{"addr":54,"T":0,"act":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"map":[128,640],
|
||||||
|
"click":{"item":"gr_gost3","icmd":"ON"},
|
||||||
|
"dclick":{"item":"lampwc3","icmd":"ON"},
|
||||||
|
"tclick":{"item":"lampbath3","icmd":"ON"},
|
||||||
|
"rpcmd":{"item":"gr_gost3","icmd":"%+2"}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"map":[641,1024],
|
||||||
|
"click":{"item":"gr_gost3","icmd":"OFF"},
|
||||||
|
"dclick":{"item":"lampwc3","icmd":"OFF"},
|
||||||
|
"tclick":{"item":"lampbath3","icmd":"OFF"},
|
||||||
|
"rpcmd":{"item":"gr_gost3","icmd":"%-2"}
|
||||||
|
}
|
||||||
|
]},
|
||||||
|
"55":{"T":66,"emit":"a01","map":[0,1024,0,1024,10]},
|
||||||
|
|
||||||
|
"56":{"T":66,"emit":"a02","map":[0,1024,0,1024,10]},
|
||||||
|
"57":{"T":66,"emit":"a03","map":[0,1024,0,1024,10]},
|
||||||
|
|
||||||
|
"58":{"T":66,"emit":"a04","map":[0,1024,0,1024,10]},
|
||||||
|
"59":{"T":66,"emit":"a05","map":[0,1024,0,1024,10]},
|
||||||
|
|
||||||
|
"60":{"T":66,"emit":"a06","map":[0,1024,0,1024,10]},
|
||||||
|
"61":{"T":66,"emit":"a07","map":[0,1024,0,1024,10]},
|
||||||
|
|
||||||
|
"62":{"T":66,"emit":"a08","map":[0,1024,0,1024,10]},
|
||||||
|
"63":{"T":66,"emit":"a09","map":[0,1024,0,1024,10]},
|
||||||
|
|
||||||
|
"64":{"T":66,"emit":"a10","map":[0,1024,0,1024,10]},
|
||||||
|
"65":{"T":66,"emit":"a11","map":[0,1024,0,1024,10]},
|
||||||
|
"66":{"T":0,"emit":"leak31","item":"water3","scmd":"OFF","rcmd":"ON"},
|
||||||
|
"67":{"T":2,"emit":"leak32","item":"water3","scmd":"OFF","rcmd":"ON"},
|
||||||
|
"68":{"T":0,"emit":"leak33","item":"water3","scmd":"OFF","rcmd":"ON"}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -720,6 +720,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem)
|
|||||||
// continue processing as SET
|
// continue processing as SET
|
||||||
case S_SET:
|
case S_SET:
|
||||||
//case S_ESET:
|
//case S_ESET:
|
||||||
|
if ((st.getArgType() == ST_RGB || st.getArgType() == ST_RGBW) && (cmd.getArgType() == ST_HSV ) || (cmd.getArgType() == ST_HSV255)) st.setArgType(cmd.getArgType());
|
||||||
if (itemType == CH_GROUP && cmd.isColor()) st.setArgType(ST_HSV);//Extend storage for group channel
|
if (itemType == CH_GROUP && cmd.isColor()) st.setArgType(ST_HSV);//Extend storage for group channel
|
||||||
st.assignFrom(cmd);
|
st.assignFrom(cmd);
|
||||||
st.saveItem(this);
|
st.saveItem(this);
|
||||||
@@ -1552,13 +1553,22 @@ int Item::SendStatus(int sendFlags) {
|
|||||||
sendFlags |= getFlag(SEND_COMMAND | SEND_PARAMETERS); //if some delayed status is pending
|
sendFlags |= getFlag(SEND_COMMAND | SEND_PARAMETERS); //if some delayed status is pending
|
||||||
|
|
||||||
char addrstr[48];
|
char addrstr[48];
|
||||||
char valstr[16] = "";
|
char valstr[20] = "";
|
||||||
char cmdstr[8] = "";
|
char cmdstr[8] = "";
|
||||||
|
|
||||||
if (sendFlags & SEND_PARAMETERS)
|
if (sendFlags & SEND_PARAMETERS)
|
||||||
{
|
{
|
||||||
// Preparing parameters payload //////////
|
// Preparing parameters payload //////////
|
||||||
st.toString(valstr, sizeof(valstr), SEND_PARAMETERS);
|
switch (st.getArgType()) {
|
||||||
|
case ST_RGB:
|
||||||
|
case ST_RGBW:
|
||||||
|
//valstr[0]='#';
|
||||||
|
st.Cmd(CMD_RGB);
|
||||||
|
st.toString(valstr, sizeof(valstr), SEND_PARAMETERS|SEND_COMMAND);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
st.toString(valstr, sizeof(valstr), SEND_PARAMETERS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sendFlags & SEND_COMMAND)
|
if (sendFlags & SEND_COMMAND)
|
||||||
@@ -1577,6 +1587,7 @@ int Item::SendStatus(int sendFlags) {
|
|||||||
strcpy_P(cmdstr, OFF_P);
|
strcpy_P(cmdstr, OFF_P);
|
||||||
break;
|
break;
|
||||||
case CMD_VOID:
|
case CMD_VOID:
|
||||||
|
case CMD_RGB:
|
||||||
sendFlags &= ~SEND_COMMAND; // Not send command for parametrized req
|
sendFlags &= ~SEND_COMMAND; // Not send command for parametrized req
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -1623,7 +1634,7 @@ int Item::SendStatus(int sendFlags) {
|
|||||||
switch (st.getArgType()) {
|
switch (st.getArgType()) {
|
||||||
case ST_RGB:
|
case ST_RGB:
|
||||||
case ST_RGBW:
|
case ST_RGBW:
|
||||||
strncat_P(addrstr, RGB_P, sizeof(addrstr));
|
strncat_P(addrstr, SET_P, sizeof(addrstr));
|
||||||
break;
|
break;
|
||||||
case ST_PERCENTS255:
|
case ST_PERCENTS255:
|
||||||
case ST_HSV255:
|
case ST_HSV255:
|
||||||
|
|||||||
@@ -384,8 +384,10 @@ itemCmd itemCmd::assignFrom(itemCmd from)
|
|||||||
switch (from.cmd.itemArgType)
|
switch (from.cmd.itemArgType)
|
||||||
{
|
{
|
||||||
case ST_RGBW:
|
case ST_RGBW:
|
||||||
|
RGBW_flag=true;
|
||||||
case ST_RGB:
|
case ST_RGB:
|
||||||
param.asInt32=from.param.asInt32;
|
param.asInt32=from.param.asInt32;
|
||||||
|
cmd.itemArgType=from.cmd.itemArgType;
|
||||||
break;
|
break;
|
||||||
// Those types are not possible to apply over RGB without convertion toward HSV
|
// Those types are not possible to apply over RGB without convertion toward HSV
|
||||||
case ST_PERCENTS255:
|
case ST_PERCENTS255:
|
||||||
|
|||||||
217
lighthub/modules/out_pid.cpp
Normal file
217
lighthub/modules/out_pid.cpp
Normal file
@@ -0,0 +1,217 @@
|
|||||||
|
#ifndef PID_DISABLE
|
||||||
|
|
||||||
|
#include "modules/out_pid.h"
|
||||||
|
#include "Arduino.h"
|
||||||
|
#include "options.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "Streaming.h"
|
||||||
|
#include "item.h"
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
bool out_pid::getConfig()
|
||||||
|
{
|
||||||
|
double kP=0.0;
|
||||||
|
double kI=0.0;
|
||||||
|
double kD=0.0;
|
||||||
|
int direction = DIRECT;
|
||||||
|
|
||||||
|
// Retrieve and store
|
||||||
|
if (!store || !item || !item->itemArg || (item->itemArg->type != aJson_Array) || aJson.getArraySize(item->itemArg)<2)
|
||||||
|
{
|
||||||
|
errorSerial<<F("PID: config failed:")<<(bool)store<<F(",")<<(bool)item<<F(",")<<(bool)item->itemArg<<F(",")<<(item->itemArg->type != aJson_Array)<<F(",")<< (aJson.getArraySize(item->itemArg)<2)<<endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
aJsonObject * kPIDObj = aJson.getArrayItem(item->itemArg, 0);
|
||||||
|
if (kPIDObj->type != aJson_Array)
|
||||||
|
{
|
||||||
|
errorSerial<<F("Invalid PID param array.")<<endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
aJsonObject * param;
|
||||||
|
switch (aJson.getArraySize(kPIDObj))
|
||||||
|
{
|
||||||
|
case 3:
|
||||||
|
param = aJson.getArrayItem(kPIDObj, 2);
|
||||||
|
if (param->type == aJson_Float) kD=param->valuefloat;
|
||||||
|
case 2:
|
||||||
|
param = aJson.getArrayItem(kPIDObj, 1);
|
||||||
|
if (param->type == aJson_Float) kI=param->valuefloat;
|
||||||
|
case 1:
|
||||||
|
param = aJson.getArrayItem(kPIDObj, 0);
|
||||||
|
if (param->type == aJson_Float) kP=param->valuefloat;
|
||||||
|
if (kP<0)
|
||||||
|
{
|
||||||
|
kP=-kP;
|
||||||
|
direction=REVERSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (item->itemVal->type)
|
||||||
|
{
|
||||||
|
case aJson_Int: item->itemVal->valuefloat = item->itemVal->valueint;
|
||||||
|
break;
|
||||||
|
case aJson_Float:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
item->itemVal->type = aJson_Float;
|
||||||
|
|
||||||
|
if (!store->pid) store->pid= new PID (&store->input, &store->output, &item->itemVal->valuefloat, kP, kI, kD, direction);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
//store->addr=item->getArg(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int out_pid::Setup()
|
||||||
|
{
|
||||||
|
if (!store) store= (pidPersistent *)item->setPersistent(new pidPersistent);
|
||||||
|
if (!store)
|
||||||
|
{ errorSerial<<F("PID: Out of memory")<<endl;
|
||||||
|
return 0;}
|
||||||
|
|
||||||
|
//store->timestamp=millis();
|
||||||
|
if (getConfig())
|
||||||
|
{
|
||||||
|
//item->clearFlag(ACTION_NEEDED);
|
||||||
|
//item->clearFlag(ACTION_IN_PROCESS);
|
||||||
|
infoSerial<<F("PID config loaded ")<< item->itemArr->name<<endl;
|
||||||
|
store->driverStatus = CST_INITIALIZED;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ errorSerial<<F("PID config error")<<endl;
|
||||||
|
store->driverStatus = CST_FAILED;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int out_pid::Stop()
|
||||||
|
{
|
||||||
|
Serial.println("Modbus De-Init");
|
||||||
|
if (store) delete (store->pid());
|
||||||
|
delete store;
|
||||||
|
item->setPersistent(NULL);
|
||||||
|
store = NULL;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int out_pid::Status()
|
||||||
|
{
|
||||||
|
if (store)
|
||||||
|
return store->driverStatus;
|
||||||
|
return CST_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
int out_pid::isActive()
|
||||||
|
{
|
||||||
|
return item->getVal();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int out_pid::Poll(short cause)
|
||||||
|
{
|
||||||
|
if ((Status() == CST_INITIALIZED) && isTimeOver(store->timestamp,millis(),store->pollingInterval))
|
||||||
|
{
|
||||||
|
|
||||||
|
store->timestamp=millis();
|
||||||
|
debugSerial<<F("endPoll ")<< item->itemArr->name << endl;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return store->pollingInterval;
|
||||||
|
};
|
||||||
|
|
||||||
|
int out_pid::getChanType()
|
||||||
|
{
|
||||||
|
return CH_MODBUS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//!Control unified Modbus item
|
||||||
|
// Priority of selection sub-items control to:
|
||||||
|
// 1. if defined standard suffix Code inside cmd
|
||||||
|
// 2. custom textual subItem
|
||||||
|
// 3. non-standard numeric suffix Code equal param id
|
||||||
|
|
||||||
|
int out_pid::Ctrl(itemCmd cmd, char* subItem, bool toExecute)
|
||||||
|
{
|
||||||
|
//int chActive = item->isActive();
|
||||||
|
//bool toExecute = (chActive>0);
|
||||||
|
//itemCmd st(ST_UINT32,CMD_VOID);
|
||||||
|
int suffixCode = cmd.getSuffix();
|
||||||
|
aJsonObject *templateParamObj = NULL;
|
||||||
|
short mappedCmdVal = 0;
|
||||||
|
|
||||||
|
// trying to find parameter in template with name == subItem (NB!! standard suffixes dint working here)
|
||||||
|
if (subItem && strlen (subItem)) templateParamObj = aJson.getObjectItem(store->parameters, subItem);
|
||||||
|
|
||||||
|
if (!templateParamObj)
|
||||||
|
{
|
||||||
|
// Trying to find template parameter where id == suffixCode
|
||||||
|
templateParamObj = store->parameters->child;
|
||||||
|
|
||||||
|
while (templateParamObj)
|
||||||
|
{
|
||||||
|
//aJsonObject *regObj = aJson.getObjectItem(paramObj, "reg");
|
||||||
|
aJsonObject *idObj = aJson.getObjectItem(templateParamObj, "id");
|
||||||
|
if (idObj->type==aJson_Int && idObj->valueint == suffixCode) break;
|
||||||
|
|
||||||
|
aJsonObject *mapObj = aJson.getObjectItem(templateParamObj, "mapcmd");
|
||||||
|
if (mapObj && (mappedCmdVal = cmd.doReverseMappingCmd(mapObj))) break;
|
||||||
|
|
||||||
|
templateParamObj=templateParamObj->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// aJsonObject *typeObj = aJson.getObjectItem(paramObj, "type");
|
||||||
|
// aJsonObject *mapObj = aJson.getObjectItem(paramObj, "map");
|
||||||
|
// aJsonObject * itemParametersObj = aJson.getArrayItem(item->itemArg, 2);
|
||||||
|
// uint16_t data = node.getResponseBuffer(posInBuffer);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (cmd.isCommand() && !suffixCode) suffixCode=S_CMD; //if some known command find, but w/o correct suffix - got it
|
||||||
|
|
||||||
|
switch(suffixCode)
|
||||||
|
{
|
||||||
|
case S_NOTFOUND:
|
||||||
|
// turn on and set
|
||||||
|
toExecute = true;
|
||||||
|
debugSerial<<F("Forced execution");
|
||||||
|
case S_SET:
|
||||||
|
if (!cmd.isValue()) return 0;
|
||||||
|
|
||||||
|
//TODO
|
||||||
|
return 1;
|
||||||
|
//break;
|
||||||
|
|
||||||
|
case S_CMD:
|
||||||
|
switch (cmd.getCmd())
|
||||||
|
{
|
||||||
|
case CMD_ON:
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
case CMD_OFF:
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
default:
|
||||||
|
debugSerial<<F("Unknown cmd ")<<cmd.getCmd()<<endl;
|
||||||
|
} //switch cmd
|
||||||
|
|
||||||
|
default:
|
||||||
|
debugSerial<<F("Unknown suffix ")<<suffixCode<<endl;
|
||||||
|
} //switch suffix
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
36
lighthub/modules/out_pid.h
Normal file
36
lighthub/modules/out_pid.h
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "options.h"
|
||||||
|
#ifndef PID_DISABLE
|
||||||
|
#include <abstractout.h>
|
||||||
|
#include <item.h>
|
||||||
|
#include <PID_v1.h>
|
||||||
|
|
||||||
|
|
||||||
|
class pidPersistent : public chPersistent {
|
||||||
|
public:
|
||||||
|
PID pid;
|
||||||
|
double output;
|
||||||
|
double input;
|
||||||
|
int driverStatus;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class out_pid : public abstractOut {
|
||||||
|
public:
|
||||||
|
|
||||||
|
out_pid(Item * _item):abstractOut(_item){store = (pidPersistent *) item->getPersistent();};
|
||||||
|
int Setup() override;
|
||||||
|
int Poll(short cause) override;
|
||||||
|
int Stop() override;
|
||||||
|
int Status() override;
|
||||||
|
int isActive() override;
|
||||||
|
int getChanType() override;
|
||||||
|
int Ctrl(itemCmd cmd, char* subItem=NULL, bool toExecute=true) override;
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
pidPersistent * store;
|
||||||
|
bool getConfig();
|
||||||
|
};
|
||||||
|
#endif
|
||||||
1110
platformio.ini
1110
platformio.ini
File diff suppressed because it is too large
Load Diff
1
spare_files/ArduinoOTA
Submodule
1
spare_files/ArduinoOTA
Submodule
Submodule spare_files/ArduinoOTA added at 8feeea7786
Reference in New Issue
Block a user