Fix pwm reset spew, protect against null reference in led status

This commit is contained in:
Lucian Copeland 2020-08-05 14:05:53 -04:00
parent 14b3b51c58
commit 78d049d0f1
2 changed files with 19 additions and 15 deletions

View File

@ -32,6 +32,7 @@
#define INDEX_EMPTY 0xFF
STATIC bool not_first_reset = false;
STATIC uint32_t reserved_timer_freq[LEDC_TIMER_MAX];
STATIC uint8_t reserved_channels[LEDC_CHANNEL_MAX];
STATIC bool never_reset_tim[LEDC_TIMER_MAX];
@ -39,7 +40,7 @@ STATIC bool never_reset_chan[LEDC_CHANNEL_MAX];
void pwmout_reset(void) {
for (size_t i = 0; i < LEDC_CHANNEL_MAX; i++ ) {
if (reserved_channels[i] != INDEX_EMPTY) {
if (reserved_channels[i] != INDEX_EMPTY && not_first_reset) {
ledc_stop(LEDC_LOW_SPEED_MODE, i, 0);
}
if (!never_reset_chan[i]) {
@ -54,6 +55,7 @@ void pwmout_reset(void) {
reserved_timer_freq[i] = 0;
}
}
not_first_reset = true;
}
pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,

View File

@ -387,20 +387,22 @@ void prep_rgb_status_animation(const pyexec_result_t* result,
if (!status->ok) {
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;
} else if (mp_obj_is_subclass_fast(result->exception_type, &mp_type_SyntaxError)) {
status->exception_color = SYNTAX_ERROR;
} else if (mp_obj_is_subclass_fast(result->exception_type, &mp_type_NameError)) {
status->exception_color = NAME_ERROR;
} else if (mp_obj_is_subclass_fast(result->exception_type, &mp_type_OSError)) {
status->exception_color = OS_ERROR;
} else if (mp_obj_is_subclass_fast(result->exception_type, &mp_type_ValueError)) {
status->exception_color = VALUE_ERROR;
} else if (mp_obj_is_subclass_fast(result->exception_type, &mp_type_MpyError)) {
status->exception_color = MPY_ERROR;
} else {
status->exception_color = OTHER_ERROR;
if (result->exception_type) {
if (mp_obj_is_subclass_fast(result->exception_type, &mp_type_IndentationError)) {
status->exception_color = INDENTATION_ERROR;
} else if (mp_obj_is_subclass_fast(result->exception_type, &mp_type_SyntaxError)) {
status->exception_color = SYNTAX_ERROR;
} else if (mp_obj_is_subclass_fast(result->exception_type, &mp_type_NameError)) {
status->exception_color = NAME_ERROR;
} else if (mp_obj_is_subclass_fast(result->exception_type, &mp_type_OSError)) {
status->exception_color = OS_ERROR;
} else if (mp_obj_is_subclass_fast(result->exception_type, &mp_type_ValueError)) {
status->exception_color = VALUE_ERROR;
} else if (mp_obj_is_subclass_fast(result->exception_type, &mp_type_MpyError)) {
status->exception_color = MPY_ERROR;
} else {
status->exception_color = OTHER_ERROR;
}
}
#endif
}