@@ -199,12 +199,15 @@ void set_rgb_status_brightness(uint8_t level){
199199 rgb_status_brightness = level ;
200200}
201201
202- void prep_rgb_status_animation (const pyexec_result_t * result , bool found_main , rgb_status_animation_t * status ) {
202+ void prep_rgb_status_animation (const pyexec_result_t * result ,
203+ bool found_main ,
204+ safe_mode_t safe_mode ,
205+ rgb_status_animation_t * status ) {
203206 #if defined(MICROPY_HW_NEOPIXEL ) || (defined(MICROPY_HW_APA102_MOSI ) && defined(MICROPY_HW_APA102_SCK ))
204207 new_status_color (ALL_DONE );
205208 status -> pattern_start = ticks_ms ;
206-
207- uint32_t total_exception_cycle = 0 ;
209+ status -> safe_mode = safe_mode ;
210+ status -> total_exception_cycle = 0 ;
208211 status -> ones = result -> exception_line % 10 ;
209212 status -> ones += status -> ones > 0 ? 1 : 0 ;
210213 status -> tens = (result -> exception_line / 10 ) % 10 ;
@@ -224,7 +227,7 @@ void prep_rgb_status_animation(const pyexec_result_t* result, bool found_main, r
224227 }
225228 status -> ok = result -> return_code != PYEXEC_EXCEPTION ;
226229 if (!status -> ok ) {
227- status -> total_exception_cycle = EXCEPTION_TYPE_LENGTH_MS * 3 + LINE_NUMBER_TOGGLE_LENGTH * digit_sum + LINE_NUMBER_TOGGLE_LENGTH * num_places ;
230+ status -> total_exception_cycle = EXCEPTION_TYPE_LENGTH_MS * 3 + LINE_NUMBER_TOGGLE_LENGTH * status -> digit_sum + LINE_NUMBER_TOGGLE_LENGTH * num_places ;
228231 }
229232 if (mp_obj_is_subclass_fast (result -> exception_type , & mp_type_IndentationError )) {
230233 status -> exception_color = INDENTATION_ERROR ;
@@ -244,26 +247,26 @@ void prep_rgb_status_animation(const pyexec_result_t* result, bool found_main, r
244247
245248void tick_rgb_status_animation (rgb_status_animation_t * status ) {
246249 #if defined(MICROPY_HW_NEOPIXEL ) || (defined(MICROPY_HW_APA102_MOSI ) && defined(MICROPY_HW_APA102_SCK ))
247- uint32_t tick_diff = ticks_ms - pattern_start ;
250+ uint32_t tick_diff = ticks_ms - status -> pattern_start ;
248251 if (status -> ok ) {
249252 // All is good. Ramp ALL_DONE up and down.
250253 if (tick_diff > ALL_GOOD_CYCLE_MS ) {
251- pattern_start = ticks_ms ;
254+ status -> pattern_start = ticks_ms ;
252255 tick_diff = 0 ;
253256 }
254257
255258 uint16_t brightness = tick_diff * 255 / (ALL_GOOD_CYCLE_MS / 2 );
256259 if (brightness > 255 ) {
257260 brightness = 511 - brightness ;
258261 }
259- if (safe_mode == NO_SAFE_MODE ) {
262+ if (status -> safe_mode == NO_SAFE_MODE ) {
260263 new_status_color (color_brightness (ALL_DONE , brightness ));
261264 } else {
262265 new_status_color (color_brightness (SAFE_MODE , brightness ));
263266 }
264267 } else {
265- if (tick_diff > total_exception_cycle ) {
266- pattern_start = ticks_ms ;
268+ if (tick_diff > status -> total_exception_cycle ) {
269+ status -> pattern_start = ticks_ms ;
267270 tick_diff = 0 ;
268271 }
269272 // First flash the file color.
@@ -275,34 +278,34 @@ void tick_rgb_status_animation(rgb_status_animation_t* status) {
275278 }
276279 // Next flash the exception color.
277280 } else if (tick_diff < EXCEPTION_TYPE_LENGTH_MS * 2 ) {
278- new_status_color (exception_color );
281+ new_status_color (status -> exception_color );
279282 // Finally flash the line number digits from highest to lowest.
280283 // Zeroes will not produce a flash but can be read by the absence of
281284 // a color from the sequence.
282- } else if (tick_diff < (EXCEPTION_TYPE_LENGTH_MS * 2 + LINE_NUMBER_TOGGLE_LENGTH * digit_sum )) {
285+ } else if (tick_diff < (EXCEPTION_TYPE_LENGTH_MS * 2 + LINE_NUMBER_TOGGLE_LENGTH * status -> digit_sum )) {
283286 uint32_t digit_diff = tick_diff - EXCEPTION_TYPE_LENGTH_MS * 2 ;
284287 if ((digit_diff % LINE_NUMBER_TOGGLE_LENGTH ) < (LINE_NUMBER_TOGGLE_LENGTH / 2 )) {
285288 new_status_color (BLACK );
286- } else if (digit_diff < LINE_NUMBER_TOGGLE_LENGTH * thousands ) {
289+ } else if (digit_diff < LINE_NUMBER_TOGGLE_LENGTH * status -> thousands ) {
287290 if (digit_diff < LINE_NUMBER_TOGGLE_LENGTH ) {
288291 new_status_color (BLACK );
289292 } else {
290293 new_status_color (THOUSANDS );
291294 }
292- } else if (digit_diff < LINE_NUMBER_TOGGLE_LENGTH * (thousands + hundreds )) {
293- if (digit_diff < LINE_NUMBER_TOGGLE_LENGTH * (thousands + 1 )) {
295+ } else if (digit_diff < LINE_NUMBER_TOGGLE_LENGTH * (status -> thousands + status -> hundreds )) {
296+ if (digit_diff < LINE_NUMBER_TOGGLE_LENGTH * (status -> thousands + 1 )) {
294297 new_status_color (BLACK );
295298 } else {
296299 new_status_color (HUNDREDS );
297300 }
298- } else if (digit_diff < LINE_NUMBER_TOGGLE_LENGTH * (thousands + hundreds + tens )) {
299- if (digit_diff < LINE_NUMBER_TOGGLE_LENGTH * (thousands + hundreds + 1 )) {
301+ } else if (digit_diff < LINE_NUMBER_TOGGLE_LENGTH * (status -> thousands + status -> hundreds + status -> tens )) {
302+ if (digit_diff < LINE_NUMBER_TOGGLE_LENGTH * (status -> thousands + status -> hundreds + 1 )) {
300303 new_status_color (BLACK );
301304 } else {
302305 new_status_color (TENS );
303306 }
304307 } else {
305- if (digit_diff < LINE_NUMBER_TOGGLE_LENGTH * (thousands + hundreds + tens + 1 )) {
308+ if (digit_diff < LINE_NUMBER_TOGGLE_LENGTH * (status -> thousands + status -> hundreds + status -> tens + 1 )) {
306309 new_status_color (BLACK );
307310 } else {
308311 new_status_color (ONES );
0 commit comments