Skip to content

Commit 1363869

Browse files
committed
use define and add documentation for BLE_AVAILABLE led blink pattern
fix error blinking period
1 parent 5054b11 commit 1363869

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/Utility/LEDFeedback/LEDFeedback.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ const uint32_t cloud[][4] = {
5555
#define SLOWBLINK_INTERVAL 2000
5656
#define ALWAYS_ON_INTERVAL -1
5757

58+
/* The BLE_AVAILABLE animation follows the pattern:
59+
* _|¯|_|¯|_|¯¯¯¯¯¯¯¯¯¯¯|_
60+
* HIGH: led on
61+
* LOW: led off
62+
*/
63+
#define N_IMPULSES_START_ON_PERIOD 5
64+
#define N_IMPULSES_END_ON_PERIOD 15
65+
5866
LEDFeedbackClass &LEDFeedbackClass::getInstance() {
5967
static LEDFeedbackClass instance;
6068
return instance;
@@ -172,14 +180,15 @@ void LEDFeedbackClass::setMode(LEDFeedbackMode mode) {
172180
#ifdef BOARD_HAS_RGB
173181
turnOFF();
174182
_ledPin = RED_LED;
183+
_ledChangeInterval = SLOWBLINK_INTERVAL;
175184
#else
176185
_ledPin = GREEN_LED;
186+
_ledChangeInterval = FASTBLINK_INTERVAL;
177187
#endif
178188
#ifdef BOARD_HAS_LED_MATRIX
179189
_framePtr = (uint32_t*)LEDMATRIX_EMOJI_SAD;
180190
matrix.loadFrame(LEDMATRIX_EMOJI_SAD);
181191
#endif
182-
_ledChangeInterval = FASTBLINK_INTERVAL;
183192
}
184193
break;
185194
default:
@@ -212,16 +221,17 @@ void LEDFeedbackClass::update() {
212221

213222
if(millis() - _lastUpdate > _ledChangeInterval/2) {
214223
_lastUpdate = millis();
224+
//Implement the pattern for BLE_AVAILABLE
215225
if(_mode == LEDFeedbackMode::BLE_AVAILABLE) {
216226
if (_count == 0){
217227
turnOFF();
218228
_count++;
219229
return;
220-
}else if(_count >= 5 && _count < 15){
230+
}else if(_count >= N_IMPULSES_START_ON_PERIOD && _count < N_IMPULSES_END_ON_PERIOD){
221231
turnON();
222232
_count++;
223233
return;
224-
}else if(_count >= 15){
234+
}else if(_count >= N_IMPULSES_END_ON_PERIOD){
225235
_count = 0;
226236
return;
227237
}else{

0 commit comments

Comments
 (0)