Fix pull kwarg DigitalInOut.switch_to_input and add example use to docs.

Thanks to jerryn from the Adafruit Forum for finding the bug!
This commit is contained in:
Scott Shawcroft 2017-01-16 10:35:46 -08:00
parent 78168bc984
commit df96823dee
1 changed files with 14 additions and 3 deletions

View File

@ -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)];