目录
  • 一、准备工作
  • 二、编译代码
  • 三、测试

8.KEYSCAN矩阵键盘扫描测试

该教程演示如何通过两块开发板实现KEYSCAN矩阵键盘扫描测试

一、准备工作

  • 准备1块BearPi-Pico H2821开发板

二、编译代码

在Windows下编译操作
  1. 点击左侧的“KConfig”,打开配置界面.

    Alt text

  2. 选择Support KEYSCAN Sample.

    [*] Enable Sample.
    [*]     Enable the Sample of peripheral.
    [ ]         Enable all the sample of peripheral, it's just for build.
    [ ]         Support ADC Sample.
    [ ]         Support BLINKY Sample.
    [ ]         Support BUTTON Sample.
    [ ]         Support DMA Sample.
    [ ]         Support I2C Sample.
    [ ]         Support I2S Sample.
    [*]         Support KEYSCAN Sample.
    
    
  3. 按下"Save"键保存配置。

    Alt text

  4. 可自行修改行列对应的GPIO以及键值

    Alt text

  5. 编译烧录固件

    参考环境搭建教程编译烧录代码

三、测试

烧录固件后按下开发的复位按键,任意行GPIO和列GPIO短接,串口日志中会打印对应的键值,当键值为0时不会打印。

keyscan register callback start!
keyscan register callback succ!
keyscan enable start!
keyscan enable start succ!
[pm_sys]pm_sys_entry.
KEY val: 0x29
KEY val: 0x2B
KEY val: 0x14
KEY val: 0x35
KEY val: 0x04