Skip to content

Commit edf8ba9

Browse files
committed
update BLE_AVAILABLE led blink pattern
fix error blinking period change bluetooth animation with snake animation for startup
1 parent 5054b11 commit edf8ba9

File tree

1 file changed

+83
-5
lines changed

1 file changed

+83
-5
lines changed

src/Utility/LEDFeedback/LEDFeedback.cpp

+83-5
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,73 @@ const uint32_t cloud[][4] = {
4747
}
4848
};
4949

50+
const uint32_t snake[][4] = {
51+
{ 0xffffffff, 0xffffffff, 0xffffffff, 66 },
52+
{ 0x7fffffff, 0xffffffff, 0xfffff7ff, 66 },
53+
{ 0x3fe7ffff, 0xffffffff, 0xff7ff3fe, 66 },
54+
{ 0x1fc3fe7f, 0xfffffff7, 0xff3fe1fc, 66 },
55+
{ 0xf81fc3f, 0xe7ff7ff3, 0xfe1fc0f8, 66 },
56+
{ 0x500f81f, 0xc3fe3fe1, 0xfc0f8070, 66 },
57+
{ 0x500f, 0x81fc1fc0, 0xf8070020, 66 },
58+
{ 0x5, 0xf80f80, 0x70020000, 66 },
59+
{ 0x5, 0xa80880, 0x50020000, 600 },
60+
{ 0xd812, 0x41040880, 0x50020000, 200 },
61+
{ 0x5, 0xa80880, 0x50020000, 600 },
62+
{ 0xd812, 0x41040880, 0x50020000, 200 },
63+
{ 0x5, 0xa80880, 0x50020000, 130 },
64+
{ 0x45, 0xa80880, 0x50020000, 130 },
65+
{ 0x45, 0xa80880, 0x10060000, 130 },
66+
{ 0x45, 0xa80080, 0x100e0000, 130 },
67+
{ 0x45, 0x280080, 0x101e0000, 130 },
68+
{ 0x41, 0x280080, 0x103e0000, 130 },
69+
{ 0x41, 0x80080, 0x107e0000, 130 },
70+
{ 0x40, 0x80084, 0x107e0000, 130 },
71+
{ 0x40, 0x4084, 0x107e0000, 130 },
72+
{ 0x40, 0x4004084, 0x107e0000, 130 },
73+
{ 0x40, 0x4204084, 0x107e0000, 130 },
74+
{ 0x60, 0x4204004, 0x107e0000, 130 },
75+
{ 0x70, 0x4204004, 0x7e0000, 130 },
76+
{ 0x70, 0x5204004, 0x7c0000, 130 },
77+
{ 0x70, 0x5a04004, 0x780000, 130 },
78+
{ 0x70, 0x5e04004, 0x700000, 130 },
79+
{ 0x70, 0x45e04004, 0x700000, 130 },
80+
{ 0x70, 0x45f04004, 0x600000, 130 },
81+
{ 0x71, 0x45f04004, 0x400000, 130 },
82+
{ 0x71, 0xc5f04004, 0x400000, 130 },
83+
{ 0x71, 0xc5f04004, 0x400002, 130 },
84+
{ 0x71, 0xe5f04004, 0x2, 130 },
85+
{ 0x71, 0xe5f24000, 0x2, 130 },
86+
{ 0x71, 0xe5f20020, 0x2, 130 },
87+
{ 0x71, 0xe1f20020, 0x2000002, 130 },
88+
{ 0x71, 0xe1f22020, 0x2002002, 130 },
89+
{ 0x31, 0xe1f22020, 0x2002006, 130 },
90+
{ 0x11, 0xe1f22020, 0x200200e, 130 },
91+
{ 0x1, 0xe1f22020, 0x200201e, 130 },
92+
{ 0x1, 0xe0f22020, 0x200203e, 130 },
93+
{ 0x1, 0xe0722020, 0x200207e, 130 },
94+
{ 0x1, 0xe0322020, 0x20020fe, 130 },
95+
{ 0x1, 0xe0122020, 0x20820fe, 130 },
96+
{ 0x1, 0xe0022020, 0x21820fe, 130 },
97+
{ 0x0, 0xe0022022, 0x221820fe, 130 },
98+
{ 0x0, 0x60022022, 0x221820fe, 130 },
99+
{ 0x0, 0x21022022, 0x221820fe, 130 },
100+
{ 0x0, 0x1822022, 0x221820fe, 130 },
101+
{ 0x0, 0x1802422, 0x2218a0fe, 130 },
102+
{ 0x0, 0x1802402, 0x2218a0fe, 130 },
103+
{ 0x0, 0x1802402, 0x2019a0fe, 130 },
104+
{ 0x0, 0x1802442, 0x201980fe, 130 },
105+
{ 0x0, 0x1802442, 0x241980fc, 130 },
106+
{ 0x4000, 0x1802442, 0x241980f8, 130 },
107+
{ 0x4000, 0x1882442, 0x241980f0, 130 },
108+
{ 0x4000, 0x1982442, 0x241980e0, 130 },
109+
{ 0x4001, 0x1982442, 0x241980c0, 130 },
110+
{ 0x6001, 0x1982442, 0x24198080, 130 },
111+
{ 0x6001, 0x1982442, 0x24198000, 130 },
112+
{ 0x6001, 0x1982442, 0x24198000, 130 },
113+
{ 0x6001, 0x1982442, 0x24198000, 130 },
114+
{ 0x6001, 0x1982442, 0x24198000, 600 }
115+
};
116+
50117
#endif
51118

52119

@@ -55,6 +122,14 @@ const uint32_t cloud[][4] = {
55122
#define SLOWBLINK_INTERVAL 2000
56123
#define ALWAYS_ON_INTERVAL -1
57124

125+
/* The BLE_AVAILABLE animation follows the pattern:
126+
* _|¯|_|¯|_|¯¯¯¯¯¯¯¯¯¯¯|_
127+
* HIGH: led on
128+
* LOW: led off
129+
*/
130+
#define N_IMPULSES_START_ON_PERIOD 5
131+
#define N_IMPULSES_END_ON_PERIOD 15
132+
58133
LEDFeedbackClass &LEDFeedbackClass::getInstance() {
59134
static LEDFeedbackClass instance;
60135
return instance;
@@ -116,8 +191,9 @@ void LEDFeedbackClass::setMode(LEDFeedbackMode mode) {
116191
_ledPin = GREEN_LED;
117192
#endif
118193
#ifdef BOARD_HAS_LED_MATRIX
119-
matrix.loadFrame(bluetooth);
120-
_framePtr = (uint32_t*)bluetooth;
194+
_framePtr = nullptr;
195+
matrix.loadSequence(snake);
196+
matrix.play(true);
121197
#endif
122198
_ledChangeInterval = HEARTBEAT_INTERVAL;
123199
_count = 0;
@@ -172,14 +248,15 @@ void LEDFeedbackClass::setMode(LEDFeedbackMode mode) {
172248
#ifdef BOARD_HAS_RGB
173249
turnOFF();
174250
_ledPin = RED_LED;
251+
_ledChangeInterval = SLOWBLINK_INTERVAL;
175252
#else
176253
_ledPin = GREEN_LED;
254+
_ledChangeInterval = FASTBLINK_INTERVAL;
177255
#endif
178256
#ifdef BOARD_HAS_LED_MATRIX
179257
_framePtr = (uint32_t*)LEDMATRIX_EMOJI_SAD;
180258
matrix.loadFrame(LEDMATRIX_EMOJI_SAD);
181259
#endif
182-
_ledChangeInterval = FASTBLINK_INTERVAL;
183260
}
184261
break;
185262
default:
@@ -212,16 +289,17 @@ void LEDFeedbackClass::update() {
212289

213290
if(millis() - _lastUpdate > _ledChangeInterval/2) {
214291
_lastUpdate = millis();
292+
//Implement the pattern for BLE_AVAILABLE
215293
if(_mode == LEDFeedbackMode::BLE_AVAILABLE) {
216294
if (_count == 0){
217295
turnOFF();
218296
_count++;
219297
return;
220-
}else if(_count >= 5 && _count < 15){
298+
}else if(_count >= N_IMPULSES_START_ON_PERIOD && _count < N_IMPULSES_END_ON_PERIOD){
221299
turnON();
222300
_count++;
223301
return;
224-
}else if(_count >= 15){
302+
}else if(_count >= N_IMPULSES_END_ON_PERIOD){
225303
_count = 0;
226304
return;
227305
}else{

0 commit comments

Comments
 (0)