GosundSP111
This commit is contained in:
parent
e604f90a14
commit
71490427f2
@ -1,19 +1,50 @@
|
||||
[env:Sonoff4ChPro]
|
||||
[common]
|
||||
platform = espressif8266
|
||||
board = esp8285
|
||||
framework = arduino
|
||||
upload_speed = 921600
|
||||
upload_port = 10.0.0.178
|
||||
monitor_speed = 115200
|
||||
build.filesystem = littlefs
|
||||
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
|
||||
board = esp32dev
|
||||
framework = arduino
|
||||
upload_speed = 921600
|
||||
monitor_speed = 115200
|
||||
build.filesystem = littlefs
|
||||
lib_deps = bblanchon/ArduinoJson @ 7.4.2
|
||||
build_flags = -D STATUS_PIN=2 -D STATUS_INVERT=false -D CORE_DEBUG_LEVEL=0
|
||||
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 Sonoff4ChPro -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 CORE_DEBUG_LEVEL=0
|
||||
@ -46,7 +46,7 @@ void listDir(const String &path, const String &indent) {
|
||||
|
||||
void configSetup() {
|
||||
#ifdef ESP32
|
||||
LittleFS.begin(true)
|
||||
LittleFS.begin(true);
|
||||
#endif
|
||||
#ifdef ESP8266
|
||||
if (!LittleFS.begin()) {
|
||||
|
||||
@ -82,9 +82,11 @@ void httpStatus() {
|
||||
|
||||
const auto relays = json["relays"].to<JsonArray>();
|
||||
httpRelayJson(relay0, relays.add<JsonObject>());
|
||||
#ifdef Sonoff4ChPro
|
||||
httpRelayJson(relay1, relays.add<JsonObject>());
|
||||
httpRelayJson(relay2, relays.add<JsonObject>());
|
||||
httpRelayJson(relay3, relays.add<JsonObject>());
|
||||
#endif
|
||||
|
||||
String response;
|
||||
serializeJson(json, response);
|
||||
@ -93,17 +95,21 @@ void httpStatus() {
|
||||
|
||||
void httpSet() {
|
||||
httpRelay(0, relay0);
|
||||
#ifdef Sonoff4ChPro
|
||||
httpRelay(1, relay1);
|
||||
httpRelay(2, relay2);
|
||||
httpRelay(3, relay3);
|
||||
#endif
|
||||
httpStatus();
|
||||
}
|
||||
|
||||
void httpOff() {
|
||||
relay0.set(false);
|
||||
#ifdef Sonoff4ChPro
|
||||
relay1.set(false);
|
||||
relay2.set(false);
|
||||
relay3.set(false);
|
||||
#endif
|
||||
httpStatus();
|
||||
}
|
||||
|
||||
|
||||
34
src/io.cpp
34
src/io.cpp
@ -1,22 +1,18 @@
|
||||
#include "io.h"
|
||||
|
||||
#ifndef STATUS_PIN
|
||||
#define STATUS_PIN 13
|
||||
#ifdef GosundSP111
|
||||
|
||||
Output status("Status", 0, true, false);
|
||||
|
||||
Button button0(13, true, true, [](const ButtonEvent event) { buttonCallback(relay0, event); });
|
||||
|
||||
Relay relay0(0, "RELAY #0", 15, false, true);
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef STATUS_INVERT
|
||||
#define STATUS_INVERT true
|
||||
#endif
|
||||
#ifdef Sonoff4ChPro
|
||||
|
||||
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);
|
||||
|
||||
Output status("Status", STATUS_PIN, STATUS_INVERT, false);
|
||||
Output status("Status", 13, true, false);
|
||||
|
||||
Button button0(0, true, true, [](const ButtonEvent event) { buttonCallback(relay0, event); });
|
||||
|
||||
@ -26,6 +22,16 @@ Button button2(10, true, true, [](const ButtonEvent event) { buttonCallback(rela
|
||||
|
||||
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
|
||||
|
||||
void buttonCallback(Output &output, const ButtonEvent event) {
|
||||
if (event == BUTTON_PRESSED) {
|
||||
output.toggle();
|
||||
|
||||
38
src/io.h
38
src/io.h
@ -6,50 +6,54 @@
|
||||
|
||||
void buttonCallback(Output &output, ButtonEvent event);
|
||||
|
||||
extern Relay relay0;
|
||||
|
||||
extern Relay relay1;
|
||||
|
||||
extern Relay relay2;
|
||||
|
||||
extern Relay relay3;
|
||||
|
||||
extern Output status;
|
||||
|
||||
extern Button button0;
|
||||
|
||||
extern Relay relay0;
|
||||
|
||||
#ifdef Sonoff4ChPro
|
||||
|
||||
extern Button button1;
|
||||
|
||||
extern Button button2;
|
||||
|
||||
extern Button button3;
|
||||
|
||||
extern Relay relay1;
|
||||
|
||||
extern Relay relay2;
|
||||
|
||||
extern Relay relay3;
|
||||
|
||||
#endif
|
||||
|
||||
inline void ioSetup() {
|
||||
status.setup();
|
||||
button0.setup();
|
||||
relay0.setup();
|
||||
#ifdef Sonoff4ChPro
|
||||
button1.setup();
|
||||
button2.setup();
|
||||
button3.setup();
|
||||
|
||||
status.setup();
|
||||
|
||||
relay0.setup();
|
||||
relay1.setup();
|
||||
relay2.setup();
|
||||
relay3.setup();
|
||||
#endif
|
||||
}
|
||||
|
||||
inline void ioLoop() {
|
||||
status.loop();
|
||||
button0.loop();
|
||||
relay0.loop();
|
||||
#ifdef Sonoff4ChPro
|
||||
button1.loop();
|
||||
button2.loop();
|
||||
button3.loop();
|
||||
|
||||
status.loop();
|
||||
|
||||
relay0.loop();
|
||||
relay0.loop();
|
||||
relay1.loop();
|
||||
relay2.loop();
|
||||
relay3.loop();
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -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/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/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/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"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user