From fc5937fa9ba026213bd93fac9ee91c44f2edcb0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Fri, 18 Aug 2017 15:49:39 +0200 Subject: [PATCH] Support for Sonoff 4CH PRO --- code/espurna/config/hardware.h | 27 +++++++++++++++++++++++++++ code/espurna/hardware.ino | 22 ++++++++++++++++++++++ code/platformio.ini | 23 ++++++++++++++++++++++- 3 files changed, 71 insertions(+), 1 deletion(-) diff --git a/code/espurna/config/hardware.h b/code/espurna/config/hardware.h index fa38822d..c68354c4 100644 --- a/code/espurna/config/hardware.h +++ b/code/espurna/config/hardware.h @@ -190,6 +190,33 @@ #define LED1_PIN 13 #define LED1_PIN_INVERSE 1 +#elif defined(SONOFF_4CH_PRO) + + #define MANUFACTURER "ITEAD" + #define DEVICE "SONOFF_4CH_PRO" + #define BUTTON1_PIN 0 + #define BUTTON1_RELAY 1 + #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH + #define BUTTON2_PIN 9 + #define BUTTON2_RELAY 2 + #define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH + #define BUTTON3_PIN 10 + #define BUTTON3_RELAY 3 + #define BUTTON3_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH + #define BUTTON4_PIN 14 + #define BUTTON4_RELAY 4 + #define BUTTON4_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH + #define RELAY1_PIN 12 + #define RELAY1_PIN_INVERSE 0 + #define RELAY2_PIN 5 + #define RELAY2_PIN_INVERSE 0 + #define RELAY3_PIN 4 + #define RELAY3_PIN_INVERSE 0 + #define RELAY4_PIN 15 + #define RELAY4_PIN_INVERSE 0 + #define LED1_PIN 13 + #define LED1_PIN_INVERSE 1 + #elif defined(ITEAD_1CH_INCHING) // The inching functionality is managed by a misterious IC in the board. diff --git a/code/espurna/hardware.ino b/code/espurna/hardware.ino index fca50029..c29cc594 100644 --- a/code/espurna/hardware.ino +++ b/code/espurna/hardware.ino @@ -292,6 +292,28 @@ void hwUpwardsCompatibility() { setSetting("relayProvider", RELAY_PROVIDER_RFBRIDGE); #endif + #ifdef SONOFF_4CH_PRO + setSetting("board", 27); + setSetting("ledGPIO", 1, 13); + setSetting("ledLogic", 1, 1); + setSetting("btnGPIO", 1, 0); + setSetting("btnGPIO", 2, 9); + setSetting("btnGPIO", 3, 10); + setSetting("btnGPIO", 4, 14); + setSetting("btnRelay", 1, 2); + setSetting("btnRelay", 2, 3); + setSetting("btnRelay", 3, 4); + setSetting("btnRelay", 4, 0); + setSetting("relayGPIO", 1, 12); + setSetting("relayGPIO", 2, 5); + setSetting("relayGPIO", 3, 4); + setSetting("relayGPIO", 4, 15); + setSetting("relayLogic", 1, 0); + setSetting("relayLogic", 2, 0); + setSetting("relayLogic", 3, 0); + setSetting("relayLogic", 4, 0); + #endif + saveSettings(); } diff --git a/code/platformio.ini b/code/platformio.ini index 1743e8f6..03fcc812 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -1,4 +1,4 @@ -[platformio] +4ch[platformio] env_default = d1-debug src_dir = espurna data_dir = espurna/data @@ -199,6 +199,27 @@ upload_speed = 115200 upload_port = "192.168.4.1" upload_flags = --auth=fibonacci --port 8266 +[env:sonoff-4ch-pro-debug] +platform = espressif8266 +framework = arduino +board = esp8285 +board_flash_mode = dout +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +build_flags = ${common.build_flags_1m} -DSONOFF_4CH_PRO + +[env:sonoff-4ch-pro-debug-ota] +platform = espressif8266 +framework = arduino +board = esp8285 +board_flash_mode = dout +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +build_flags = ${common.build_flags_1m} -DSONOFF_4CH_PRO +upload_speed = 115200 +upload_port = "192.168.4.1" +upload_flags = --auth=fibonacci --port 8266 + [env:sonoff-touch-debug] platform = espressif8266 framework = arduino