1| Supported Targets | ESP32-S2 | 2| ----------------- | -------- | 3 4# Matrix Keyboard Example (based on Dedicated GPIO) 5 6(See the README.md file in the upper level 'examples' directory for more information about examples.) 7 8## Overview 9 10This example mainly illustrates how to drive a common matrix keyboard using the dedicated GPIO APIs, including: 11 12* Manipulate the level on a group of GPIOs 13* Trigger edge interrupt 14* Read level on a group of GPIOs 15 16Dedicated GPIO is designed to speed up CPU operations on one or a group of GPIOs by writing assembly codes with Espressif customized instructions (please refer TRM to get more information about these instructions). 17 18This matrix keyboard driver is interrupt-driven, supports a configurable debounce time. GPIOs used by row and column lines are also configurable during driver installation stage. 19 20## How to use example 21 22### Hardware Required 23 24This example can run on any target that has the dedicated feature (e.g. ESP32-S2). It's not necessary for your matrix board to have pull-up resisters on row/column lines. The driver has enabled internal pull-up resister by default. A typical matrix board should look as follows: 25 26``` 27row_0 +--------+-------------------+------------------------------+-----------------+ 28 | | | 29 | + | + | + 30 | +-+-+ | +-+-+ ...... | +-+-+ 31 . +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ 32 . | | | 33 . . | . | . | 34 . | . | ...... . | 35 . | . | . | 36 . | . | . | 37 | | | 38row_n +--------+-------------------+------------------------------+-----------------+ 39 | | | | | | 40 | + | | + | | + | 41 | +-+-+ | | +-+-+ | ...... | +-+-+ | 42 +-----+ +-----+ +-----+ +-----+ +-----+ +-----+ 43 | | | 44 | | | 45 | | | 46 + + + 47 col_0 col_1 ...... col_m 48``` 49 50### Build and Flash 51 52Build the project and flash it to the board, then run monitor tool to view serial output: 53 54``` 55idf.py -p PORT flash monitor 56``` 57 58(Replace PORT with the name of the serial port to use.) 59 60(To exit the serial monitor, type ``Ctrl-]``.) 61 62See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects. 63 64## Example Output 65 66``` 67I (2883) example: press event, key code = 0002 68I (3003) example: release event, key code = 0002 69I (5053) example: press event, key code = 0001 70I (5203) example: release event, key code = 0001 71I (6413) example: press event, key code = 0000 72I (6583) example: release event, key code = 0000 73I (7963) example: press event, key code = 0003 74I (8113) example: release event, key code = 0003 75I (8773) example: press event, key code = 0103 76I (8923) example: release event, key code = 0103 77I (9543) example: press event, key code = 0203 78I (9683) example: release event, key code = 0203 79``` 80