Allow disabling each class in keypad

.. for boards like pewpewm4 which need a specific kind. And need
some space.
This commit is contained in:
Jeff Epler 2023-04-01 19:22:52 -05:00
parent 736af5b0c8
commit 05cf5213e2
No known key found for this signature in database
GPG Key ID: D5BF15AB975AB4DE
5 changed files with 38 additions and 0 deletions

View File

@ -44,6 +44,8 @@ CIRCUITPY_AUDIOIO = 1
CIRCUITPY_AUDIOMIXER = 1
CIRCUITPY_DISPLAYIO = 1
CIRCUITPY_KEYPAD = 1
CIRCUITPY_KEYPAD_SHIFTREGISTERKEYS = 0
CIRCUITPY_KEYPAD_KEYMATRIX = 0
CIRCUITPY_MATH = 1
CIRCUITPY_STAGE = 1
CIRCUITPY_SYNTHIO = 1

View File

@ -291,6 +291,15 @@ CFLAGS += -DCIRCUITPY_JSON=$(CIRCUITPY_JSON)
CIRCUITPY_KEYPAD ?= $(CIRCUITPY_FULL_BUILD)
CFLAGS += -DCIRCUITPY_KEYPAD=$(CIRCUITPY_KEYPAD)
CIRCUITPY_KEYPAD_KEYS ?= $(CIRCUITPY_KEYPAD)
CFLAGS += -DCIRCUITPY_KEYPAD_KEYS=$(CIRCUITPY_KEYPAD_KEYS)
CIRCUITPY_KEYPAD_KEYMATRIX ?= $(CIRCUITPY_KEYPAD)
CFLAGS += -DCIRCUITPY_KEYPAD_KEYMATRIX=$(CIRCUITPY_KEYPAD_KEYMATRIX)
CIRCUITPY_KEYPAD_SHIFTREGISTERKEYS ?= $(CIRCUITPY_KEYPAD)
CFLAGS += -DCIRCUITPY_KEYPAD_SHIFTREGISTERKEYS=$(CIRCUITPY_KEYPAD_SHIFTREGISTERKEYS)
CIRCUITPY_MATH ?= 1
CFLAGS += -DCIRCUITPY_MATH=$(CIRCUITPY_MATH)

View File

@ -71,6 +71,7 @@
//| ...
STATIC mp_obj_t keypad_keymatrix_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
#if CIRCUITPY_KEYPAD_KEYMATRIX
keypad_keymatrix_obj_t *self = m_new_obj(keypad_keymatrix_obj_t);
self->base.type = &keypad_keymatrix_type;
enum { ARG_row_pins, ARG_column_pins, ARG_columns_to_anodes, ARG_interval, ARG_max_events };
@ -114,8 +115,13 @@ STATIC mp_obj_t keypad_keymatrix_make_new(const mp_obj_type_t *type, size_t n_ar
common_hal_keypad_keymatrix_construct(self, num_row_pins, row_pins_array, num_column_pins, column_pins_array, args[ARG_columns_to_anodes].u_bool, interval, max_events);
return MP_OBJ_FROM_PTR(self);
#else
mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_KeyMatrix);
#endif
}
#if CIRCUITPY_KEYPAD_KEYMATRIX
//| def deinit(self) -> None:
//| """Stop scanning and release the pins."""
//| ...
@ -228,9 +234,13 @@ STATIC const mp_rom_map_elem_t keypad_keymatrix_locals_dict_table[] = {
STATIC MP_DEFINE_CONST_DICT(keypad_keymatrix_locals_dict, keypad_keymatrix_locals_dict_table);
#endif
const mp_obj_type_t keypad_keymatrix_type = {
{ &mp_type_type },
.name = MP_QSTR_KeyMatrix,
.make_new = keypad_keymatrix_make_new,
#if CIRCUITPY_KEYPAD_KEYMATRIX
.locals_dict = (mp_obj_t)&keypad_keymatrix_locals_dict,
#endif
};

View File

@ -73,6 +73,7 @@
//| ...
STATIC mp_obj_t keypad_keys_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
#if CIRCUITPY_KEYPAD_KEYS
keypad_keys_obj_t *self = m_new_obj(keypad_keys_obj_t);
self->base.type = &keypad_keys_type;
enum { ARG_pins, ARG_value_when_pressed, ARG_pull, ARG_interval, ARG_max_events };
@ -106,8 +107,13 @@ STATIC mp_obj_t keypad_keys_make_new(const mp_obj_type_t *type, size_t n_args, s
common_hal_keypad_keys_construct(self, num_pins, pins_array, value_when_pressed, args[ARG_pull].u_bool, interval, max_events);
return MP_OBJ_FROM_PTR(self);
#else
mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_Keys);
#endif
}
#if CIRCUITPY_KEYPAD_KEYS
//| def deinit(self) -> None:
//| """Stop scanning and release the pins."""
//| ...
@ -162,10 +168,13 @@ STATIC const mp_rom_map_elem_t keypad_keys_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(keypad_keys_locals_dict, keypad_keys_locals_dict_table);
#endif
const mp_obj_type_t keypad_keys_type = {
{ &mp_type_type },
.name = MP_QSTR_Keys,
.make_new = keypad_keys_make_new,
#if CIRCUITPY_KEYPAD_KEYS
.locals_dict = (mp_obj_t)&keypad_keys_locals_dict,
#endif
};

View File

@ -82,6 +82,7 @@
//| ...
STATIC mp_obj_t keypad_shiftregisterkeys_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
#if CIRCUITPY_KEYPAD_KEYMATRIX
keypad_shiftregisterkeys_obj_t *self = m_new_obj(keypad_shiftregisterkeys_obj_t);
self->base.type = &keypad_shiftregisterkeys_type;
enum { ARG_clock, ARG_data, ARG_latch, ARG_value_to_latch, ARG_key_count, ARG_value_when_pressed, ARG_interval, ARG_max_events };
@ -113,8 +114,12 @@ STATIC mp_obj_t keypad_shiftregisterkeys_make_new(const mp_obj_type_t *type, siz
self, clock, data, latch, value_to_latch, key_count, value_when_pressed, interval, max_events);
return MP_OBJ_FROM_PTR(self);
#else
mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_ShiftRegisterKeys);
#endif
}
#if CIRCUITPY_KEYPAD_KEYMATRIX
//| def deinit(self) -> None:
//| """Stop scanning and release the pins."""
//| ...
@ -169,10 +174,13 @@ STATIC const mp_rom_map_elem_t keypad_shiftregisterkeys_locals_dict_table[] = {
};
STATIC MP_DEFINE_CONST_DICT(keypad_shiftregisterkeys_locals_dict, keypad_shiftregisterkeys_locals_dict_table);
#endif
const mp_obj_type_t keypad_shiftregisterkeys_type = {
{ &mp_type_type },
.name = MP_QSTR_ShiftRegisterKeys,
.make_new = keypad_shiftregisterkeys_make_new,
#if CIRCUITPY_KEYPAD_KEYMATRIX
.locals_dict = (mp_obj_t)&keypad_shiftregisterkeys_locals_dict,
#endif
};