diff options
| author | ATMakersBill <bill@atmakers.org> | 2018-10-09 18:37:52 -0400 |
|---|---|---|
| committer | ATMakersBill <bill@atmakers.org> | 2018-10-09 18:37:52 -0400 |
| commit | 9f94712ad10193c4fc6d888ef3ebc611bc0e011c (patch) | |
| tree | 42ff1fc2225fbfad638dc83a93e694ac61331c0d /shared-bindings/supervisor | |
| parent | bc0a13552478036b75e351c21b84ae3fa3f45d30 (diff) | |
replacing change to input() with separate method to check for USB Serial input
Diffstat (limited to 'shared-bindings/supervisor')
| -rwxr-xr-x | shared-bindings/supervisor/Runtime.c | 20 | ||||
| -rwxr-xr-x | shared-bindings/supervisor/Runtime.h | 2 |
2 files changed, 22 insertions, 0 deletions
diff --git a/shared-bindings/supervisor/Runtime.c b/shared-bindings/supervisor/Runtime.c index b061595cf..1cf2a3548 100755 --- a/shared-bindings/supervisor/Runtime.c +++ b/shared-bindings/supervisor/Runtime.c @@ -80,8 +80,28 @@ const mp_obj_property_t supervisor_serial_connected_obj = { (mp_obj_t)&mp_const_none_obj}, }; +/*Added to allow for polling of USB Console*/ +STATIC mp_obj_t supervisor_get_serial_bytes_available(mp_obj_t self){ + if (!common_hal_get_serial_bytes_available()) { + return mp_const_false; + } + else { + return mp_const_true; + } +} +MP_DEFINE_CONST_FUN_OBJ_1(supervisor_get_serial_bytes_available_obj, supervisor_get_serial_bytes_available); + +const mp_obj_property_t supervisor_serial_bytes_available_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&supervisor_get_serial_bytes_available_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + + STATIC const mp_rom_map_elem_t supervisor_runtime_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_serial_connected), MP_ROM_PTR(&supervisor_serial_connected_obj) }, + { MP_ROM_QSTR(MP_QSTR_serial_bytes_available), MP_ROM_PTR(&supervisor_serial_bytes_available_obj) }, }; STATIC MP_DEFINE_CONST_DICT(supervisor_runtime_locals_dict, supervisor_runtime_locals_dict_table); diff --git a/shared-bindings/supervisor/Runtime.h b/shared-bindings/supervisor/Runtime.h index 4a67925ec..864b070cd 100755 --- a/shared-bindings/supervisor/Runtime.h +++ b/shared-bindings/supervisor/Runtime.h @@ -35,6 +35,8 @@ const mp_obj_type_t supervisor_runtime_type; bool common_hal_get_serial_connected(void); +bool common_hal_get_serial_bytes_available(void); + //TODO: placeholders for future functions //bool common_hal_get_repl_active(void); //bool common_hal_get_usb_enumerated(void); |
