From 94ad5d622697089da96f3433db2e8e8139dcab19 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 15 Apr 2022 11:50:55 +0200 Subject: [PATCH] added new light --- include/README | 0 lib/README | 0 platformio.ini | 0 src/credentials.sample.h | 0 src/main.cpp | 31 +++++++++++++++++++++++++++++++ test/README | 0 6 files changed, 31 insertions(+) mode change 100644 => 100755 include/README mode change 100644 => 100755 lib/README mode change 100644 => 100755 platformio.ini mode change 100644 => 100755 src/credentials.sample.h mode change 100644 => 100755 src/main.cpp mode change 100644 => 100755 test/README diff --git a/include/README b/include/README old mode 100644 new mode 100755 diff --git a/lib/README b/lib/README old mode 100644 new mode 100755 diff --git a/platformio.ini b/platformio.ini old mode 100644 new mode 100755 diff --git a/src/credentials.sample.h b/src/credentials.sample.h old mode 100644 new mode 100755 diff --git a/src/main.cpp b/src/main.cpp old mode 100644 new mode 100755 index 9ad5451..e094aa5 --- a/src/main.cpp +++ b/src/main.cpp @@ -31,6 +31,10 @@ int redPin3 = 25; int greenPin3 = 26; int bluePin3 = 32; +int redPin4 = 19; +int greenPin4 = 13; +int bluePin4 = 33; + const int redChannel1 = 0; const int greenChannel1 = 1; const int blueChannel1 = 2; @@ -43,6 +47,10 @@ const int redChannel3 = 6; const int greenChannel3 = 7; const int blueChannel3 = 8; +const int redChannel4 = 9; +const int greenChannel4 = 10; +const int blueChannel4 = 11; + // connect to wifi – returns true if successful or false if not boolean connectWifi(){ boolean state = true; @@ -124,6 +132,20 @@ void cabinetLightChanged(EspalexaDevice* d) { } } +void floorLightChanged(EspalexaDevice* d) { + if (d == nullptr) return; + + if (d->getValue() == 0) { + ledcWrite(redChannel4, 0); + ledcWrite(greenChannel4, 0); + ledcWrite(blueChannel4, 0); + } else { + ledcWrite(redChannel4, lightDimming(d->getR(), d->getValue())); + ledcWrite(greenChannel4, lightDimming(d->getG(), d->getValue())); + ledcWrite(blueChannel4, lightDimming(d->getB(), d->getValue())); + } +} + void ledStripsSetup() { // setup channels ledcSetup(redChannel1, freq, resolution); @@ -137,6 +159,10 @@ void ledStripsSetup() { ledcSetup(redChannel3, freq, resolution); ledcSetup(greenChannel3, freq, resolution); ledcSetup(blueChannel3, freq, resolution); + + ledcSetup(redChannel4, freq, resolution); + ledcSetup(greenChannel4, freq, resolution); + ledcSetup(blueChannel4, freq, resolution); // attach pins ledcAttachPin(redPin1, redChannel1); @@ -150,6 +176,10 @@ void ledStripsSetup() { ledcAttachPin(redPin3, redChannel3); ledcAttachPin(greenPin3, greenChannel3); ledcAttachPin(bluePin3, blueChannel3); + + ledcAttachPin(redPin4, redChannel4); + ledcAttachPin(greenPin4, greenChannel4); + ledcAttachPin(bluePin4, blueChannel4); } void setup() { @@ -163,6 +193,7 @@ void setup() { espalexa.addDevice("arbeitslicht", workingLightChanged, EspalexaDeviceType::color); espalexa.addDevice("monitorlicht", monitorLightChanged, EspalexaDeviceType::color); espalexa.addDevice("schranklicht", cabinetLightChanged, EspalexaDeviceType::color); + espalexa.addDevice("bodenbeleuchtung", floorLightChanged, EspalexaDeviceType::color); espalexa.begin(); } else { diff --git a/test/README b/test/README old mode 100644 new mode 100755