mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-15 17:52:08 +02:00
fix: Completely turn off LEDbar
This commit is contained in:
@ -485,6 +485,7 @@ private:
|
|||||||
if (EEPROM.readBytes(0, &config, sizeof(config)) != sizeof(config)) {
|
if (EEPROM.readBytes(0, &config, sizeof(config)) != sizeof(config)) {
|
||||||
config.inF = false;
|
config.inF = false;
|
||||||
config.inUSAQI = false;
|
config.inUSAQI = false;
|
||||||
|
config.useRGBLedBar = UseLedBarCO2; // default use LED bar for CO2
|
||||||
memset(config.models, 0, sizeof(config.models));
|
memset(config.models, 0, sizeof(config.models));
|
||||||
memset(config.mqttBrokers, 0, sizeof(config.mqttBrokers));
|
memset(config.mqttBrokers, 0, sizeof(config.mqttBrokers));
|
||||||
|
|
||||||
@ -743,13 +744,17 @@ void setup() {
|
|||||||
/** Show boot display */
|
/** Show boot display */
|
||||||
Serial.println("Firmware Version: " + ag.getVersion());
|
Serial.println("Firmware Version: " + ag.getVersion());
|
||||||
displayShowText("AirGradient ONE", "FW Version: ", ag.getVersion());
|
displayShowText("AirGradient ONE", "FW Version: ", ag.getVersion());
|
||||||
|
|
||||||
|
boardInit();
|
||||||
delay(DISPLAY_DELAY_SHOW_CONTENT_MS);
|
delay(DISPLAY_DELAY_SHOW_CONTENT_MS);
|
||||||
|
|
||||||
/** Init sensor */
|
/** Init sensor */
|
||||||
boardInit();
|
|
||||||
|
|
||||||
/** Init AirGradient server */
|
/** Init AirGradient server */
|
||||||
agServer.begin();
|
agServer.begin();
|
||||||
|
if (agServer.getLedBarMode() == UseLedBarOff) {
|
||||||
|
ag.ledBar.setEnable(false);
|
||||||
|
}
|
||||||
|
|
||||||
/** Run LED test on start up */
|
/** Run LED test on start up */
|
||||||
displayShowText("Press now for", "LED test &", "offline mode");
|
displayShowText("Press now for", "LED test &", "offline mode");
|
||||||
@ -799,6 +804,8 @@ void setup() {
|
|||||||
dispSmHandler(APP_SM_WIFI_OK_SERVER_OK_SENSOR_CONFIG_FAILED);
|
dispSmHandler(APP_SM_WIFI_OK_SERVER_OK_SENSOR_CONFIG_FAILED);
|
||||||
ledSmHandler(APP_SM_WIFI_OK_SERVER_OK_SENSOR_CONFIG_FAILED);
|
ledSmHandler(APP_SM_WIFI_OK_SERVER_OK_SENSOR_CONFIG_FAILED);
|
||||||
delay(DISPLAY_DELAY_SHOW_CONTENT_MS);
|
delay(DISPLAY_DELAY_SHOW_CONTENT_MS);
|
||||||
|
} else {
|
||||||
|
ag.ledBar.setEnable(agServer.getLedBarMode() != UseLedBarOff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1767,6 +1774,9 @@ static void updateServerConfiguration(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update LED bar
|
||||||
|
ag.ledBar.setEnable(agServer.getLedBarMode() != UseLedBarOff);
|
||||||
|
|
||||||
if (agServer.getCo2AbcDaysConfig() > 0) {
|
if (agServer.getCo2AbcDaysConfig() > 0) {
|
||||||
if (hasSensorS8) {
|
if (hasSensorS8) {
|
||||||
int newHour = agServer.getCo2AbcDaysConfig() * 24;
|
int newHour = agServer.getCo2AbcDaysConfig() * 24;
|
||||||
@ -2143,9 +2153,11 @@ static void sensorLedColorHandler(void) {
|
|||||||
case UseLedBarPM:
|
case UseLedBarPM:
|
||||||
setRGBledPMcolor(pm25);
|
setRGBledPMcolor(pm25);
|
||||||
break;
|
break;
|
||||||
|
case UseLedBarOff:
|
||||||
|
ag.ledBar.clear();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
ag.ledBar.setColor(0, 0, 0, ag.ledBar.getNumberOfLeds() - 1);
|
ag.ledBar.clear();
|
||||||
ag.ledBar.setColor(0, 0, 0, ag.ledBar.getNumberOfLeds() - 2);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,6 +115,10 @@ void LedBar::setColor(uint8_t red, uint8_t green, uint8_t blue) {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void LedBar::show(void) {
|
void LedBar::show(void) {
|
||||||
|
// Ignore update the LED if LED bar disabled
|
||||||
|
if (enabled == false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (pixel()->canShow()) {
|
if (pixel()->canShow()) {
|
||||||
pixel()->show();
|
pixel()->show();
|
||||||
}
|
}
|
||||||
@ -125,3 +129,15 @@ void LedBar::show(void) {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void LedBar::clear(void) { pixel()->clear(); }
|
void LedBar::clear(void) { pixel()->clear(); }
|
||||||
|
|
||||||
|
void LedBar::setEnable(bool enable) {
|
||||||
|
if (this->enabled != enable) {
|
||||||
|
if (enable == false) {
|
||||||
|
pixel()->clear();
|
||||||
|
pixel()->show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this->enabled = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LedBar::isEnabled(void) { return enabled; }
|
||||||
|
@ -23,8 +23,11 @@ public:
|
|||||||
int getNumberOfLeds(void);
|
int getNumberOfLeds(void);
|
||||||
void show(void);
|
void show(void);
|
||||||
void clear(void);
|
void clear(void);
|
||||||
|
void setEnable(bool enable);
|
||||||
|
bool isEnabled(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool enabled = true;
|
||||||
const BoardDef *_bsp;
|
const BoardDef *_bsp;
|
||||||
bool _isBegin = false;
|
bool _isBegin = false;
|
||||||
uint8_t _ledState = 0;
|
uint8_t _ledState = 0;
|
||||||
|
Reference in New Issue
Block a user