From 2121ea63cd8192013c2c44a02e0c2fa24f12a800 Mon Sep 17 00:00:00 2001 From: oogm Date: Sun, 29 May 2022 13:33:27 +0200 Subject: [PATCH 1/8] Add BP5758 light controller support - init sequence working, light responds randomly --- tasmota/language/af_AF.h | 2 + tasmota/language/bg_BG.h | 2 + tasmota/language/cs_CZ.h | 2 + tasmota/language/de_DE.h | 2 + tasmota/language/el_GR.h | 2 + tasmota/language/en_GB.h | 2 + tasmota/language/es_ES.h | 2 + tasmota/language/fr_FR.h | 2 + tasmota/language/fy_NL.h | 2 + tasmota/language/he_HE.h | 2 + tasmota/language/hu_HU.h | 2 + tasmota/language/it_IT.h | 2 + tasmota/language/ko_KO.h | 2 + tasmota/language/nl_NL.h | 2 + tasmota/language/pl_PL.h | 2 + tasmota/language/pt_BR.h | 2 + tasmota/language/pt_PT.h | 2 + tasmota/language/ro_RO.h | 2 + tasmota/language/ru_RU.h | 2 + tasmota/language/sk_SK.h | 2 + tasmota/language/sv_SE.h | 2 + tasmota/language/tr_TR.h | 2 + tasmota/language/uk_UA.h | 2 + tasmota/language/vi_VN.h | 2 + tasmota/language/zh_CN.h | 2 + tasmota/language/zh_TW.h | 2 + tasmota/my_user_config.h | 1 + tasmota/tasmota_configurations.h | 4 + tasmota/tasmota_template.h | 6 + tasmota/xlgt_08_bp5758d.ino | 208 +++++++++++++++++++++++++++++++ 30 files changed, 271 insertions(+) create mode 100644 tasmota/xlgt_08_bp5758d.ino diff --git a/tasmota/language/af_AF.h b/tasmota/language/af_AF.h index 968c0e1cd..d07ea47f8 100644 --- a/tasmota/language/af_AF.h +++ b/tasmota/language/af_AF.h @@ -773,6 +773,8 @@ #define D_SENSOR_DDSU666_RX "DDSU666 Rx" #define D_SENSOR_SM2135_CLK "SM2135 Clk" #define D_SENSOR_SM2135_DAT "SM2135 Dat" +#define D_SENSOR_BP5758D_CLK "BP5758D Clk" +#define D_SENSOR_BP5758D_DAT "BP5758D Dat" #define D_SENSOR_DEEPSLEEP "Diep slaap" #define D_SENSOR_EXS_ENABLE "EXS Inskakel" #define D_SENSOR_CLIENT_TX "Client TX" diff --git a/tasmota/language/bg_BG.h b/tasmota/language/bg_BG.h index c59f70c66..155da5507 100644 --- a/tasmota/language/bg_BG.h +++ b/tasmota/language/bg_BG.h @@ -773,6 +773,8 @@ #define D_SENSOR_DDSU666_RX "DDSU666 Rx" #define D_SENSOR_SM2135_CLK "SM2135 Clk" #define D_SENSOR_SM2135_DAT "SM2135 Dat" +#define D_SENSOR_BP5758D_CLK "BP5758D Clk" +#define D_SENSOR_BP5758D_DAT "BP5758D Dat" #define D_SENSOR_DEEPSLEEP "DeepSleep" #define D_SENSOR_EXS_ENABLE "EXS Enable" #define D_SENSOR_CLIENT_TX "Client TX" diff --git a/tasmota/language/cs_CZ.h b/tasmota/language/cs_CZ.h index b1b1ec1ab..d57e42a24 100644 --- a/tasmota/language/cs_CZ.h +++ b/tasmota/language/cs_CZ.h @@ -773,6 +773,8 @@ #define D_SENSOR_DDSU666_RX "DDSU666 Rx" #define D_SENSOR_SM2135_CLK "SM2135 Clk" #define D_SENSOR_SM2135_DAT "SM2135 Dat" +#define D_SENSOR_BP5758D_CLK "BP5758D Clk" +#define D_SENSOR_BP5758D_DAT "BP5758D Dat" #define D_SENSOR_DEEPSLEEP "DeepSleep" #define D_SENSOR_EXS_ENABLE "EXS Enable" #define D_SENSOR_CLIENT_TX "Client TX" diff --git a/tasmota/language/de_DE.h b/tasmota/language/de_DE.h index 1d7916525..da558a560 100644 --- a/tasmota/language/de_DE.h +++ b/tasmota/language/de_DE.h @@ -773,6 +773,8 @@ #define D_SENSOR_DDSU666_RX "DDSU666 Rx" #define D_SENSOR_SM2135_CLK "SM2135 Clk" #define D_SENSOR_SM2135_DAT "SM2135 Dat" +#define D_SENSOR_BP5758D_CLK "BP5758D Clk" +#define D_SENSOR_BP5758D_DAT "BP5758D Dat" #define D_SENSOR_DEEPSLEEP "DeepSleep" #define D_SENSOR_EXS_ENABLE "EXS Enable" #define D_SENSOR_CLIENT_TX "Client TX" diff --git a/tasmota/language/el_GR.h b/tasmota/language/el_GR.h index 45c6f9038..bc9cae4d1 100644 --- a/tasmota/language/el_GR.h +++ b/tasmota/language/el_GR.h @@ -773,6 +773,8 @@ #define D_SENSOR_DDSU666_RX "DDSU666 Rx" #define D_SENSOR_SM2135_CLK "SM2135 Clk" #define D_SENSOR_SM2135_DAT "SM2135 Dat" +#define D_SENSOR_BP5758D_CLK "BP5758D Clk" +#define D_SENSOR_BP5758D_DAT "BP5758D Dat" #define D_SENSOR_DEEPSLEEP "DeepSleep" #define D_SENSOR_EXS_ENABLE "EXS Enable" #define D_SENSOR_CLIENT_TX "Client TX" diff --git a/tasmota/language/en_GB.h b/tasmota/language/en_GB.h index ba25d36ae..6f5b040ea 100644 --- a/tasmota/language/en_GB.h +++ b/tasmota/language/en_GB.h @@ -773,6 +773,8 @@ #define D_SENSOR_DDSU666_RX "DDSU666 Rx" #define D_SENSOR_SM2135_CLK "SM2135 Clk" #define D_SENSOR_SM2135_DAT "SM2135 Dat" +#define D_SENSOR_BP5758D_CLK "BP5758D Clk" +#define D_SENSOR_BP5758D_DAT "BP5758D Dat" #define D_SENSOR_DEEPSLEEP "DeepSleep" #define D_SENSOR_EXS_ENABLE "EXS Enable" #define D_SENSOR_CLIENT_TX "Client TX" diff --git a/tasmota/language/es_ES.h b/tasmota/language/es_ES.h index acc71ce36..c730b9bdf 100644 --- a/tasmota/language/es_ES.h +++ b/tasmota/language/es_ES.h @@ -773,6 +773,8 @@ #define D_SENSOR_DDSU666_RX "DDSU666 Rx" #define D_SENSOR_SM2135_CLK "SM2135 Clk" #define D_SENSOR_SM2135_DAT "SM2135 Dat" +#define D_SENSOR_BP5758D_CLK "BP5758D Clk" +#define D_SENSOR_BP5758D_DAT "BP5758D Dat" #define D_SENSOR_DEEPSLEEP "DeepSleep" #define D_SENSOR_EXS_ENABLE "EXS Enable" #define D_SENSOR_CLIENT_TX "Client TX" diff --git a/tasmota/language/fr_FR.h b/tasmota/language/fr_FR.h index c27665fe7..2718ed619 100644 --- a/tasmota/language/fr_FR.h +++ b/tasmota/language/fr_FR.h @@ -773,6 +773,8 @@ #define D_SENSOR_DDSU666_RX "DDSU666 RX" #define D_SENSOR_SM2135_CLK "SM2135 CLK" #define D_SENSOR_SM2135_DAT "SM2135 DAT" +#define D_SENSOR_BP5758D_CLK "BP5758D Clk" +#define D_SENSOR_BP5758D_DAT "BP5758D Dat" #define D_SENSOR_DEEPSLEEP "Hibernation" #define D_SENSOR_EXS_ENABLE "EXS Enable" #define D_SENSOR_CLIENT_TX "Esclave TX" diff --git a/tasmota/language/fy_NL.h b/tasmota/language/fy_NL.h index db6150f80..4890eb1fd 100644 --- a/tasmota/language/fy_NL.h +++ b/tasmota/language/fy_NL.h @@ -773,6 +773,8 @@ #define D_SENSOR_DDSU666_RX "DDSU666 Rx" #define D_SENSOR_SM2135_CLK "SM2135 Clk" #define D_SENSOR_SM2135_DAT "SM2135 Dat" +#define D_SENSOR_BP5758D_CLK "BP5758D Clk" +#define D_SENSOR_BP5758D_DAT "BP5758D Dat" #define D_SENSOR_DEEPSLEEP "DeepSleep" #define D_SENSOR_EXS_ENABLE "EXS Enable" #define D_SENSOR_CLIENT_TX "Client TX" diff --git a/tasmota/language/he_HE.h b/tasmota/language/he_HE.h index 9ca125c10..7207d6197 100644 --- a/tasmota/language/he_HE.h +++ b/tasmota/language/he_HE.h @@ -773,6 +773,8 @@ #define D_SENSOR_DDSU666_RX "DDSU666 Rx" #define D_SENSOR_SM2135_CLK "SM2135 Clk" #define D_SENSOR_SM2135_DAT "SM2135 Dat" +#define D_SENSOR_BP5758D_CLK "BP5758D Clk" +#define D_SENSOR_BP5758D_DAT "BP5758D Dat" #define D_SENSOR_DEEPSLEEP "DeepSleep" #define D_SENSOR_EXS_ENABLE "EXS Enable" #define D_SENSOR_CLIENT_TX "Client TX" diff --git a/tasmota/language/hu_HU.h b/tasmota/language/hu_HU.h index ee64407b3..b964ef793 100644 --- a/tasmota/language/hu_HU.h +++ b/tasmota/language/hu_HU.h @@ -773,6 +773,8 @@ #define D_SENSOR_DDSU666_RX "DDSU666 Rx" #define D_SENSOR_SM2135_CLK "SM2135 Clk" #define D_SENSOR_SM2135_DAT "SM2135 Dat" +#define D_SENSOR_BP5758D_CLK "BP5758D Clk" +#define D_SENSOR_BP5758D_DAT "BP5758D Dat" #define D_SENSOR_DEEPSLEEP "DeepSleep" #define D_SENSOR_EXS_ENABLE "EXS Enable" #define D_SENSOR_CLIENT_TX "Client TX" diff --git a/tasmota/language/it_IT.h b/tasmota/language/it_IT.h index dd6d4e146..c001a5715 100644 --- a/tasmota/language/it_IT.h +++ b/tasmota/language/it_IT.h @@ -771,6 +771,8 @@ #define D_SENSOR_DDSU666_RX "DDSU666 - RX" #define D_SENSOR_SM2135_CLK "SM2135 - CLK" #define D_SENSOR_SM2135_DAT "SM2135 - DATI" +#define D_SENSOR_BP5758D_CLK "BP5758D Clk" +#define D_SENSOR_BP5758D_DAT "BP5758D DATi" #define D_SENSOR_DEEPSLEEP "Sleep profondo" #define D_SENSOR_EXS_ENABLE "EXS - Abilita" #define D_SENSOR_CLIENT_TX "Client - TX" diff --git a/tasmota/language/ko_KO.h b/tasmota/language/ko_KO.h index 40f4cd824..aa4232772 100644 --- a/tasmota/language/ko_KO.h +++ b/tasmota/language/ko_KO.h @@ -773,6 +773,8 @@ #define D_SENSOR_DDSU666_RX "DDSU666 Rx" #define D_SENSOR_SM2135_CLK "SM2135 Clk" #define D_SENSOR_SM2135_DAT "SM2135 Dat" +#define D_SENSOR_BP5758D_CLK "BP5758D Clk" +#define D_SENSOR_BP5758D_DAT "BP5758D Dat" #define D_SENSOR_DEEPSLEEP "DeepSleep" #define D_SENSOR_EXS_ENABLE "EXS Enable" #define D_SENSOR_CLIENT_TX "Client TX" diff --git a/tasmota/language/nl_NL.h b/tasmota/language/nl_NL.h index 0e5cf5a06..4060e3cd7 100644 --- a/tasmota/language/nl_NL.h +++ b/tasmota/language/nl_NL.h @@ -773,6 +773,8 @@ #define D_SENSOR_DDSU666_RX "DDSU666 Rx" #define D_SENSOR_SM2135_CLK "SM2135 Clk" #define D_SENSOR_SM2135_DAT "SM2135 Dat" +#define D_SENSOR_BP5758D_CLK "BP5758D Clk" +#define D_SENSOR_BP5758D_DAT "BP5758D Dat" #define D_SENSOR_DEEPSLEEP "DeepSleep" #define D_SENSOR_EXS_ENABLE "EXS Enable" #define D_SENSOR_CLIENT_TX "Client TX" diff --git a/tasmota/language/pl_PL.h b/tasmota/language/pl_PL.h index a8b514340..6bf3b66d2 100644 --- a/tasmota/language/pl_PL.h +++ b/tasmota/language/pl_PL.h @@ -773,6 +773,8 @@ #define D_SENSOR_DDSU666_RX "DDSU666 Rx" #define D_SENSOR_SM2135_CLK "SM2135 Clk" #define D_SENSOR_SM2135_DAT "SM2135 Dat" +#define D_SENSOR_BP5758D_CLK "BP5758D Clk" +#define D_SENSOR_BP5758D_DAT "BP5758D Dat" #define D_SENSOR_DEEPSLEEP "Głęboko uśpiony" #define D_SENSOR_EXS_ENABLE "Załącz EXS" #define D_SENSOR_CLIENT_TX "Klient TX" diff --git a/tasmota/language/pt_BR.h b/tasmota/language/pt_BR.h index 866960151..fc8f54ad7 100644 --- a/tasmota/language/pt_BR.h +++ b/tasmota/language/pt_BR.h @@ -773,6 +773,8 @@ #define D_SENSOR_DDSU666_RX "DDSU666 Rx" #define D_SENSOR_SM2135_CLK "SM2135 Clk" #define D_SENSOR_SM2135_DAT "SM2135 Dat" +#define D_SENSOR_BP5758D_CLK "BP5758D Clk" +#define D_SENSOR_BP5758D_DAT "BP5758D Dat" #define D_SENSOR_DEEPSLEEP "DeepSleep" #define D_SENSOR_EXS_ENABLE "EXS Enable" #define D_SENSOR_CLIENT_TX "Client TX" diff --git a/tasmota/language/pt_PT.h b/tasmota/language/pt_PT.h index 6da2d62cb..d02cfb137 100644 --- a/tasmota/language/pt_PT.h +++ b/tasmota/language/pt_PT.h @@ -773,6 +773,8 @@ #define D_SENSOR_DDSU666_RX "DDSU666 Rx" #define D_SENSOR_SM2135_CLK "SM2135 Clk" #define D_SENSOR_SM2135_DAT "SM2135 Dat" +#define D_SENSOR_BP5758D_CLK "BP5758D Clk" +#define D_SENSOR_BP5758D_DAT "BP5758D Dat" #define D_SENSOR_DEEPSLEEP "DeepSleep" #define D_SENSOR_EXS_ENABLE "EXS Enable" #define D_SENSOR_CLIENT_TX "Client TX" diff --git a/tasmota/language/ro_RO.h b/tasmota/language/ro_RO.h index 4cfa25cb6..b6fb28845 100644 --- a/tasmota/language/ro_RO.h +++ b/tasmota/language/ro_RO.h @@ -773,6 +773,8 @@ #define D_SENSOR_DDSU666_RX "DDSU666 Rx" #define D_SENSOR_SM2135_CLK "SM2135 Clk" #define D_SENSOR_SM2135_DAT "SM2135 Dat" +#define D_SENSOR_BP5758D_CLK "BP5758D Clk" +#define D_SENSOR_BP5758D_DAT "BP5758D Dat" #define D_SENSOR_DEEPSLEEP "DeepSleep" #define D_SENSOR_EXS_ENABLE "EXS Enable" #define D_SENSOR_CLIENT_TX "Client TX" diff --git a/tasmota/language/ru_RU.h b/tasmota/language/ru_RU.h index fc83143b0..d69309c34 100644 --- a/tasmota/language/ru_RU.h +++ b/tasmota/language/ru_RU.h @@ -773,6 +773,8 @@ #define D_SENSOR_DDSU666_RX "DDSU666 Rx" #define D_SENSOR_SM2135_CLK "SM2135 Clk" #define D_SENSOR_SM2135_DAT "SM2135 Dat" +#define D_SENSOR_BP5758D_CLK "BP5758D Clk" +#define D_SENSOR_BP5758D_DAT "BP5758D Dat" #define D_SENSOR_DEEPSLEEP "DeepSleep" #define D_SENSOR_EXS_ENABLE "EXS Enable" #define D_SENSOR_CLIENT_TX "Client TX" diff --git a/tasmota/language/sk_SK.h b/tasmota/language/sk_SK.h index 840edb230..3820d88e8 100644 --- a/tasmota/language/sk_SK.h +++ b/tasmota/language/sk_SK.h @@ -773,6 +773,8 @@ #define D_SENSOR_DDSU666_RX "DDSU666 Rx" #define D_SENSOR_SM2135_CLK "SM2135 Clk" #define D_SENSOR_SM2135_DAT "SM2135 Dat" +#define D_SENSOR_BP5758D_CLK "BP5758D Clk" +#define D_SENSOR_BP5758D_DAT "BP5758D Dat" #define D_SENSOR_DEEPSLEEP "DeepSleep" #define D_SENSOR_EXS_ENABLE "EXS Enable" #define D_SENSOR_CLIENT_TX "Client TX" diff --git a/tasmota/language/sv_SE.h b/tasmota/language/sv_SE.h index 1a3b7c6fd..e5ae351bb 100644 --- a/tasmota/language/sv_SE.h +++ b/tasmota/language/sv_SE.h @@ -773,6 +773,8 @@ #define D_SENSOR_DDSU666_RX "DDSU666 Rx" #define D_SENSOR_SM2135_CLK "SM2135 Clk" #define D_SENSOR_SM2135_DAT "SM2135 Dat" +#define D_SENSOR_BP5758D_CLK "BP5758D Clk" +#define D_SENSOR_BP5758D_DAT "BP5758D Dat" #define D_SENSOR_DEEPSLEEP "DeepSleep" #define D_SENSOR_EXS_ENABLE "EXS Enable" #define D_SENSOR_CLIENT_TX "Client TX" diff --git a/tasmota/language/tr_TR.h b/tasmota/language/tr_TR.h index a2c341ee6..942936615 100644 --- a/tasmota/language/tr_TR.h +++ b/tasmota/language/tr_TR.h @@ -773,6 +773,8 @@ #define D_SENSOR_DDSU666_RX "DDSU666 Rx" #define D_SENSOR_SM2135_CLK "SM2135 Clk" #define D_SENSOR_SM2135_DAT "SM2135 Dat" +#define D_SENSOR_BP5758D_CLK "BP5758D Clk" +#define D_SENSOR_BP5758D_DAT "BP5758D Dat" #define D_SENSOR_DEEPSLEEP "DeepSleep" #define D_SENSOR_EXS_ENABLE "EXS Enable" #define D_SENSOR_CLIENT_TX "Client TX" diff --git a/tasmota/language/uk_UA.h b/tasmota/language/uk_UA.h index c93062ef7..a0e5c5eaf 100644 --- a/tasmota/language/uk_UA.h +++ b/tasmota/language/uk_UA.h @@ -773,6 +773,8 @@ #define D_SENSOR_DDSU666_RX "DDSU666 Rx" #define D_SENSOR_SM2135_CLK "SM2135 Clk" #define D_SENSOR_SM2135_DAT "SM2135 Dat" +#define D_SENSOR_BP5758D_CLK "BP5758D Clk" +#define D_SENSOR_BP5758D_DAT "BP5758D Dat" #define D_SENSOR_DEEPSLEEP "DeepSleep" #define D_SENSOR_EXS_ENABLE "EXS Enable" #define D_SENSOR_CLIENT_TX "Client TX" diff --git a/tasmota/language/vi_VN.h b/tasmota/language/vi_VN.h index 44d92507b..8833d1046 100644 --- a/tasmota/language/vi_VN.h +++ b/tasmota/language/vi_VN.h @@ -773,6 +773,8 @@ #define D_SENSOR_DDSU666_RX "DDSU666 Rx" #define D_SENSOR_SM2135_CLK "SM2135 Clk" #define D_SENSOR_SM2135_DAT "SM2135 Dat" +#define D_SENSOR_BP5758D_CLK "BP5758D Clk" +#define D_SENSOR_BP5758D_DAT "BP5758D Dat" #define D_SENSOR_DEEPSLEEP "DeepSleep" #define D_SENSOR_EXS_ENABLE "EXS Enable" #define D_SENSOR_CLIENT_TX "Client TX" diff --git a/tasmota/language/zh_CN.h b/tasmota/language/zh_CN.h index cde32877e..7db58cadb 100644 --- a/tasmota/language/zh_CN.h +++ b/tasmota/language/zh_CN.h @@ -773,6 +773,8 @@ #define D_SENSOR_DDSU666_RX "DDSU666 Rx" #define D_SENSOR_SM2135_CLK "SM2135 Clk" #define D_SENSOR_SM2135_DAT "SM2135 Dat" +#define D_SENSOR_BP5758D_CLK "BP5758D Clk" +#define D_SENSOR_BP5758D_DAT "BP5758D Dat" #define D_SENSOR_DEEPSLEEP "DeepSleep" #define D_SENSOR_EXS_ENABLE "EXS Enable" #define D_SENSOR_CLIENT_TX "Client TX" diff --git a/tasmota/language/zh_TW.h b/tasmota/language/zh_TW.h index 95639cc38..7f067f023 100644 --- a/tasmota/language/zh_TW.h +++ b/tasmota/language/zh_TW.h @@ -773,6 +773,8 @@ #define D_SENSOR_DDSU666_RX "DDSU666 Rx" #define D_SENSOR_SM2135_CLK "SM2135 Clk" #define D_SENSOR_SM2135_DAT "SM2135 Dat" +#define D_SENSOR_BP5758D_CLK "BP5758D Clk" +#define D_SENSOR_BP5758D_DAT "BP5758D Dat" #define D_SENSOR_DEEPSLEEP "DeepSleep" #define D_SENSOR_EXS_ENABLE "EXS Enable" #define D_SENSOR_CLIENT_TX "Client TX" diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index e513d6595..3ece102f0 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -555,6 +555,7 @@ #define USE_MY92X1 // Add support for MY92X1 RGBCW led controller as used in Sonoff B1, Ailight and Lohas #define USE_SM16716 // Add support for SM16716 RGB LED controller (+0k7 code) #define USE_SM2135 // Add support for SM2135 RGBCW led control as used in Action LSC (+0k6 code) +#define USE_BP5758D // Add support for BP5758D RGBCW led control as used in some Tuya lightbulbs #define USE_SONOFF_L1 // Add support for Sonoff L1 led control #define USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED controller (+0k3 code) #define USE_LIGHT_PALETTE // Add support for color palette (+0k7 code) diff --git a/tasmota/tasmota_configurations.h b/tasmota/tasmota_configurations.h index f6b7682c4..97fad2865 100644 --- a/tasmota/tasmota_configurations.h +++ b/tasmota/tasmota_configurations.h @@ -69,6 +69,7 @@ #define USE_MY92X1 // Add support for MY92X1 RGBCW led controller as used in Sonoff B1, Ailight and Lohas #define USE_SM16716 // Add support for SM16716 RGB LED controller (+0k7 code) #define USE_SM2135 // Add support for SM2135 RGBCW led control as used in Action LSC (+0k6 code) +#define USE_BP5758D // Add support for BP5758D RGBCW led control as used in some Tuya lightbulbs #define USE_SONOFF_L1 // Add support for Sonoff L1 led control #define USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED controller #define USE_LIGHT_PALETTE // Add support for color palette (+0k9 code) @@ -402,6 +403,7 @@ #undef USE_MY92X1 // Disable support for MY92X1 RGBCW led controller as used in Sonoff B1, Ailight and Lohas #undef USE_SM16716 // Disable support for SM16716 RGB LED controller (+0k7 code) #undef USE_SM2135 // Disable support for SM2135 RGBCW led control as used in Action LSC (+0k6 code) +#undef USE_BP5758D // Disable support for BP5758D RGBCW led control #undef USE_SONOFF_L1 // Disable support for Sonoff L1 led control #undef USE_ELECTRIQ_MOODL // Disable support for ElectriQ iQ-wifiMOODL RGBW LED controller #undef USE_LIGHT_PALETTE // Disable support for color palette (+0k9 code) @@ -550,6 +552,7 @@ #undef USE_MY92X1 // Disable support for MY92X1 RGBCW led controller as used in Sonoff B1, Ailight and Lohas #undef USE_SM16716 // Disable support for SM16716 RGB LED controller (+0k7 code) #undef USE_SM2135 // Disable support for SM2135 RGBCW led control as used in Action LSC (+0k6 code) +#undef USE_BP5758D // Disable support for BP5758D RGBCW led control #undef USE_SONOFF_L1 // Disable support for Sonoff L1 led control #undef USE_ELECTRIQ_MOODL // Disable support for ElectriQ iQ-wifiMOODL RGBW LED controller #undef USE_LIGHT_PALETTE // Disable support for color palette (+0k9 code) @@ -694,6 +697,7 @@ #undef USE_MY92X1 // Disable support for MY92X1 RGBCW led controller as used in Sonoff B1, Ailight and Lohas #undef USE_SM16716 // Disable support for SM16716 RGB LED controller (+0k7 code) #undef USE_SM2135 // Disable support for SM2135 RGBCW led control as used in Action LSC (+0k6 code) +#undef USE_BP5758D // Disable support for BP5758D RGBCW led control #undef USE_SONOFF_L1 // Disable support for Sonoff L1 led control #undef USE_ELECTRIQ_MOODL // Disable support for ElectriQ iQ-wifiMOODL RGBW LED controller #undef USE_LIGHT_PALETTE // Disable support for color palette (+0k9 code) diff --git a/tasmota/tasmota_template.h b/tasmota/tasmota_template.h index 5c6fa8237..ca9c2732a 100644 --- a/tasmota/tasmota_template.h +++ b/tasmota/tasmota_template.h @@ -188,6 +188,7 @@ enum UserSelectablePins { GPIO_MS01, // Sonoff MS01 Moisture Sensor 1wire interface GPIO_SDIO_CMD, GPIO_SDIO_CLK, GPIO_SDIO_D0, GPIO_SDIO_D1, GPIO_SDIO_D2, GPIO_SDIO_D3, // SD Card SDIO interface, including 1-bit and 4-bit modes GPIO_FLOWRATEMETER_IN, // Flowrate Meter + GPIO_BP5758D_CLK, GPIO_BP5758D_DAT, // BP5758D PWM controller GPIO_SENSOR_END }; enum ProgramSelectablePins { @@ -420,6 +421,7 @@ const char kSensorNames[] PROGMEM = D_SENSOR_SDIO_D2 "|" D_SENSOR_SDIO_D3 "|" D_SENSOR_FLOWRATEMETER "|" + D_SENSOR_BP5758D_CLK "|" D_SENSOR_BP5758D_DAT "|" ; const char kSensorNamesFixed[] PROGMEM = @@ -661,6 +663,10 @@ const uint16_t kGpioNiceList[] PROGMEM = { AGPIO(GPIO_SM2135_CLK), // SM2135 CLOCK AGPIO(GPIO_SM2135_DAT) + MAX_SM2135_DAT, // SM2135 DATA #endif // USE_SM2135 +#ifdef USE_BP5758D + AGPIO(GPIO_BP5758D_CLK), // BP5758D CLOCK + AGPIO(GPIO_BP5758D_DAT), // BP5758D DATA +#endif // USE_BP5758D #ifdef USE_TUYA_MCU AGPIO(GPIO_TUYA_TX), // Tuya Serial interface AGPIO(GPIO_TUYA_RX), // Tuya Serial interface diff --git a/tasmota/xlgt_08_bp5758d.ino b/tasmota/xlgt_08_bp5758d.ino new file mode 100644 index 000000000..1739779c1 --- /dev/null +++ b/tasmota/xlgt_08_bp5758d.ino @@ -0,0 +1,208 @@ +/* + xlgt_08_bp5758d.ino - bp5758d five channel led support for Tasmota + + Copyright (C) 2022 Theo Arends and oomg + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifdef USE_LIGHT +#ifdef USE_BP5758D +/*********************************************************************************************\ + * BP5758D RGBCW Led bulbs commonly used by Tuya hardware + * + * TODO: Adapt + * Fitop 10W RGBCCT Bulb (BA60H-W0080-RCBW-E7) + * {"NAME":"Fitop 10W RGBCCT","GPIO":[1,1,1,1,1,4032,1,1,4069,1,1,1,1,1],"FLAG":0,"BASE":18,"CMND":"RGBWWTable 167,102,109,255,255"} +\*********************************************************************************************/ + +#define XLGT_08 8 + +// Layout: Bits B[7:8]=10 (address selection identification bits), B[5:6] sleep mode if set to 00, B[0:4] Address selection +#define BP5758D_ADDR_SLEEP 0x86 //10 00 0110: Sleep mode bits set (OUT1 gray-scale level setup selected, ignored by chip) +#define BP5758D_ADDR_SETUP 0x90 //10 01 0000: OUT1-5 enable/disable setup - used during init +#define BP5758D_ADDR_OUT1_CR 0x91 //10 01 0001: OUT1 current range +#define BP5758D_ADDR_OUT2_CR 0x92 //10 01 0010: OUT2 current range +#define BP5758D_ADDR_OUT3_CR 0x93 //10 01 0011: OUT3 current range +#define BP5758D_ADDR_OUT4_CR 0x94 //10 01 0100: OUT4 current range +#define BP5758D_ADDR_OUT5_CR 0x95 //10 01 0101: OUT5 current range +#define BP5758D_ADDR_OUT1_GL 0x96 //10 01 0110: OUT1 gray-scale level +#define BP5758D_ADDR_OUT2_GL 0x98 //10 01 1000: OUT2 gray-scale level +#define BP5758D_ADDR_OUT3_GL 0x9A //10 01 1010: OUT3 gray-scale level +#define BP5758D_ADDR_OUT4_GL 0x9C //10 01 1100: OUT4 gray-scale level +#define BP5758D_ADDR_OUT5_GL 0x9E //10 01 1110: OUT5 gray-scale level + +// Output enabled (OUT1-5, represented by lower 5 bits) +#define BP5758D_ENABLE_OUTPUTS_ALL 0x1F + +// Current values: Bit 6 to 0 represent 30mA, 32mA, 16mA, 8mA, 4mA, 2mA, 1mA respectively +#define BP5758D_10MA 0x0A // 0 0001010 +#define BP5758D_14MA 0x0E // 0 0001110 +#define BP5758D_15MA 0x0F // 0 0001111 +#define BP5758D_65MA 0x63 // 0 1100011 +#define BP5758D_90MA 0x7C // 0 1111100 + +struct BP5758D { + uint8_t clk = 0; + uint8_t data = 0; + uint8_t current; +} Bp5758d; + +/*********************************************************************************************\ + * Bp5758d code - mostly copied over from SM2135 +\*********************************************************************************************/ +const uint8_t BP5758D_DELAY = 2; + +void Bp5758dSetLow(uint8_t pin) { + noInterrupts(); + digitalWrite(pin, LOW); + pinMode(pin, OUTPUT); + interrupts(); +} + +void Bp5758dSetHigh(uint8_t pin) { + noInterrupts(); + pinMode(pin, INPUT_PULLUP); + interrupts(); +} + +bool Bp5758dInit(void) { + digitalWrite(Bp5758d.data, LOW); + digitalWrite(Bp5758d.clk, LOW); + Bp5758dSetHigh(Bp5758d.data); + Bp5758dSetHigh(Bp5758d.clk); + return (!((digitalRead(Bp5758d.data) == LOW || digitalRead(Bp5758d.clk) == LOW))); +} + +bool Bp5758dWrite(uint8_t value) { + AddLog(LOG_LEVEL_DEBUG, PSTR("LGT: Bp5758dWrite %2x"), value); + for (uint8_t curr = 0X80; curr != 0; curr >>= 1) { + if (curr & value) { + Bp5758dSetHigh(Bp5758d.data); + } else { + Bp5758dSetLow(Bp5758d.data); + } + Bp5758dSetHigh(Bp5758d.clk); + delayMicroseconds(BP5758D_DELAY); + Bp5758dSetLow(Bp5758d.clk); + } + // get Ack or Nak + Bp5758dSetHigh(Bp5758d.data); + Bp5758dSetHigh(Bp5758d.clk); + delayMicroseconds(BP5758D_DELAY / 2); + uint8_t ack = digitalRead(Bp5758d.data); + Bp5758dSetLow(Bp5758d.clk); + delayMicroseconds(BP5758D_DELAY / 2); + Bp5758dSetLow(Bp5758d.data); + return (0 == ack); +} + +bool Bp5758dStart(uint8_t addr) { + AddLog(LOG_LEVEL_DEBUG, PSTR("LGT: Bp5758dStart")); + Bp5758dSetLow(Bp5758d.data); + delayMicroseconds(BP5758D_DELAY); + Bp5758dSetLow(Bp5758d.clk); + return Bp5758dWrite(addr); +} + +void Bp5758dStop(void) { + AddLog(LOG_LEVEL_DEBUG, PSTR("LGT: Bp5758dStop")); + Bp5758dSetLow(Bp5758d.data); + delayMicroseconds(BP5758D_DELAY); + Bp5758dSetHigh(Bp5758d.clk); + delayMicroseconds(BP5758D_DELAY); + Bp5758dSetHigh(Bp5758d.data); + delayMicroseconds(BP5758D_DELAY); +} + +/********************************************************************************************/ + +bool Bp5758dSetChannels(void) { + uint8_t *cur_col = (uint8_t*)XdrvMailbox.data; + // Even though we could address changing channels only, in practice we observed that the lightbulb always sets all channels. + Bp5758dStart(BP5758D_ADDR_OUT1_GL); + // Brigtness values are transmitted as two bytes. The light-bulb accepts a 10-bit integer (0-1023) as an input value. + // The first 5bits of this input are transmitted in first byte, the second 5bits in the second byte. + // Because or tasmota's controls are 8bit (0-255), we need to multiply by 4 (or shift two bits to the left). + // We thus transmit the first 5bits of tasmota's input as byte1, and the remaining 3bits as byte2 (shifted left two bits). + Bp5758dWrite(cur_col[0] >> 3); //Red: Only take first 5bits of tasmota's input + Bp5758dWrite((cur_col[0] & 0x07) << 2); //Only take last 3 bits, multiplied by 4 / shifted to left + Bp5758dWrite(cur_col[1] >> 3); //Green + Bp5758dWrite((cur_col[1] & 0x07) << 2); + Bp5758dWrite(cur_col[2] >> 3); //Blue + Bp5758dWrite((cur_col[2] & 0x07) << 2); + Bp5758dWrite(cur_col[3] >> 3); //Warm + Bp5758dWrite((cur_col[3] & 0x07) << 2); + Bp5758dWrite(cur_col[4] >> 3); //Cold + Bp5758dWrite((cur_col[4] & 0x07) << 2); + Bp5758dStop(); + return true; +} + +void Bp5758dModuleSelected(void) +{ + if (PinUsed(GPIO_BP5758D_CLK) && PinUsed(GPIO_BP5758D_DAT)) { + Bp5758d.clk = Pin(GPIO_BP5758D_CLK); + Bp5758d.data = Pin(GPIO_BP5758D_DAT); + + // For it's init sequence, BP5758D just sets all fields + Bp5758dInit(); + Bp5758dStart(BP5758D_ADDR_SETUP); + // Output enabled: enable all outputs since we're using a RGBCW light + Bp5758dWrite(BP5758D_ENABLE_OUTPUTS_ALL); + // Set currents for OUT1-OUT5 + Bp5758dWrite(BP5758D_14MA); + Bp5758dWrite(BP5758D_14MA); + Bp5758dWrite(BP5758D_14MA); + Bp5758dWrite(BP5758D_14MA); + Bp5758dWrite(BP5758D_14MA); + // Set grayscale levels ouf all outputs to 0 + Bp5758dWrite(0x00); + Bp5758dWrite(0x00); + Bp5758dWrite(0x00); + Bp5758dWrite(0x00); + Bp5758dWrite(0x00); + Bp5758dWrite(0x00); + Bp5758dWrite(0x00); + Bp5758dWrite(0x00); + Bp5758dWrite(0x00); + Bp5758dWrite(0x00); + + TasmotaGlobal.light_type = LT_RGBWC; + TasmotaGlobal.light_driver = XLGT_08; + AddLog(LOG_LEVEL_DEBUG, PSTR("LGT: BP5758D Found")); + } +} + +/*********************************************************************************************\ + * Interface +\*********************************************************************************************/ + +bool Xlgt08(uint8_t function) +{ + bool result = false; + + switch (function) { + case FUNC_SET_CHANNELS: + result = Bp5758dSetChannels(); + break; + case FUNC_MODULE_INIT: + Bp5758dModuleSelected(); + break; + } + return result; +} + +#endif // USE_BP5758D +#endif // USE_LIGHT From 6dd20a566fe7e71282f5293870cc622d3bb8a01b Mon Sep 17 00:00:00 2001 From: oogm Date: Sun, 29 May 2022 14:24:22 +0200 Subject: [PATCH 2/8] Light control fully functional at 8bit resolution --- tasmota/xlgt_08_bp5758d.ino | 92 ++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 48 deletions(-) diff --git a/tasmota/xlgt_08_bp5758d.ino b/tasmota/xlgt_08_bp5758d.ino index 1739779c1..87c612336 100644 --- a/tasmota/xlgt_08_bp5758d.ino +++ b/tasmota/xlgt_08_bp5758d.ino @@ -22,9 +22,8 @@ /*********************************************************************************************\ * BP5758D RGBCW Led bulbs commonly used by Tuya hardware * - * TODO: Adapt - * Fitop 10W RGBCCT Bulb (BA60H-W0080-RCBW-E7) - * {"NAME":"Fitop 10W RGBCCT","GPIO":[1,1,1,1,1,4032,1,1,4069,1,1,1,1,1],"FLAG":0,"BASE":18,"CMND":"RGBWWTable 167,102,109,255,255"} + * Example configuration for a Fitop RGBCCT filament light bulb: + * {"NAME":"Fitop Filament RGBCCT","GPIO":[1,1,0,1,1,0,0,0,8416,0,8384,0,0,0],"FLAG":0,"BASE":18,"CMND":"RGBWWTable 255,109,245,255,255"} \*********************************************************************************************/ #define XLGT_08 8 @@ -60,10 +59,11 @@ struct BP5758D { } Bp5758d; /*********************************************************************************************\ - * Bp5758d code - mostly copied over from SM2135 + * Bp5758d code \*********************************************************************************************/ const uint8_t BP5758D_DELAY = 2; +/* void Bp5758dSetLow(uint8_t pin) { noInterrupts(); digitalWrite(pin, LOW); @@ -76,53 +76,48 @@ void Bp5758dSetHigh(uint8_t pin) { pinMode(pin, INPUT_PULLUP); interrupts(); } +*/ -bool Bp5758dInit(void) { - digitalWrite(Bp5758d.data, LOW); - digitalWrite(Bp5758d.clk, LOW); - Bp5758dSetHigh(Bp5758d.data); - Bp5758dSetHigh(Bp5758d.clk); - return (!((digitalRead(Bp5758d.data) == LOW || digitalRead(Bp5758d.clk) == LOW))); +void Bp5758dInit(void) { + pinMode(Bp5758d.data, OUTPUT); + pinMode(Bp5758d.clk, OUTPUT); + Bp5758dStop(); } -bool Bp5758dWrite(uint8_t value) { +void Bp5758dWrite(uint8_t value) { AddLog(LOG_LEVEL_DEBUG, PSTR("LGT: Bp5758dWrite %2x"), value); - for (uint8_t curr = 0X80; curr != 0; curr >>= 1) { - if (curr & value) { - Bp5758dSetHigh(Bp5758d.data); - } else { - Bp5758dSetLow(Bp5758d.data); - } - Bp5758dSetHigh(Bp5758d.clk); - delayMicroseconds(BP5758D_DELAY); - Bp5758dSetLow(Bp5758d.clk); - } - // get Ack or Nak - Bp5758dSetHigh(Bp5758d.data); - Bp5758dSetHigh(Bp5758d.clk); - delayMicroseconds(BP5758D_DELAY / 2); - uint8_t ack = digitalRead(Bp5758d.data); - Bp5758dSetLow(Bp5758d.clk); - delayMicroseconds(BP5758D_DELAY / 2); - Bp5758dSetLow(Bp5758d.data); - return (0 == ack); + for (int bit_idx = 7; bit_idx >= 0; bit_idx--) { + bool bit = bitRead(value, bit_idx); + digitalWrite(Bp5758d.data, bit); + delayMicroseconds(BP5758D_DELAY); + digitalWrite(Bp5758d.clk, HIGH); + delayMicroseconds(BP5758D_DELAY); + digitalWrite(Bp5758d.clk, LOW); + delayMicroseconds(BP5758D_DELAY); + } + // Wait for ACK + pinMode(Bp5758d.data, INPUT); + digitalWrite(Bp5758d.clk, HIGH); + delayMicroseconds(BP5758D_DELAY); + digitalWrite(Bp5758d.clk, LOW); + delayMicroseconds(BP5758D_DELAY); + pinMode(Bp5758d.data, OUTPUT); } -bool Bp5758dStart(uint8_t addr) { +void Bp5758dStart(uint8_t addr) { AddLog(LOG_LEVEL_DEBUG, PSTR("LGT: Bp5758dStart")); - Bp5758dSetLow(Bp5758d.data); + digitalWrite(Bp5758d.data, LOW); delayMicroseconds(BP5758D_DELAY); - Bp5758dSetLow(Bp5758d.clk); - return Bp5758dWrite(addr); + digitalWrite(Bp5758d.clk, LOW); + delayMicroseconds(BP5758D_DELAY); + Bp5758dWrite(addr); } void Bp5758dStop(void) { AddLog(LOG_LEVEL_DEBUG, PSTR("LGT: Bp5758dStop")); - Bp5758dSetLow(Bp5758d.data); + digitalWrite(Bp5758d.clk, HIGH); delayMicroseconds(BP5758D_DELAY); - Bp5758dSetHigh(Bp5758d.clk); - delayMicroseconds(BP5758D_DELAY); - Bp5758dSetHigh(Bp5758d.data); + digitalWrite(Bp5758d.data, HIGH); delayMicroseconds(BP5758D_DELAY); } @@ -136,16 +131,16 @@ bool Bp5758dSetChannels(void) { // The first 5bits of this input are transmitted in first byte, the second 5bits in the second byte. // Because or tasmota's controls are 8bit (0-255), we need to multiply by 4 (or shift two bits to the left). // We thus transmit the first 5bits of tasmota's input as byte1, and the remaining 3bits as byte2 (shifted left two bits). - Bp5758dWrite(cur_col[0] >> 3); //Red: Only take first 5bits of tasmota's input - Bp5758dWrite((cur_col[0] & 0x07) << 2); //Only take last 3 bits, multiplied by 4 / shifted to left - Bp5758dWrite(cur_col[1] >> 3); //Green - Bp5758dWrite((cur_col[1] & 0x07) << 2); - Bp5758dWrite(cur_col[2] >> 3); //Blue - Bp5758dWrite((cur_col[2] & 0x07) << 2); - Bp5758dWrite(cur_col[3] >> 3); //Warm - Bp5758dWrite((cur_col[3] & 0x07) << 2); - Bp5758dWrite(cur_col[4] >> 3); //Cold - Bp5758dWrite((cur_col[4] & 0x07) << 2); + Bp5758dWrite((cur_col[0] & 0x07) << 2); //Red: Only take last 3 bits, multiplied by 4 / shifted to left + Bp5758dWrite(cur_col[0] >> 3); //Only take first 5bits of tasmota's input + Bp5758dWrite((cur_col[1] & 0x07) << 2); //Green + Bp5758dWrite(cur_col[1] >> 3); + Bp5758dWrite((cur_col[2] & 0x07) << 2); //Blue + Bp5758dWrite(cur_col[2] >> 3); + Bp5758dWrite((cur_col[4] & 0x07) << 2); //Cold + Bp5758dWrite(cur_col[4] >> 3); + Bp5758dWrite((cur_col[3] & 0x07) << 2); //Warm + Bp5758dWrite(cur_col[3] >> 3); Bp5758dStop(); return true; } @@ -178,6 +173,7 @@ void Bp5758dModuleSelected(void) Bp5758dWrite(0x00); Bp5758dWrite(0x00); Bp5758dWrite(0x00); + Bp5758dStop(); TasmotaGlobal.light_type = LT_RGBWC; TasmotaGlobal.light_driver = XLGT_08; From 4ec98e100ed22d2b4c36e43c4d4e14f1ce5184fe Mon Sep 17 00:00:00 2001 From: oogm Date: Sun, 29 May 2022 16:34:58 +0200 Subject: [PATCH 3/8] Change driver to user 10bit input (feature parity to original driver) --- tasmota/xdrv_04_light.ino | 3 +++ tasmota/xlgt_08_bp5758d.ino | 30 +++++++++++++++--------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/tasmota/xdrv_04_light.ino b/tasmota/xdrv_04_light.ino index 4a11cabf6..0067d9563 100644 --- a/tasmota/xdrv_04_light.ino +++ b/tasmota/xdrv_04_light.ino @@ -2193,12 +2193,15 @@ void LightSetOutputs(const uint16_t *cur_col_10) { char *tmp_data = XdrvMailbox.data; char *tmp_topic = XdrvMailbox.topic; + char *tmp_command = XdrvMailbox.command; XdrvMailbox.data = (char*)cur_col; XdrvMailbox.topic = (char*)scale_col; + XdrvMailbox.command = (char*)cur_col_10; if (XlgtCall(FUNC_SET_CHANNELS)) { /* Serviced */ } else if (XdrvCall(FUNC_SET_CHANNELS)) { /* Serviced */ } XdrvMailbox.data = tmp_data; XdrvMailbox.topic = tmp_topic; + XdrvMailbox.command = tmp_command; } // Just apply basic Gamma to each channel diff --git a/tasmota/xlgt_08_bp5758d.ino b/tasmota/xlgt_08_bp5758d.ino index 87c612336..23379875d 100644 --- a/tasmota/xlgt_08_bp5758d.ino +++ b/tasmota/xlgt_08_bp5758d.ino @@ -123,24 +123,24 @@ void Bp5758dStop(void) { /********************************************************************************************/ -bool Bp5758dSetChannels(void) { - uint8_t *cur_col = (uint8_t*)XdrvMailbox.data; +bool Bp5758dSetChannels(void) { + uint16_t *cur_col_10 = (uint16_t*)XdrvMailbox.command; + // Even though we could address changing channels only, in practice we observed that the lightbulb always sets all channels. Bp5758dStart(BP5758D_ADDR_OUT1_GL); // Brigtness values are transmitted as two bytes. The light-bulb accepts a 10-bit integer (0-1023) as an input value. - // The first 5bits of this input are transmitted in first byte, the second 5bits in the second byte. - // Because or tasmota's controls are 8bit (0-255), we need to multiply by 4 (or shift two bits to the left). - // We thus transmit the first 5bits of tasmota's input as byte1, and the remaining 3bits as byte2 (shifted left two bits). - Bp5758dWrite((cur_col[0] & 0x07) << 2); //Red: Only take last 3 bits, multiplied by 4 / shifted to left - Bp5758dWrite(cur_col[0] >> 3); //Only take first 5bits of tasmota's input - Bp5758dWrite((cur_col[1] & 0x07) << 2); //Green - Bp5758dWrite(cur_col[1] >> 3); - Bp5758dWrite((cur_col[2] & 0x07) << 2); //Blue - Bp5758dWrite(cur_col[2] >> 3); - Bp5758dWrite((cur_col[4] & 0x07) << 2); //Cold - Bp5758dWrite(cur_col[4] >> 3); - Bp5758dWrite((cur_col[3] & 0x07) << 2); //Warm - Bp5758dWrite(cur_col[3] >> 3); + // The first 5bits of this input are transmitted in second byte, the second 5bits in the first byte. + Bp5758dWrite((uint8_t)(cur_col_10[0] & 0x1F)); //Red: Only take last 3 bits, multiplied by 4 / shifted to left + Bp5758dWrite((uint8_t)(cur_col_10[0] >> 5)); //Only take first 5bits of tasmota's input + Bp5758dWrite((uint8_t)(cur_col_10[1] & 0x1F)); //Green + Bp5758dWrite((uint8_t)(cur_col_10[1] >> 5)); + Bp5758dWrite((uint8_t)(cur_col_10[2] & 0x1F)); //Blue + Bp5758dWrite((uint8_t)(cur_col_10[2] >> 5)); + Bp5758dWrite((uint8_t)(cur_col_10[4] & 0x1F)); //Cold + Bp5758dWrite((uint8_t)(cur_col_10[4] >> 5)); + Bp5758dWrite((uint8_t)(cur_col_10[3] & 0x1F)); //Warm + Bp5758dWrite((uint8_t)(cur_col_10[3] >> 5)); + Bp5758dStop(); return true; } From cae46e0d015ab6b91a422170204290d87cde0c8f Mon Sep 17 00:00:00 2001 From: oogm Date: Sun, 29 May 2022 17:41:39 +0200 Subject: [PATCH 4/8] Remove logs and add references --- tasmota/xlgt_08_bp5758d.ino | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/tasmota/xlgt_08_bp5758d.ino b/tasmota/xlgt_08_bp5758d.ino index 23379875d..e2104ddf2 100644 --- a/tasmota/xlgt_08_bp5758d.ino +++ b/tasmota/xlgt_08_bp5758d.ino @@ -59,25 +59,10 @@ struct BP5758D { } Bp5758d; /*********************************************************************************************\ - * Bp5758d code + * Bp5758d code - inspired by SM2135 and github.com/dbuezas/esphome-bp5758 \*********************************************************************************************/ const uint8_t BP5758D_DELAY = 2; -/* -void Bp5758dSetLow(uint8_t pin) { - noInterrupts(); - digitalWrite(pin, LOW); - pinMode(pin, OUTPUT); - interrupts(); -} - -void Bp5758dSetHigh(uint8_t pin) { - noInterrupts(); - pinMode(pin, INPUT_PULLUP); - interrupts(); -} -*/ - void Bp5758dInit(void) { pinMode(Bp5758d.data, OUTPUT); pinMode(Bp5758d.clk, OUTPUT); @@ -85,7 +70,6 @@ void Bp5758dInit(void) { } void Bp5758dWrite(uint8_t value) { - AddLog(LOG_LEVEL_DEBUG, PSTR("LGT: Bp5758dWrite %2x"), value); for (int bit_idx = 7; bit_idx >= 0; bit_idx--) { bool bit = bitRead(value, bit_idx); digitalWrite(Bp5758d.data, bit); @@ -105,7 +89,6 @@ void Bp5758dWrite(uint8_t value) { } void Bp5758dStart(uint8_t addr) { - AddLog(LOG_LEVEL_DEBUG, PSTR("LGT: Bp5758dStart")); digitalWrite(Bp5758d.data, LOW); delayMicroseconds(BP5758D_DELAY); digitalWrite(Bp5758d.clk, LOW); @@ -114,7 +97,6 @@ void Bp5758dStart(uint8_t addr) { } void Bp5758dStop(void) { - AddLog(LOG_LEVEL_DEBUG, PSTR("LGT: Bp5758dStop")); digitalWrite(Bp5758d.clk, HIGH); delayMicroseconds(BP5758D_DELAY); digitalWrite(Bp5758d.data, HIGH); From 1aaf186cae27074cf5549961ae3c1f70c17355b7 Mon Sep 17 00:00:00 2001 From: oogm Date: Sun, 29 May 2022 17:55:48 +0200 Subject: [PATCH 5/8] Add support for BP5758's sleep mode --- tasmota/xlgt_08_bp5758d.ino | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tasmota/xlgt_08_bp5758d.ino b/tasmota/xlgt_08_bp5758d.ino index e2104ddf2..5bded58d4 100644 --- a/tasmota/xlgt_08_bp5758d.ino +++ b/tasmota/xlgt_08_bp5758d.ino @@ -108,6 +108,13 @@ void Bp5758dStop(void) { bool Bp5758dSetChannels(void) { uint16_t *cur_col_10 = (uint16_t*)XdrvMailbox.command; + // If we receive 0 for all channels, we'll assume that the lightbulb is off, and activate BP5758d's sleep mode. + if (cur_col_10[0]==0 && cur_col_10[1]==0 && cur_col_10[2]==0 && cur_col_10[3]==0 && cur_col_10[4]==0) { + Bp5758dStart(BP5758D_ADDR_SLEEP); + Bp5758dStop(); + return true; + } + // Even though we could address changing channels only, in practice we observed that the lightbulb always sets all channels. Bp5758dStart(BP5758D_ADDR_OUT1_GL); // Brigtness values are transmitted as two bytes. The light-bulb accepts a 10-bit integer (0-1023) as an input value. From 72932b9b027c388742b25f255c724d5efb45bc90 Mon Sep 17 00:00:00 2001 From: oogm Date: Sun, 29 May 2022 18:01:55 +0200 Subject: [PATCH 6/8] Add feature to changelog --- RELEASENOTES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index f1e019c8d..415c63d5f 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -119,6 +119,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo - Support for Sonoff Zigbee Bridge Pro by Stephan Hadinger [#15701](https://github.com/arendst/Tasmota/issues/15701) - Support for flowrate meters like YF-DN50 and similary [#15474](https://github.com/arendst/Tasmota/issues/15474) - ESP32 Command ``Restart 3`` to switch between SafeBoot and Production +- Support for 5-channel light dimmer driver BP5758D used in Tuya bulbs ### Breaking Changed From ca3079296bdafca2401481227743e95e47e189da Mon Sep 17 00:00:00 2001 From: oogm Date: Sun, 29 May 2022 18:08:42 +0200 Subject: [PATCH 7/8] Fix outdated comment --- tasmota/xlgt_08_bp5758d.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasmota/xlgt_08_bp5758d.ino b/tasmota/xlgt_08_bp5758d.ino index 5bded58d4..e2e93fe97 100644 --- a/tasmota/xlgt_08_bp5758d.ino +++ b/tasmota/xlgt_08_bp5758d.ino @@ -119,8 +119,8 @@ bool Bp5758dSetChannels(void) { Bp5758dStart(BP5758D_ADDR_OUT1_GL); // Brigtness values are transmitted as two bytes. The light-bulb accepts a 10-bit integer (0-1023) as an input value. // The first 5bits of this input are transmitted in second byte, the second 5bits in the first byte. - Bp5758dWrite((uint8_t)(cur_col_10[0] & 0x1F)); //Red: Only take last 3 bits, multiplied by 4 / shifted to left - Bp5758dWrite((uint8_t)(cur_col_10[0] >> 5)); //Only take first 5bits of tasmota's input + Bp5758dWrite((uint8_t)(cur_col_10[0] & 0x1F)); //Red + Bp5758dWrite((uint8_t)(cur_col_10[0] >> 5)); Bp5758dWrite((uint8_t)(cur_col_10[1] & 0x1F)); //Green Bp5758dWrite((uint8_t)(cur_col_10[1] >> 5)); Bp5758dWrite((uint8_t)(cur_col_10[2] & 0x1F)); //Blue From bf67031c409bd0b3d5092333126ba071f8f31053 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 30 May 2022 09:35:08 +0200 Subject: [PATCH 8/8] Default disable --- tasmota/my_user_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index 3ece102f0..6752e2b09 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -555,7 +555,7 @@ #define USE_MY92X1 // Add support for MY92X1 RGBCW led controller as used in Sonoff B1, Ailight and Lohas #define USE_SM16716 // Add support for SM16716 RGB LED controller (+0k7 code) #define USE_SM2135 // Add support for SM2135 RGBCW led control as used in Action LSC (+0k6 code) -#define USE_BP5758D // Add support for BP5758D RGBCW led control as used in some Tuya lightbulbs +//#define USE_BP5758D // Add support for BP5758D RGBCW led control as used in some Tuya lightbulbs #define USE_SONOFF_L1 // Add support for Sonoff L1 led control #define USE_ELECTRIQ_MOODL // Add support for ElectriQ iQ-wifiMOODL RGBW LED controller (+0k3 code) #define USE_LIGHT_PALETTE // Add support for color palette (+0k7 code)