From 3e84c832387cdf1849fa09ae9ac4ae59b56260aa Mon Sep 17 00:00:00 2001 From: Martijn Bakker Date: Tue, 5 Sep 2017 20:56:17 +0200 Subject: [PATCH] Add Huacanxing H802 support --- code/espurna/config/arduino.h | 1 + code/espurna/config/hardware.h | 24 ++++++++++++++++++++++++ code/espurna/hardware.ino | 15 +++++++++++++++ code/platformio.ini | 23 +++++++++++++++++++++++ 4 files changed, 63 insertions(+) diff --git a/code/espurna/config/arduino.h b/code/espurna/config/arduino.h index 856456ac..d2afba64 100644 --- a/code/espurna/config/arduino.h +++ b/code/espurna/config/arduino.h @@ -39,6 +39,7 @@ //#define JANGOE_WIFI_RELAY_NO //#define JORGEGARCIA_WIFI_RELAYS //#define OPENENERGYMONITOR_MQTT_RELAY +//#define HUACANXING_H802 //-------------------------------------------------------------------------------- // Features (values below are non-default values) diff --git a/code/espurna/config/hardware.h b/code/espurna/config/hardware.h index bdfad3a7..50c7787f 100644 --- a/code/espurna/config/hardware.h +++ b/code/espurna/config/hardware.h @@ -809,6 +809,30 @@ #define RELAY1_TYPE RELAY_TYPE_LATCHED #define RELAY1_RESET_PIN 12 +// ----------------------------------------------------------------------------- +// HUACANXING H802 +// ----------------------------------------------------------------------------- + +#elif defined(HUACANXING_H802) + + // Info + #define MANUFACTURER "HUACANXING" + #define DEVICE "H802" + #define RELAY_PROVIDER RELAY_PROVIDER_LIGHT + #define LIGHT_PROVIDER LIGHT_PROVIDER_DIMMER + #define DUMMY_RELAY_COUNT 1 + + // Channels + #define LIGHT_CH1_PIN 12 // RED + #define LIGHT_CH2_PIN 14 // GREEN + #define LIGHT_CH3_PIN 13 // BLUE + #define LIGHT_CH4_PIN 15 // WHITE + + #define LIGHT_CH1_INVERSE 0 + #define LIGHT_CH2_INVERSE 0 + #define LIGHT_CH3_INVERSE 0 + #define LIGHT_CH4_INVERSE 0 + // ----------------------------------------------------------------------------- // Unknown hardware // ----------------------------------------------------------------------------- diff --git a/code/espurna/hardware.ino b/code/espurna/hardware.ino index d465a487..e38ae2df 100644 --- a/code/espurna/hardware.ino +++ b/code/espurna/hardware.ino @@ -419,6 +419,21 @@ void hwUpwardsCompatibility() { setSetting("relayResetGPIO", 1, 12); setSetting("relayType", 1, RELAY_TYPE_NORMAL); + #elif defined(HUACANXING_H802) + + setSetting("board", 36); + setSetting("relayProvider", RELAY_PROVIDER_LIGHT); + setSetting("lightProvider", LIGHT_PROVIDER_DIMMER); + setSetting("chGPIO", 1, 12); + setSetting("chGPIO", 2, 14); + setSetting("chGPIO", 3, 13); + setSetting("chGPIO", 4, 15); + setSetting("chLogic", 1, 0); + setSetting("chLogic", 2, 0); + setSetting("chLogic", 3, 0); + setSetting("chLogic", 4, 0); + setSetting("relays", 1); + #else #error "UNSUPPORTED HARDWARE!" diff --git a/code/platformio.ini b/code/platformio.ini index 3dbc4734..006c26e9 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -831,3 +831,26 @@ build_flags = ${common.build_flags} -D${env.BOARD} upload_speed = 115200 upload_port = "${env.IP}" upload_flags = --auth=${env.AUTH} --port 8266 + +[env:huacanxing-h802] +platform = espressif8266 +framework = arduino +board = esp01_1m +board_flash_mode = dout +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +build_flags = -g -Wl,-Tesp8266.flash.1m0.ld -DHUACANXING_H802 -DDEBUG_PORT=Serial1 +monitor_baud = 115200 + +[env:huacanxing-h802-ota] +platform = espressif8266 +framework = arduino +board = esp01_1m +board_flash_mode = dout +lib_deps = ${common.lib_deps} +lib_ignore = ${common.lib_ignore} +build_flags = -g -Wl,-Tesp8266.flash.1m0.ld -DHUACANXING_H802 -DDEBUG_PORT=Serial1 +upload_speed = 115200 +upload_port = "192.168.4.1" +upload_flags = --auth=fibonacci --port 8266 +monitor_baud = 115200