Rdzleo f9dc7d4861 feat: 触屏版迁移到按键版,两键实现全部交互功能
1. 按键驱动重构:GPIO中断+手动去抖 → iot_button组件(单击/双击/长按)
2. 新增key_nav按键导航管理器:上下文状态机 + Set界面焦点蓝色边框高亮
3. 移除所有触摸手势/点击事件(ScreenHome/ScreenImg/ScreenSet)
4. 应援灯颜色切换优化:DISPOFF→直接写GRAM→DISPON,消除分band刷新
5. 亮度调节按键化:BOOT +10% / KEY -10% / KEY长按退出
6. 休眠管理适配:按键唤醒统一由key_nav处理
7. 新增迁移总结文档 docs/touch-to-button-migration.md

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 14:57:14 +08:00

1.7 KiB

Component Registry

Component: Button

Online documentation

After creating a new button object by calling function button_create(), the button object can create press events, every press event can have its own callback.

List of supported events:

  • Button pressed
  • Button released
  • Button pressed repeat
  • Button press repeat done
  • Button single click
  • Button double click
  • Button multiple click
  • Button long press start
  • Button long press hold
  • Button long press up
  • Button Press end

There are three ways this driver can handle buttons:

  1. Buttons connected to standard digital GPIO
  2. Multiple buttons connected to single ADC channel
  3. Matrix keyboard employs multiple GPIOs for operation.
  4. Custom button connect to any driver

The component supports the following functionalities:

  1. Creation of an unlimited number of buttons, accommodating various types simultaneously.
  2. Multiple callback functions for a single event.
  3. Allowing customization of the consecutive key press count to any desired number.
  4. Facilitating the setup of callbacks for any specified long-press duration.
  5. Support power save mode (Only for gpio button)

Add component to your project

Please use the component manager command add-dependency to add the button to your project's dependency, during the CMake step the component will be downloaded automatically

idf.py add-dependency "espressif/button=*"