From 616652ea224cba0c33bfeff0434e9781f377d868 Mon Sep 17 00:00:00 2001 From: Jeroen Date: Mon, 1 May 2023 14:51:02 +0200 Subject: [PATCH] Added support for Dingtian Relay Board v3.6.10 (#18535) * Added support for Dingtian Relay Board v3.6.10 * Output OE was never initialized * Removed white spaces trying to fix language builds * Fix for https://github.com/arendst/Tasmota/pull/18535#pullrequestreview-1406978097 * Fixed language builds --------- Co-authored-by: JeroenSt --- tasmota/include/tasmota_template.h | 3 ++ tasmota/language/af_AF.h | 1 + tasmota/language/bg_BG.h | 1 + tasmota/language/ca_AD.h | 1 + tasmota/language/cs_CZ.h | 1 + tasmota/language/de_DE.h | 1 + tasmota/language/el_GR.h | 1 + tasmota/language/en_GB.h | 1 + tasmota/language/es_ES.h | 1 + tasmota/language/fr_FR.h | 1 + tasmota/language/fy_NL.h | 1 + tasmota/language/he_HE.h | 1 + tasmota/language/hu_HU.h | 1 + tasmota/language/it_IT.h | 1 + tasmota/language/ko_KO.h | 1 + tasmota/language/nl_NL.h | 1 + tasmota/language/pl_PL.h | 1 + tasmota/language/pt_BR.h | 1 + tasmota/language/pt_PT.h | 1 + tasmota/language/ro_RO.h | 1 + tasmota/language/ru_RU.h | 1 + tasmota/language/sk_SK.h | 1 + tasmota/language/sv_SE.h | 1 + tasmota/language/tr_TR.h | 1 + tasmota/language/uk_UA.h | 1 + tasmota/language/vi_VN.h | 1 + tasmota/language/zh_CN.h | 1 + tasmota/language/zh_TW.h | 1 + .../xdrv_90_esp32_dingtian_relay.ino | 48 +++++++++++-------- 29 files changed, 59 insertions(+), 19 deletions(-) diff --git a/tasmota/include/tasmota_template.h b/tasmota/include/tasmota_template.h index 15ac3d198..009934be7 100644 --- a/tasmota/include/tasmota_template.h +++ b/tasmota/include/tasmota_template.h @@ -210,6 +210,7 @@ enum UserSelectablePins { GPIO_PCF8574_INT, // PCF8574 interrupt GPIO_LOX_O2_RX, // LOX-O2 RX GPIO_GM861_TX, GPIO_GM861_RX, // GM861 Serial interface + GPIO_DINGTIAN_OE, // New version of Dingtian relay board where PL is not shared with OE GPIO_SENSOR_END }; // Error as warning to rethink GPIO usage with max 2045 @@ -467,6 +468,7 @@ const char kSensorNames[] PROGMEM = D_SENSOR_PCF8574_INT "|" D_SENSOR_LOX_O2_RX "|" D_SENSOR_GM861_TX "|" D_SENSOR_GM861_RX "|" + D_GPIO_DINGTIAN_OE "|" ; const char kSensorNamesFixed[] PROGMEM = @@ -1121,6 +1123,7 @@ const uint16_t kGpioNiceList[] PROGMEM = { AGPIO(GPIO_DINGTIAN_SDI), AGPIO(GPIO_DINGTIAN_Q7), AGPIO(GPIO_DINGTIAN_PL), + AGPIO(GPIO_DINGTIAN_OE), AGPIO(GPIO_DINGTIAN_RCK), #endif diff --git a/tasmota/language/af_AF.h b/tasmota/language/af_AF.h index b4b1cfed8..f63671846 100644 --- a/tasmota/language/af_AF.h +++ b/tasmota/language/af_AF.h @@ -919,6 +919,7 @@ #define D_GPIO_DINGTIAN_SDI "Dingtian SDI" #define D_GPIO_DINGTIAN_Q7 "Dingtian Q7" #define D_GPIO_DINGTIAN_PL "Dingtian PL" +#define D_GPIO_DINGTIAN_OE "Dingtian OE" #define D_GPIO_DINGTIAN_RCK "Dingtian RCK" #define D_SENSOR_CM11_TX "CM110x TX" #define D_SENSOR_CM11_RX "CM110x RX" diff --git a/tasmota/language/bg_BG.h b/tasmota/language/bg_BG.h index 7ed573c10..672d88b93 100644 --- a/tasmota/language/bg_BG.h +++ b/tasmota/language/bg_BG.h @@ -919,6 +919,7 @@ #define D_GPIO_DINGTIAN_SDI "Dingtian SDI" #define D_GPIO_DINGTIAN_Q7 "Dingtian Q7" #define D_GPIO_DINGTIAN_PL "Dingtian PL" +#define D_GPIO_DINGTIAN_OE "Dingtian OE" #define D_GPIO_DINGTIAN_RCK "Dingtian RCK" #define D_SENSOR_CM11_TX "CM110x TX" #define D_SENSOR_CM11_RX "CM110x RX" diff --git a/tasmota/language/ca_AD.h b/tasmota/language/ca_AD.h index f82f4d619..277902023 100644 --- a/tasmota/language/ca_AD.h +++ b/tasmota/language/ca_AD.h @@ -919,6 +919,7 @@ #define D_GPIO_DINGTIAN_SDI "Dingtian SDI" #define D_GPIO_DINGTIAN_Q7 "Dingtian Q7" #define D_GPIO_DINGTIAN_PL "Dingtian PL" +#define D_GPIO_DINGTIAN_OE "Dingtian OE" #define D_GPIO_DINGTIAN_RCK "Dingtian RCK" #define D_SENSOR_CM11_TX "CM110x TX" #define D_SENSOR_CM11_RX "CM110x RX" diff --git a/tasmota/language/cs_CZ.h b/tasmota/language/cs_CZ.h index 261396243..e42c875de 100644 --- a/tasmota/language/cs_CZ.h +++ b/tasmota/language/cs_CZ.h @@ -919,6 +919,7 @@ #define D_GPIO_DINGTIAN_SDI "Dingtian SDI" #define D_GPIO_DINGTIAN_Q7 "Dingtian Q7" #define D_GPIO_DINGTIAN_PL "Dingtian PL" +#define D_GPIO_DINGTIAN_OE "Dingtian OE" #define D_GPIO_DINGTIAN_RCK "Dingtian RCK" #define D_SENSOR_CM11_TX "CM110x TX" #define D_SENSOR_CM11_RX "CM110x RX" diff --git a/tasmota/language/de_DE.h b/tasmota/language/de_DE.h index 8135fd778..408408245 100644 --- a/tasmota/language/de_DE.h +++ b/tasmota/language/de_DE.h @@ -919,6 +919,7 @@ #define D_GPIO_DINGTIAN_SDI "Dingtian SDI" #define D_GPIO_DINGTIAN_Q7 "Dingtian Q7" #define D_GPIO_DINGTIAN_PL "Dingtian PL" +#define D_GPIO_DINGTIAN_OE "Dingtian OE" #define D_GPIO_DINGTIAN_RCK "Dingtian RCK" #define D_SENSOR_CM11_TX "CM110x TX" #define D_SENSOR_CM11_RX "CM110x RX" diff --git a/tasmota/language/el_GR.h b/tasmota/language/el_GR.h index 86fdbc4e0..a359d49dd 100644 --- a/tasmota/language/el_GR.h +++ b/tasmota/language/el_GR.h @@ -919,6 +919,7 @@ #define D_GPIO_DINGTIAN_SDI "Dingtian SDI" #define D_GPIO_DINGTIAN_Q7 "Dingtian Q7" #define D_GPIO_DINGTIAN_PL "Dingtian PL" +#define D_GPIO_DINGTIAN_OE "Dingtian OE" #define D_GPIO_DINGTIAN_RCK "Dingtian RCK" #define D_SENSOR_CM11_TX "CM110x TX" #define D_SENSOR_CM11_RX "CM110x RX" diff --git a/tasmota/language/en_GB.h b/tasmota/language/en_GB.h index a322b71c5..b746c0634 100644 --- a/tasmota/language/en_GB.h +++ b/tasmota/language/en_GB.h @@ -919,6 +919,7 @@ #define D_GPIO_DINGTIAN_SDI "Dingtian SDI" #define D_GPIO_DINGTIAN_Q7 "Dingtian Q7" #define D_GPIO_DINGTIAN_PL "Dingtian PL" +#define D_GPIO_DINGTIAN_OE "Dingtian OE" #define D_GPIO_DINGTIAN_RCK "Dingtian RCK" #define D_SENSOR_CM11_TX "CM110x TX" #define D_SENSOR_CM11_RX "CM110x RX" diff --git a/tasmota/language/es_ES.h b/tasmota/language/es_ES.h index 740912dd6..26dd59688 100644 --- a/tasmota/language/es_ES.h +++ b/tasmota/language/es_ES.h @@ -919,6 +919,7 @@ #define D_GPIO_DINGTIAN_SDI "Dingtian SDI" #define D_GPIO_DINGTIAN_Q7 "Dingtian Q7" #define D_GPIO_DINGTIAN_PL "Dingtian PL" +#define D_GPIO_DINGTIAN_OE "Dingtian OE" #define D_GPIO_DINGTIAN_RCK "Dingtian RCK" #define D_SENSOR_CM11_TX "CM110x TX" #define D_SENSOR_CM11_RX "CM110x RX" diff --git a/tasmota/language/fr_FR.h b/tasmota/language/fr_FR.h index 28de55477..ae600b589 100644 --- a/tasmota/language/fr_FR.h +++ b/tasmota/language/fr_FR.h @@ -919,6 +919,7 @@ #define D_GPIO_DINGTIAN_SDI "Dingtian SDI" #define D_GPIO_DINGTIAN_Q7 "Dingtian Q7" #define D_GPIO_DINGTIAN_PL "Dingtian PL" +#define D_GPIO_DINGTIAN_OE "Dingtian OE" #define D_GPIO_DINGTIAN_RCK "Dingtian RCk" #define D_SENSOR_CM11_TX "CM110x Tx" #define D_SENSOR_CM11_RX "CM110x Rx" diff --git a/tasmota/language/fy_NL.h b/tasmota/language/fy_NL.h index cf98979de..0ef74fdb6 100644 --- a/tasmota/language/fy_NL.h +++ b/tasmota/language/fy_NL.h @@ -919,6 +919,7 @@ #define D_GPIO_DINGTIAN_SDI "Dingtian SDI" #define D_GPIO_DINGTIAN_Q7 "Dingtian Q7" #define D_GPIO_DINGTIAN_PL "Dingtian PL" +#define D_GPIO_DINGTIAN_OE "Dingtian OE" #define D_GPIO_DINGTIAN_RCK "Dingtian RCK" #define D_SENSOR_CM11_TX "CM110x TX" #define D_SENSOR_CM11_RX "CM110x RX" diff --git a/tasmota/language/he_HE.h b/tasmota/language/he_HE.h index 13e86a53f..c1d13b7bc 100644 --- a/tasmota/language/he_HE.h +++ b/tasmota/language/he_HE.h @@ -919,6 +919,7 @@ #define D_GPIO_DINGTIAN_SDI "Dingtian SDI" #define D_GPIO_DINGTIAN_Q7 "Dingtian Q7" #define D_GPIO_DINGTIAN_PL "Dingtian PL" +#define D_GPIO_DINGTIAN_OE "Dingtian OE" #define D_GPIO_DINGTIAN_RCK "Dingtian RCK" #define D_SENSOR_CM11_TX "CM110x TX" #define D_SENSOR_CM11_RX "CM110x RX" diff --git a/tasmota/language/hu_HU.h b/tasmota/language/hu_HU.h index 3990ac173..71540307b 100644 --- a/tasmota/language/hu_HU.h +++ b/tasmota/language/hu_HU.h @@ -919,6 +919,7 @@ #define D_GPIO_DINGTIAN_SDI "Dingtian SDI" #define D_GPIO_DINGTIAN_Q7 "Dingtian Q7" #define D_GPIO_DINGTIAN_PL "Dingtian PL" +#define D_GPIO_DINGTIAN_OE "Dingtian OE" #define D_GPIO_DINGTIAN_RCK "Dingtian RCK" #define D_SENSOR_CM11_TX "CM110x TX" #define D_SENSOR_CM11_RX "CM110x RX" diff --git a/tasmota/language/it_IT.h b/tasmota/language/it_IT.h index 247ea5e1f..2690363bb 100644 --- a/tasmota/language/it_IT.h +++ b/tasmota/language/it_IT.h @@ -919,6 +919,7 @@ #define D_GPIO_DINGTIAN_SDI "Dingtian - SDI" #define D_GPIO_DINGTIAN_Q7 "Dingtian - Q7" #define D_GPIO_DINGTIAN_PL "Dingtian - PL" +#define D_GPIO_DINGTIAN_OE "Dingtian - OE" #define D_GPIO_DINGTIAN_RCK "Dingtian - RCK" #define D_SENSOR_CM11_TX "CM110x - TX" #define D_SENSOR_CM11_RX "CM110x - RX" diff --git a/tasmota/language/ko_KO.h b/tasmota/language/ko_KO.h index 7577e1399..4f941a3b8 100644 --- a/tasmota/language/ko_KO.h +++ b/tasmota/language/ko_KO.h @@ -919,6 +919,7 @@ #define D_GPIO_DINGTIAN_SDI "Dingtian SDI" #define D_GPIO_DINGTIAN_Q7 "Dingtian Q7" #define D_GPIO_DINGTIAN_PL "Dingtian PL" +#define D_GPIO_DINGTIAN_OE "Dingtian OE" #define D_GPIO_DINGTIAN_RCK "Dingtian RCK" #define D_SENSOR_CM11_TX "CM110x TX" #define D_SENSOR_CM11_RX "CM110x RX" diff --git a/tasmota/language/nl_NL.h b/tasmota/language/nl_NL.h index a645fdc71..05f85db2b 100644 --- a/tasmota/language/nl_NL.h +++ b/tasmota/language/nl_NL.h @@ -919,6 +919,7 @@ #define D_GPIO_DINGTIAN_SDI "Dingtian SDI" #define D_GPIO_DINGTIAN_Q7 "Dingtian Q7" #define D_GPIO_DINGTIAN_PL "Dingtian PL" +#define D_GPIO_DINGTIAN_OE "Dingtian OE" #define D_GPIO_DINGTIAN_RCK "Dingtian RCK" #define D_SENSOR_CM11_TX "CM110x TX" #define D_SENSOR_CM11_RX "CM110x RX" diff --git a/tasmota/language/pl_PL.h b/tasmota/language/pl_PL.h index e4fa104cb..4444de792 100644 --- a/tasmota/language/pl_PL.h +++ b/tasmota/language/pl_PL.h @@ -919,6 +919,7 @@ #define D_GPIO_DINGTIAN_SDI "Dingtian SDI" #define D_GPIO_DINGTIAN_Q7 "Dingtian Q7" #define D_GPIO_DINGTIAN_PL "Dingtian PL" +#define D_GPIO_DINGTIAN_OE "Dingtian OE" #define D_GPIO_DINGTIAN_RCK "Dingtian RCK" #define D_SENSOR_CM11_TX "CM110x TX" #define D_SENSOR_CM11_RX "CM110x RX" diff --git a/tasmota/language/pt_BR.h b/tasmota/language/pt_BR.h index 81cb42864..ea04901c7 100644 --- a/tasmota/language/pt_BR.h +++ b/tasmota/language/pt_BR.h @@ -919,6 +919,7 @@ #define D_GPIO_DINGTIAN_SDI "Dingtian SDI" #define D_GPIO_DINGTIAN_Q7 "Dingtian Q7" #define D_GPIO_DINGTIAN_PL "Dingtian PL" +#define D_GPIO_DINGTIAN_OE "Dingtian OE" #define D_GPIO_DINGTIAN_RCK "Dingtian RCK" #define D_SENSOR_CM11_TX "CM110x TX" #define D_SENSOR_CM11_RX "CM110x RX" diff --git a/tasmota/language/pt_PT.h b/tasmota/language/pt_PT.h index b8c5f3986..3377d7d72 100644 --- a/tasmota/language/pt_PT.h +++ b/tasmota/language/pt_PT.h @@ -919,6 +919,7 @@ #define D_GPIO_DINGTIAN_SDI "Dingtian SDI" #define D_GPIO_DINGTIAN_Q7 "Dingtian Q7" #define D_GPIO_DINGTIAN_PL "Dingtian PL" +#define D_GPIO_DINGTIAN_OE "Dingtian OE" #define D_GPIO_DINGTIAN_RCK "Dingtian RCK" #define D_SENSOR_CM11_TX "CM110x TX" #define D_SENSOR_CM11_RX "CM110x RX" diff --git a/tasmota/language/ro_RO.h b/tasmota/language/ro_RO.h index 57034470f..c97bc649a 100644 --- a/tasmota/language/ro_RO.h +++ b/tasmota/language/ro_RO.h @@ -919,6 +919,7 @@ #define D_GPIO_DINGTIAN_SDI "Dingtian SDI" #define D_GPIO_DINGTIAN_Q7 "Dingtian Q7" #define D_GPIO_DINGTIAN_PL "Dingtian PL" +#define D_GPIO_DINGTIAN_OE "Dingtian OE" #define D_GPIO_DINGTIAN_RCK "Dingtian RCK" #define D_SENSOR_CM11_TX "CM110x TX" #define D_SENSOR_CM11_RX "CM110x RX" diff --git a/tasmota/language/ru_RU.h b/tasmota/language/ru_RU.h index 3afd6b55f..6e9bbe95d 100644 --- a/tasmota/language/ru_RU.h +++ b/tasmota/language/ru_RU.h @@ -919,6 +919,7 @@ #define D_GPIO_DINGTIAN_SDI "Dingtian SDI" #define D_GPIO_DINGTIAN_Q7 "Dingtian Q7" #define D_GPIO_DINGTIAN_PL "Dingtian PL" +#define D_GPIO_DINGTIAN_OE "Dingtian OE" #define D_GPIO_DINGTIAN_RCK "Dingtian RCK" #define D_SENSOR_CM11_TX "CM110x TX" #define D_SENSOR_CM11_RX "CM110x RX" diff --git a/tasmota/language/sk_SK.h b/tasmota/language/sk_SK.h index 61b253e19..679abff2e 100644 --- a/tasmota/language/sk_SK.h +++ b/tasmota/language/sk_SK.h @@ -919,6 +919,7 @@ #define D_GPIO_DINGTIAN_SDI "Dingtian SDI" #define D_GPIO_DINGTIAN_Q7 "Dingtian Q7" #define D_GPIO_DINGTIAN_PL "Dingtian PL" +#define D_GPIO_DINGTIAN_OE "Dingtian OE" #define D_GPIO_DINGTIAN_RCK "Dingtian RCK" #define D_SENSOR_CM11_TX "CM110x TX" #define D_SENSOR_CM11_RX "CM110x RX" diff --git a/tasmota/language/sv_SE.h b/tasmota/language/sv_SE.h index b398d0b06..0c3c896fe 100644 --- a/tasmota/language/sv_SE.h +++ b/tasmota/language/sv_SE.h @@ -919,6 +919,7 @@ #define D_GPIO_DINGTIAN_SDI "Dingtian SDI" #define D_GPIO_DINGTIAN_Q7 "Dingtian Q7" #define D_GPIO_DINGTIAN_PL "Dingtian PL" +#define D_GPIO_DINGTIAN_OE "Dingtian OE" #define D_GPIO_DINGTIAN_RCK "Dingtian RCK" #define D_SENSOR_CM11_TX "CM110x TX" #define D_SENSOR_CM11_RX "CM110x RX" diff --git a/tasmota/language/tr_TR.h b/tasmota/language/tr_TR.h index c7c14ee28..bc62a9ff5 100644 --- a/tasmota/language/tr_TR.h +++ b/tasmota/language/tr_TR.h @@ -919,6 +919,7 @@ #define D_GPIO_DINGTIAN_SDI "Dingtian SDI" #define D_GPIO_DINGTIAN_Q7 "Dingtian Q7" #define D_GPIO_DINGTIAN_PL "Dingtian PL" +#define D_GPIO_DINGTIAN_OE "Dingtian OE" #define D_GPIO_DINGTIAN_RCK "Dingtian RCK" #define D_SENSOR_CM11_TX "CM110x TX" #define D_SENSOR_CM11_RX "CM110x RX" diff --git a/tasmota/language/uk_UA.h b/tasmota/language/uk_UA.h index 0063ed1be..d0664f542 100644 --- a/tasmota/language/uk_UA.h +++ b/tasmota/language/uk_UA.h @@ -919,6 +919,7 @@ #define D_GPIO_DINGTIAN_SDI "Dingtian SDI" #define D_GPIO_DINGTIAN_Q7 "Dingtian Q7" #define D_GPIO_DINGTIAN_PL "Dingtian PL" +#define D_GPIO_DINGTIAN_OE "Dingtian OE" #define D_GPIO_DINGTIAN_RCK "Dingtian RCK" #define D_SENSOR_CM11_TX "CM110x TX" #define D_SENSOR_CM11_RX "CM110x RX" diff --git a/tasmota/language/vi_VN.h b/tasmota/language/vi_VN.h index 08204fff6..74e8398a2 100644 --- a/tasmota/language/vi_VN.h +++ b/tasmota/language/vi_VN.h @@ -919,6 +919,7 @@ #define D_GPIO_DINGTIAN_SDI "Dingtian SDI" #define D_GPIO_DINGTIAN_Q7 "Dingtian Q7" #define D_GPIO_DINGTIAN_PL "Dingtian PL" +#define D_GPIO_DINGTIAN_OE "Dingtian OE" #define D_GPIO_DINGTIAN_RCK "Dingtian RCK" #define D_SENSOR_CM11_TX "CM110x TX" #define D_SENSOR_CM11_RX "CM110x RX" diff --git a/tasmota/language/zh_CN.h b/tasmota/language/zh_CN.h index cd0880c0c..b4fa7c00e 100644 --- a/tasmota/language/zh_CN.h +++ b/tasmota/language/zh_CN.h @@ -919,6 +919,7 @@ #define D_GPIO_DINGTIAN_SDI "Dingtian SDI" #define D_GPIO_DINGTIAN_Q7 "Dingtian Q7" #define D_GPIO_DINGTIAN_PL "Dingtian PL" +#define D_GPIO_DINGTIAN_OE "Dingtian OE" #define D_GPIO_DINGTIAN_RCK "Dingtian RCK" #define D_SENSOR_CM11_TX "CM110x TX" #define D_SENSOR_CM11_RX "CM110x RX" diff --git a/tasmota/language/zh_TW.h b/tasmota/language/zh_TW.h index 6ae065861..a5611d532 100644 --- a/tasmota/language/zh_TW.h +++ b/tasmota/language/zh_TW.h @@ -919,6 +919,7 @@ #define D_GPIO_DINGTIAN_SDI "Dingtian SDI" #define D_GPIO_DINGTIAN_Q7 "Dingtian Q7" #define D_GPIO_DINGTIAN_PL "Dingtian PL" +#define D_GPIO_DINGTIAN_OE "Dingtian OE" #define D_GPIO_DINGTIAN_RCK "Dingtian RCK" #define D_SENSOR_CM11_TX "CM110x TX" #define D_SENSOR_CM11_RX "CM110x RX" diff --git a/tasmota/tasmota_xdrv_driver/xdrv_90_esp32_dingtian_relay.ino b/tasmota/tasmota_xdrv_driver/xdrv_90_esp32_dingtian_relay.ino index 93bfd2a34..c6dbd9193 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_90_esp32_dingtian_relay.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_90_esp32_dingtian_relay.ino @@ -30,18 +30,22 @@ #error DINGTIAN - Only one of DINGTIAN_USE_AS_BUTTON or DINGTIAN_USE_AS_SWITCH should be defined #endif +#define DINGTIAN_SET_OUTPUT(pin,value) { pinMode((pin), OUTPUT); digitalWrite((pin), (value)); } +#define DINGTIAN_SET_INPUT(pin) { pinMode((pin), INPUT); } + /******************************************************************************************************** * Global private data */ struct DINGTIAN_DATA { - uint32_t outputs; // keep ouputs state - uint32_t last_inputs; // previous inputs state - uint8_t count; // number of relay and input (8 * numver of shift registers) - uint8_t first; // index of 1st Tasmota relay assigned to 1st Dingtian relays - int8_t key_offset; // index of virtual key + uint32_t outputs; // keep ouputs state + uint32_t last_inputs; // previous inputs state + uint8_t count; // number of relay and input (8 * numver of shift registers) + uint8_t first; // index of 1st Tasmota relay assigned to 1st Dingtian relays + int8_t key_offset; // index of virtual key + bool outputs_initialized; // set when the outputs are initialized // pins - uint8_t pin_clk, pin_sdi, pin_q7, pin_pl, pin_rck; + uint8_t pin_clk, pin_sdi, pin_q7, pin_pl, pin_oe, pin_rck; } *Dingtian = nullptr; @@ -56,7 +60,7 @@ uint32_t DingtianReadWrite(uint32_t outputs) // setup digitalWrite(Dingtian->pin_rck, 0); // rclk and clkinh to 0 - digitalWrite(Dingtian->pin_pl, 1); // load inputs in '165, ready for shift-in (side effect '595 in tri-state) + if (PinUsed(GPIO_DINGTIAN_PL)) digitalWrite(Dingtian->pin_pl, 1); // load inputs in '165, ready for shift-in (side effect '595 in tri-state) for ( int i = Dingtian->count ; i > 0 ; i-- ) { // relay out to '595 digitalWrite(Dingtian->pin_sdi, outputs & 1); @@ -70,7 +74,13 @@ uint32_t DingtianReadWrite(uint32_t outputs) } // ending digitalWrite(Dingtian->pin_rck, 1); // rclk pulse to load '595 into output registers - digitalWrite(Dingtian->pin_pl, 0); // re-enable '595 ouputs + if (PinUsed(GPIO_DINGTIAN_PL)) digitalWrite(Dingtian->pin_pl, 0); // re-enable '595 ouputs (old board version) + if (!Dingtian->outputs_initialized && PinUsed(GPIO_DINGTIAN_OE)) + { + digitalWrite(Dingtian->pin_oe, 0); // enable '595 ouputs (new board version) + DINGTIAN_SET_OUTPUT(Dingtian->pin_oe, 0); + Dingtian->outputs_initialized = true; + } #ifdef DINGTIAN_INPUTS_INVERTED return ~inputs; @@ -83,33 +93,33 @@ uint32_t DingtianReadWrite(uint32_t outputs) * Driver initialisation */ -#define DINGTIAN_SET_OUTPUT(pin,value) { pinMode((pin), OUTPUT); digitalWrite((pin), (value)); } -#define DINGTIAN_SET_INPUT(pin) { pinMode((pin), INPUT); } - void DingtianInit(void) { if (PinUsed(GPIO_DINGTIAN_CLK, GPIO_ANY) && PinUsed(GPIO_DINGTIAN_SDI) && PinUsed(GPIO_DINGTIAN_Q7) - && PinUsed(GPIO_DINGTIAN_PL) && PinUsed(GPIO_DINGTIAN_RCK)) { + && (PinUsed(GPIO_DINGTIAN_PL) || PinUsed(GPIO_DINGTIAN_OE)) && PinUsed(GPIO_DINGTIAN_RCK)) { // allocate Dingtian data structure Dingtian = (struct DINGTIAN_DATA*)calloc(1, sizeof(struct DINGTIAN_DATA)); if (Dingtian) { // get pins - Dingtian->pin_clk = Pin(GPIO_DINGTIAN_CLK, GPIO_ANY); // shift clock : 595's SCLK & 165's CLK - Dingtian->pin_sdi = Pin(GPIO_DINGTIAN_SDI); // Serial out : 595's SER - Dingtian->pin_q7 = Pin(GPIO_DINGTIAN_Q7); // Serial in : 165's Q7 - Dingtian->pin_pl = Pin(GPIO_DINGTIAN_PL); // Input load : 595's nOE & 165's PL (or SH/LD on some datasheet) - Dingtian->pin_rck = Pin(GPIO_DINGTIAN_RCK); // Output load : 595's RCLK & 165's CLKINH + Dingtian->pin_clk = Pin(GPIO_DINGTIAN_CLK, GPIO_ANY); // shift clock : 595's SCLK & 165's CLK + Dingtian->pin_sdi = Pin(GPIO_DINGTIAN_SDI); // Serial out : 595's SER + Dingtian->pin_q7 = Pin(GPIO_DINGTIAN_Q7); // Serial in : 165's Q7 + if (PinUsed(GPIO_DINGTIAN_PL)) Dingtian->pin_pl = Pin(GPIO_DINGTIAN_PL); // Input load : 595's nOE & 165's PL (or SH/LD on some datasheet) + if (PinUsed(GPIO_DINGTIAN_OE)) Dingtian->pin_oe = Pin(GPIO_DINGTIAN_OE); // Output enable : 595's nOE (v3.6.10) + Dingtian->pin_rck = Pin(GPIO_DINGTIAN_RCK); // Output load : 595's RCLK & 165's CLKINH // number of shift registers is the CLK index Dingtian->count = ((GetPin(Dingtian->pin_clk) - AGPIO(GPIO_DINGTIAN_CLK)) + 1) * 8; - AddLog(LOG_LEVEL_DEBUG, PSTR("DNGT: clk:%d, sdi:%d, q7:%d, pl:%d, rck:%d, count:%d"), - Dingtian->pin_clk, Dingtian->pin_sdi, Dingtian->pin_q7, Dingtian->pin_pl, Dingtian->pin_rck, Dingtian->count); + AddLog(LOG_LEVEL_DEBUG, PSTR("DNGT: clk:%d, sdi:%d, q7:%d, pl:%d, oe:%d, rck:%d, count:%d"), + Dingtian->pin_clk, Dingtian->pin_sdi, Dingtian->pin_q7, Dingtian->pin_pl, Dingtian->pin_oe, Dingtian->pin_rck, Dingtian->count); DINGTIAN_SET_OUTPUT(Dingtian->pin_clk, 0); DINGTIAN_SET_OUTPUT(Dingtian->pin_sdi, 0); DINGTIAN_SET_INPUT( Dingtian->pin_q7); DINGTIAN_SET_OUTPUT(Dingtian->pin_pl, 0); + //Do not initialize Dingtian->pin_oe so the relays will not toggle while restarting DINGTIAN_SET_OUTPUT(Dingtian->pin_rck, 0); + Dingtian->outputs_initialized = false; Dingtian->first = TasmotaGlobal.devices_present; Dingtian->key_offset = -1; UpdateDevicesPresent(Dingtian->count);