change button to on off for both

This commit is contained in:
interfisch 2022-10-18 22:59:51 +02:00
parent 339085d261
commit cb1acca462
4 changed files with 29 additions and 22 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch

10
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,10 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
],
"unwantedRecommendations": [
"ms-vscode.cpptools-extension-pack"
]
}

View File

@ -3,10 +3,10 @@
"device_id": "ledstoffroehre", "device_id": "ledstoffroehre",
"wifi": { "wifi": {
"ssid": "CTDO-IoT", "ssid": "CTDO-IoT",
"password": "12345678" "password": ""
}, },
"mqtt": { "mqtt": {
"host": "raum.ctdo.de", "host": "mqtt.ctdo.de",
"port": 1883, "port": 1883,
"auth": false "auth": false
}, },

View File

@ -2,8 +2,6 @@
#include<Homie.h> #include<Homie.h>
#include<ArduinoOTA.h> #include<ArduinoOTA.h>
//curl -X PUT http://homie.config/config -d @config.json --header "Content-Type: application/json"
// homie/ledstoffroehre/lamp/fluorescent0/set // homie/ledstoffroehre/lamp/fluorescent0/set
#define PIN_LAMP0_EDGE D5 #define PIN_LAMP0_EDGE D5
@ -22,7 +20,7 @@
//int timeout = (1000 - 50); //int timeout = (1000 - 50);
#define FW_NAME "ledstoffroehre" #define FW_NAME "ledstoffroehre"
#define FW_VERSION "1.0.1" #define FW_VERSION "1.0.2"
@ -58,8 +56,8 @@ int setbrightness0 = 0;
int setbrightness1 = 0; int setbrightness1 = 0;
bool fluorescent0Active=false; bool fluorescent0Active=false;
bool fluorescent1Active=false; bool fluorescent1Active=false;
int fluorescent0Quality=50; // 0 to 100 int fluorescent0Quality=10; // 0 to 100
int fluorescent1Quality=50; int fluorescent1Quality=10;
#define FLUORESCENQUALITYMAX 100 #define FLUORESCENQUALITYMAX 100
#define FLUORESCENTTEMPMAX 1000 #define FLUORESCENTTEMPMAX 1000
int fluorescent0Temp=0; int fluorescent0Temp=0;
@ -80,7 +78,7 @@ int tempincreasemax1=10; //the higher the faster lightup
#define FLASHPROBABILITYMIN_MIN 50 #define FLASHPROBABILITYMIN_MIN 50
#define FLASHPROBABILITYMIN_MAX 100 //should not be more than FLASHPROBABILITY_MIN #define FLASHPROBABILITYMIN_MAX 100 //should not be more than FLASHPROBABILITY_MIN
#define TEMPINCREASEMAX_MIN 1 #define TEMPINCREASEMAX_MIN 1
#define TEMPINCREASEMAX_MAX FLUORESCENTTEMPMAX/5 #define TEMPINCREASEMAX_MAX FLUORESCENTTEMPMAX/20
bool lastSensorValue = false; bool lastSensorValue = false;
@ -322,19 +320,13 @@ void loopHandler()
bool btn0 = debouncer_btn0.read(); bool btn0 = debouncer_btn0.read();
bool btn1 = debouncer_btn1.read(); bool btn1 = debouncer_btn1.read();
if (!btn0){ if (!btn0){ //btn0 turns off
if (setbrightness0==0){
fluorescent0Handler_change("255");
}else{
fluorescent0Handler_change("0"); fluorescent0Handler_change("0");
}
}
if (!btn1){
if (setbrightness1==0){
fluorescent1Handler_change("255");
}else{
fluorescent1Handler_change("0"); fluorescent1Handler_change("0");
} }
if (!btn1){ //btn1 turns of
fluorescent0Handler_change("255");
fluorescent1Handler_change("255");
} }
} }
@ -350,9 +342,9 @@ void setup() {
debouncer_btn0.attach(PIN_BUTTON0, INPUT_PULLUP); debouncer_btn0.attach(PIN_BUTTON0, INPUT_PULLUP);
debouncer_btn0.interval(50); debouncer_btn0.interval(10);
debouncer_btn1.attach(PIN_BUTTON1, INPUT_PULLUP); debouncer_btn1.attach(PIN_BUTTON1, INPUT_PULLUP);
debouncer_btn1.interval(50); debouncer_btn1.interval(10);
debouncer.attach(PIN_SENSOR, INPUT); debouncer.attach(PIN_SENSOR, INPUT);
debouncer.interval(50); debouncer.interval(50);