diff --git a/.gitignore b/.gitignore
index 10def43f9..a85580d0b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,6 +11,7 @@ output/**
/custom.mk
/.vs
.vscode
+recents.json
node_modules
Debug*/**
libs_for_simulator/**
@@ -21,11 +22,16 @@ ILU.dll
ILUT.dll
SDL2.dll
nfd_d.lib
+configMemory.bin
/sim_lastPublish_long.txt
/sim_lastPublishes.txt
/sim_lastPublish.txt
+/lastHTTPPacket.txt
/lastMQTTPublishSentByOBK.txt
*.sln
# MacOS ignores
.DS_Store
+
+# MSVC
+enc_temp_folder/**
diff --git a/docs/README.md b/docs/README.md
index 097091412..c7ee06622 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -13,15 +13,15 @@ Do not add anything here, as it will overwritten with next rebuild.
# Doc tables
| Section | Comment |
|:------------- |------:|
-| [IO/Pin Roles](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/ioRoles.md) (77 total) | You can set pin roles in 'Configure Module' section or use one of predefined templates in Web App. For each pin, you also set coresponding channel value. This is needed for modules with multiple relays. If you have 3 relays and 3 buttons, you need to use channel values like 1, 2, and 3. Just enter '1' in the text field, etc. |
-| [Flags](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/flags.md) (41 total) | Flags are global and allows you to alter behaviour of the device. |
-| [Drivers](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/drivers.md) (36 total) | Drivers allows you to control certain peripherals or enable certain features that are off by default. |
-| [Script constants](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/constants.md) (24 total) | Every console command that takes an integer argument supports certain constant expansion. |
-| [Channel Types](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/channelTypes.md) (39 total) | Channel types are often not required and don't have to be configured, but in some cases they are required for better device control from OpenBeken web panel. Channel types describes the kind of value stored in channel, for example, if you have a Tuya Fan Controller with 3 speeds control, you can set the channel type to LowMidHigh and it will display the correct UI radiobutton on OpenBeken panel. Some channels have '_div10' or '_div100' sufixes. This is for TuyaMCU. This is needed because TuyaMCU sends values as integers, so it sends, for example, 215 for 21.5C temperature, and we store it internally as 215 and only convert to float for display. |
+| [IO/Pin Roles](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/ioRoles.md) (79 total) | You can set pin roles in 'Configure Module' section or use one of predefined templates in Web App. For each pin, you also set coresponding channel value. This is needed for modules with multiple relays. If you have 3 relays and 3 buttons, you need to use channel values like 1, 2, and 3. Just enter '1' in the text field, etc. |
+| [Flags](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/flags.md) (42 total) | Flags are global and allows you to alter behaviour of the device. |
+| [Drivers](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/drivers.md) (39 total) | Drivers allows you to control certain peripherals or enable certain features that are off by default. |
+| [Script constants](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/constants.md) (27 total) | Every console command that takes an integer argument supports certain constant expansion. |
+| [Channel Types](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/channelTypes.md) (40 total) | Channel types are often not required and don't have to be configured, but in some cases they are required for better device control from OpenBeken web panel. Channel types describes the kind of value stored in channel, for example, if you have a Tuya Fan Controller with 3 speeds control, you can set the channel type to LowMidHigh and it will display the correct UI radiobutton on OpenBeken panel. Some channels have '_div10' or '_div100' sufixes. This is for TuyaMCU. This is needed because TuyaMCU sends values as integers, so it sends, for example, 215 for 21.5C temperature, and we store it internally as 215 and only convert to float for display. |
| [FAQ](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/faq.md) (27 total) | Here is a detailed list of questions you may ask. Some information from docs is repeated here. |
-| [Console/Script commands](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands.md) (262 total) | There are multiple console commands that allow you to automate your devices. Commands can be entered manually in command line, can be send by HTTP (just like in Tasmota), can be send by MQTT and also can be scripted. |
+| [Console/Script commands](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands.md) (277 total) | There are multiple console commands that allow you to automate your devices. Commands can be entered manually in command line, can be send by HTTP (just like in Tasmota), can be send by MQTT and also can be scripted. |
| [Command Examples](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commandExamples.md) (10 total) | Here you can find some examples of console commands usage |
| [Autoexec.bat examples (configs)](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/autoexecExamples.md) (15 total) | Here you can find examples of autoexec.bat configs. The autoexec.bat file can be created in Web Application, under LittleFS tab, and is run every time device reboots (unless device enters safe mode/AP mode). The autoexec.bat file allows you to create more advanced configs, setup TuyaMCU mappings, etc |
| [MQTT Topics](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/mqttTopics.md) (25 total) | MQTT topic names and content for incoming and ougoing OBK MQTT publishes |
| [Script examples](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/scriptExamples.md) (5 total) | Scripts can be put in autoexec.bat and then they will start automatically on reboot, you can also put script in other LittleFS file and use startScript [fileName] [Label] command to run them. From the firmware point of view, scripts and autoexecs are basically the same thing. There is, however, a little bit more advanced system of execution for scripts which can be written in a form of scripts threads that run over time, can have delays within then, conditional checks and jumps. |
-| [Console/Script commands [Extended Edition]](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands-extended.md) (262 total) | More details on commands. |
+| [Console/Script commands [Extended Edition]](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands-extended.md) (277 total) | More details on commands. |
diff --git a/docs/channelTypes.md b/docs/channelTypes.md
index 912afd96d..6ce343579 100644
--- a/docs/channelTypes.md
+++ b/docs/channelTypes.md
@@ -43,4 +43,5 @@ Do not add anything here, as it will overwritten with next rebuild.
| Power_div10 | Just like power, but with one decimal place (but stored as integer, for TuyaMCU support) |
| ReadOnlyLowMidHigh | Like LowMidHigh, but just read only |
| SmokePercent | Smoke percentage |
+| Illuminance | Illuminance in Lux |
| Max | This is the current total number of available channel types. |
diff --git a/docs/commands-extended.md b/docs/commands-extended.md
index 79eaebb4b..afca0bb62 100644
--- a/docs/commands-extended.md
+++ b/docs/commands-extended.md
@@ -62,6 +62,7 @@ Do not add anything here, as it will overwritten with next rebuild.
| echo | [Message] | Sends given message back to console. This command expands variables, so writing $CH12 will print value of channel 12, etc. Remember that you can also use special channel indices to access persistant flash variables and to access LED variables like dimmer, etc. | File: cmnds/cmd_main.c Function: CMD_Echo |
| EnergyCntReset | | Resets the total Energy Counter, the one that is usually kept after device reboots. After this commands, the counter will start again from 0. | File: driver/drv_bl_shared.c Function: BL09XX_ResetEnergyCounter |
| exec | [Filename] | exec - run autoexec.bat or other file from LFS if present | File: cmnds/cmd_tasmota.c Function: cmnd_lfsexec |
+| ExitSimulator | | [SIMULATOR ONLY] Exits the application instance | File: cmnds/cmd_simulatorOnly.c Function: CMD_ExitSimulator |
| fakeTuyaPacket | [HexString] | This simulates packet being sent from TuyaMCU to our OBK device. | File: driver/drv_tuyaMCU.c Function: TuyaMCU_FakePacket |
| flags | [IntegerValue] | Sets the device flags | File: cmnds/cmd_main.c Function: CMD_Flags |
| FriendlyName | [Name] | Sets the full name of the device | File: cmnds/cmd_channels.c Function: CMD_FriendlyName |
@@ -73,10 +74,18 @@ Do not add anything here, as it will overwritten with next rebuild.
| HSBColor1 | [Hue] | Tasmota-style colour access. Sets hue in 0 to 360 range. | File: cmnds/cmd_newLEDDriver.c Function: setHue |
| HSBColor2 | [Saturation] | Tasmota-style colour access. Set saturation in 0 to 100 range. | File: cmnds/cmd_newLEDDriver.c Function: setSaturation |
| HSBColor3 | [Brightness] | Tasmota-style colour access. Sets brightness in 0 to 100 range. | File: cmnds/cmd_newLEDDriver.c Function: setBrightness |
+| HT16K33_Blink | HT16K33_Blink | | File: driver/drv_ht16k33.c Function: NULL); |
+| HT16K33_Brightness | HT16K33_Brightness | | File: driver/drv_ht16k33.c Function: NULL); |
+| HT16K33_Char | HT16K33_Char | | File: driver/drv_ht16k33.c Function: NULL); |
+| HT16K33_Print | HT16K33_Print | | File: driver/drv_ht16k33.c Function: NULL); |
+| HT16K33_Raw | HT16K33_Raw | | File: driver/drv_ht16k33.c Function: NULL); |
+| HT16K33_Test | HT16K33_Test | | File: driver/drv_ht16k33.c Function: NULL); |
| if | [Condition]['then'][CommandA]['else'][CommandB] | Executed a conditional. Condition should be single line. You must always use 'then' after condition. 'else' is optional. Use aliases or quotes for commands with spaces | File: cmnds/cmd_main.c Function: CMD_If |
| IREnable | [Str][1or0] | Enable/disable aspects of IR. IREnable RXTX 0/1 - enable Rx whilst Tx. IREnable [protocolname] 0/1 - enable/disable a specified protocol | File: driver/drv_ir.cpp Function: IR_Enable |
| IRSend | [PROT-ADDR-CMD-REP] | Sends IR commands in the form PROT-ADDR-CMD-REP, e.g. NEC-1-1A-0 | File: driver/drv_ir.cpp Function: IR_Send_Cmd |
| json_test | cmnd_json_test | | File: cmnds/cmd_test.c Function: NULL); |
+| KP18058_Map | [Ch0][Ch1][Ch2][Ch3][Ch4] | Maps KP18058_Map RGBCW values to given indices of KP18058 channels. This is because KP18058 channels order is not the same for some devices. Some devices are using RGBCW order and some are using GBRCW, etc, etc. Example usage: KP18058_Map 0 1 2 3 4 | File: driver/drv_sm2235.c Function: KP18058_Map |
+| KP18058_RGBCW | [HexColor] | Don't use it. It's for direct access of KP18058 driver. You don't need it because LED driver automatically calls it, so just use led_basecolor_rgb | File: driver/drv_bp5758d.c Function: KP18058_RGBCW |
| lcd_clear | | Clears the LCD | File: i2c/drv_i2c_lcd_pcf8574t.c Function: DRV_I2C_LCD_PCF8574_Clear |
| lcd_clearAndGoto | | Clears LCD and go to pos | File: i2c/drv_i2c_lcd_pcf8574t.c Function: DRV_I2C_LCD_PCF8574_ClearAndGoTo |
| lcd_goto | | Go to position on LCD | File: i2c/drv_i2c_lcd_pcf8574t.c Function: DRV_I2C_LCD_PCF8574_GoTo |
@@ -126,6 +135,11 @@ Do not add anything here, as it will overwritten with next rebuild.
| MAX72XX_Scroll | DRV_MAX72XX_Scroll | | File: driver/drv_max72xx_single.c Function: NULL); |
| MAX72XX_Setup | [Value] | Sets the maximum current for LED driver. | File: driver/drv_sm2135.c Function: SM2135_Current |
| MCP23017_MapPinToChannel | | Maps port expander bit to OBK channel | File: i2c/drv_i2c_main.c Function: DRV_I2C_MCP23017_MapPinToChannel |
+| MCP9808_Adr | MCP9808_Adr | | File: driver/drv_mcp9808.c Function: NULL); |
+| MCP9808_AlertMin | MCP9808_AlertMin | | File: driver/drv_mcp9808.c Function: NULL); |
+| MCP9808_AlertRange | MCP9808_AlertRange | | File: driver/drv_mcp9808.c Function: NULL); |
+| MCP9808_Calibrate | MCP9808_Calibrate | | File: driver/drv_mcp9808.c Function: NULL); |
+| MCP9808_Cycle | MCP9808_cycle | | File: driver/drv_mcp9808.c Function: NULL); |
| MqttClient | [ValueString] | Sets the MQTT client. Command keeps Tasmota syntax | File: cmnds/cmd_tasmota.c Function: cmnd_MqttClient |
| MqttHost | [ValueString] | Sets the MQTT host. Command keeps Tasmota syntax | File: cmnds/cmd_tasmota.c Function: cmnd_MqttHost |
| MqttPassword | [ValueString] | Sets the MQTT pass. Command keeps Tasmota syntax | File: cmnds/cmd_tasmota.c Function: cmnd_MqttPassword |
@@ -163,7 +177,7 @@ Do not add anything here, as it will overwritten with next rebuild.
| scanI2C | | | File: i2c/drv_i2c_main.c Function: DRV_I2C_MCP23017_MapPinToChannel |
| scheduleHADiscovery | [Seconds] | This will schedule HA discovery, the discovery will happen with given number of seconds, but timer only counts when MQTT is connected. It will not work without MQTT online, so you must set MQTT credentials first. | File: cmnds/cmd_main.c Function: CMD_ScheduleHADiscovery |
| sendGet | [TargetURL] | Sends a HTTP GET request to target URL. May include GET arguments. Can be used to control devices by Tasmota HTTP protocol. Command supports argument expansion, so $CH11 changes to value of channel 11, etc, etc. | File: cmnds/cmd_send.c Function: CMD_SendGET |
-| sendPOST | CMD_SendPOST | | File: cmnds/cmd_send.c Function: NULL); |
+| sendPOST | [TargetURL] [HTTP Port] [Content Type] [Post Content] | Sends a HTTP POST request to target URL. Arguments can contain variable expansion. | File: cmnds/cmd_send.c Function: CMD_SendPOST |
| setButtonColor | [ButtonIndex][Color] | Sets the colour of custom scriptable HTTP page button | File: driver/drv_httpButtons.c Function: CMD_setButtonColor |
| setButtonCommand | [ButtonIndex][Command] | Sets the command of custom scriptable HTTP page button | File: driver/drv_httpButtons.c Function: CMD_setButtonCommand |
| setButtonEnabled | [ButtonIndex][1or0] | Sets the visibility of custom scriptable HTTP page button | File: driver/drv_httpButtons.c Function: CMD_setButtonEnabled |
@@ -200,10 +214,9 @@ Do not add anything here, as it will overwritten with next rebuild.
| SHT_SetAlert | [temp_high, temp_low, hum_high, hum_low] Req:all | Set Sensor alert configuration e.g.:SHT_SetAlertCmd | File: driver/drv_sht3x.c Function: SHT3X_SetAlertcmd |
| SHT_StopPer | | Stop periodical capture for SHT Sensor | File: driver/drv_sht3x.c Function: SHT3X_StopPerCmd |
| simonirtest | | Simons Special Test | File: cmnds/cmd_main.c Function: CMD_SimonTest |
-| SM16703P_Send | | NULL | File: driver/drv_sm16703P.c Function: SM16703P_Send_Cmd |
-| SM16703P_Test | | qq | File: driver/drv_ucs1912.c Function: SM16703P_Test |
-| SM16703P_Test_3xOne | | NULL | File: driver/drv_sm16703P.c Function: SM16703P_Test_3xOne |
-| SM16703P_Test_3xZero | | NULL | File: driver/drv_sm16703P.c Function: SM16703P_Test_3xZero |
+| SM16703P_Init | SM16703P_Start | | File: driver/drv_sm16703P.c Function: NULL); |
+| SM16703P_SetPixel | SM16703P_CMD_setPixel | | File: driver/drv_sm16703P.c Function: NULL); |
+| SM16703P_Start | SM16703P_StartTX | | File: driver/drv_sm16703P.c Function: NULL); |
| SM2135_Current | [RGBLimit][CWLimit] | Sets the maximum current for LED driver. Please note that arguments are using SM2135 codes, see [full list of codes here](https://www.elektroda.com/rtvforum/viewtopic.php?p=20493415#20493415) | File: driver/drv_sm2135.c Function: SM2135_Current |
| SM2135_Map | [Ch0][Ch1][Ch2][Ch3][Ch4] | Maps the RGBCW values to given indices of SM2135 channels. This is because SM2135 channels order is not the same for some devices. Some devices are using RGBCW order and some are using GBRCW, etc, etc. Example usage: SM2135_Map 0 1 2 3 4 | File: driver/drv_sm2135.c Function: SM2135_Map |
| SM2135_RGBCW | [HexColor] | Don't use it. It's for direct access of SM2135 driver. You don't need it because LED driver automatically calls it, so just use led_basecolor_rgb | File: driver/drv_sm2135.c Function: SM2135_RGBCW |
@@ -247,6 +260,7 @@ Do not add anything here, as it will overwritten with next rebuild.
| toggler_name | | Handles toggler_name0, toggler_name1, etc. Sets the name of a toggler for GUI. | File: driver/drv_pwmToggler.c Function: Toggler_NameX |
| toggler_set | [Value] | Sets the VALUE of given output. Handles toggler_set0, toggler_set1, etc. The last digit after command name is changed to slot index. | File: driver/drv_pwmToggler.c Function: Toggler_SetX |
| tuyaMcu_defWiFiState | | Command sets the default WiFi state for TuyaMCU when device is not online. It may be required for some devices to work, because Tuya designs them to ignore touch buttons or beep when not paired. Please see [values table and description here](https://www.elektroda.com/rtvforum/viewtopic.php?p=20483899#20483899). | File: driver/drv_tuyaMCU.c Function: Cmd_TuyaMCU_Send_RSSI |
+| tuyaMcu_sendColor | Cmd_TuyaMCU_SendColor | | File: driver/drv_tuyaMCU.c Function: NULL); |
| tuyaMcu_sendCurTime | | Sends a current date by TuyaMCU to clock/callendar MCU. Time is taken from NTP driver, so NTP also should be already running. | File: driver/drv_tuyaMCU.c Function: TuyaMCU_Send_SetTime_Current |
| tuyaMcu_sendHeartbeat | | Send heartbeat to TuyaMCU | File: driver/drv_tuyaMCU.c Function: TuyaMCU_SendHeartbeat |
| tuyaMcu_sendMCUConf | | Send MCU conf command | File: driver/drv_tuyaMCU.c Function: TuyaMCU_SendMCUConf |
@@ -256,6 +270,7 @@ Do not add anything here, as it will overwritten with next rebuild.
| tuyaMcu_sendState | [dpID][dpType][dpValue] | Manually send set state command. Do not use it. Use mapping, so communication is bidirectional and automatic. | File: driver/drv_tuyaMCU.c Function: TuyaMCU_SendStateCmd |
| tuyaMcu_setBaudRate | [BaudValue] | Sets the baud rate used by TuyaMCU UART communication. Default value is 9600. Some other devices require 115200. | File: driver/drv_tuyaMCU.c Function: TuyaMCU_SetBaudRate |
| tuyaMcu_setDimmerRange | [Min][Max] | Set dimmer range used by TuyaMCU | File: driver/drv_tuyaMCU.c Function: TuyaMCU_SetDimmerRange |
+| tuyaMcu_setupLED | Cmd_TuyaMCU_SetupLED | | File: driver/drv_tuyaMCU.c Function: NULL); |
| tuyaMcu_testSendTime | | Sends a example date by TuyaMCU to clock/callendar MCU | File: driver/drv_tuyaMCU.c Function: TuyaMCU_Send_SetTime_Example |
| uartFakeHex | [HexString] | Spoofs a fake hex packet so it looks like TuyaMCU send that to us. Used for testing. | File: driver/drv_uart.c Function: CMD_UART_FakeHex |
| uartInit | [BaudRate] | Manually starts UART1 port. Keep in mind that you don't need to do it for TuyaMCU and BL0942, those drivers do it automatically. | File: driver/drv_uart.c Function: CMD_UART_Init |
diff --git a/docs/commands.md b/docs/commands.md
index 652cc4214..3f9848c59 100644
--- a/docs/commands.md
+++ b/docs/commands.md
@@ -65,6 +65,7 @@ Do not add anything here, as it will overwritten with next rebuild.
| echo | [Message] | Sends given message back to console. This command expands variables, so writing $CH12 will print value of channel 12, etc. Remember that you can also use special channel indices to access persistant flash variables and to access LED variables like dimmer, etc. |
| EnergyCntReset | | Resets the total Energy Counter, the one that is usually kept after device reboots. After this commands, the counter will start again from 0. |
| exec | [Filename] | exec - run autoexec.bat or other file from LFS if present |
+| ExitSimulator | | [SIMULATOR ONLY] Exits the application instance |
| fakeTuyaPacket | [HexString] | This simulates packet being sent from TuyaMCU to our OBK device. |
| flags | [IntegerValue] | Sets the device flags |
| FriendlyName | [Name] | Sets the full name of the device |
@@ -76,10 +77,18 @@ Do not add anything here, as it will overwritten with next rebuild.
| HSBColor1 | [Hue] | Tasmota-style colour access. Sets hue in 0 to 360 range. |
| HSBColor2 | [Saturation] | Tasmota-style colour access. Set saturation in 0 to 100 range. |
| HSBColor3 | [Brightness] | Tasmota-style colour access. Sets brightness in 0 to 100 range. |
+| HT16K33_Blink | HT16K33_Blink | |
+| HT16K33_Brightness | HT16K33_Brightness | |
+| HT16K33_Char | HT16K33_Char | |
+| HT16K33_Print | HT16K33_Print | |
+| HT16K33_Raw | HT16K33_Raw | |
+| HT16K33_Test | HT16K33_Test | |
| if | [Condition]['then'][CommandA]['else'][CommandB] | Executed a conditional. Condition should be single line. You must always use 'then' after condition. 'else' is optional. Use aliases or quotes for commands with spaces |
| IREnable | [Str][1or0] | Enable/disable aspects of IR. IREnable RXTX 0/1 - enable Rx whilst Tx. IREnable [protocolname] 0/1 - enable/disable a specified protocol |
| IRSend | [PROT-ADDR-CMD-REP] | Sends IR commands in the form PROT-ADDR-CMD-REP, e.g. NEC-1-1A-0 |
| json_test | cmnd_json_test | |
+| KP18058_Map | [Ch0][Ch1][Ch2][Ch3][Ch4] | Maps KP18058_Map RGBCW values to given indices of KP18058 channels. This is because KP18058 channels order is not the same for some devices. Some devices are using RGBCW order and some are using GBRCW, etc, etc. Example usage: KP18058_Map 0 1 2 3 4 |
+| KP18058_RGBCW | [HexColor] | Don't use it. It's for direct access of KP18058 driver. You don't need it because LED driver automatically calls it, so just use led_basecolor_rgb |
| lcd_clear | | Clears the LCD |
| lcd_clearAndGoto | | Clears LCD and go to pos |
| lcd_goto | | Go to position on LCD |
@@ -129,6 +138,11 @@ Do not add anything here, as it will overwritten with next rebuild.
| MAX72XX_Scroll | DRV_MAX72XX_Scroll | |
| MAX72XX_Setup | [Value] | Sets the maximum current for LED driver. |
| MCP23017_MapPinToChannel | | Maps port expander bit to OBK channel |
+| MCP9808_Adr | MCP9808_Adr | |
+| MCP9808_AlertMin | MCP9808_AlertMin | |
+| MCP9808_AlertRange | MCP9808_AlertRange | |
+| MCP9808_Calibrate | MCP9808_Calibrate | |
+| MCP9808_Cycle | MCP9808_cycle | |
| MqttClient | [ValueString] | Sets the MQTT client. Command keeps Tasmota syntax |
| MqttHost | [ValueString] | Sets the MQTT host. Command keeps Tasmota syntax |
| MqttPassword | [ValueString] | Sets the MQTT pass. Command keeps Tasmota syntax |
@@ -166,7 +180,7 @@ Do not add anything here, as it will overwritten with next rebuild.
| scanI2C | | |
| scheduleHADiscovery | [Seconds] | This will schedule HA discovery, the discovery will happen with given number of seconds, but timer only counts when MQTT is connected. It will not work without MQTT online, so you must set MQTT credentials first. |
| sendGet | [TargetURL] | Sends a HTTP GET request to target URL. May include GET arguments. Can be used to control devices by Tasmota HTTP protocol. Command supports argument expansion, so $CH11 changes to value of channel 11, etc, etc. |
-| sendPOST | CMD_SendPOST | |
+| sendPOST | [TargetURL] [HTTP Port] [Content Type] [Post Content] | Sends a HTTP POST request to target URL. Arguments can contain variable expansion. |
| setButtonColor | [ButtonIndex][Color] | Sets the colour of custom scriptable HTTP page button |
| setButtonCommand | [ButtonIndex][Command] | Sets the command of custom scriptable HTTP page button |
| setButtonEnabled | [ButtonIndex][1or0] | Sets the visibility of custom scriptable HTTP page button |
@@ -203,10 +217,9 @@ Do not add anything here, as it will overwritten with next rebuild.
| SHT_SetAlert | [temp_high, temp_low, hum_high, hum_low] Req:all | Set Sensor alert configuration e.g.:SHT_SetAlertCmd |
| SHT_StopPer | | Stop periodical capture for SHT Sensor |
| simonirtest | | Simons Special Test |
-| SM16703P_Send | | NULL |
-| SM16703P_Test | | qq |
-| SM16703P_Test_3xOne | | NULL |
-| SM16703P_Test_3xZero | | NULL |
+| SM16703P_Init | SM16703P_Start | |
+| SM16703P_SetPixel | SM16703P_CMD_setPixel | |
+| SM16703P_Start | SM16703P_StartTX | |
| SM2135_Current | [RGBLimit][CWLimit] | Sets the maximum current for LED driver. Please note that arguments are using SM2135 codes, see [full list of codes here](https://www.elektroda.com/rtvforum/viewtopic.php?p=20493415#20493415) |
| SM2135_Map | [Ch0][Ch1][Ch2][Ch3][Ch4] | Maps the RGBCW values to given indices of SM2135 channels. This is because SM2135 channels order is not the same for some devices. Some devices are using RGBCW order and some are using GBRCW, etc, etc. Example usage: SM2135_Map 0 1 2 3 4 |
| SM2135_RGBCW | [HexColor] | Don't use it. It's for direct access of SM2135 driver. You don't need it because LED driver automatically calls it, so just use led_basecolor_rgb |
@@ -250,6 +263,7 @@ Do not add anything here, as it will overwritten with next rebuild.
| toggler_name | | Handles toggler_name0, toggler_name1, etc. Sets the name of a toggler for GUI. |
| toggler_set | [Value] | Sets the VALUE of given output. Handles toggler_set0, toggler_set1, etc. The last digit after command name is changed to slot index. |
| tuyaMcu_defWiFiState | | Command sets the default WiFi state for TuyaMCU when device is not online. It may be required for some devices to work, because Tuya designs them to ignore touch buttons or beep when not paired. Please see [values table and description here](https://www.elektroda.com/rtvforum/viewtopic.php?p=20483899#20483899). |
+| tuyaMcu_sendColor | Cmd_TuyaMCU_SendColor | |
| tuyaMcu_sendCurTime | | Sends a current date by TuyaMCU to clock/callendar MCU. Time is taken from NTP driver, so NTP also should be already running. |
| tuyaMcu_sendHeartbeat | | Send heartbeat to TuyaMCU |
| tuyaMcu_sendMCUConf | | Send MCU conf command |
@@ -259,6 +273,7 @@ Do not add anything here, as it will overwritten with next rebuild.
| tuyaMcu_sendState | [dpID][dpType][dpValue] | Manually send set state command. Do not use it. Use mapping, so communication is bidirectional and automatic. |
| tuyaMcu_setBaudRate | [BaudValue] | Sets the baud rate used by TuyaMCU UART communication. Default value is 9600. Some other devices require 115200. |
| tuyaMcu_setDimmerRange | [Min][Max] | Set dimmer range used by TuyaMCU |
+| tuyaMcu_setupLED | Cmd_TuyaMCU_SetupLED | |
| tuyaMcu_testSendTime | | Sends a example date by TuyaMCU to clock/callendar MCU |
| uartFakeHex | [HexString] | Spoofs a fake hex packet so it looks like TuyaMCU send that to us. Used for testing. |
| uartInit | [BaudRate] | Manually starts UART1 port. Keep in mind that you don't need to do it for TuyaMCU and BL0942, those drivers do it automatically. |
diff --git a/docs/constants.md b/docs/constants.md
index b43551a79..4682287fd 100644
--- a/docs/constants.md
+++ b/docs/constants.md
@@ -11,6 +11,8 @@ Do not add anything here, as it will overwritten with next rebuild.
| $CH*** | Provides channel access, so you can do math expressions on channel values. $CH1 is channel 1, $CH20 is channel 20, $CH140 is channel 140, etc |
| $CH** | Provides channel access, as above. |
| $CH* | Provides channel access, as above. |
+| $FLAG** | Provides flag access, as above. |
+| $FLAG* | Provides flag access, as above. |
| $led_dimmer | Current value of LED dimmer, 0-100 range |
| $led_enableAll | Returns 1 if LED is enabled, otherwise 0. |
| $led_hue | Current LED Hue value |
@@ -23,6 +25,7 @@ Do not add anything here, as it will overwritten with next rebuild.
| $voltage | Current value of voltage from energy metering chip. You can use those variables to make, for example, a change handler that fires when voltage is above 245, etc. |
| $current | Current value of current from energy metering chip |
| $power | Current value of power from energy metering chip |
+| $energy | Current value of energy counter from energy metering chip |
| $day | Current weekday from NTP |
| $hour | Current hour from NTP |
| $minute | Current minute from NTP |
diff --git a/docs/drivers.md b/docs/drivers.md
index 8d2ab102b..48ddad023 100644
--- a/docs/drivers.md
+++ b/docs/drivers.md
@@ -22,8 +22,9 @@ Do not add anything here, as it will overwritten with next rebuild.
| IR | IRLibrary wrapper, so you can receive remote signals and send them. See [forum discussion here](https://www.elektroda.com/rtvforum/topic3920360.html), also see [LED strip and IR YT video](https://www.youtube.com/watch?v=KU0tDwtjfjw) |
| DDP | DDP is a LED control protocol that is using UDP. You can use xLights or any other app to control OBK LEDs that way. |
| SSDP | SSDP is a discovery protocol, so BK devices can show up in, for example, Windows network section |
-| Wemo | Wemo emulation for Alexa. You must also start SSDP so it can run, because it depends on SSDP discovery. |
| DGR | Tasmota Device groups driver. See [forum example](https://www.elektroda.com/rtvforum/topic3925472.html) and TODO-video tutorial (will post on YT soon) |
+| Wemo | Wemo emulation for Alexa. You must also start SSDP so it can run, because it depends on SSDP discovery. |
+| Hue | Hue emulation for Alexa. You must also start SSDP so it can run, because it depends on SSDP discovery. |
| PWMToggler | PWMToggler is a custom abstraction layer that can run on top of raw PWM channels. It provides ability to turn off/on the PWM while keeping it's value, which is not possible by direct channel operations. It can be used for some custom devices with extra lights/lasers. See example [here](https://www.elektroda.com/rtvforum/topic3939064.html). |
| DoorSensor | DoorSensor is using deep sleep to preserve battery. This is used for devices without TuyaMCU, where BK deep sleep and wakeup on GPIO is used. This drives requires you to set a DoorSensor pin. Change on door sensor pin wakes up the device. If there are no changes for some time, device goes to sleep. See example [here](https://www.elektroda.com/rtvforum/topic3960149.html). If your door sensor does not wake up in certain pos, please use DSEdge command (try all 3 options, default is 2). |
| MAX72XX_Clock | Simple hardcoded driver for MAX72XX clock. Requirex manual start of MAX72XX driver with MAX72XX setup and NTP start. |
@@ -33,11 +34,13 @@ Do not add anything here, as it will overwritten with next rebuild.
| BP1658CJ | BP1658CJ custom-'I2C' LED driver for RGBCW lights. This will start automatically if you set both BP1658CJ pin roles. This may need you to remap the RGBCW indexes with BP1658CJ_Map command |
| SM2235 | SM2335 andd SM2235 custom-'I2C' LED driver for RGBCW lights. This will start automatically if you set both SM2235 pin roles. This may need you to remap the RGBCW indexes with SM2235_Map command |
| CHT8305 | CHT8305 is a Temperature and Humidity sensor with I2C interface. |
-| KP18068 | KP18068 I2C LED driver |
-| MAX72XX | MAX72XX LED matrix display driver with font and simple script interface. |
+| KP18068 | KP18068 I2C LED driver. Unfinished due to the lack of the information. |
+| KP18058 | KP18058 I2C LED driver. Working, see reverse-engineering [topic](https://www.elektroda.pl/rtvforum/topic3991620.html) |
+| MAX72XX | MAX72XX LED matrix display driver with font and simple script interface. See [protocol explanation](https://www.elektroda.pl/rtvforum/viewtopic.php?p=18040628#18040628) |
| TM1637 | Driver for 7-segment LED display with DIO/CLK interface |
| GN6932 | Driver for 7-segment LED display with DIO/CLK/STB interface. See [this topic](https://www.elektroda.com/rtvforum/topic3971252.html) for details. |
| TM1638 | Driver for 7-segment LED display with DIO/CLK/STB interface. TM1638 is very similiar to GN6932 and TM1637. See [this topic](https://www.elektroda.com/rtvforum/viewtopic.php?p=20553628#20553628) for details. |
+| HT16K33 | Driver for 16-segment LED display with I2C. See [protocol explanation](https://www.elektroda.pl/rtvforum/topic3984616.html) |
| SHT3X | Humidity/temperature sensor. See [SHT Sensor tutorial topic here](https://www.elektroda.com/rtvforum/topic3958369.html), also see [this sensor teardown](https://www.elektroda.com/rtvforum/topic3945688.html) |
| SGP | SGP Air Quality sensor with I2C interface. |
| ShiftRegister | ShiftRegisterShiftRegisterShiftRegisterShiftRegister |
diff --git a/docs/flags.md b/docs/flags.md
index 42f805d5c..44e85656a 100644
--- a/docs/flags.md
+++ b/docs/flags.md
@@ -46,3 +46,4 @@ Do not add anything here, as it will overwritten with next rebuild.
| 38 | [Power] Set power and current to zero if all relays are open |
| 39 | [MQTT] [Debug] Publish all channels (don't enable it, it will be publish all 64 possible channels on connect) |
| 40 | [MQTT] Use kWh unit for energy consumption (total, last hour, today) instead of Wh |
+| 41 | [BTN] Ignore all button events (aka child lock) |
diff --git a/docs/ioRoles.md b/docs/ioRoles.md
index b4b3e27e3..3cefba0e5 100644
--- a/docs/ioRoles.md
+++ b/docs/ioRoles.md
@@ -81,4 +81,6 @@ Do not add anything here, as it will overwritten with next rebuild.
| TM1638_DAT | QQQ |
| TM1638_STB | QQQ |
| BAT_Relay_n | Like BAT_Relay, but inversed. See [battery driver topic here](https://www.elektroda.com/rtvforum/topic3959103.html) |
+| KP18058_CLK | QQQ |
+| KP18058_DAT | QQQ |
| Total_Options | Current total number of available IOR roles |
diff --git a/docs/json/channelTypes.json b/docs/json/channelTypes.json
index 27252fb47..fbac34428 100644
--- a/docs/json/channelTypes.json
+++ b/docs/json/channelTypes.json
@@ -303,6 +303,14 @@
"file": "new_pins.h",
"driver": ""
},
+ {
+ "name": "Illuminance",
+ "title": "TODO",
+ "descr": "Illuminance in Lux",
+ "enum": "ChType_Illuminance",
+ "file": "new_pins.h",
+ "driver": ""
+ },
{
"name": "Max",
"title": "TODO",
diff --git a/docs/json/commands.json b/docs/json/commands.json
index eb6022f93..648f4b5ee 100644
--- a/docs/json/commands.json
+++ b/docs/json/commands.json
@@ -512,6 +512,15 @@
"requires": "",
"examples": ""
},
+ {
+ "name": "ExitSimulator",
+ "args": "",
+ "descr": "[SIMULATOR ONLY] Exits the application instance",
+ "fn": "CMD_ExitSimulator",
+ "file": "cmnds/cmd_simulatorOnly.c",
+ "requires": "",
+ "examples": ""
+ },
{
"name": "fakeTuyaPacket",
"args": "[HexString]",
@@ -611,6 +620,60 @@
"requires": "",
"examples": ""
},
+ {
+ "name": "HT16K33_Blink",
+ "args": "HT16K33_Blink",
+ "descr": "",
+ "fn": "NULL);",
+ "file": "driver/drv_ht16k33.c",
+ "requires": "",
+ "examples": ""
+ },
+ {
+ "name": "HT16K33_Brightness",
+ "args": "HT16K33_Brightness",
+ "descr": "",
+ "fn": "NULL);",
+ "file": "driver/drv_ht16k33.c",
+ "requires": "",
+ "examples": ""
+ },
+ {
+ "name": "HT16K33_Char",
+ "args": "HT16K33_Char",
+ "descr": "",
+ "fn": "NULL);",
+ "file": "driver/drv_ht16k33.c",
+ "requires": "",
+ "examples": ""
+ },
+ {
+ "name": "HT16K33_Print",
+ "args": "HT16K33_Print",
+ "descr": "",
+ "fn": "NULL);",
+ "file": "driver/drv_ht16k33.c",
+ "requires": "",
+ "examples": ""
+ },
+ {
+ "name": "HT16K33_Raw",
+ "args": "HT16K33_Raw",
+ "descr": "",
+ "fn": "NULL);",
+ "file": "driver/drv_ht16k33.c",
+ "requires": "",
+ "examples": ""
+ },
+ {
+ "name": "HT16K33_Test",
+ "args": "HT16K33_Test",
+ "descr": "",
+ "fn": "NULL);",
+ "file": "driver/drv_ht16k33.c",
+ "requires": "",
+ "examples": ""
+ },
{
"name": "if",
"args": "[Condition]['then'][CommandA]['else'][CommandB]",
@@ -647,6 +710,24 @@
"requires": "",
"examples": ""
},
+ {
+ "name": "KP18058_Map",
+ "args": "[Ch0][Ch1][Ch2][Ch3][Ch4]",
+ "descr": "Maps KP18058_Map RGBCW values to given indices of KP18058 channels. This is because KP18058 channels order is not the same for some devices. Some devices are using RGBCW order and some are using GBRCW, etc, etc. Example usage: KP18058_Map 0 1 2 3 4",
+ "fn": "KP18058_Map",
+ "file": "driver/drv_sm2235.c",
+ "requires": "",
+ "examples": ""
+ },
+ {
+ "name": "KP18058_RGBCW",
+ "args": "[HexColor]",
+ "descr": "Don't use it. It's for direct access of KP18058 driver. You don't need it because LED driver automatically calls it, so just use led_basecolor_rgb",
+ "fn": "KP18058_RGBCW",
+ "file": "driver/drv_bp5758d.c",
+ "requires": "",
+ "examples": ""
+ },
{
"name": "lcd_clear",
"args": "",
@@ -1088,6 +1169,51 @@
"requires": "",
"examples": ""
},
+ {
+ "name": "MCP9808_Adr",
+ "args": "MCP9808_Adr",
+ "descr": "",
+ "fn": "NULL);",
+ "file": "driver/drv_mcp9808.c",
+ "requires": "",
+ "examples": ""
+ },
+ {
+ "name": "MCP9808_AlertMin",
+ "args": "MCP9808_AlertMin",
+ "descr": "",
+ "fn": "NULL);",
+ "file": "driver/drv_mcp9808.c",
+ "requires": "",
+ "examples": ""
+ },
+ {
+ "name": "MCP9808_AlertRange",
+ "args": "MCP9808_AlertRange",
+ "descr": "",
+ "fn": "NULL);",
+ "file": "driver/drv_mcp9808.c",
+ "requires": "",
+ "examples": ""
+ },
+ {
+ "name": "MCP9808_Calibrate",
+ "args": "MCP9808_Calibrate",
+ "descr": "",
+ "fn": "NULL);",
+ "file": "driver/drv_mcp9808.c",
+ "requires": "",
+ "examples": ""
+ },
+ {
+ "name": "MCP9808_Cycle",
+ "args": "MCP9808_cycle",
+ "descr": "",
+ "fn": "NULL);",
+ "file": "driver/drv_mcp9808.c",
+ "requires": "",
+ "examples": ""
+ },
{
"name": "MqttClient",
"args": "[ValueString]",
@@ -1423,9 +1549,9 @@
},
{
"name": "sendPOST",
- "args": "CMD_SendPOST",
- "descr": "",
- "fn": "NULL);",
+ "args": "[TargetURL] [HTTP Port] [Content Type] [Post Content]",
+ "descr": "Sends a HTTP POST request to target URL. Arguments can contain variable expansion.",
+ "fn": "CMD_SendPOST",
"file": "cmnds/cmd_send.c",
"requires": "",
"examples": ""
@@ -1755,37 +1881,28 @@
"examples": ""
},
{
- "name": "SM16703P_Send",
- "args": "",
- "descr": "NULL",
- "fn": "SM16703P_Send_Cmd",
+ "name": "SM16703P_Init",
+ "args": "SM16703P_Start",
+ "descr": "",
+ "fn": "NULL);",
"file": "driver/drv_sm16703P.c",
"requires": "",
"examples": ""
},
{
- "name": "SM16703P_Test",
- "args": "",
- "descr": "qq",
- "fn": "SM16703P_Test",
- "file": "driver/drv_ucs1912.c",
- "requires": "",
- "examples": ""
- },
- {
- "name": "SM16703P_Test_3xOne",
- "args": "",
- "descr": "NULL",
- "fn": "SM16703P_Test_3xOne",
+ "name": "SM16703P_SetPixel",
+ "args": "SM16703P_CMD_setPixel",
+ "descr": "",
+ "fn": "NULL);",
"file": "driver/drv_sm16703P.c",
"requires": "",
"examples": ""
},
{
- "name": "SM16703P_Test_3xZero",
- "args": "",
- "descr": "NULL",
- "fn": "SM16703P_Test_3xZero",
+ "name": "SM16703P_Start",
+ "args": "SM16703P_StartTX",
+ "descr": "",
+ "fn": "NULL);",
"file": "driver/drv_sm16703P.c",
"requires": "",
"examples": ""
@@ -2177,6 +2294,15 @@
"requires": "",
"examples": ""
},
+ {
+ "name": "tuyaMcu_sendColor",
+ "args": "Cmd_TuyaMCU_SendColor",
+ "descr": "",
+ "fn": "NULL);",
+ "file": "driver/drv_tuyaMCU.c",
+ "requires": "",
+ "examples": ""
+ },
{
"name": "tuyaMcu_sendCurTime",
"args": "",
@@ -2258,6 +2384,15 @@
"requires": "",
"examples": ""
},
+ {
+ "name": "tuyaMcu_setupLED",
+ "args": "Cmd_TuyaMCU_SetupLED",
+ "descr": "",
+ "fn": "NULL);",
+ "file": "driver/drv_tuyaMCU.c",
+ "requires": "",
+ "examples": ""
+ },
{
"name": "tuyaMcu_testSendTime",
"args": "",
diff --git a/docs/json/constants.json b/docs/json/constants.json
index 21af26723..5eb5ba948 100644
--- a/docs/json/constants.json
+++ b/docs/json/constants.json
@@ -29,6 +29,18 @@
"descr": "Provides channel access, as above.",
"requires": ""
},
+ {
+ "name": "$FLAG**",
+ "title": "$FLAG**",
+ "descr": "Provides flag access, as above.",
+ "requires": ""
+ },
+ {
+ "name": "$FLAG*",
+ "title": "$FLAG*",
+ "descr": "Provides flag access, as above.",
+ "requires": ""
+ },
{
"name": "$led_dimmer",
"title": "$led_dimmer",
@@ -101,6 +113,12 @@
"descr": "Current value of power from energy metering chip",
"requires": ""
},
+ {
+ "name": "$energy",
+ "title": "$energy",
+ "descr": "Current value of energy counter from energy metering chip",
+ "requires": ""
+ },
{
"name": "$day",
"title": "$day",
diff --git a/docs/json/drivers.json b/docs/json/drivers.json
index c45397609..23551db81 100644
--- a/docs/json/drivers.json
+++ b/docs/json/drivers.json
@@ -89,6 +89,12 @@
"descr": "SSDP is a discovery protocol, so BK devices can show up in, for example, Windows network section",
"requires": ""
},
+ {
+ "name": "DGR",
+ "title": "TODO",
+ "descr": "Tasmota Device groups driver. See [forum example](https://www.elektroda.com/rtvforum/topic3925472.html) and TODO-video tutorial (will post on YT soon)",
+ "requires": ""
+ },
{
"name": "Wemo",
"title": "TODO",
@@ -96,9 +102,9 @@
"requires": ""
},
{
- "name": "DGR",
+ "name": "Hue",
"title": "TODO",
- "descr": "Tasmota Device groups driver. See [forum example](https://www.elektroda.com/rtvforum/topic3925472.html) and TODO-video tutorial (will post on YT soon)",
+ "descr": "Hue emulation for Alexa. You must also start SSDP so it can run, because it depends on SSDP discovery.",
"requires": ""
},
{
@@ -158,13 +164,19 @@
{
"name": "KP18068",
"title": "TODO",
- "descr": "KP18068 I2C LED driver",
+ "descr": "KP18068 I2C LED driver. Unfinished due to the lack of the information.",
+ "requires": ""
+ },
+ {
+ "name": "KP18058",
+ "title": "TODO",
+ "descr": "KP18058 I2C LED driver. Working, see reverse-engineering [topic](https://www.elektroda.pl/rtvforum/topic3991620.html)",
"requires": ""
},
{
"name": "MAX72XX",
"title": "TODO",
- "descr": "MAX72XX LED matrix display driver with font and simple script interface.",
+ "descr": "MAX72XX LED matrix display driver with font and simple script interface. See [protocol explanation](https://www.elektroda.pl/rtvforum/viewtopic.php?p=18040628#18040628)",
"requires": ""
},
{
@@ -185,6 +197,12 @@
"descr": "Driver for 7-segment LED display with DIO/CLK/STB interface. TM1638 is very similiar to GN6932 and TM1637. See [this topic](https://www.elektroda.com/rtvforum/viewtopic.php?p=20553628#20553628) for details.",
"requires": ""
},
+ {
+ "name": "HT16K33",
+ "title": "TODO",
+ "descr": "Driver for 16-segment LED display with I2C. See [protocol explanation](https://www.elektroda.pl/rtvforum/topic3984616.html)",
+ "requires": ""
+ },
{
"name": "SHT3X",
"title": "TODO",
diff --git a/docs/json/flags.json b/docs/json/flags.json
index a190cca07..4f3c0fdaa 100644
--- a/docs/json/flags.json
+++ b/docs/json/flags.json
@@ -285,5 +285,12 @@
"title": "todo",
"file": "new_pins.h",
"descr": "[MQTT] Use kWh unit for energy consumption (total, last hour, today) instead of Wh"
+ },
+ {
+ "index": "41",
+ "enum": "OBK_FLAG_BUTTON_DISABLE_ALL",
+ "title": "todo",
+ "file": "new_pins.h",
+ "descr": "[BTN] Ignore all button events (aka child lock)"
}
]
\ No newline at end of file
diff --git a/docs/json/ioRoles.json b/docs/json/ioRoles.json
index a8300b287..90a5a624e 100644
--- a/docs/json/ioRoles.json
+++ b/docs/json/ioRoles.json
@@ -607,6 +607,22 @@
"file": "new_pins.h",
"driver": ""
},
+ {
+ "name": "KP18058_CLK",
+ "title": "TODO",
+ "descr": "QQQ",
+ "enum": "KP18058_CLK",
+ "file": "new_pins.h",
+ "driver": ""
+ },
+ {
+ "name": "KP18058_DAT",
+ "title": "TODO",
+ "descr": "QQQ",
+ "enum": "KP18058_DAT",
+ "file": "new_pins.h",
+ "driver": ""
+ },
{
"name": "Total_Options",
"title": "TODO",
diff --git a/openBeken_win32_mvsc2017.vcxproj b/openBeken_win32_mvsc2017.vcxproj
index a75fd973e..f40fb3e86 100644
--- a/openBeken_win32_mvsc2017.vcxproj
+++ b/openBeken_win32_mvsc2017.vcxproj
@@ -1,4 +1,4 @@
-
+
@@ -166,7 +166,7 @@
Disabled.\libs_for_simulator\SDL2-2.24.2\include;.\src\win32\stubs\;.\libs_for_simulator\DevIL-Windows-SDK-1.8.0\include;.\libs_for_simulator\freeglut-MSVC-3.0.0-2.mp\include;.\libs_for_simulator\nativefiledialog\src\include;%(AdditionalIncludeDirectories)
- WINDOWS;%(PreprocessorDefinitions);_USE_32BIT_TIME_T
+ WINDOWS;%(PreprocessorDefinitions);_USE_32BIT_TIME_T;DEBUGtrueEnableFastChecksMultiThreadedDebugDLL
@@ -183,17 +183,17 @@
Disabled.\libs_for_simulator\SDL2-2.24.2\include;.\src\win32\stubs\;.\libs_for_simulator\DevIL-Windows-SDK-1.8.0\include;.\libs_for_simulator\freeglut-MSVC-3.0.0-2.mp\include;.\libs_for_simulator\nativefiledialog\src\include;%(AdditionalIncludeDirectories)
- WINDOWS;%(PreprocessorDefinitions);_USE_32BIT_TIME_T;WIN32_LEAN_AND_MEAN;WIN32;_CRT_NON_CONFORMING_SWPRINTFS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ WINDOWS;%(PreprocessorDefinitions);_USE_32BIT_TIME_T;WIN32_LEAN_AND_MEAN;WIN32;_CRT_NON_CONFORMING_SWPRINTFS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CONSOLEtrueDefault
- MultiThreadedDLL
+ MultiThreadedLevel3EditAndContinuetrueMachineX86
- .\libs_for_simulator\SDL2-2.24.2\lib\x86;.\libs_for_simulator\DevIL-Windows-SDK-1.8.0\lib\x86\Release;.\libs_for_simulator\freeglut-MSVC-3.0.0-2.mp\lib;.\libs_for_simulator\nativefiledialog\build\lib\Debug\x86
+ .\libs_for_simulator\SDL2-2.24.2\lib\x86;.\libs_for_simulator\DevIL-Windows-SDK-1.8.0\lib\x86\Release;.\libs_for_simulator\freeglut-MSVC-3.0.0-2.mp\lib;.\libs_for_simulator\nativefiledialog\build\lib\Release\x86
@@ -298,6 +298,7 @@
true
+ true
@@ -338,6 +339,7 @@
true
+ true
@@ -348,10 +350,13 @@
+
+ true
+ true
@@ -359,6 +364,7 @@
+ true
@@ -950,6 +956,7 @@
+
@@ -1057,6 +1064,7 @@
+
diff --git a/openBeken_win32_mvsc2017.vcxproj.filters b/openBeken_win32_mvsc2017.vcxproj.filters
index aafa7ae68..f663fbe16 100644
--- a/openBeken_win32_mvsc2017.vcxproj.filters
+++ b/openBeken_win32_mvsc2017.vcxproj.filters
@@ -869,6 +869,25 @@
SelfTest
+
+ Drv
+
+
+ Drv
+
+
+
+ Cmd
+
+
+ Drv
+
+
+ Drv
+
+
+ SelfTest
+
@@ -1273,6 +1292,9 @@
Drv
+
+ Drv
+
diff --git a/run_without_selfTests.bat b/run_without_selfTests.bat
new file mode 100644
index 000000000..b277f7734
--- /dev/null
+++ b/run_without_selfTests.bat
@@ -0,0 +1 @@
+openBeken_win32.exe -runUnitTests 0
\ No newline at end of file
diff --git a/src/cmnds/cmd_eventHandlers.c b/src/cmnds/cmd_eventHandlers.c
index 4cf4d12a2..b75326ddf 100644
--- a/src/cmnds/cmd_eventHandlers.c
+++ b/src/cmnds/cmd_eventHandlers.c
@@ -79,7 +79,7 @@ addChangeHandler NoPingTime > 40 doRelayClick
// This will automatically turn off relay after about 2 seconds
// NOTE: addRepeatingEvent [RepeatTime] [RepeatCount]
-// addChangeHandler Channel0 != 0 addRepeatingEvent 2 1 setChannel 0 0
+addChangeHandler Channel0 != 0 addRepeatingEvent 2 1 setChannel 0 0
AddEventHandler OnClick 0 addChannel 1 -10 0 100 AddEventHandler OnClick 1 addChannel 1 10 0 100
@@ -177,7 +177,7 @@ int EVENT_ParseEventName(const char *s) {
return CMD_EVENT_LED_STATE;
if (!stricmp(s, "LEDMode"))
return CMD_EVENT_LED_MODE;
- if(!stricmp(s,"energycounter"))
+ if(!stricmp(s,"energycounter") || !stricmp(s, "energy"))
return CMD_EVENT_CHANGE_CONSUMPTION_TOTAL;
if(!stricmp(s,"energycounter_last_hour"))
return CMD_EVENT_CHANGE_CONSUMPTION_LAST_HOUR;
diff --git a/src/cmnds/cmd_if.c b/src/cmnds/cmd_if.c
index b906d7014..09119934d 100644
--- a/src/cmnds/cmd_if.c
+++ b/src/cmnds/cmd_if.c
@@ -160,6 +160,10 @@ float getChannelValue(const char *s) {
int idx = atoi(s + 3);
return CHANNEL_Get(idx);
}
+float getFlagValue(const char *s) {
+ int idx = atoi(s + 5);
+ return CFG_HasFlag(idx);
+}
float getLedDimmer(const char *s) {
return LED_GetDimmer();
@@ -210,6 +214,10 @@ float getCurrent(const char *s) {
float getPower(const char *s) {
return DRV_GetReading(OBK_POWER);
}
+float getEnergy(const char *s) {
+ return DRV_GetReading(OBK_CONSUMPTION_TOTAL);
+}
+
float getNTPOn(const char *s) {
return NTP_IsTimeSynced();
@@ -262,6 +270,16 @@ const constant_t g_constants[] = {
//cnstdetail:"descr":"Provides channel access, as above.",
//cnstdetail:"requires":""}
{"$CH*", &getChannelValue},
+ //cnstdetail:{"name":"$FLAG**",
+ //cnstdetail:"title":"$FLAG**",
+ //cnstdetail:"descr":"Provides flag access, as above.",
+ //cnstdetail:"requires":""}
+ {"$FLAG**", &getFlagValue},
+ //cnstdetail:{"name":"$FLAG*",
+ //cnstdetail:"title":"$FLAG*",
+ //cnstdetail:"descr":"Provides flag access, as above.",
+ //cnstdetail:"requires":""}
+ {"$FLAG*", &getFlagValue},
//cnstdetail:{"name":"$led_dimmer",
//cnstdetail:"title":"$led_dimmer",
//cnstdetail:"descr":"Current value of LED dimmer, 0-100 range",
@@ -323,6 +341,11 @@ const constant_t g_constants[] = {
//cnstdetail:"descr":"Current value of power from energy metering chip",
//cnstdetail:"requires":""}
{"$power", &getPower},
+ //cnstdetail:{"name":"$energy",
+ //cnstdetail:"title":"$energy",
+ //cnstdetail:"descr":"Current value of energy counter from energy metering chip",
+ //cnstdetail:"requires":""}
+ {"$energy", &getEnergy},
//cnstdetail:{"name":"$day",
//cnstdetail:"title":"$day",
//cnstdetail:"descr":"Current weekday from NTP",
diff --git a/src/cmnds/cmd_local.h b/src/cmnds/cmd_local.h
index 6cc836cef..c3936b0a6 100644
--- a/src/cmnds/cmd_local.h
+++ b/src/cmnds/cmd_local.h
@@ -19,7 +19,6 @@ int get_cmd(const char *s, char *dest, int maxlen, int stripnum);
float CMD_EvaluateExpression(const char *s, const char *stop);
commandResult_t CMD_If(const void *context, const char *cmd, const char *args, int cmdFlags);
void CMD_ExpandConstantsWithinString(const char *in, char *out, int outLen);
-const char *CMD_ExpandConstant(const char *s, const char *stop, float *out);
#endif // __CMD_LOCAL_H__
diff --git a/src/cmnds/cmd_newLEDDriver.c b/src/cmnds/cmd_newLEDDriver.c
index 54eff5db9..e08d72286 100644
--- a/src/cmnds/cmd_newLEDDriver.c
+++ b/src/cmnds/cmd_newLEDDriver.c
@@ -107,9 +107,18 @@ void LED_ResetGlobalVariablesToDefaults() {
bool LED_IsLedDriverChipRunning()
{
+#ifndef PLATFORM_W600
+#ifndef OBK_DISABLE_ALL_DRIVERS
+ if (TuyaMCU_IsLEDRunning()) {
+ return true;
+ }
+#endif
+#endif
#ifndef OBK_DISABLE_ALL_DRIVERS
return DRV_IsRunning("SM2135") || DRV_IsRunning("BP5758D")
- || DRV_IsRunning("TESTLED") || DRV_IsRunning("SM2235") || DRV_IsRunning("BP1658CJ");
+ || DRV_IsRunning("TESTLED") || DRV_IsRunning("SM2235") || DRV_IsRunning("BP1658CJ")
+ || DRV_IsRunning("KP18058")
+ ;
#else
return false;
#endif
@@ -253,6 +262,9 @@ void LED_I2CDriver_WriteRGBCW(float* finalRGBCW) {
if (DRV_IsRunning("SM2235")) {
SM2235_Write(finalRGBCW);
}
+ if (DRV_IsRunning("KP18058")) {
+ KP18058_Write(finalRGBCW);
+ }
#endif
}
void LED_RunOnEverySecond() {
@@ -552,7 +564,12 @@ void apply_smart_light() {
#ifndef OBK_DISABLE_ALL_DRIVERS
DRV_DGR_OnLedFinalColorsChange(baseRGBCW);
#endif
-
+#ifndef PLATFORM_W600
+#ifndef OBK_DISABLE_ALL_DRIVERS
+ TuyaMCU_OnRGBCWChange(finalColors, g_lightEnableAll, g_lightMode, g_brightness0to100*0.01f, LED_GetTemperature0to1Range());
+#endif
+#endif
+
// I am not sure if it's the best place to do it
// NOTE: this will broadcast MQTT only if a flag is set
sendFullRGBCW_IfEnabled();
diff --git a/src/cmnds/cmd_public.h b/src/cmnds/cmd_public.h
index 2ff498f70..b4eb1ed4a 100644
--- a/src/cmnds/cmd_public.h
+++ b/src/cmnds/cmd_public.h
@@ -44,6 +44,7 @@ commandResult_t CMD_ExecuteCommandArgs(const char* cmd, const char* args, int cm
// Please remember to free the returned string
char* CMD_ExpandingStrdup(const char* in);
commandResult_t CMD_CreateAliasHelper(const char *alias, const char *ocmd);
+const char *CMD_ExpandConstant(const char *s, const char *stop, float *out);
enum EventCode {
CMD_EVENT_NONE,
diff --git a/src/cmnds/cmd_send.c b/src/cmnds/cmd_send.c
index 50d1e5361..6140e0ef9 100644
--- a/src/cmnds/cmd_send.c
+++ b/src/cmnds/cmd_send.c
@@ -59,10 +59,13 @@ int CMD_InitSendCommands() {
//cmddetail:"examples":""}
CMD_RegisterCommand("sendGet", CMD_SendGET, NULL);
- //cmddetail:{"name":"sendPost","args":"[TargetURL] [HTTP Port] [Content Type] [Post Content]",
- //cmddetail:"descr":"Sends a HTTP POST request to target URL",
+ // TODO example
+ // SendPost "http://192.168.0.1/write?db=energy" 8086 "application/octet-stream" "current,clientid=A0:92:08:CB:41:E1 value=$current""
+
+ //cmddetail:{"name":"sendPOST","args":"[TargetURL] [HTTP Port] [Content Type] [Post Content]",
+ //cmddetail:"descr":"Sends a HTTP POST request to target URL. Arguments can contain variable expansion.",
//cmddetail:"fn":"CMD_SendPOST","file":"cmnds/cmd_send.c","requires":"",
- //cmddetail:"examples":"SendPost ""http://192.168.0.1/write?db=energy"" 8086 ""application/octet-stream"" ""current,clientid=A0:92:08:CB:41:E1 value=$current"""}
+ //cmddetail:"examples":""}
CMD_RegisterCommand("sendPOST", CMD_SendPOST, NULL);
//CMD_RegisterCommand("testPost", CMD_TestPOST, NULL);
diff --git a/src/cmnds/cmd_simulatorOnly.c b/src/cmnds/cmd_simulatorOnly.c
new file mode 100644
index 000000000..d59c0dde1
--- /dev/null
+++ b/src/cmnds/cmd_simulatorOnly.c
@@ -0,0 +1,30 @@
+#include "../new_pins.h"
+#include "../new_cfg.h"
+#include "../logging/logging.h"
+#include "../obk_config.h"
+
+#if WINDOWS
+
+#include
+#include "cmd_local.h"
+
+// exits Windows application
+static commandResult_t CMD_ExitSimulator(const void* context, const char* cmd, const char* args, int cmdFlags) {
+ Tokenizer_TokenizeString(args, 0);
+
+ exit(0);
+
+ return CMD_RES_OK;
+}
+
+
+void CMD_InitSimulatorOnlyCommands() {
+ //cmddetail:{"name":"ExitSimulator","args":"",
+ //cmddetail:"descr":"[SIMULATOR ONLY] Exits the application instance",
+ //cmddetail:"fn":"CMD_ExitSimulator","file":"cmnds/cmd_simulatorOnly.c","requires":"",
+ //cmddetail:"examples":""}
+ CMD_RegisterCommand("ExitSimulator", CMD_ExitSimulator, NULL);
+}
+
+#endif WINDOWS
+
diff --git a/src/cmnds/cmd_tokenizer.c b/src/cmnds/cmd_tokenizer.c
index e836496b8..3f87f5230 100644
--- a/src/cmnds/cmd_tokenizer.c
+++ b/src/cmnds/cmd_tokenizer.c
@@ -52,6 +52,9 @@ int Tokenizer_GetArgsCount() {
bool Tokenizer_IsArgInteger(int i) {
if(i >= g_numArgs)
return false;
+ if (*g_args[i] == '$') {
+ return true;
+ }
return strIsInteger(g_args[i]);
}
const char *Tokenizer_GetArg(int i) {
diff --git a/src/driver/drv_bl_shared.c b/src/driver/drv_bl_shared.c
index 6db5f28f7..576f6d4a7 100644
--- a/src/driver/drv_bl_shared.c
+++ b/src/driver/drv_bl_shared.c
@@ -624,6 +624,10 @@ void BL_ProcessUpdate(float voltage, float current, float power,
if (energyCounterMinutes != NULL)
{
stats = cJSON_CreateArray();
+ // WARNING - it causes HA problems?
+ // See: https://github.com/openshwprojects/OpenBK7231T_App/issues/870
+ // Basically HA has 256 chars state limit?
+ // Wait, no, it's over 256 even without samples?
for(i = 0; i < energyCounterSampleCount; i++)
{
cJSON_AddItemToArray(stats, cJSON_CreateNumber(energyCounterMinutes[i]));
diff --git a/src/driver/drv_chargingLimit.c b/src/driver/drv_chargingLimit.c
new file mode 100644
index 000000000..43cb9044e
--- /dev/null
+++ b/src/driver/drv_chargingLimit.c
@@ -0,0 +1,107 @@
+#include "../new_common.h"
+#include "../new_pins.h"
+#include "../new_cfg.h"
+// Commands register, execution API and cmd tokenizer
+#include "../cmnds/cmd_public.h"
+#include "../mqtt/new_mqtt.h"
+#include "../logging/logging.h"
+#include "drv_local.h"
+#include "../hal/hal_pins.h"
+
+static int chl_targetChannel = -1;
+static int chl_targetChannelStartValue = -1;
+static int chl_targetChannelMaxDelta = -1;
+static int chl_timeLeftSeconds = -1;
+static char *chl_commandToRun = 0;
+static int chl_lastDelteForDisplay = -1;
+
+// startDriver ChargingLimit
+// chSetupLimit [limitChannelIndex] [maxAllowedLimitChannelDelta] [timeoutOr-1] [commandToRun]
+// chSetupLimit 5 5000 3600 "POWER OFF"
+// or:
+// alias myOff backlog POWER OFF; and smth else; and delse;
+// chSetupLimit 5 5000 3600 myOff
+commandResult_t ChargingLimit_SetupCommand(const void* context, const char* cmd, const char* args, int cmdFlags) {
+ const char *newCmd;
+
+ Tokenizer_TokenizeString(args, TOKENIZER_ALLOW_QUOTES);
+ // following check must be done after 'Tokenizer_TokenizeString',
+ // so we know arguments count in Tokenizer. 'cmd' argument is
+ // only for warning display
+ if (Tokenizer_CheckArgsCountAndPrintWarning(cmd, 1)) {
+ return CMD_RES_NOT_ENOUGH_ARGUMENTS;
+ }
+
+ chl_targetChannel = Tokenizer_GetArgInteger(0);
+ chl_targetChannelStartValue = CHANNEL_Get(chl_targetChannel);
+ chl_targetChannelMaxDelta = Tokenizer_GetArgInteger(1);
+ chl_timeLeftSeconds = Tokenizer_GetArgInteger(2);
+ newCmd = Tokenizer_GetArg(3);
+ if (chl_commandToRun != 0 && !strcmp(chl_commandToRun, newCmd)) {
+ // no change, avoid free + malloc
+ }
+ else {
+ if (chl_commandToRun)
+ free(chl_commandToRun);
+ chl_commandToRun = strdup(newCmd);
+ }
+
+ return CMD_RES_OK;
+}
+void ChargingLimit_Init() {
+
+ CMD_RegisterCommand("chSetupLimit", ChargingLimit_SetupCommand, NULL);
+}
+void ChargingLimit_OnLimitReached(bool bTimedOut) {
+ // cast event
+ CMD_ExecuteCommand(chl_commandToRun, 0);
+ // reset variables
+ chl_targetChannel = -1;
+ chl_targetChannelStartValue = -1;
+ chl_targetChannelMaxDelta = -1;
+ chl_timeLeftSeconds = -1;
+ // do not reset command because we may want to reuse the strdup allocation
+}
+void ChargingLimit_OnEverySecond() {
+ int newValue;
+
+ // if off
+ if (chl_targetChannel == -1)
+ return;
+ // tick time
+ if (chl_timeLeftSeconds != -1) {
+ chl_timeLeftSeconds--;
+ if (chl_timeLeftSeconds <= 0) {
+ ChargingLimit_OnLimitReached(true);
+ return;
+ }
+ }
+ // check channel
+ newValue = CHANNEL_Get(chl_targetChannel);
+ chl_lastDelteForDisplay = newValue - chl_targetChannelStartValue;
+ // absolute
+ if (chl_lastDelteForDisplay < 0)
+ chl_lastDelteForDisplay = -chl_lastDelteForDisplay;
+ // has exceed?
+ if (chl_lastDelteForDisplay > chl_targetChannelMaxDelta) {
+ ChargingLimit_OnLimitReached(false);
+ }
+}
+
+void ChargingLimit_AppendInformationToHTTPIndexPage(http_request_t* request)
+{
+ if (chl_targetChannel == -1) {
+ hprintf255(request, "
Charging limit reached
");
+ }
+ else {
+ hprintf255(request, "
Charging limit on for channel %i - %i/%i, time left %i s