move project to platformio, untested

This commit is contained in:
interfisch 2022-10-18 22:18:11 +02:00
parent 5f97df2ab9
commit 339085d261
3 changed files with 97 additions and 5 deletions

46
lib/README Normal file
View File

@ -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 <Foo.h>
#include <Bar.h>
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

23
platformio.ini Normal file
View File

@ -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

View File

@ -1,5 +1,6 @@
#include <Homie.h> #include<Arduino.h>
#include <ArduinoOTA.h> #include<Homie.h>
#include<ArduinoOTA.h>
//curl -X PUT http://homie.config/config -d @config.json --header "Content-Type: application/json" //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" #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 lamp0e=0;
int lamp0=0; int lamp0=0;
int lamp1e=0; int lamp1e=0;
@ -65,8 +85,8 @@ int tempincreasemax1=10; //the higher the faster lightup
bool lastSensorValue = false; bool lastSensorValue = false;
HomieNode lightNode("lamp", "lamp"); HomieNode lightNode("lamp", "lamp", "lamp");
HomieNode sensorNode("sensor", "sensor"); HomieNode sensorNode("sensor", "sensor","sensor");
Bounce debouncer = Bounce(); Bounce debouncer = Bounce();
Bounce debouncer_btn0 = Bounce(); Bounce debouncer_btn0 = Bounce();
@ -132,6 +152,7 @@ bool fluorescent1Handler_change(String value){
} }
void resetLamp0(){ void resetLamp0(){
fluorescent0Active = false; //set effect off fluorescent0Active = false; //set effect off
fluorescent0LastActivated = millis(); fluorescent0LastActivated = millis();
@ -195,6 +216,8 @@ bool lamp0Handler(const HomieRange& range, const String& value) {
return true; return true;
} }
bool lamp1Handler(const HomieRange& range, const String& value) { bool lamp1Handler(const HomieRange& range, const String& value) {
Homie.getLogger() << "lamp1 " << ": " << value << endl; Homie.getLogger() << "lamp1 " << ": " << value << endl;
lamp1 = value.toInt(); lamp1 = value.toInt();