feat(boards): Add secondary button support to Waveshare ESP32-C6-Touch-AMOLED-2.16
- Enable BTN_FWD_GPIO (GPIO 10) as secondary button for mode toggle (Shift+Tab) - Update BOARD_HAS_SECONDARY_BUTTON flag from 0 to 1 - Clarify button layout: BOOT (primary PTT), PWR (cycle screens via AXP), KEY (secondary mode toggle) - Document KEY GPIO discovery method (empirical scanning of unused GPIOs) - Update button_count calculation to include secondary button when available - Initialize both BTN_BACK_GPIO and BTN_FWD_GPIO in input_hal_init() - Refactor input_hal_is_held() to use switch statement for cleaner multi-button handling
This commit is contained in:
@@ -42,12 +42,17 @@
|
|||||||
#define AXP2101_ADDR 0x34
|
#define AXP2101_ADDR 0x34
|
||||||
|
|
||||||
// ---- Buttons ----
|
// ---- Buttons ----
|
||||||
// Only one user GPIO button (BOOT). The "PWR" side button is the AXP2101
|
// Three side-mounted buttons:
|
||||||
// PKEY input — already serviced by power.cpp via the PKEY_SHORT_IRQ path.
|
// BOOT (primary) — GPIO 9, sends Space (PTT) over BLE HID
|
||||||
#define BTN_BACK_GPIO 9 // BOOT — primary, Space (PTT)
|
// PWR (cycle screens) — AXP2101 PKEY IRQ, handled in power.cpp
|
||||||
|
// KEY (secondary) — GPIO 10, sends Shift+Tab (mode toggle) over BLE HID
|
||||||
|
// KEY GPIO isn't documented by Waveshare; identified empirically by
|
||||||
|
// scanning unused GPIOs at boot (see git history of board_init.cpp).
|
||||||
|
#define BTN_BACK_GPIO 9
|
||||||
|
#define BTN_FWD_GPIO 10
|
||||||
|
|
||||||
// ---- Capability flags ----
|
// ---- Capability flags ----
|
||||||
#define BOARD_HAS_SECONDARY_BUTTON 0
|
#define BOARD_HAS_SECONDARY_BUTTON 1
|
||||||
#define BOARD_HAS_ROTATION 0 // C6 has no PSRAM headroom for the rotation strip
|
#define BOARD_HAS_ROTATION 0 // C6 has no PSRAM headroom for the rotation strip
|
||||||
#define BOARD_HAS_IMU 1 // present + initialized for I2C bus health
|
#define BOARD_HAS_IMU 1 // present + initialized for I2C bus health
|
||||||
#define BOARD_HAS_BATTERY 1
|
#define BOARD_HAS_BATTERY 1
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ static const BoardCaps caps = {
|
|||||||
.name = BOARD_NAME,
|
.name = BOARD_NAME,
|
||||||
.width = LCD_WIDTH,
|
.width = LCD_WIDTH,
|
||||||
.height = LCD_HEIGHT,
|
.height = LCD_HEIGHT,
|
||||||
.button_count = 1, // BOOT only; PWR is via AXP PKEY IRQ
|
// BOOT (primary) + KEY (secondary) GPIO buttons. PWR is on the AXP
|
||||||
|
// PKEY and handled separately (not counted here).
|
||||||
|
.button_count = (uint8_t)(1 + BOARD_HAS_SECONDARY_BUTTON),
|
||||||
.has_rotation = (bool)BOARD_HAS_ROTATION,
|
.has_rotation = (bool)BOARD_HAS_ROTATION,
|
||||||
.has_battery = (bool)BOARD_HAS_BATTERY,
|
.has_battery = (bool)BOARD_HAS_BATTERY,
|
||||||
.has_imu = (bool)BOARD_HAS_IMU,
|
.has_imu = (bool)BOARD_HAS_IMU,
|
||||||
|
|||||||
@@ -2,16 +2,17 @@
|
|||||||
#include "board.h"
|
#include "board.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
// Only BOOT is wired to a MCU GPIO. The "PWR" side button is the AXP2101
|
|
||||||
// PKEY, handled in power.cpp.
|
|
||||||
|
|
||||||
void input_hal_init(void) {
|
void input_hal_init(void) {
|
||||||
pinMode(BTN_BACK_GPIO, INPUT_PULLUP);
|
pinMode(BTN_BACK_GPIO, INPUT_PULLUP);
|
||||||
|
pinMode(BTN_FWD_GPIO, INPUT_PULLUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool input_hal_is_held(InputButton btn) {
|
bool input_hal_is_held(InputButton btn) {
|
||||||
if (btn == INPUT_BTN_PRIMARY) {
|
switch (btn) {
|
||||||
|
case INPUT_BTN_PRIMARY:
|
||||||
return digitalRead(BTN_BACK_GPIO) == LOW;
|
return digitalRead(BTN_BACK_GPIO) == LOW;
|
||||||
|
case INPUT_BTN_SECONDARY:
|
||||||
|
return digitalRead(BTN_FWD_GPIO) == LOW;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user