esp32/machine_pin: Make it so None as pull value disables pull up/down.
Previously specifying None as the pull value would leave the pull up/down state unchanged. This change makes it so -1 leaves the state unchanged and None makes the pin float, as per the docs.
This commit is contained in:
parent
ea2fcdd338
commit
349b54525e
|
@ -137,7 +137,7 @@ STATIC mp_obj_t machine_pin_obj_init_helper(const machine_pin_obj_t *self, size_
|
|||
enum { ARG_mode, ARG_pull, ARG_value };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_mode, MP_ARG_OBJ, {.u_obj = mp_const_none}},
|
||||
{ MP_QSTR_pull, MP_ARG_OBJ, {.u_obj = mp_const_none}},
|
||||
{ MP_QSTR_pull, MP_ARG_OBJ, {.u_obj = MP_OBJ_NEW_SMALL_INT(-1)}},
|
||||
{ MP_QSTR_value, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL}},
|
||||
};
|
||||
|
||||
|
@ -164,9 +164,13 @@ STATIC mp_obj_t machine_pin_obj_init_helper(const machine_pin_obj_t *self, size_
|
|||
}
|
||||
|
||||
// configure pull
|
||||
if (args[ARG_pull].u_obj != mp_const_none) {
|
||||
if (args[ARG_pull].u_obj != MP_OBJ_NEW_SMALL_INT(-1)) {
|
||||
if (args[ARG_pull].u_obj == mp_const_none) {
|
||||
gpio_set_pull_mode(self->id, GPIO_FLOATING);
|
||||
} else {
|
||||
gpio_set_pull_mode(self->id, mp_obj_get_int(args[ARG_pull].u_obj));
|
||||
}
|
||||
}
|
||||
|
||||
return mp_const_none;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue