diff options
| author | Scott Shawcroft <scott.shawcroft@gmail.com> | 2017-01-16 10:35:46 -0800 |
|---|---|---|
| committer | Scott Shawcroft <scott.shawcroft@gmail.com> | 2017-01-16 10:35:46 -0800 |
| commit | df96823deed7af4587cb9ebfa7f5d471417f90f1 (patch) | |
| tree | fe3c5eebf0bd623cb143826b16628864cc451500 | |
| parent | 78168bc984631f8445eedcb51a190fccbdf35328 (diff) | |
Fix pull kwarg DigitalInOut.switch_to_input and add example use to docs.
Thanks to jerryn from the Adafruit Forum for finding the bug!
| -rw-r--r-- | shared-bindings/nativeio/DigitalInOut.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/shared-bindings/nativeio/DigitalInOut.c b/shared-bindings/nativeio/DigitalInOut.c index 6c15944eb..f3f9bf038 100644 --- a/shared-bindings/nativeio/DigitalInOut.c +++ b/shared-bindings/nativeio/DigitalInOut.c @@ -136,9 +136,20 @@ MP_DEFINE_CONST_FUN_OBJ_KW(nativeio_digitalinout_switch_to_output_obj, 1, native //| .. method:: switch_to_input(pull=None) //| -//| Switch to read in digital values. +//| Switch to read in digital values. //| -//| :param Pull pull: pull configuration for the input +//| :param Pull pull: pull configuration for the input +//| +//| Example usage:: +//| +//| import nativeio +//| import board +//| +//| with nativeio.DigitalInOut(board.SLIDE_SWITCH) as switch: +//| switch.switch_to_input(pull=nativeio.DigitalInOut.Pull.up) +//| # Or, after switch_to_input +//| switch.pull = nativeio.DigitalInOut.Pull.up +//| print(switch.value) //| typedef struct { mp_obj_base_t base; @@ -149,7 +160,7 @@ extern const nativeio_digitalinout_pull_obj_t nativeio_digitalinout_pull_down_ob STATIC mp_obj_t nativeio_digitalinout_switch_to_input(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_pull }; static const mp_arg_t allowed_args[] = { - { MP_QSTR_value, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = mp_const_none} }, + { MP_QSTR_pull, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = mp_const_none} }, }; nativeio_digitalinout_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; |
