From 4b87ce223fc6bb01e30e48356c82afd54b26efc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Wed, 8 Nov 2017 18:47:29 +0100 Subject: [PATCH] Support for YJZK 2-gang switch --- code/espurna/config/general.h | 2 +- code/espurna/config/hardware.h | 34 ++++++++++++++++++++++++++++++++++ code/espurna/hardware.ino | 15 +++++++++++++++ code/platformio.ini | 23 +++++++++++++++++++++++ 4 files changed, 73 insertions(+), 1 deletion(-) diff --git a/code/espurna/config/general.h b/code/espurna/config/general.h index d43e32e7..974c446a 100644 --- a/code/espurna/config/general.h +++ b/code/espurna/config/general.h @@ -246,7 +246,7 @@ PROGMEM const char* const custom_reset_string[] = { // All defined LEDs in the board can be managed through MQTT // except the first one when LED_AUTO is set to 1. -// If LED_AUTO is set to 1 the board will a defined LED to show wifi status. +// If LED_AUTO is set to 1 the board will use a defined LED to show wifi status. #define LED_AUTO 1 // LED # to use as WIFI status indicator diff --git a/code/espurna/config/hardware.h b/code/espurna/config/hardware.h index 0a4d6cf2..eac36be8 100644 --- a/code/espurna/config/hardware.h +++ b/code/espurna/config/hardware.h @@ -602,6 +602,40 @@ #define LED1_PIN 13 #define LED1_PIN_INVERSE 1 + +// ----------------------------------------------------------------------------- +// YJZK +// ----------------------------------------------------------------------------- + +#elif defined(YJZK_SWITCH_2CH) + + // Info + #define MANUFACTURER "YJZK" + #define DEVICE "SWITCH_2CH" + + // Buttons + #define BUTTON1_PIN 0 + #define BUTTON2_PIN 9 + + #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH + #define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH + + #define BUTTON1_RELAY 1 + #define BUTTON2_RELAY 2 + + // Relays + #define RELAY1_PIN 12 + #define RELAY2_PIN 5 + + #define RELAY1_TYPE RELAY_TYPE_NORMAL + #define RELAY2_TYPE RELAY_TYPE_NORMAL + + // LEDs + #define LED1_PIN 13 + #define LED1_PIN_INVERSE 0 + #define LED_WIFI 0 + + // ----------------------------------------------------------------------------- // Electrodragon boards // ----------------------------------------------------------------------------- diff --git a/code/espurna/hardware.ino b/code/espurna/hardware.ino index f9c1b04a..b290deb6 100644 --- a/code/espurna/hardware.ino +++ b/code/espurna/hardware.ino @@ -566,6 +566,21 @@ void hwUpwardsCompatibility() { setSetting("myDCKIGPIO", 15); setSetting("relays", 1); + #elif defined(YJZK_SWITCH_2CH) + + setSetting("board", 47); + setSetting("ledGPIO", 1, 13); + setSetting("ledLogic", 1, 0); + setSetting("ledWifi", 0); + setSetting("btnGPIO", 1, 0); + setSetting("btnGPIO", 2, 9); + setSetting("btnRelay", 1, 1); + setSetting("btnRelay", 2, 2); + setSetting("relayGPIO", 1, 12); + setSetting("relayGPIO", 2, 5); + setSetting("relayType", 1, RELAY_TYPE_NORMAL); + setSetting("relayType", 2, RELAY_TYPE_NORMAL); + #else #error "UNSUPPORTED HARDWARE!" diff --git a/code/platformio.ini b/code/platformio.ini index 231ec307..886bf020 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -1093,6 +1093,29 @@ upload_port = "192.168.4.1" upload_flags = --auth=fibonacci --port 8266 monitor_baud = 115200 +[env:yjzk-switch-2ch] +platform = ${common.platform} +framework = arduino +board = esp01_1m +board_flash_mode = dout +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +build_flags = ${common.build_flags_1m} -DYJZK_SWITCH_2CH +monitor_baud = 115200 + +[env:yjzk-switch-2ch-ota] +platform = ${common.platform} +framework = arduino +board = esp01_1m +board_flash_mode = dout +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +build_flags = ${common.build_flags_1m} -DYJZK_SWITCH_2CH +upload_speed = 115200 +upload_port = "192.168.4.1" +upload_flags = --auth=fibonacci --port 8266 +monitor_baud = 115200 + # ------------------------------------------------------------------------------ # GENERIC OTA ENVIRONMENTS # ------------------------------------------------------------------------------