@@ -46,8 +46,8 @@ const mp_arg_t mpcallback_init_args[] = {
4646 { MP_QSTR_mode , MP_ARG_KW_ONLY | MP_ARG_INT , {.u_int = 0 } },
4747 { MP_QSTR_handler , MP_ARG_KW_ONLY | MP_ARG_OBJ , {.u_obj = mp_const_none } },
4848 { MP_QSTR_priority , MP_ARG_KW_ONLY | MP_ARG_INT , {.u_int = 1 } },
49- { MP_QSTR_value , MP_ARG_KW_ONLY | MP_ARG_INT , {.u_int = 0 } },
50- { MP_QSTR_wakes , MP_ARG_KW_ONLY | MP_ARG_INT , {.u_int = PYB_PWR_MODE_ACTIVE } },
49+ { MP_QSTR_value , MP_ARG_KW_ONLY | MP_ARG_OBJ , {.u_obj = mp_const_none } },
50+ { MP_QSTR_wake_from , MP_ARG_KW_ONLY | MP_ARG_INT , {.u_int = PYB_PWR_MODE_ACTIVE } },
5151};
5252
5353/******************************************************************************
@@ -58,14 +58,14 @@ void mpcallback_init0 (void) {
5858 mp_obj_list_init (& MP_STATE_PORT (mpcallback_obj_list ), 0 );
5959}
6060
61- mp_obj_t mpcallback_new (mp_obj_t parent , mp_obj_t handler , const mp_cb_methods_t * methods ) {
61+ mp_obj_t mpcallback_new (mp_obj_t parent , mp_obj_t handler , const mp_cb_methods_t * methods , bool enable ) {
6262 mpcallback_obj_t * self = m_new_obj (mpcallback_obj_t );
6363 self -> base .type = & pyb_callback_type ;
6464 self -> handler = handler ;
6565 self -> parent = parent ;
6666 self -> methods = (mp_cb_methods_t * )methods ;
67- self -> isenabled = true ;
68- // remove any old callback if present
67+ self -> isenabled = enable ;
68+ // remove it in case it was already registered
6969 mpcallback_remove (self -> parent );
7070 mp_obj_list_append (& MP_STATE_PORT (mpcallback_obj_list ), self );
7171 return self ;
@@ -138,11 +138,11 @@ void mpcallback_handler (mp_obj_t self_in) {
138138 // uncaught exception; disable the callback so that it doesn't run again
139139 self -> methods -> disable (self -> parent );
140140 self -> handler = mp_const_none ;
141- // signal the error using the heart beat led and print an
142- // exception message as well
143- mperror_signal_error ();
141+ // signal the error using the heart beat led and
142+ // by printing a message
144143 printf ("Uncaught exception in callback handler\n" );
145144 mp_obj_print_exception (& mp_plat_print , (mp_obj_t )nlr .ret_val );
145+ mperror_signal_error ();
146146 }
147147 gc_unlock ();
148148 }
0 commit comments