8000 Fix pull kwarg DigitalInOut.switch_to_input and add example use to docs. · pcurry/circuitpython@df96823 · GitHub
[go: up one dir, main page]

Skip to content

Commit df96823

Browse files
committed
Fix pull kwarg DigitalInOut.switch_to_input and add example use to docs.
Thanks to jerryn from the Adafruit Forum for finding the bug!
1 parent 78168bc commit df96823

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

shared-bindings/nativeio/DigitalInOut.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,20 @@ MP_DEFINE_CONST_FUN_OBJ_KW(nativeio_digitalinout_switch_to_output_obj, 1, native
136136

137137
//| .. method:: switch_to_input(pull=None)
138138
//|
139-
//| Switch to read in digital values.
139+
//| Switch to read in digital values.
140140
//|
141-
//| :param Pull pull: pull configuration for the input
141+
//| :param Pull pull: pull configuration for the input
142+
//|
143+
//| Example usage::
144+
//|
145+
//| import nativeio
146+
//| import board
147+
//|
148+
//| with nativeio.DigitalInOut(board.SLIDE_SWITCH) as switch:
149+
//| switch.switch_to_input(pull=nativeio.DigitalInOut.Pull.up)
150+
//| # Or, after switch_to_input
151+
//| switch.pull = nativeio.DigitalInOut.Pull.up
152+
//| print(switch.value)
142153
//|
143154
typedef struct {
144155
mp_obj_base_t base;
@@ -149,7 +160,7 @@ extern const nativeio_digitalinout_pull_obj_t nativeio_digitalinout_pull_down_ob
149160
STATIC mp_obj_t nativeio_digitalinout_switch_to_input(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
150161
enum { ARG_pull };
151162
static const mp_arg_t allowed_args[] = {
152-
{ MP_QSTR_value, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = mp_const_none} },
163+
{ MP_QSTR_pull, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_rom_obj = mp_const_none} },
153164
};
154165
nativeio_digitalinout_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
155166
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];

0 commit comments

Comments
 (0)
0