aboutsummaryrefslogtreecommitdiff
path: root/supervisor/shared/rgb_led_status.c
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2017-11-01 08:17:41 -0400
committerGitHub <noreply@github.com>2017-11-01 08:17:41 -0400
commit0076a3c868b489cf837bfcde72890aefdcb93bed (patch)
tree5572e3f865c8d9b70c21955224666733f2681b05 /supervisor/shared/rgb_led_status.c
parentdc3f13d13f0f07124bd4cca51dededa46246c05b (diff)
parentf4c82563451fe51d679d159c156926e47181d5db (diff)
Merge pull request #393 from tannewt/m4_neopixel
Now with more blinky!!!
Diffstat (limited to 'supervisor/shared/rgb_led_status.c')
-rw-r--r--supervisor/shared/rgb_led_status.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/supervisor/shared/rgb_led_status.c b/supervisor/shared/rgb_led_status.c
index 15150f18b..0f29b254a 100644
--- a/supervisor/shared/rgb_led_status.c
+++ b/supervisor/shared/rgb_led_status.c
@@ -199,12 +199,15 @@ void set_rgb_status_brightness(uint8_t level){
rgb_status_brightness = level;
}
-void prep_rgb_status_animation(const pyexec_result_t* result, bool found_main, rgb_status_animation_t* status) {
+void prep_rgb_status_animation(const pyexec_result_t* result,
+ bool found_main,
+ safe_mode_t safe_mode,
+ rgb_status_animation_t* status) {
#if defined(MICROPY_HW_NEOPIXEL) || (defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK))
new_status_color(ALL_DONE);
status->pattern_start = ticks_ms;
-
- uint32_t total_exception_cycle = 0;
+ status->safe_mode = safe_mode;
+ status->total_exception_cycle = 0;
status->ones = result->exception_line % 10;
status->ones += status->ones > 0 ? 1 : 0;
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
}
status->ok = result->return_code != PYEXEC_EXCEPTION;
if (!status->ok) {
- status->total_exception_cycle = EXCEPTION_TYPE_LENGTH_MS * 3 + LINE_NUMBER_TOGGLE_LENGTH * digit_sum + LINE_NUMBER_TOGGLE_LENGTH * num_places;
+ status->total_exception_cycle = EXCEPTION_TYPE_LENGTH_MS * 3 + LINE_NUMBER_TOGGLE_LENGTH * status->digit_sum + LINE_NUMBER_TOGGLE_LENGTH * num_places;
}
if (mp_obj_is_subclass_fast(result->exception_type, &mp_type_IndentationError)) {
status->exception_color = INDENTATION_ERROR;
@@ -244,11 +247,11 @@ void prep_rgb_status_animation(const pyexec_result_t* result, bool found_main, r
void tick_rgb_status_animation(rgb_status_animation_t* status) {
#if defined(MICROPY_HW_NEOPIXEL) || (defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK))
- uint32_t tick_diff = ticks_ms - pattern_start;
+ uint32_t tick_diff = ticks_ms - status->pattern_start;
if (status->ok) {
// All is good. Ramp ALL_DONE up and down.
if (tick_diff > ALL_GOOD_CYCLE_MS) {
- pattern_start = ticks_ms;
+ status->pattern_start = ticks_ms;
tick_diff = 0;
}
@@ -256,14 +259,14 @@ void tick_rgb_status_animation(rgb_status_animation_t* status) {
if (brightness > 255) {
brightness = 511 - brightness;
}
- if (safe_mode == NO_SAFE_MODE) {
+ if (status->safe_mode == NO_SAFE_MODE) {
new_status_color(color_brightness(ALL_DONE, brightness));
} else {
new_status_color(color_brightness(SAFE_MODE, brightness));
}
} else {
- if (tick_diff > total_exception_cycle) {
- pattern_start = ticks_ms;
+ if (tick_diff > status->total_exception_cycle) {
+ status->pattern_start = ticks_ms;
tick_diff = 0;
}
// First flash the file color.
@@ -275,34 +278,34 @@ void tick_rgb_status_animation(rgb_status_animation_t* status) {
}
// Next flash the exception color.
} else if (tick_diff < EXCEPTION_TYPE_LENGTH_MS * 2) {
- new_status_color(exception_color);
+ new_status_color(status->exception_color);
// Finally flash the line number digits from highest to lowest.
// Zeroes will not produce a flash but can be read by the absence of
// a color from the sequence.
- } else if (tick_diff < (EXCEPTION_TYPE_LENGTH_MS * 2 + LINE_NUMBER_TOGGLE_LENGTH * digit_sum)) {
+ } else if (tick_diff < (EXCEPTION_TYPE_LENGTH_MS * 2 + LINE_NUMBER_TOGGLE_LENGTH * status->digit_sum)) {
uint32_t digit_diff = tick_diff - EXCEPTION_TYPE_LENGTH_MS * 2;
if ((digit_diff % LINE_NUMBER_TOGGLE_LENGTH) < (LINE_NUMBER_TOGGLE_LENGTH / 2)) {
new_status_color(BLACK);
- } else if (digit_diff < LINE_NUMBER_TOGGLE_LENGTH * thousands) {
+ } else if (digit_diff < LINE_NUMBER_TOGGLE_LENGTH * status->thousands) {
if (digit_diff < LINE_NUMBER_TOGGLE_LENGTH) {
new_status_color(BLACK);
} else {
new_status_color(THOUSANDS);
}
- } else if (digit_diff < LINE_NUMBER_TOGGLE_LENGTH * (thousands + hundreds)) {
- if (digit_diff < LINE_NUMBER_TOGGLE_LENGTH * (thousands + 1)) {
+ } else if (digit_diff < LINE_NUMBER_TOGGLE_LENGTH * (status->thousands + status->hundreds)) {
+ if (digit_diff < LINE_NUMBER_TOGGLE_LENGTH * (status->thousands + 1)) {
new_status_color(BLACK);
} else {
new_status_color(HUNDREDS);
}
- } else if (digit_diff < LINE_NUMBER_TOGGLE_LENGTH * (thousands + hundreds + tens)) {
- if (digit_diff < LINE_NUMBER_TOGGLE_LENGTH * (thousands + hundreds + 1)) {
+ } else if (digit_diff < LINE_NUMBER_TOGGLE_LENGTH * (status->thousands + status->hundreds + status->tens)) {
+ if (digit_diff < LINE_NUMBER_TOGGLE_LENGTH * (status->thousands + status->hundreds + 1)) {
new_status_color(BLACK);
} else {
new_status_color(TENS);
}
} else {
- if (digit_diff < LINE_NUMBER_TOGGLE_LENGTH * (thousands + hundreds + tens + 1)) {
+ if (digit_diff < LINE_NUMBER_TOGGLE_LENGTH * (status->thousands + status->hundreds + status->tens + 1)) {
new_status_color(BLACK);
} else {
new_status_color(ONES);