From dc9664924041e9f3355a5cb554cc4c4b36d8b74b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Tue, 5 Dec 2017 15:58:58 +0100 Subject: [PATCH] Support for Sonoff Dual R2 --- code/espurna/config/hardware.h | 26 ++++++++++++++++++++++++++ code/espurna/hardware.ino | 16 ++++++++++++++++ code/platformio.ini | 21 +++++++++++++++++++++ 3 files changed, 63 insertions(+) diff --git a/code/espurna/config/hardware.h b/code/espurna/config/hardware.h index d205707b..2c6e5f00 100644 --- a/code/espurna/config/hardware.h +++ b/code/espurna/config/hardware.h @@ -330,6 +330,32 @@ #define LED1_PIN 13 #define LED1_PIN_INVERSE 1 +#elif defined(ITEAD_SONOFF_DUAL_R2) + + #define MANUFACTURER "ITEAD" + #define DEVICE "SONOFF_DUAL_R2" + + // Buttons + #define BUTTON1_PIN 0 + #define BUTTON2_PIN 9 + #define BUTTON3_PIN 10 + #define BUTTON1_RELAY 1 + #define BUTTON2_RELAY 2 + #define BUTTON3_RELAY 1 + #define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH + #define BUTTON2_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH + #define BUTTON3_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH + + // 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 1 + #elif defined(ITEAD_SONOFF_4CH) // Info diff --git a/code/espurna/hardware.ino b/code/espurna/hardware.ino index 6830466b..b8612fc8 100644 --- a/code/espurna/hardware.ino +++ b/code/espurna/hardware.ino @@ -587,6 +587,22 @@ void hwUpwardsCompatibility() { setSetting("relayType", 1, RELAY_TYPE_NORMAL); setSetting("relayType", 2, RELAY_TYPE_NORMAL); + #elif defined(ITEAD_SONOFF_DUAL_R2) + + setSetting("board", 48); + setSetting("ledGPIO", 1, 13); + setSetting("ledLogic", 1, 1); + setSetting("btnGPIO", 1, 0); + setSetting("btnGPIO", 2, 9); + setSetting("btnGPIO", 3, 10); + setSetting("btnRelay", 1, 1); + setSetting("btnRelay", 2, 2); + setSetting("btnRelay", 3, 1); + 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 6091fd53..b5aff57b 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -296,6 +296,27 @@ upload_speed = 115200 upload_port = "192.168.4.1" upload_flags = --auth=fibonacci --port 8266 +[env:itead-sonoff-dual-r2] +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} -DITEAD_SONOFF_DUAL_R2 + +[env:itead-sonoff-dual-ota-r2] +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} -DITEAD_SONOFF_DUAL_R2 +upload_speed = 115200 +upload_port = "192.168.4.1" +upload_flags = --auth=fibonacci --port 8266 + [env:itead-sonoff-4ch] platform = ${common.platform} framework = arduino