fix signed/unsigned compilation problem

This commit is contained in:
Dan Halbert 2021-06-10 01:14:16 -04:00
parent d3d9e0a487
commit 01a8a95b2c
2 changed files with 4 additions and 4 deletions

View File

@ -117,7 +117,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(keypad_keys_scan_obj, keypad_keys_scan);
STATIC mp_obj_t keypad_keys_state(mp_obj_t self_in, mp_obj_t key_num_obj) {
keypad_keys_obj_t *self = MP_OBJ_TO_PTR(self_in);
mp_int_t key_num = mp_obj_int_get_checked(key_num_obj);
if (key_num < 0 || key_num >= common_hal_keypad_keys_length(self)) {
if (key_num < 0 || (mp_uint_t)key_num >= common_hal_keypad_keys_length(self)) {
mp_raise_ValueError_varg(translate("%q out of range"), MP_QSTR_key_num);
}

View File

@ -106,13 +106,13 @@ size_t common_hal_keypad_keys_length(keypad_keys_obj_t *self) {
bool common_hal_keypad_keys_scan(keypad_keys_obj_t *self) {
uint64_t now = port_get_raw_ticks(NULL);
uint64_t last_scan_ticks = self->last_scan_ticks;
self->last_scan_ticks = now;
if (now - last_scan_ticks < DEBOUNCE_TICKS) {
if (now - self->last_scan_ticks < DEBOUNCE_TICKS) {
// Too soon.
return false;
}
self->last_scan_ticks = now;
for (mp_uint_t key_num = 0; key_num < common_hal_keypad_keys_length(self); key_num++) {
self->previously_pressed[key_num] = self->currently_pressed[key_num];
self->currently_pressed[key_num] =