From e56f06384150e0e3ce723c0bc296af017ae8124d Mon Sep 17 00:00:00 2001 From: whowechina Date: Tue, 17 Sep 2024 20:33:30 +0800 Subject: [PATCH] Minor optimizations --- firmware/src/commands.c | 8 ++++---- firmware/src/touch.c | 3 ++- firmware/src/touch.h | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/firmware/src/commands.c b/firmware/src/commands.c index a1a743a..8f05b5c 100644 --- a/firmware/src/commands.c +++ b/firmware/src/commands.c @@ -395,11 +395,11 @@ static void handle_debounce(int argc, char *argv[]) disp_sense(); } -static void print_readings(const char *title, const uint16_t *raw, int num) +static void print_readings(const char *title, const uint16_t *readings, int num) { printf(" %s |", title); for (int i = 0; i < num; i++) { - printf(" %4d |", raw[i]); + printf(" %4d |", readings[i]); } printf("\n"); } @@ -416,13 +416,13 @@ static void handle_raw() touch_sensor_ok(1) ? "OK" : "ERR", touch_sensor_ok(2) ? "OK" : "ERR"); - printf(" Sensor readings:\n"); + printf(" By Sensor:\n"); printf(" |___1__|___2__|___3__|___4__|___5__|___6__|___7__|___8__|___9__|__10__|__11__|__12__|\n"); print_readings("0", raw, 12); print_readings("1", raw + 12, 12); print_readings("2", raw + 24, 12); - printf(" Zone readings:\n"); + printf(" By Zone:\n"); printf(" |___1__|___2__|___3__|___4__|___5__|___6__|___7__|___8__|\n"); print_readings("A", zones, 8); print_readings("B", zones + 8, 8); diff --git a/firmware/src/touch.c b/firmware/src/touch.c index 707d801..f4ee64c 100644 --- a/firmware/src/touch.c +++ b/firmware/src/touch.c @@ -167,7 +167,8 @@ const uint16_t *touch_raw() return readout; } -const uint16_t *map_raw_to_zones(uint16_t* raw) { +const uint16_t *map_raw_to_zones(const uint16_t* raw) +{ static uint16_t zones[36]; for (int i = 0; i < 34; i++) { diff --git a/firmware/src/touch.h b/firmware/src/touch.h index ab7f5eb..9ef46a1 100644 --- a/firmware/src/touch.h +++ b/firmware/src/touch.h @@ -29,7 +29,7 @@ uint64_t touch_touchmap(); void touch_set_map(unsigned sensor, unsigned key); const uint16_t *touch_raw(); -const uint16_t *map_raw_to_zones(uint16_t *raw); +const uint16_t *map_raw_to_zones(const uint16_t *raw); bool touch_sensor_ok(unsigned i); void touch_update_config();