Merge lp:~sammyshp/flashlight-firmware/aux-blink-fix into lp:~toykeeper/flashlight-firmware/anduril2

Proposed by Sven Greiner
Status: Needs review
Proposed branch: lp:~sammyshp/flashlight-firmware/aux-blink-fix
Merge into: lp:~toykeeper/flashlight-firmware/anduril2
Diff against target: 86 lines (+26/-26)
1 file modified
ToyKeeper/spaghetti-monster/fsm-misc.c (+26/-26)
To merge this branch: bzr merge lp:~sammyshp/flashlight-firmware/aux-blink-fix
Reviewer Review Type Date Requested Status
Selene ToyKeeper Pending
Review via email: mp+407819@code.launchpad.net

Description of the change

Previously the aux LED might have flashed at high intensity until the next loop was started, starting the pattern. I've changed the order in the switch statement so that they are off by default.

There might be a better way of fixing this which avoids the short darkness that might be visible now.

To post a comment you must log in.

Unmerged revisions

619. By Sven Greiner

Fix initial AUX level for blinking mode

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ToyKeeper/spaghetti-monster/fsm-misc.c'
2--- ToyKeeper/spaghetti-monster/fsm-misc.c 2021-04-02 00:29:17 +0000
3+++ ToyKeeper/spaghetti-monster/fsm-misc.c 2021-08-30 08:49:32 +0000
4@@ -112,14 +112,6 @@
5 switch (lvl) {
6 #ifdef AVRXMEGA3 // ATTINY816, 817, etc
7
8- case 0: // indicator off
9- AUXLED_PORT.DIRSET = (1 << AUXLED_PIN); // set as output
10- AUXLED_PORT.OUTCLR = (1 << AUXLED_PIN); // set output low
11- #ifdef AUXLED2_PIN // second LED mirrors the first
12- AUXLED2_PORT.DIRSET = (1 << AUXLED2_PIN); // set as output
13- AUXLED2_PORT.OUTCLR = (1 << AUXLED2_PIN); // set output low
14- #endif
15- break;
16 case 1: // indicator low
17 AUXLED_PORT.DIRCLR = (1 << AUXLED_PIN); // set as input
18 // this resolves to PORTx.PINxCTRL = PORT_PULLUPEN_bm;
19@@ -130,7 +122,7 @@
20 *((uint8_t *)&AUXLED2_PORT + 0x10 + AUXLED2_PIN) = PORT_PULLUPEN_bm; // enable internal pull-up
21 #endif
22 break;
23- default: // indicator high
24+ case 2: // indicator high
25 AUXLED_PORT.DIRSET = (1 << AUXLED_PIN); // set as output
26 AUXLED_PORT.OUTSET = (1 << AUXLED_PIN); // set as high
27 #ifdef AUXLED2_PIN // second LED mirrors the first
28@@ -138,10 +130,34 @@
29 AUXLED2_PORT.OUTSET = (1 << AUXLED2_PIN); // set as high
30 #endif
31 break;
32+ default: // indicator off
33+ AUXLED_PORT.DIRSET = (1 << AUXLED_PIN); // set as output
34+ AUXLED_PORT.OUTCLR = (1 << AUXLED_PIN); // set output low
35+ #ifdef AUXLED2_PIN // second LED mirrors the first
36+ AUXLED2_PORT.DIRSET = (1 << AUXLED2_PIN); // set as output
37+ AUXLED2_PORT.OUTCLR = (1 << AUXLED2_PIN); // set output low
38+ #endif
39+ break;
40
41 #else
42
43- case 0: // indicator off
44+ case 1: // indicator low
45+ DDRB &= 0xff ^ (1 << AUXLED_PIN);
46+ PORTB |= (1 << AUXLED_PIN);
47+ #ifdef AUXLED2_PIN // second LED mirrors the first
48+ DDRB &= 0xff ^ (1 << AUXLED2_PIN);
49+ PORTB |= (1 << AUXLED2_PIN);
50+ #endif
51+ break;
52+ case 2: // indicator high
53+ DDRB |= (1 << AUXLED_PIN);
54+ PORTB |= (1 << AUXLED_PIN);
55+ #ifdef AUXLED2_PIN // second LED mirrors the first
56+ DDRB |= (1 << AUXLED2_PIN);
57+ PORTB |= (1 << AUXLED2_PIN);
58+ #endif
59+ break;
60+ default: // indicator off
61 DDRB &= 0xff ^ (1 << AUXLED_PIN);
62 PORTB &= 0xff ^ (1 << AUXLED_PIN);
63 #ifdef AUXLED2_PIN // second LED mirrors the first
64@@ -149,22 +165,6 @@
65 PORTB &= 0xff ^ (1 << AUXLED2_PIN);
66 #endif
67 break;
68- case 1: // indicator low
69- DDRB &= 0xff ^ (1 << AUXLED_PIN);
70- PORTB |= (1 << AUXLED_PIN);
71- #ifdef AUXLED2_PIN // second LED mirrors the first
72- DDRB &= 0xff ^ (1 << AUXLED2_PIN);
73- PORTB |= (1 << AUXLED2_PIN);
74- #endif
75- break;
76- default: // indicator high
77- DDRB |= (1 << AUXLED_PIN);
78- PORTB |= (1 << AUXLED_PIN);
79- #ifdef AUXLED2_PIN // second LED mirrors the first
80- DDRB |= (1 << AUXLED2_PIN);
81- PORTB |= (1 << AUXLED2_PIN);
82- #endif
83- break;
84
85 #endif // MCU type
86 }

Subscribers

People subscribed via source and target branches

to status/vote changes: