change button to on off for both
This commit is contained in:
parent
339085d261
commit
cb1acca462
|
@ -0,0 +1,5 @@
|
||||||
|
.pio
|
||||||
|
.vscode/.browse.c_cpp.db*
|
||||||
|
.vscode/c_cpp_properties.json
|
||||||
|
.vscode/launch.json
|
||||||
|
.vscode/ipch
|
|
@ -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"
|
||||||
|
]
|
||||||
|
}
|
|
@ -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
|
||||||
},
|
},
|
||||||
|
|
32
src/main.cpp
32
src/main.cpp
|
@ -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("0");
|
||||||
fluorescent0Handler_change("255");
|
fluorescent1Handler_change("0");
|
||||||
}else{
|
|
||||||
fluorescent0Handler_change("0");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!btn1){
|
if (!btn1){ //btn1 turns of
|
||||||
if (setbrightness1==0){
|
fluorescent0Handler_change("255");
|
||||||
fluorescent1Handler_change("255");
|
fluorescent1Handler_change("255");
|
||||||
}else{
|
|
||||||
fluorescent1Handler_change("0");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
|
Loading…
Reference in New Issue