From 339085d2619b9fb286eccfc39d41a363fd36d85c Mon Sep 17 00:00:00 2001 From: Fisch Date: Tue, 18 Oct 2022 22:18:11 +0200 Subject: [PATCH] move project to platformio, untested --- lib/README | 46 ++++++++++++++++++++++++++++++ platformio.ini | 23 +++++++++++++++ LEDstoffroehre.ino => src/main.cpp | 33 +++++++++++++++++---- 3 files changed, 97 insertions(+), 5 deletions(-) create mode 100644 lib/README create mode 100644 platformio.ini rename LEDstoffroehre.ino => src/main.cpp (91%) diff --git a/lib/README b/lib/README new file mode 100644 index 0000000..6debab1 --- /dev/null +++ b/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +PlatformIO Library Dependency Finder will find automatically dependent +libraries scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 0000000..d467c56 --- /dev/null +++ b/platformio.ini @@ -0,0 +1,23 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:d1_mini] +platform = espressif8266 @ 2.5.0 #using old esp version, because of "obsolete API, use ::begin(WiFiClient, url)" error. Try again if fix available in platformio over vscode +board = d1_mini +framework = arduino + +monitor_port = /dev/ttyUSB0 +monitor_speed = 115200 + + +lib_deps = + ArduinoJson@6.16.1 #dependency of homie. using older version because of "ambiguous overload for operator|" error + Homie@3.0.0 + thomasfredericks/Bounce2@^2.71 \ No newline at end of file diff --git a/LEDstoffroehre.ino b/src/main.cpp similarity index 91% rename from LEDstoffroehre.ino rename to src/main.cpp index 40d9d28..305523c 100644 --- a/LEDstoffroehre.ino +++ b/src/main.cpp @@ -1,5 +1,6 @@ -#include -#include +#include +#include +#include //curl -X PUT http://homie.config/config -d @config.json --header "Content-Type: application/json" @@ -24,6 +25,25 @@ #define FW_VERSION "1.0.1" + +bool fluorescentHandler(const HomieRange& range, const String& value); +void resetLamp1(); +void resetLamp0(); +void loopHandler(); +void output(); +bool lamp1Handler(const HomieRange& range, const String& value); +bool lamp0Handler(const HomieRange& range, const String& value); +bool lampHandler(const HomieRange& range, const String& value); +bool fluorescent1QualityHandler(const HomieRange& range, const String& value); +bool fluorescent0QualityHandler(const HomieRange& range, const String& value); +bool fluorescentQualityHandler(const HomieRange& range, const String& value); +bool fluorescent1Handler_change(String value); +bool fluorescent1Handler(const HomieRange& range, const String& value); +bool fluorescent0Handler_change(String value); +bool fluorescent0Handler(const HomieRange& range, const String& value); + + + int lamp0e=0; int lamp0=0; int lamp1e=0; @@ -65,8 +85,8 @@ int tempincreasemax1=10; //the higher the faster lightup bool lastSensorValue = false; -HomieNode lightNode("lamp", "lamp"); -HomieNode sensorNode("sensor", "sensor"); +HomieNode lightNode("lamp", "lamp", "lamp"); +HomieNode sensorNode("sensor", "sensor","sensor"); Bounce debouncer = Bounce(); Bounce debouncer_btn0 = Bounce(); @@ -132,6 +152,7 @@ bool fluorescent1Handler_change(String value){ } + void resetLamp0(){ fluorescent0Active = false; //set effect off fluorescent0LastActivated = millis(); @@ -195,6 +216,8 @@ bool lamp0Handler(const HomieRange& range, const String& value) { return true; } + + bool lamp1Handler(const HomieRange& range, const String& value) { Homie.getLogger() << "lamp1 " << ": " << value << endl; lamp1 = value.toInt(); @@ -371,4 +394,4 @@ void loop() { ArduinoOTA.handle(); -} +} \ No newline at end of file