Skip to content

Commit 2de4d65

Browse files
committed
add new animation for board connected with Serial or with BLE
1 parent 4bcfe6a commit 2de4d65

File tree

3 files changed

+53
-22
lines changed

3 files changed

+53
-22
lines changed

src/configuratorAgents/AgentsManager.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,15 @@ AgentsManagerStates AgentsManagerClass::handleInit() {
239239
(*agent)->end();
240240
}
241241
}
242-
LEDFeedbackClass::getInstance().setMode(LEDFeedbackClass::LEDFeedbackMode::PEER_CONNECTED);
242+
243+
if(_selectedAgent->getAgentType() == ConfiguratorAgent::AgentTypes::BLE) {
244+
LEDFeedbackClass::getInstance().setMode(LEDFeedbackClass::LEDFeedbackMode::PEER_CONNECTED_BLE);
245+
} else if(_selectedAgent->getAgentType() == ConfiguratorAgent::AgentTypes::USB_SERIAL) {
246+
LEDFeedbackClass::getInstance().setMode(LEDFeedbackClass::LEDFeedbackMode::PEER_CONNECTED_SERIAL);
247+
} else {
248+
LEDFeedbackClass::getInstance().setMode(LEDFeedbackClass::LEDFeedbackMode::PEER_CONNECTED);
249+
}
250+
243251
}
244252
return nextState;
245253
}

src/utility/LEDFeedback.cpp

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@
1919
#include "Arduino_LED_Matrix.h"
2020

2121
ArduinoLEDMatrix ledMatrixAnimationHandler;
22+
23+
const uint32_t usb_image[3] = {
24+
0x3c,
25+
0x267fe0,
26+
0x160e0000,
27+
28+
};
29+
2230
const uint32_t bluetooth[3] = {
2331

2432
0x401600d,
@@ -28,22 +36,16 @@ const uint32_t bluetooth[3] = {
2836

2937
const uint32_t cloud[][4] = {
3038
{
31-
0xc013,
32-
0x82644424,
33-
0x24023fc,
34-
66
35-
},
36-
{
37-
0xc013,
38-
0x82644424,
39-
0x24023fc,
40-
66
39+
0x1c023,
40+
0x4484044,
41+
0x43f8000,
42+
500
4143
},
4244
{
43-
0xc013,
44-
0x82644824,
45-
0x24023fc,
46-
66
45+
0xe011,
46+
0x82242022,
47+
0x21fc000,
48+
500
4749
}
4850
};
4951

@@ -204,17 +206,25 @@ void LEDFeedbackClass::setMode(LEDFeedbackMode mode) {
204206
break;
205207
case LEDFeedbackMode::PEER_CONNECTED:
206208
{
207-
#ifdef BOARD_HAS_RGB
208-
turnOFF();
209-
_ledPin = BLUE_LED;
210-
#else
211-
_ledPin = GREEN_LED;
212-
#endif
209+
configurePeerConnectedMode();
210+
}
211+
break;
212+
case LEDFeedbackMode::PEER_CONNECTED_BLE:
213+
{
214+
configurePeerConnectedMode();
213215
#ifdef BOARD_HAS_LED_MATRIX
214216
ledMatrixAnimationHandler.loadFrame(bluetooth);
215217
_framePtr = (uint32_t*)bluetooth;
216218
#endif
217-
_ledChangeInterval = ALWAYS_ON_INTERVAL;
219+
}
220+
break;
221+
case LEDFeedbackMode::PEER_CONNECTED_SERIAL:
222+
{
223+
configurePeerConnectedMode();
224+
#ifdef BOARD_HAS_LED_MATRIX
225+
ledMatrixAnimationHandler.loadFrame(usb_image);
226+
_framePtr = (uint32_t*)usb_image;
227+
#endif
218228
}
219229
break;
220230
case LEDFeedbackMode::CONNECTING_TO_NETWORK:
@@ -348,4 +358,14 @@ void LEDFeedbackClass::turnON() {
348358
_ledState = true;
349359
}
350360

361+
void LEDFeedbackClass::configurePeerConnectedMode() {
362+
#ifdef BOARD_HAS_RGB
363+
turnOFF();
364+
_ledPin = BLUE_LED;
365+
#else
366+
_ledPin = GREEN_LED;
367+
#endif
368+
_ledChangeInterval = ALWAYS_ON_INTERVAL;
369+
}
370+
351371
#endif // NETWORK_CONFIGURATOR_COMPATIBLE

src/utility/LEDFeedback.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class LEDFeedbackClass {
1616
NONE,
1717
BLE_AVAILABLE,
1818
PEER_CONNECTED,
19+
PEER_CONNECTED_BLE,
20+
PEER_CONNECTED_SERIAL,
1921
CONNECTING_TO_NETWORK,
2022
CONNECTED_TO_CLOUD,
2123
ERROR
@@ -30,6 +32,7 @@ class LEDFeedbackClass {
3032
LEDFeedbackClass() {};
3133
void turnON();
3234
void turnOFF();
35+
void configurePeerConnectedMode();
3336
LEDFeedbackMode _mode = LEDFeedbackMode::NONE;
3437
uint32_t _lastUpdate = 0;
3538
uint32_t _count = 0;

0 commit comments

Comments
 (0)