mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-15 08:56:34 +02:00
fix: Completely turn off LEDbar
This commit is contained in:
@ -112,9 +112,13 @@ void LedBar::setColor(uint8_t red, uint8_t green, uint8_t blue) {
|
||||
|
||||
/**
|
||||
* @brief Call to turn LED on/off base on the setting color
|
||||
*
|
||||
*
|
||||
*/
|
||||
void LedBar::show(void) {
|
||||
// Ignore update the LED if LED bar disabled
|
||||
if (enabled == false) {
|
||||
return;
|
||||
}
|
||||
if (pixel()->canShow()) {
|
||||
pixel()->show();
|
||||
}
|
||||
@ -122,6 +126,18 @@ void LedBar::show(void) {
|
||||
|
||||
/**
|
||||
* @brief Set all LED to off color (r,g,b) = (0,0,0)
|
||||
*
|
||||
*
|
||||
*/
|
||||
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);
|
||||
void show(void);
|
||||
void clear(void);
|
||||
void setEnable(bool enable);
|
||||
bool isEnabled(void);
|
||||
|
||||
private:
|
||||
bool enabled = true;
|
||||
const BoardDef *_bsp;
|
||||
bool _isBegin = false;
|
||||
uint8_t _ledState = 0;
|
||||
|
Reference in New Issue
Block a user