Sensor entfernt

This commit is contained in:
starcalc 2018-04-28 17:10:50 +02:00
parent 2571f871d3
commit 4c07244426
1 changed files with 5 additions and 25 deletions

View File

@ -6,12 +6,10 @@
#include "NeoPatterns.h"
#define PIN D1
#define SENSOR D0
#define NUMPIXELS 80
bool lastSensorValue = false;
#define FW_NAME "esp-schild"
#define FW_VERSION "1.0.1"
void StripComplete(){
return;
@ -20,9 +18,6 @@ void StripComplete(){
NeoPatterns pixels = NeoPatterns(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800,&StripComplete);
HomieNode stripNode("strip", "strip");
HomieNode sensorNode("sensor", "sensor");
Bounce debouncer = Bounce();
bool onSetColor(const HomieRange& range, const String& value){
if (!range.isRange || range.index < 0 || range.index > 1) {
@ -39,9 +34,6 @@ bool onSetColor(const HomieRange& range, const String& value){
stripNode.setProperty("color_" + String(range.index)).send(value);
}
bool onSetPixel(const HomieRange& range, const String& value){
if(!range.isRange) {
pixels.None();
@ -115,22 +107,13 @@ bool onSetLength(const HomieRange& range, const String& value){
void loopHandler() {
pixels.Update();
bool sensorValue = debouncer.read();
if (Homie.isConfigured() && Homie.isConnected() && sensorValue != lastSensorValue) {
sensorNode.setProperty("motion").send(sensorValue ? "true" : "false");
lastSensorValue = sensorValue;
}
}
void setup() {
Serial.begin(115200);
debouncer.attach(SENSOR,INPUT);
debouncer.interval(50);
Homie_setFirmware("schild", "1.0.0");
Homie_setFirmware(FW_NAME, FW_VERSION);
Homie_setBrand(FW_NAME);
Homie.setLoopFunction(loopHandler);
stripNode.advertiseRange("pixel", 0, NUMPIXELS-1).settable(onSetPixel);
@ -140,8 +123,6 @@ void setup() {
stripNode.advertise("clear").settable(onSetClear);
stripNode.advertise("length").settable(onSetLength);
sensorNode.advertise("motion");
pixels.begin();
pixels.clear();
pixels.setBrightness(64);
@ -150,7 +131,7 @@ void setup() {
Homie.setup();
ArduinoOTA.setHostname(Homie.getConfiguration().deviceId);
ArduinoOTA.setPassword((const char *)"ctdo2342");
// ArduinoOTA.setPassword((const char *)"ctdo2342");
ArduinoOTA.onStart([]() {
pixels.clear();
});
@ -166,6 +147,5 @@ void setup() {
void loop() {
Homie.loop();
debouncer.update();
ArduinoOTA.handle();
}