File tree Expand file tree Collapse file tree 1 file changed +48
-2
lines changed Expand file tree Collapse file tree 1 file changed +48
-2
lines changed Original file line number Diff line number Diff line change @@ -30,9 +30,54 @@ volatile uint8_t ledKeepValue = 0;
30
30
volatile uint8_t ledTargetValue = 20 ;
31
31
volatile int8_t ledDirection = 1 ;
32
32
volatile int divisor = 0 ;
33
+
34
+ DigitalOut green (PK_6, 1 );
35
+ DigitalOut blue (PK_7, 1 );
36
+
37
+ Ticker swap_ticker;
33
38
int envie_swap_index = -1 ;
34
39
35
- DigitalOut led (PK_6);
40
+ static inline void swap_feedback () {
41
+
42
+ static int blink_idx = 0 ;
43
+ static int blink_state = 0 ;
44
+
45
+ if (envie_swap_index >= 0 ){
46
+ switch (blink_state) {
47
+ case 0 : {
48
+ if (blink_idx < envie_swap_index) {
49
+ if (blue == 0 ){
50
+ blue = 1 ;
51
+ } else {
52
+ blue = 0 ;
53
+ blink_idx++;
54
+ }
55
+ } else {
56
+ blink_idx = 0 ;
57
+ blink_state = 1 ;
58
+ }
59
+ green = 1 ;
60
+ }
61
+ break ;
62
+
63
+ case 1 : {
64
+ if (blink_idx < (15 - envie_swap_index)) {
65
+ if (green == 0 ){
66
+ green = 1 ;
67
+ } else {
68
+ green = 0 ;
69
+ blink_idx++;
70
+ }
71
+ } else {
72
+ blink_idx = 0 ;
73
+ blink_state = 0 ;
74
+ }
75
+ blue = 1 ;
76
+ }
77
+ break ;
78
+ }
79
+ }
80
+ }
36
81
37
82
static inline void LED_pulse (DigitalOut* led)
38
83
{
@@ -178,6 +223,7 @@ int target_init(void) {
178
223
RTCSetBKPRegister (RTC_BKP_DR0, 0 );
179
224
HAL_FLASH_Lock ();
180
225
BOOT_LOG_DBG (" Envie app magic 0x%x" , RTCGetBKPRegister (RTC_BKP_DR0));
226
+ swap_ticker.attach (&swap_feedback, 250ms);
181
227
return 0 ;
182
228
183
229
} else {
@@ -242,7 +288,7 @@ void envie_loop(void) {
242
288
HAL_PCD_IRQHandler (&hpcd);
243
289
}
244
290
#endif
245
- LED_pulse (&led );
291
+ LED_pulse (&green );
246
292
}
247
293
}
248
294
You can’t perform that action at this time.
0 commit comments