diff options
| author | Damien George <damien.p.george@gmail.com> | 2014-03-22 23:53:50 +0000 |
|---|---|---|
| committer | Damien George <damien.p.george@gmail.com> | 2014-03-22 23:53:50 +0000 |
| commit | 02fa0358005fed02e989e7b1ad9b31f7a9ae8637 (patch) | |
| tree | 5da32f082d00a1db50881bc2f83cb11e28d0a970 /stmhal/pybmodule.c | |
| parent | c91097223d0dced28b874002e759e1907e56e054 (diff) | |
stmhal: Add input() and pyb.input() functions.
Diffstat (limited to 'stmhal/pybmodule.c')
| -rw-r--r-- | stmhal/pybmodule.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/stmhal/pybmodule.c b/stmhal/pybmodule.c index 09cdf83b8..772732984 100644 --- a/stmhal/pybmodule.c +++ b/stmhal/pybmodule.c @@ -196,12 +196,20 @@ STATIC mp_obj_t pyb_hid_send_report(mp_obj_t arg) { return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_1(pyb_hid_send_report_obj, pyb_hid_send_report); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_hid_send_report_obj, pyb_hid_send_report); #if 0 MP_DEFINE_CONST_FUN_OBJ_2(pyb_I2C_obj, pyb_I2C); // TODO put this in i2c.c #endif +extern int stdin_rx_chr(void); + +STATIC mp_obj_t pyb_input(void ) { + return mp_obj_new_int(stdin_rx_chr()); +} + +STATIC MP_DEFINE_CONST_FUN_OBJ_0(pyb_input_obj, pyb_input); + MP_DECLARE_CONST_FUN_OBJ(pyb_source_dir_obj); // defined in main.c MP_DECLARE_CONST_FUN_OBJ(pyb_main_obj); // defined in main.c @@ -268,6 +276,9 @@ STATIC const mp_map_elem_t pyb_module_globals_table[] = { #endif #endif + // input + { MP_OBJ_NEW_QSTR(MP_QSTR_input), (mp_obj_t)&pyb_input_obj }, + // pin mapper { MP_OBJ_NEW_QSTR(MP_QSTR_Pin), (mp_obj_t)&pin_map_obj }, |
