added new light

master
alex 2022-04-15 11:50:55 +02:00
parent 1b23dc2bb5
commit 94ad5d6226
6 changed files with 31 additions and 0 deletions

0
include/README Normal file → Executable file
View File

0
lib/README Normal file → Executable file
View File

0
platformio.ini Normal file → Executable file
View File

0
src/credentials.sample.h Normal file → Executable file
View File

31
src/main.cpp Normal file → Executable file
View File

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

0
test/README Normal file → Executable file
View File