diff --git a/adafruit_seesaw/keypad.py b/adafruit_seesaw/keypad.py index 031e975..eb3a8c8 100644 --- a/adafruit_seesaw/keypad.py +++ b/adafruit_seesaw/keypad.py @@ -26,6 +26,10 @@ ==================================================== """ +import struct +from enum import IntEnum +from typing import NamedTuple + try: from micropython import const except ImportError: @@ -48,6 +52,30 @@ def const(x): _KEYPAD_COUNT = const(0x04) _KEYPAD_FIFO = const(0x10) + +class ResponseType(IntEnum): + # Types for the repsonse + TYPE_KEY = 0 + TYPE_COUNT = 1 + TYPE_STATUS = 2 + TYPE_INVALID = 0xff + + +class SeesawKeyResponse(NamedTuple): + response_type: ResponseType + data: int + + unpacker: struct.Struct = struct.Struct('