diff --git a/py/argcheck.c b/py/argcheck.c index 7710cf1592..8b6588a556 100644 --- a/py/argcheck.c +++ b/py/argcheck.c @@ -189,14 +189,16 @@ mp_float_t mp_arg_validate_obj_float_non_negative(mp_obj_t float_in, mp_float_t const mp_float_t f = (float_in == MP_OBJ_NULL) ? default_for_null : mp_obj_get_float(float_in); - if (f <= 0.0f) { + if (f <= (mp_float_t)0.0) { mp_raise_ValueError_varg(translate("%q must be >= 0"), arg_name); } return f; } size_t mp_arg_validate_length_with_name(mp_int_t i, size_t length, qstr arg_name, qstr length_name) { - mp_raise_ValueError_varg(translate("%q length must be %q"), MP_QSTR_pressed, MP_QSTR_num_keys); + if (i != (mp_int_t)length) { + mp_raise_ValueError_varg(translate("%q length must be %q"), MP_QSTR_pressed, MP_QSTR_num_keys); + } return (size_t)i; } diff --git a/shared-bindings/keypad/Keys.c b/shared-bindings/keypad/Keys.c index 6286104be4..5f1d0ecc7d 100644 --- a/shared-bindings/keypad/Keys.c +++ b/shared-bindings/keypad/Keys.c @@ -36,7 +36,7 @@ //| class Keys: //| """Manage a set of independent keys.""" //| -//| def __init__(self, pins: Sequence[microcontroller.Pin], *, level_when_pressed: bool, pull: bool = True, interval: float = 0.020, max_events: int = 64) -> None: +//| def __init__(self, pins: Sequence[microcontroller.Pin], *, value_when_pressed: bool, pull: bool = True, interval: float = 0.020, max_events: int = 64) -> None: //| """ //| Create a `Keys` object that will scan keys attached to the given sequence of pins. //| Each key is independent and attached to its own pin. diff --git a/shared-bindings/keypad/ShiftRegisterKeys.c b/shared-bindings/keypad/ShiftRegisterKeys.c index 583e20e243..7896ed7a38 100644 --- a/shared-bindings/keypad/ShiftRegisterKeys.c +++ b/shared-bindings/keypad/ShiftRegisterKeys.c @@ -36,7 +36,7 @@ //| class ShiftRegisterKeys: //| """Manage a set of keys attached to an incoming shift register.""" //| -//| def __init__(self, clock: microcontroller.Pin, data: microcontroller.Pin, latch: microcontroller.Pin, level_when_pressed: bool, interval: float = 0.020, max_events: int = 64) -> None: +//| def __init__(self, clock: microcontroller.Pin, data: microcontroller.Pin, latch: microcontroller.Pin, value_when_pressed: bool, interval: float = 0.020, max_events: int = 64) -> None: //| """ //| Create a `Keys` object that will scan keys attached to a parallel-in serial-out shift register //| like the 74HC165 or equivalent.