From 675ed488cb7c548782ca5df25b08d8a1d310dc52 Mon Sep 17 00:00:00 2001 From: whowechina Date: Sun, 12 Apr 2026 16:08:41 +0800 Subject: [PATCH] Slider debug feature --- firmware/src/cli.c | 12 +++++++++++- firmware/src/commands.c | 18 ++++++++++++++++-- firmware/src/config.h | 1 + 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/firmware/src/cli.c b/firmware/src/cli.c index f5c5d33..8c5c54d 100644 --- a/firmware/src/cli.c +++ b/firmware/src/cli.c @@ -22,9 +22,12 @@ static const char *commands[MAX_COMMANDS]; static const char *helps[MAX_COMMANDS]; static cmd_handler_t handlers[MAX_COMMANDS]; static int max_cmd_len = 0; - static int num_commands = 0; +__attribute__((weak)) void cli_ctrl_c_cb(void) +{ +} + uint64_t board_id_64() { pico_unique_board_id_t id; @@ -179,6 +182,13 @@ void cli_run() if (c < 0) { return; } + + if (c == 0x03) { /* Ctrl+C */ + cli_ctrl_c_cb(); + cmd_len = 0; + printf("^C\n%s", cli_prompt); + return; + } if (c == '\b' || c == 127) { // both backspace and delete if (cmd_len > 0) { diff --git a/firmware/src/commands.c b/firmware/src/commands.c index 245790e..599601a 100644 --- a/firmware/src/commands.c +++ b/firmware/src/commands.c @@ -13,6 +13,8 @@ #include "savedata.h" #include "cli.h" +#include "slide.h" + #include "usb_descriptors.h" #define SENSE_LIMIT_MAX 9 @@ -386,23 +388,35 @@ static void handle_trigger(int argc, char *argv[]) static void handle_debug(int argc, char *argv[]) { - const char *usage = "Usage: debug \n"; + const char *usage = "Usage: debug \n"; if (argc != 1) { printf(usage); return; } - const char *choices[] = {"sensor"}; + const char *choices[] = {"sensor", "slider_cluster"}; switch (cli_match_prefix(choices, count_of(choices), argv[0])) { case 0: diva_runtime.debug.sensor ^= true; hebtn_debug(diva_runtime.debug.sensor); break; + case 1: + diva_runtime.debug.slide_cluster ^= true; + slide_set_debug_cluster(diva_runtime.debug.slide_cluster); + break; default: printf(usage); break; } } +void cli_ctrl_c_cb(void) +{ + diva_runtime.debug.sensor = false; + diva_runtime.debug.slide_cluster = false; + hebtn_debug(false); + slide_set_debug_cluster(false); +} + static void handle_save() { savedata_request(true); diff --git a/firmware/src/config.h b/firmware/src/config.h index a514d19..949a5c7 100644 --- a/firmware/src/config.h +++ b/firmware/src/config.h @@ -42,6 +42,7 @@ typedef struct { bool hid_ps4; struct { bool sensor; + bool slide_cluster; } debug; } diva_runtime_t;