add Indicators
This commit is contained in:
@@ -12,12 +12,14 @@
|
||||
WiFiClient espClient;
|
||||
uint8_t lastBrightness;
|
||||
HADevice device;
|
||||
HAMqtt mqtt(espClient, device, 22);
|
||||
HAMqtt mqtt(espClient, device, 25);
|
||||
|
||||
unsigned long reconnectTimer = 0;
|
||||
const unsigned long reconnectInterval = 30000; // 30 Sekunden
|
||||
|
||||
HALight *Matrix = nullptr;
|
||||
HALight *Indikator1 = nullptr;
|
||||
HALight *Indikator2 = nullptr;
|
||||
HASelect *BriMode = nullptr;
|
||||
HAButton *dismiss = nullptr;
|
||||
HAButton *nextApp = nullptr;
|
||||
@@ -101,23 +103,45 @@ void onSelectCommand(int8_t index, HASelect *sender)
|
||||
|
||||
void onRGBColorCommand(HALight::RGBColor color, HALight *sender)
|
||||
{
|
||||
TEXTCOLOR_565 = ((color.red & 0x1F) << 11) | ((color.green & 0x3F) << 5) | (color.blue & 0x1F);
|
||||
saveSettings();
|
||||
if (sender == Matrix)
|
||||
{
|
||||
TEXTCOLOR_565 = ((color.red & 0x1F) << 11) | ((color.green & 0x3F) << 5) | (color.blue & 0x1F);
|
||||
saveSettings();
|
||||
}
|
||||
else if (sender == Indikator1)
|
||||
{
|
||||
DisplayManager.setIndicator1(true, ((color.red & 0x1F) << 11) | ((color.green & 0x3F) << 5) | (color.blue & 0x1F));
|
||||
}
|
||||
else if (sender == Indikator2)
|
||||
{
|
||||
DisplayManager.setIndicator2(true, ((color.red & 0x1F) << 11) | ((color.green & 0x3F) << 5) | (color.blue & 0x1F));
|
||||
}
|
||||
sender->setRGBColor(color); // report color back to the Home Assistant
|
||||
}
|
||||
|
||||
void onStateCommand(bool state, HALight *sender)
|
||||
{
|
||||
if (state)
|
||||
if (sender == Matrix)
|
||||
{
|
||||
MATRIX_OFF = false;
|
||||
DisplayManager.setBrightness(lastBrightness);
|
||||
if (state)
|
||||
{
|
||||
MATRIX_OFF = false;
|
||||
DisplayManager.setBrightness(lastBrightness);
|
||||
}
|
||||
else
|
||||
{
|
||||
MATRIX_OFF = true;
|
||||
lastBrightness = BRIGHTNESS;
|
||||
DisplayManager.setBrightness(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (sender == Indikator1)
|
||||
{
|
||||
MATRIX_OFF = true;
|
||||
lastBrightness = BRIGHTNESS;
|
||||
DisplayManager.setBrightness(0);
|
||||
DisplayManager.setIndicator1(state, 0);
|
||||
}
|
||||
else if (sender == Indikator2)
|
||||
{
|
||||
DisplayManager.setIndicator2(state, 0);
|
||||
}
|
||||
|
||||
sender->setState(state);
|
||||
@@ -265,7 +289,7 @@ void connect()
|
||||
}
|
||||
}
|
||||
|
||||
char matID[40], briID[40];
|
||||
char matID[40], ind1ID[40], ind2ID[40], briID[40];
|
||||
char btnAID[40], btnBID[40], btnCID[40], appID[40], tempID[40], humID[40], luxID[40], verID[40], ramID[40], upID[40], sigID[40], btnLID[40], btnMID[40], btnRID[40], transID[40], updateID[40], doUpdateID[40];
|
||||
#ifdef ULANZI
|
||||
char batID[40];
|
||||
@@ -304,6 +328,20 @@ void MQTTManager_::setup()
|
||||
Matrix->setCurrentState(true);
|
||||
Matrix->setBRIGHTNESS(BRIGHTNESS);
|
||||
|
||||
sprintf(ind1ID, HAi1ID, macStr);
|
||||
Indikator1 = new HALight(ind1ID, HALight::RGBFeature);
|
||||
Indikator1->setIcon(HAi1Icon);
|
||||
Indikator1->setName(HAi1Name);
|
||||
Indikator1->onStateCommand(onStateCommand);
|
||||
Indikator1->onRGBColorCommand(onRGBColorCommand);
|
||||
|
||||
sprintf(ind2ID, HAi2ID, macStr);
|
||||
Indikator2 = new HALight(ind2ID, HALight::RGBFeature);
|
||||
Indikator2->setIcon(HAi2Icon);
|
||||
Indikator2->setName(HAi2Name);
|
||||
Indikator2->onStateCommand(onStateCommand);
|
||||
Indikator2->onRGBColorCommand(onRGBColorCommand);
|
||||
|
||||
HALight::RGBColor color;
|
||||
color.red = (TEXTCOLOR_565 >> 11) << 3;
|
||||
color.green = ((TEXTCOLOR_565 >> 5) & 0x3F) << 2;
|
||||
|
||||
Reference in New Issue
Block a user