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
=== modified file 'ToyKeeper/spaghetti-monster/fsm-misc.c'
--- ToyKeeper/spaghetti-monster/fsm-misc.c 2021-04-02 00:29:17 +0000
+++ ToyKeeper/spaghetti-monster/fsm-misc.c 2021-08-30 08:49:32 +0000
@@ -112,14 +112,6 @@
112 switch (lvl) {112 switch (lvl) {
113 #ifdef AVRXMEGA3 // ATTINY816, 817, etc113 #ifdef AVRXMEGA3 // ATTINY816, 817, etc
114114
115 case 0: // indicator off
116 AUXLED_PORT.DIRSET = (1 << AUXLED_PIN); // set as output
117 AUXLED_PORT.OUTCLR = (1 << AUXLED_PIN); // set output low
118 #ifdef AUXLED2_PIN // second LED mirrors the first
119 AUXLED2_PORT.DIRSET = (1 << AUXLED2_PIN); // set as output
120 AUXLED2_PORT.OUTCLR = (1 << AUXLED2_PIN); // set output low
121 #endif
122 break;
123 case 1: // indicator low115 case 1: // indicator low
124 AUXLED_PORT.DIRCLR = (1 << AUXLED_PIN); // set as input116 AUXLED_PORT.DIRCLR = (1 << AUXLED_PIN); // set as input
125 // this resolves to PORTx.PINxCTRL = PORT_PULLUPEN_bm;117 // this resolves to PORTx.PINxCTRL = PORT_PULLUPEN_bm;
@@ -130,7 +122,7 @@
130 *((uint8_t *)&AUXLED2_PORT + 0x10 + AUXLED2_PIN) = PORT_PULLUPEN_bm; // enable internal pull-up122 *((uint8_t *)&AUXLED2_PORT + 0x10 + AUXLED2_PIN) = PORT_PULLUPEN_bm; // enable internal pull-up
131 #endif123 #endif
132 break;124 break;
133 default: // indicator high125 case 2: // indicator high
134 AUXLED_PORT.DIRSET = (1 << AUXLED_PIN); // set as output126 AUXLED_PORT.DIRSET = (1 << AUXLED_PIN); // set as output
135 AUXLED_PORT.OUTSET = (1 << AUXLED_PIN); // set as high127 AUXLED_PORT.OUTSET = (1 << AUXLED_PIN); // set as high
136 #ifdef AUXLED2_PIN // second LED mirrors the first128 #ifdef AUXLED2_PIN // second LED mirrors the first
@@ -138,10 +130,34 @@
138 AUXLED2_PORT.OUTSET = (1 << AUXLED2_PIN); // set as high130 AUXLED2_PORT.OUTSET = (1 << AUXLED2_PIN); // set as high
139 #endif131 #endif
140 break;132 break;
133 default: // indicator off
134 AUXLED_PORT.DIRSET = (1 << AUXLED_PIN); // set as output
135 AUXLED_PORT.OUTCLR = (1 << AUXLED_PIN); // set output low
136 #ifdef AUXLED2_PIN // second LED mirrors the first
137 AUXLED2_PORT.DIRSET = (1 << AUXLED2_PIN); // set as output
138 AUXLED2_PORT.OUTCLR = (1 << AUXLED2_PIN); // set output low
139 #endif
140 break;
141 141
142 #else142 #else
143143
144 case 0: // indicator off144 case 1: // indicator low
145 DDRB &= 0xff ^ (1 << AUXLED_PIN);
146 PORTB |= (1 << AUXLED_PIN);
147 #ifdef AUXLED2_PIN // second LED mirrors the first
148 DDRB &= 0xff ^ (1 << AUXLED2_PIN);
149 PORTB |= (1 << AUXLED2_PIN);
150 #endif
151 break;
152 case 2: // indicator high
153 DDRB |= (1 << AUXLED_PIN);
154 PORTB |= (1 << AUXLED_PIN);
155 #ifdef AUXLED2_PIN // second LED mirrors the first
156 DDRB |= (1 << AUXLED2_PIN);
157 PORTB |= (1 << AUXLED2_PIN);
158 #endif
159 break;
160 default: // indicator off
145 DDRB &= 0xff ^ (1 << AUXLED_PIN);161 DDRB &= 0xff ^ (1 << AUXLED_PIN);
146 PORTB &= 0xff ^ (1 << AUXLED_PIN);162 PORTB &= 0xff ^ (1 << AUXLED_PIN);
147 #ifdef AUXLED2_PIN // second LED mirrors the first163 #ifdef AUXLED2_PIN // second LED mirrors the first
@@ -149,22 +165,6 @@
149 PORTB &= 0xff ^ (1 << AUXLED2_PIN);165 PORTB &= 0xff ^ (1 << AUXLED2_PIN);
150 #endif166 #endif
151 break;167 break;
152 case 1: // indicator low
153 DDRB &= 0xff ^ (1 << AUXLED_PIN);
154 PORTB |= (1 << AUXLED_PIN);
155 #ifdef AUXLED2_PIN // second LED mirrors the first
156 DDRB &= 0xff ^ (1 << AUXLED2_PIN);
157 PORTB |= (1 << AUXLED2_PIN);
158 #endif
159 break;
160 default: // indicator high
161 DDRB |= (1 << AUXLED_PIN);
162 PORTB |= (1 << AUXLED_PIN);
163 #ifdef AUXLED2_PIN // second LED mirrors the first
164 DDRB |= (1 << AUXLED2_PIN);
165 PORTB |= (1 << AUXLED2_PIN);
166 #endif
167 break;
168168
169 #endif // MCU type169 #endif // MCU type
170 }170 }

Subscribers

People subscribed via source and target branches

to status/vote changes: