Make status light flash blue for incompatible mpy (fixes #1369)

This commit is contained in:
Terri Oda 2019-05-08 11:54:08 -07:00
parent 1a8e50c773
commit a9b05d37d7
8 changed files with 12 additions and 1 deletions

View File

@ -722,6 +722,7 @@ STATIC const mp_rom_map_elem_t mp_module_builtins_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_KeyError), MP_ROM_PTR(&mp_type_KeyError) }, { MP_ROM_QSTR(MP_QSTR_KeyError), MP_ROM_PTR(&mp_type_KeyError) },
{ MP_ROM_QSTR(MP_QSTR_LookupError), MP_ROM_PTR(&mp_type_LookupError) }, { MP_ROM_QSTR(MP_QSTR_LookupError), MP_ROM_PTR(&mp_type_LookupError) },
{ MP_ROM_QSTR(MP_QSTR_MemoryError), MP_ROM_PTR(&mp_type_MemoryError) }, { MP_ROM_QSTR(MP_QSTR_MemoryError), MP_ROM_PTR(&mp_type_MemoryError) },
{ MP_ROM_QSTR(MP_QSTR_MpyError), MP_ROM_PTR(&mp_type_MpyError) },
{ MP_ROM_QSTR(MP_QSTR_NameError), MP_ROM_PTR(&mp_type_NameError) }, { MP_ROM_QSTR(MP_QSTR_NameError), MP_ROM_PTR(&mp_type_NameError) },
{ MP_ROM_QSTR(MP_QSTR_NotImplementedError), MP_ROM_PTR(&mp_type_NotImplementedError) }, { MP_ROM_QSTR(MP_QSTR_NotImplementedError), MP_ROM_PTR(&mp_type_NotImplementedError) },
{ MP_ROM_QSTR(MP_QSTR_OSError), MP_ROM_PTR(&mp_type_OSError) }, { MP_ROM_QSTR(MP_QSTR_OSError), MP_ROM_PTR(&mp_type_OSError) },

View File

@ -599,6 +599,7 @@ extern const mp_obj_type_t mp_type_ReloadException;
extern const mp_obj_type_t mp_type_KeyError; extern const mp_obj_type_t mp_type_KeyError;
extern const mp_obj_type_t mp_type_LookupError; extern const mp_obj_type_t mp_type_LookupError;
extern const mp_obj_type_t mp_type_MemoryError; extern const mp_obj_type_t mp_type_MemoryError;
extern const mp_obj_type_t mp_type_MpyError;
extern const mp_obj_type_t mp_type_NameError; extern const mp_obj_type_t mp_type_NameError;
extern const mp_obj_type_t mp_type_NotImplementedError; extern const mp_obj_type_t mp_type_NotImplementedError;
extern const mp_obj_type_t mp_type_OSError; extern const mp_obj_type_t mp_type_OSError;

View File

@ -298,6 +298,7 @@ MP_DEFINE_EXCEPTION(Exception, BaseException)
MP_DEFINE_EXCEPTION(NotImplementedError, RuntimeError) MP_DEFINE_EXCEPTION(NotImplementedError, RuntimeError)
MP_DEFINE_EXCEPTION(SyntaxError, Exception) MP_DEFINE_EXCEPTION(SyntaxError, Exception)
MP_DEFINE_EXCEPTION(IndentationError, SyntaxError) MP_DEFINE_EXCEPTION(IndentationError, SyntaxError)
MP_DEFINE_EXCEPTION(MpyError, Exception)
/* /*
MP_DEFINE_EXCEPTION(TabError, IndentationError) MP_DEFINE_EXCEPTION(TabError, IndentationError)
*/ */

View File

@ -220,7 +220,7 @@ mp_raw_code_t *mp_raw_code_load(mp_reader_t *reader) {
|| header[1] != MPY_VERSION || header[1] != MPY_VERSION
|| header[2] != MPY_FEATURE_FLAGS || header[2] != MPY_FEATURE_FLAGS
|| header[3] > mp_small_int_bits()) { || header[3] > mp_small_int_bits()) {
mp_raise_ValueError(translate("Incompatible .mpy file. Please update all .mpy files. See http://adafru.it/mpy-update for more info.")); mp_raise_MpyError(translate("Incompatible .mpy file. Please update all .mpy files. See http://adafru.it/mpy-update for more info."));
} }
mp_raw_code_t *rc = load_raw_code(reader); mp_raw_code_t *rc = load_raw_code(reader);
reader->close(reader->data); reader->close(reader->data);

View File

@ -1598,6 +1598,10 @@ NORETURN void mp_raise_NotImplementedError_varg(const compressed_string_t *fmt,
nlr_raise(exception); nlr_raise(exception);
} }
NORETURN void mp_raise_MpyError(const compressed_string_t *msg) {
mp_raise_msg(&mp_type_MpyError, msg);
}
#if MICROPY_STACK_CHECK || MICROPY_ENABLE_PYSTACK #if MICROPY_STACK_CHECK || MICROPY_ENABLE_PYSTACK
NORETURN void mp_raise_recursion_depth(void) { NORETURN void mp_raise_recursion_depth(void) {
mp_raise_RuntimeError(translate("maximum recursion depth exceeded")); mp_raise_RuntimeError(translate("maximum recursion depth exceeded"));

View File

@ -163,6 +163,7 @@ NORETURN void mp_raise_OSError_msg(const compressed_string_t *msg);
NORETURN void mp_raise_OSError_msg_varg(const compressed_string_t *fmt, ...); NORETURN void mp_raise_OSError_msg_varg(const compressed_string_t *fmt, ...);
NORETURN void mp_raise_NotImplementedError(const compressed_string_t *msg); NORETURN void mp_raise_NotImplementedError(const compressed_string_t *msg);
NORETURN void mp_raise_NotImplementedError_varg(const compressed_string_t *fmt, ...); NORETURN void mp_raise_NotImplementedError_varg(const compressed_string_t *fmt, ...);
NORETURN void mp_raise_MpyError(const compressed_string_t *msg);
NORETURN void mp_raise_recursion_depth(void); NORETURN void mp_raise_recursion_depth(void);
#if MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG #if MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG

View File

@ -31,4 +31,5 @@
#define NAME_ERROR WHITE #define NAME_ERROR WHITE
#define OS_ERROR ORANGE #define OS_ERROR ORANGE
#define VALUE_ERROR PURPLE #define VALUE_ERROR PURPLE
#define MPY_ERROR BLUE
#define OTHER_ERROR YELLOW #define OTHER_ERROR YELLOW

View File

@ -247,6 +247,8 @@ void prep_rgb_status_animation(const pyexec_result_t* result,
status->exception_color = OS_ERROR; status->exception_color = OS_ERROR;
} else if (mp_obj_is_subclass_fast(result->exception_type, &mp_type_ValueError)) { } else if (mp_obj_is_subclass_fast(result->exception_type, &mp_type_ValueError)) {
status->exception_color = VALUE_ERROR; status->exception_color = VALUE_ERROR;
} else if (mp_obj_is_subclass_fast(result->exception_type, &mp_type_MpyError)) {
status->exception_color = MPY_ERROR;
} else { } else {
status->exception_color = OTHER_ERROR; status->exception_color = OTHER_ERROR;
} }