GosundSP111

This commit is contained in:
Patrick Haßel 2025-08-30 08:15:26 +02:00
parent e604f90a14
commit ae1c6f5cda
6 changed files with 105 additions and 40 deletions

View File

@ -1,19 +1,50 @@
[env:Sonoff4ChPro] [common]
platform = espressif8266 platform = espressif8266
board = esp8285 board = esp8285
framework = arduino framework = arduino
upload_speed = 921600 upload_speed = 921600
upload_port = 10.0.0.178
monitor_speed = 115200 monitor_speed = 115200
build.filesystem = littlefs build.filesystem = littlefs
lib_deps = bblanchon/ArduinoJson @ 7.4.2 lib_deps = bblanchon/ArduinoJson @ 7.4.2
[env:ESP32Test] [env:Sonoff4ChPro]
platform = ${common.platform}
board = ${common.board}
framework = ${common.framework}
upload_speed = ${common.upload_speed}
monitor_speed = ${common.monitor_speed}
build.filesystem = ${common.build.filesystem}
lib_deps = ${common.lib_deps}
upload_port = 10.0.0.178
build_flags = -D Sonoff4ChPro
[env:Sonoff4ChPro_ESP32]
platform = espressif32 platform = espressif32
board = esp32dev board = esp32dev
framework = arduino framework = ${common.framework}
upload_speed = 921600 upload_speed = ${common.upload_speed}
monitor_speed = 115200 monitor_speed = ${common.monitor_speed}
build.filesystem = littlefs build.filesystem = ${common.build.filesystem}
lib_deps = bblanchon/ArduinoJson @ 7.4.2 lib_deps = ${common.lib_deps}
build_flags = -D STATUS_PIN=2 -D STATUS_INVERT=false -D CORE_DEBUG_LEVEL=0 build_flags = -D Sonoff4ChPro -D ESP32_TESTBOARD -D CORE_DEBUG_LEVEL=0
[env:GosundSP111]
platform = ${common.platform}
board = ${common.board}
framework = ${common.framework}
upload_speed = ${common.upload_speed}
monitor_speed = ${common.monitor_speed}
build.filesystem = ${common.build.filesystem}
lib_deps = ${common.lib_deps}
upload_port = 10.0.0.179
build_flags = -D GosundSP111
[env:GosundSP111_ESP32]
platform = espressif32
board = esp32dev
framework = ${common.framework}
upload_speed = ${common.upload_speed}
monitor_speed = ${common.monitor_speed}
build.filesystem = ${common.build.filesystem}
lib_deps = ${common.lib_deps}
build_flags = -D GosundSP111 -D ESP32_TESTBOARD -D CORE_DEBUG_LEVEL=0

View File

@ -46,7 +46,7 @@ void listDir(const String &path, const String &indent) {
void configSetup() { void configSetup() {
#ifdef ESP32 #ifdef ESP32
LittleFS.begin(true) LittleFS.begin(true);
#endif #endif
#ifdef ESP8266 #ifdef ESP8266
if (!LittleFS.begin()) { if (!LittleFS.begin()) {

View File

@ -82,9 +82,11 @@ void httpStatus() {
const auto relays = json["relays"].to<JsonArray>(); const auto relays = json["relays"].to<JsonArray>();
httpRelayJson(relay0, relays.add<JsonObject>()); httpRelayJson(relay0, relays.add<JsonObject>());
#ifdef Sonoff4ChPro
httpRelayJson(relay1, relays.add<JsonObject>()); httpRelayJson(relay1, relays.add<JsonObject>());
httpRelayJson(relay2, relays.add<JsonObject>()); httpRelayJson(relay2, relays.add<JsonObject>());
httpRelayJson(relay3, relays.add<JsonObject>()); httpRelayJson(relay3, relays.add<JsonObject>());
#endif
String response; String response;
serializeJson(json, response); serializeJson(json, response);
@ -93,17 +95,21 @@ void httpStatus() {
void httpSet() { void httpSet() {
httpRelay(0, relay0); httpRelay(0, relay0);
#ifdef Sonoff4ChPro
httpRelay(1, relay1); httpRelay(1, relay1);
httpRelay(2, relay2); httpRelay(2, relay2);
httpRelay(3, relay3); httpRelay(3, relay3);
#endif
httpStatus(); httpStatus();
} }
void httpOff() { void httpOff() {
relay0.set(false); relay0.set(false);
#ifdef Sonoff4ChPro
relay1.set(false); relay1.set(false);
relay2.set(false); relay2.set(false);
relay3.set(false); relay3.set(false);
#endif
httpStatus(); httpStatus();
} }

View File

@ -1,22 +1,26 @@
#include "io.h" #include "io.h"
#ifndef STATUS_PIN #ifdef GosundSP111
#define STATUS_PIN 13
#endif
#ifndef STATUS_INVERT #ifndef ESP32_TESTBOARD
#define STATUS_PIN 0
#define STATUS_INVERT true #define STATUS_INVERT true
#endif #endif
Relay relay0(0, "RELAY #0", 12, false, true); Button button0(13, true, true, [](const ButtonEvent event) { buttonCallback(relay0, event); });
Relay relay1(1, "RELAY #1", 5, false, true); Relay relay0(0, "RELAY #0", 15, false, true);
Relay relay2(2, "RELAY #2", 4, false, true); #endif
Relay relay3(3, "RELAY #3", 15, false, true); #ifdef Sonoff4ChPro
Output status("Status", STATUS_PIN, STATUS_INVERT, false); #ifndef ESP32_TESTBOARD
#define STATUS_PIN 13
#define STATUS_INVERT true
#endif
Output status("Status", 13, true, false);
Button button0(0, true, true, [](const ButtonEvent event) { buttonCallback(relay0, event); }); Button button0(0, true, true, [](const ButtonEvent event) { buttonCallback(relay0, event); });
@ -26,6 +30,23 @@ Button button2(10, true, true, [](const ButtonEvent event) { buttonCallback(rela
Button button3(14, true, true, [](const ButtonEvent event) { buttonCallback(relay3, event); }); Button button3(14, true, true, [](const ButtonEvent event) { buttonCallback(relay3, event); });
Relay relay0(0, "RELAY #0", 12, false, true);
Relay relay1(1, "RELAY #1", 5, false, true);
Relay relay2(2, "RELAY #2", 4, false, true);
Relay relay3(3, "RELAY #3", 15, false, true);
#endif
#ifdef ESP32_TESTBOARD
#define STATUS_PIN 2
#define STATUS_INVERT false
#endif
Output status("Status", STATUS_PIN, STATUS_INVERT, true);
void buttonCallback(Output &output, const ButtonEvent event) { void buttonCallback(Output &output, const ButtonEvent event) {
if (event == BUTTON_PRESSED) { if (event == BUTTON_PRESSED) {
output.toggle(); output.toggle();

View File

@ -6,50 +6,54 @@
void buttonCallback(Output &output, ButtonEvent event); void buttonCallback(Output &output, ButtonEvent event);
extern Relay relay0;
extern Relay relay1;
extern Relay relay2;
extern Relay relay3;
extern Output status; extern Output status;
extern Button button0; extern Button button0;
extern Relay relay0;
#ifdef Sonoff4ChPro
extern Button button1; extern Button button1;
extern Button button2; extern Button button2;
extern Button button3; extern Button button3;
extern Relay relay1;
extern Relay relay2;
extern Relay relay3;
#endif
inline void ioSetup() { inline void ioSetup() {
status.setup();
button0.setup(); button0.setup();
relay0.setup();
#ifdef Sonoff4ChPro
button1.setup(); button1.setup();
button2.setup(); button2.setup();
button3.setup(); button3.setup();
status.setup();
relay0.setup();
relay1.setup(); relay1.setup();
relay2.setup(); relay2.setup();
relay3.setup(); relay3.setup();
#endif
} }
inline void ioLoop() { inline void ioLoop() {
status.loop();
button0.loop(); button0.loop();
relay0.loop();
#ifdef Sonoff4ChPro
button1.loop(); button1.loop();
button2.loop(); button2.loop();
button3.loop(); button3.loop();
relay1.loop();
status.loop();
relay0.loop();
relay0.loop();
relay2.loop(); relay2.loop();
relay3.loop(); relay3.loop();
#endif
} }
#endif #endif

View File

@ -7,5 +7,8 @@ minify index.html | sed 's|http://10.42.0.204||g' > index.html.min || exit 2
#curl -s 'http://10.42.0.204/upload/index' -F "file=@index.html.min" #curl -s 'http://10.42.0.204/upload/index' -F "file=@index.html.min"
#curl -s 'http://10.42.0.204/upload/icon' -F "file=@icon.svg" #curl -s 'http://10.42.0.204/upload/icon' -F "file=@icon.svg"
curl -s 'http://10.0.0.178/upload/index' -F "file=@index.html.min" #curl -s 'http://10.0.0.178/upload/index' -F "file=@index.html.min"
curl -s 'http://10.0.0.178/upload/icon' -F "file=@icon.svg" #curl -s 'http://10.0.0.178/upload/icon' -F "file=@icon.svg"
curl -s 'http://10.0.0.174/upload/index' -F "file=@index.html.min"
curl -s 'http://10.0.0.174/upload/icon' -F "file=@icon.svg"