From 289c8cb49cc0fedadece424e959ae8b7c42d34c3 Mon Sep 17 00:00:00 2001 From: "Alex. Tircovnicu" Date: Mon, 2 Nov 2020 20:14:52 +0100 Subject: [PATCH] hardware: add support for Gosund P1 Power Strip (#2391) --- code/espurna/board.cpp | 4 +++ code/espurna/config/arduino.h | 1 + code/espurna/config/hardware.h | 57 ++++++++++++++++++++++++++++++++++ code/platformio.ini | 4 +++ 4 files changed, 66 insertions(+) diff --git a/code/espurna/board.cpp b/code/espurna/board.cpp index ccceadc6..406454d2 100644 --- a/code/espurna/board.cpp +++ b/code/espurna/board.cpp @@ -688,6 +688,10 @@ int getBoardId() { return 158; #elif defined(PRODINO_WIFI) return 159; + #elif defined(GOSUND_SP111) + return 160; + #elif defined(GOSUND_P1) + return 161; #else return -1; // CUSTOM #endif diff --git a/code/espurna/config/arduino.h b/code/espurna/config/arduino.h index 17a0cf5f..5b7d50b7 100644 --- a/code/espurna/config/arduino.h +++ b/code/espurna/config/arduino.h @@ -66,6 +66,7 @@ //#define GENERIC_V9261F //#define GIZWITS_WITTY_CLOUD //#define GOSUND_SP111 +//#define GOSUND_P1 //#define GOSUND_WP3 //#define GOSUND_WS1 //#define GREEN_ESP8266RELAY diff --git a/code/espurna/config/hardware.h b/code/espurna/config/hardware.h index a8920804..f5354ccf 100644 --- a/code/espurna/config/hardware.h +++ b/code/espurna/config/hardware.h @@ -3464,6 +3464,63 @@ #define HLW8012_POWER_RATIO 3414290 #define HLW8012_INTERRUPT_ON FALLING +// ---------------------------------------------------------------------------------------- +// Power strip 15A - 3 Sockets + 3 USB ports +// This device uses just one digital button (main one). All other three buttons are connected +// to the ADC pin via resistors with different values. This approach is known under the name of +// "Resistor Ladder" - https://en.wikipedia.org/wiki/Resistor_ladder +// https://www.amazon.de/-/en/gp/product/B085XXCPRD +// ---------------------------------------------------------------------------------------- + +#elif defined(GOSUND_P1) + + // Info + #define MANUFACTURER "GOSUND" + #define DEVICE "P1" + + + //Enable this to view buttons analog level. + //#define ANALOG_SUPPORT 1 + + // Disable UART noise + #define DEBUG_SERIAL_SUPPORT 0 + + // Buttons + #define BUTTON_PROVIDER_ANALOG_SUPPORT 1 + #define BUTTON1_PIN 16 + #define BUTTON1_CONFIG BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH + #define BUTTON1_RELAY 4 + + #define BUTTON2_PIN 17 + #define BUTTON2_RELAY 3 + #define BUTTON2_PROVIDER BUTTON_PROVIDER_ANALOG + #define BUTTON2_ANALOG_LEVEL 220 + + #define BUTTON3_PIN 17 + #define BUTTON3_RELAY 2 + #define BUTTON3_PROVIDER BUTTON_PROVIDER_ANALOG + #define BUTTON3_ANALOG_LEVEL 470 + + #define BUTTON4_PIN 17 + #define BUTTON4_RELAY 1 + #define BUTTON4_PROVIDER BUTTON_PROVIDER_ANALOG + #define BUTTON4_ANALOG_LEVEL 730 + + // Relays + #define RELAY1_PIN 14 + #define RELAY2_PIN 12 + #define RELAY3_PIN 13 + #define RELAY4_PIN 5 + #define RELAY4_TYPE RELAY_TYPE_INVERSE + + // LEDs + #define LED1_PIN 2 + #define LED1_PIN_INVERSE 1 + + // CSE7766 + #define CSE7766_SUPPORT 1 + #define CSE7766_RX_PIN 3 + // ---------------------------------------------------------------------------------------- // Homecube 16A is similar but some pins differ and it also has RGB LEDs // https://www.amazon.de/gp/product/B07D7RVF56/ref=oh_aui_detailpage_o00_s01?ie=UTF8&psc=1 diff --git a/code/platformio.ini b/code/platformio.ini index 5bebedea..d71a4f84 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -873,6 +873,10 @@ src_build_flags = -DGOSUND_WS1 extends = env:esp8266-1m-base src_build_flags = -DGOSUND_SP111 +[env:gosund-p1] +extends = env:esp8266-1m-base +src_build_flags = -DGOSUND_P1 + [env:digoo-nx-sp202] extends = env:esp8266-1m-base src_build_flags = -DDIGOO_NX_SP202