mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-15 17:52:08 +02:00
Merge pull request #138 from airgradienthq/hotfix/ledbar-flickers
Fix LED bar flickers
This commit is contained in:
@ -467,9 +467,10 @@ static void ledBarEnabledUpdate(void) {
|
|||||||
if ((brightness == 0) || (configuration.getLedBarMode() == LedBarModeOff)) {
|
if ((brightness == 0) || (configuration.getLedBarMode() == LedBarModeOff)) {
|
||||||
ag->ledBar.setEnable(false);
|
ag->ledBar.setEnable(false);
|
||||||
} else {
|
} else {
|
||||||
ag->ledBar.setBrighness(brightness);
|
ag->ledBar.setBrightness(brightness);
|
||||||
ag->ledBar.setEnable(configuration.getLedBarMode() != LedBarModeOff);
|
ag->ledBar.setEnable(configuration.getLedBarMode() != LedBarModeOff);
|
||||||
}
|
}
|
||||||
|
ag->ledBar.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -812,10 +813,6 @@ static void configUpdateHandle() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ag->isOne()) {
|
|
||||||
ledBarEnabledUpdate();
|
|
||||||
stateMachine.executeLedBarTest();
|
|
||||||
}
|
|
||||||
stateMachine.executeCo2Calibration();
|
stateMachine.executeCo2Calibration();
|
||||||
|
|
||||||
String mqttUri = configuration.getMqttBrokerUri();
|
String mqttUri = configuration.getMqttBrokerUri();
|
||||||
@ -851,15 +848,36 @@ static void configUpdateHandle() {
|
|||||||
|
|
||||||
if (ag->isOne()) {
|
if (ag->isOne()) {
|
||||||
if (configuration.isLedBarBrightnessChanged()) {
|
if (configuration.isLedBarBrightnessChanged()) {
|
||||||
ag->ledBar.setBrighness(configuration.getLedBarBrightness());
|
if (configuration.getLedBarBrightness() == 0) {
|
||||||
Serial.println("Set 'LedBarBrightness' brightness: " +
|
ag->ledBar.setEnable(false);
|
||||||
String(configuration.getLedBarBrightness()));
|
} else {
|
||||||
|
if (configuration.getLedBarMode() != LedBarMode::LedBarModeOff) {
|
||||||
|
ag->ledBar.setEnable(true);
|
||||||
|
}
|
||||||
|
ag->ledBar.setBrightness(configuration.getLedBarBrightness());
|
||||||
|
}
|
||||||
|
ag->ledBar.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (configuration.isLedBarModeChanged()) {
|
||||||
|
if (configuration.getLedBarBrightness() == 0) {
|
||||||
|
ag->ledBar.setEnable(false);
|
||||||
|
} else {
|
||||||
|
if(configuration.getLedBarMode() == LedBarMode::LedBarModeOff) {
|
||||||
|
ag->ledBar.setEnable(false);
|
||||||
|
} else {
|
||||||
|
ag->ledBar.setEnable(true);
|
||||||
|
ag->ledBar.setBrightness(configuration.getLedBarBrightness());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ag->ledBar.show();
|
||||||
|
}
|
||||||
|
|
||||||
if (configuration.isDisplayBrightnessChanged()) {
|
if (configuration.isDisplayBrightnessChanged()) {
|
||||||
oledDisplay.setBrightness(configuration.getDisplayBrightness());
|
oledDisplay.setBrightness(configuration.getDisplayBrightness());
|
||||||
Serial.println("Set 'DisplayBrightness' brightness: " +
|
|
||||||
String(configuration.getDisplayBrightness()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stateMachine.executeLedBarTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
fwNewVersion = configuration.newFirmwareVersion();
|
fwNewVersion = configuration.newFirmwareVersion();
|
||||||
|
@ -372,6 +372,7 @@ bool Configuration::parse(String data, bool isLocal) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_ledBarModeChanged = false;
|
||||||
if (JSON.typeof_(root[jprop_ledBarMode]) == "string") {
|
if (JSON.typeof_(root[jprop_ledBarMode]) == "string") {
|
||||||
String mode = root[jprop_ledBarMode];
|
String mode = root[jprop_ledBarMode];
|
||||||
if (mode == getLedBarModeName(LedBarMode::LedBarModeCO2) ||
|
if (mode == getLedBarModeName(LedBarMode::LedBarModeCO2) ||
|
||||||
@ -380,6 +381,7 @@ bool Configuration::parse(String data, bool isLocal) {
|
|||||||
String oldMode = jconfig[jprop_ledBarMode];
|
String oldMode = jconfig[jprop_ledBarMode];
|
||||||
if (mode != oldMode) {
|
if (mode != oldMode) {
|
||||||
jconfig[jprop_ledBarMode] = mode;
|
jconfig[jprop_ledBarMode] = mode;
|
||||||
|
_ledBarModeChanged = true;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -559,6 +561,7 @@ bool Configuration::parse(String data, bool isLocal) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ledBarBrightnessChanged = false;
|
||||||
if (JSON.typeof_(root[jprop_ledBarBrightness]) == "number") {
|
if (JSON.typeof_(root[jprop_ledBarBrightness]) == "number") {
|
||||||
int value = root[jprop_ledBarBrightness];
|
int value = root[jprop_ledBarBrightness];
|
||||||
int oldValue = jconfig[jprop_ledBarBrightness];
|
int oldValue = jconfig[jprop_ledBarBrightness];
|
||||||
@ -1147,6 +1150,12 @@ void Configuration::setOfflineModeWithoutSave(bool offline) {
|
|||||||
_offlineMode = offline;
|
_offlineMode = offline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Configuration::isLedBarModeChanged(void) {
|
||||||
|
bool changed = _ledBarModeChanged;
|
||||||
|
_ledBarModeChanged = false;
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
bool Configuration::isDisplayBrightnessChanged(void) {
|
bool Configuration::isDisplayBrightnessChanged(void) {
|
||||||
bool changed = displayBrightnessChanged;
|
bool changed = displayBrightnessChanged;
|
||||||
displayBrightnessChanged = false;
|
displayBrightnessChanged = false;
|
||||||
|
@ -18,6 +18,7 @@ private:
|
|||||||
bool displayBrightnessChanged = false;
|
bool displayBrightnessChanged = false;
|
||||||
String otaNewFirmwareVersion;
|
String otaNewFirmwareVersion;
|
||||||
bool _offlineMode = false;
|
bool _offlineMode = false;
|
||||||
|
bool _ledBarModeChanged = false;
|
||||||
|
|
||||||
AirGradient* ag;
|
AirGradient* ag;
|
||||||
|
|
||||||
@ -80,6 +81,7 @@ public:
|
|||||||
bool isOfflineMode(void);
|
bool isOfflineMode(void);
|
||||||
void setOfflineMode(bool offline);
|
void setOfflineMode(bool offline);
|
||||||
void setOfflineModeWithoutSave(bool offline);
|
void setOfflineModeWithoutSave(bool offline);
|
||||||
|
bool isLedBarModeChanged(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /** _AG_CONFIG_H_ */
|
#endif /** _AG_CONFIG_H_ */
|
||||||
|
@ -64,7 +64,7 @@ void LedBar::setColor(uint8_t red, uint8_t green, uint8_t blue, int ledNum) {
|
|||||||
*
|
*
|
||||||
* @param brightness Brightness (0 - 100)%
|
* @param brightness Brightness (0 - 100)%
|
||||||
*/
|
*/
|
||||||
void LedBar::setBrighness(uint8_t brightness) {
|
void LedBar::setBrightness(uint8_t brightness) {
|
||||||
if (this->isBegin() == false) {
|
if (this->isBegin() == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ public:
|
|||||||
void begin(void);
|
void begin(void);
|
||||||
void setColor(uint8_t red, uint8_t green, uint8_t blue, int ledNum);
|
void setColor(uint8_t red, uint8_t green, uint8_t blue, int ledNum);
|
||||||
void setColor(uint8_t red, uint8_t green, uint8_t blue);
|
void setColor(uint8_t red, uint8_t green, uint8_t blue);
|
||||||
void setBrighness(uint8_t brightness);
|
void setBrightness(uint8_t brightness);
|
||||||
int getNumberOfLeds(void);
|
int getNumberOfLeds(void);
|
||||||
void show(void);
|
void show(void);
|
||||||
void clear(void);
|
void clear(void);
|
||||||
|
Reference in New Issue
Block a user