добавляет HALightColorTemperatureBrightness
This commit is contained in:
@@ -42,6 +42,35 @@ void IRLight::setBrightness(int newBrightness) {
|
||||
brightness = newBrightness;
|
||||
}
|
||||
|
||||
void IRLight::setColorTemperature(int color) {
|
||||
if (color < 208) {
|
||||
color_temp = 2;
|
||||
brightness = 14;
|
||||
irsend->sendRaw(RDButtonB, 67, 38);
|
||||
} else if (color < 294) {
|
||||
color_temp = 1;
|
||||
brightness = 14;
|
||||
irsend->sendRaw(RDButtonCenter, 67, 38);
|
||||
} else {
|
||||
color_temp = 0;
|
||||
brightness = 14;
|
||||
irsend->sendRaw(RDButtonA, 67, 38);
|
||||
}
|
||||
}
|
||||
|
||||
int IRLight::getColorTemperature() {
|
||||
switch (color_temp)
|
||||
{
|
||||
case 0:
|
||||
return 370;
|
||||
case 1:
|
||||
return 262;
|
||||
case 2:
|
||||
return 154;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void IRLight::brightnessUp() {
|
||||
if (brightness < getBrightnessScale()) {
|
||||
brightness++;
|
||||
@@ -58,8 +87,9 @@ void IRLight::brightnessDown() {
|
||||
|
||||
void IRLight::begin() {
|
||||
irsend->begin();
|
||||
irsend->sendRaw(RDCentralButton, 67, 38);
|
||||
brightness = 14;
|
||||
color_temp = 1;
|
||||
irsend->sendRaw(RDButtonCenter, 67, 38);
|
||||
delay(250);
|
||||
off();
|
||||
}
|
||||
|
15
src/main.cpp
15
src/main.cpp
@@ -55,8 +55,9 @@ PubSubClient client(espClient);
|
||||
DHT dht(DHTPIN, DHTTYPE);
|
||||
|
||||
IRLight irlight(4);
|
||||
HALightBrightness halight(client, "light", "l-1", irlight);
|
||||
HALightColorTemperatureBrightness halight(client, "light", "l-1", irlight);
|
||||
|
||||
void setup_devices();
|
||||
void setup_wifi();
|
||||
void setup_time();
|
||||
void setup_mqtt();
|
||||
@@ -76,9 +77,7 @@ void setup()
|
||||
Serial.begin(115200);
|
||||
delay(1000);
|
||||
|
||||
irlight.begin();
|
||||
dht.begin();
|
||||
|
||||
setup_devices();
|
||||
setup_wifi();
|
||||
setup_time();
|
||||
setup_mqtt();
|
||||
@@ -110,6 +109,12 @@ void loop()
|
||||
delay(100);
|
||||
}
|
||||
|
||||
void setup_devices()
|
||||
{
|
||||
irlight.begin();
|
||||
dht.begin();
|
||||
}
|
||||
|
||||
void setup_wifi()
|
||||
{
|
||||
delay(10);
|
||||
@@ -192,8 +197,6 @@ void reconnect()
|
||||
}
|
||||
}
|
||||
|
||||
const int unused = 0;
|
||||
|
||||
void mqtt_callback(char *topic, byte *payload, unsigned int length)
|
||||
{
|
||||
Serial.print("Message arrived [");
|
||||
|
Reference in New Issue
Block a user