fix brightness event spam, add configuration backdoor in mqtt events
This commit is contained in:
parent
92d5e73bd8
commit
9a3bf84214
@ -60,8 +60,6 @@ ConfigService::onStart()
|
||||
m_config.save();
|
||||
}
|
||||
m_coordMap = m_config.toCoordMap();
|
||||
//m_coordMap.pixelCount = min(HardwareConfig::MAX_LED_NUM, max(1, m_config.data.pixelCount));
|
||||
//m_coordMap.startPixel = min(m_coordMap.pixelCount, max(0, m_config.data.startPixel));
|
||||
|
||||
m_pixelCount = AnimatedNumber{max(1, m_coordMap.pixelCount)};
|
||||
m_startPixel = AnimatedNumber{max(0, m_coordMap.startPixel)};
|
||||
|
@ -3,15 +3,19 @@
|
||||
#include "./Figments/Figments.h"
|
||||
|
||||
struct HardwareConfig {
|
||||
uint8_t version = 1;
|
||||
uint8_t version = 2;
|
||||
uint8_t checksum = 0;
|
||||
struct TaskState {
|
||||
char name[16] = {0};
|
||||
bool isRunning = false;
|
||||
bool isDisabled = false;
|
||||
};
|
||||
struct Data {
|
||||
uint16_t pixelCount = 255;
|
||||
uint16_t startPixel = 0;
|
||||
uint8_t lastRed = 255;
|
||||
uint8_t lastGreen = 255;
|
||||
uint8_t lastBlue = 255;
|
||||
char lastScene[16] = {0};
|
||||
TaskState serviceStates[32];
|
||||
};
|
||||
Data data;
|
||||
|
@ -37,7 +37,8 @@ using namespace NSFastLED;
|
||||
#define MAX_BRIGHTNESS 255
|
||||
//#define PSU_MILLIAMPS 4800
|
||||
//#define PSU_MILLIAMPS 500
|
||||
#define PSU_MILLIAMPS 1000
|
||||
//#define PSU_MILLIAMPS 1000
|
||||
#define PSU_MILLIAMPS 2000
|
||||
|
||||
// Enable system thread, so rendering happens while booting
|
||||
SYSTEM_THREAD(ENABLED);
|
||||
@ -276,6 +277,8 @@ class MQTTTelemetry : public BufferedInputSource, OnlineTaskMixin {
|
||||
writer.name("SSID").value(WiFi.SSID());
|
||||
//writer.name("MAC").value(WiFi.macAddress());
|
||||
writer.name("localip").value(WiFi.localIP().toString());
|
||||
writer.name("startPixel").value(Static<ConfigService>::instance()->coordMap()->startPixel);
|
||||
writer.name("pixelCount").value(Static<ConfigService>::instance()->coordMap()->pixelCount);
|
||||
writer.endObject();
|
||||
writer.buffer()[std::min(writer.bufferSize(), writer.dataSize())] = 0;
|
||||
m_client.publish(m_attrTopic, heartbeatBuf);
|
||||
@ -369,6 +372,18 @@ class MQTTTelemetry : public BufferedInputSource, OnlineTaskMixin {
|
||||
strcpy(m_patternBuf, (const char*) cmdIter.value().toString());
|
||||
setEvent(InputEvent{InputEvent::SetPattern, m_patternBuf});
|
||||
}
|
||||
|
||||
if (cmdIter.name() == "pixelCount") {
|
||||
setEvent(InputEvent{InputEvent::SetDisplayLength, cmdIter.value().toInt()});
|
||||
}
|
||||
|
||||
if (cmdIter.name() == "startPixel") {
|
||||
setEvent(InputEvent{InputEvent::SetDisplayOffset, cmdIter.value().toInt()});
|
||||
}
|
||||
|
||||
if (cmdIter.name() == "save") {
|
||||
setEvent(InputEvent{InputEvent::SaveConfigurationRequest});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -557,6 +572,7 @@ InputFunc circadianRhythm([]() {
|
||||
needsUpdate = true;
|
||||
}
|
||||
if (needsUpdate) {
|
||||
needsUpdate = false;
|
||||
return InputEvent{InputEvent::SetBrightness, brightnessForTime(Time.hour(), Time.minute())};
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user