Skip to content

Commit 2d30d6d

Browse files
committed
add support for keycodes to make inky-buttons usable
1 parent 123aad7 commit 2d30d6d

File tree

1 file changed

+34
-0
lines changed
  • ports/raspberrypi/boards/pimoroni_inky_frame_5_7

1 file changed

+34
-0
lines changed

ports/raspberrypi/boards/pimoroni_inky_frame_5_7/pins.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,41 @@
22

33
#include "supervisor/board.h"
44
#include "shared-module/displayio/__init__.h"
5+
#include "py/objtuple.h"
6+
#include "py/qstr.h"
7+
58
#include "inky-shared.h"
69

10+
// for use with keypad.ShiftRegisterKeys: map keycode (bit-number)
11+
// to logical names board.KEYCODES.SW_A etc.
12+
// N.B.: labels and bit-numbers in the schematic are reversed, i.e.
13+
// SW_A on D0 has bit-number 7
14+
15+
STATIC const qstr board_keycodes_fields[] = {
16+
MP_QSTR_SW_A,
17+
MP_QSTR_SW_B,
18+
MP_QSTR_SW_C,
19+
MP_QSTR_SW_D,
20+
MP_QSTR_SW_E,
21+
MP_QSTR_RTC_ALARM,
22+
MP_QSTR_EXT_TRIGGER,
23+
MP_QSTR_INKY_BUS
24+
};
25+
26+
STATIC MP_DEFINE_ATTRTUPLE(
27+
board_keycodes_obj,
28+
board_keycodes_fields,
29+
8,
30+
MP_ROM_INT(7),
31+
MP_ROM_INT(6),
32+
MP_ROM_INT(5),
33+
MP_ROM_INT(4),
34+
MP_ROM_INT(3),
35+
MP_ROM_INT(2),
36+
MP_ROM_INT(1),
37+
MP_ROM_INT(0)
38+
);
39+
740
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
841
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
942

@@ -49,5 +82,6 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
4982

5083
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].epaper_display)},
5184
{ MP_ROM_QSTR(MP_QSTR_ENABLE_DIO), MP_ROM_PTR(&enable_pin_obj)}, // GP2
85+
{ MP_ROM_QSTR(MP_QSTR_KEYCODES), MP_ROM_PTR(&board_keycodes_obj)},
5286
};
5387
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);

0 commit comments

Comments
 (0)