From d925d4ab7e07937a5bbfe915b066aebf7086d188 Mon Sep 17 00:00:00 2001 From: OPTOC <9159397+optoc@user.noreply.gitee.com> Date: Wed, 10 Sep 2025 10:19:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8F=90=E7=A4=BA=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E7=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/drivers/led_strip/led_strip.c | 24 ++++++++++++++++++++++++ app/drivers/led_strip/led_strip.h | 7 +++++-- app/drivers/sertrf/key.c | 10 ++++++---- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/app/drivers/led_strip/led_strip.c b/app/drivers/led_strip/led_strip.c index 002cbbf..c0a0a96 100644 --- a/app/drivers/led_strip/led_strip.c +++ b/app/drivers/led_strip/led_strip.c @@ -11,6 +11,8 @@ uint16_t toggle_cycle = 1000; bool toggle_flag = true; static uint8_t rgb_color_index = RGB_COLOR_RAD; +static uint8_t color_lat = 0, cyle_lat = 0; + rgb_color_t rgb_color_rad = {0,255,0,0,0,1,0}; rgb_color_t rgb_color_orange = {0,255,80,0,0,1,0}; rgb_color_t rgb_color_green = {0,0,255,0,0,1,0}; @@ -205,4 +207,26 @@ void rgb_toggle(rgb_color_t* rgb_color) void rgb_color_change(uint8_t index, uint8_t color) { rgb_color_index = color; +} + +void rgb_Indicator_light_on(uint8_t index, uint8_t color, uint16_t cyle) +{ + if(color_lat != rgb_color_index && rgb_color_index != color) + { + color_lat = rgb_color_index; + rgb_color_change(index, color); + } + if(cyle_lat != cyle && toggle_cycle != cyle) + { + cyle_lat = toggle_cycle; + rgb_update_cyle(cyle); + } + +} +void rgb_Indicator_light_off(uint8_t index) +{ + rgb_color_change(index, color_lat); + rgb_update_cyle(cyle_lat); + color_lat = 0; + cyle_lat = 0; } \ No newline at end of file diff --git a/app/drivers/led_strip/led_strip.h b/app/drivers/led_strip/led_strip.h index ba2fcb1..818ed6e 100644 --- a/app/drivers/led_strip/led_strip.h +++ b/app/drivers/led_strip/led_strip.h @@ -37,7 +37,8 @@ typedef struct rgb_color_s typedef enum { - RGB_COLOR_RAD = 0, + RGB_COLOR_NONE = 0, + RGB_COLOR_RAD, RGB_COLOR_ORANGE, RGB_COLOR_GREEN, RGB_COLOR_WHITE, @@ -54,4 +55,6 @@ void work_rgb_led_start(void); void _work_rgb_led(void *arg); void rgb_update_cyle(uint16_t cyle); void rgb_toggle(rgb_color_t* rgb_color); -void rgb_color_change(uint8_t index, uint8_t color); \ No newline at end of file +void rgb_color_change(uint8_t index, uint8_t color); +void rgb_Indicator_light_on(uint8_t index, uint8_t color, uint16_t cyle); +void rgb_Indicator_light_off(uint8_t index); \ No newline at end of file diff --git a/app/drivers/sertrf/key.c b/app/drivers/sertrf/key.c index ebadcef..747b2bd 100644 --- a/app/drivers/sertrf/key.c +++ b/app/drivers/sertrf/key.c @@ -33,9 +33,11 @@ static void my_button_handler(button_event_t evt) { // SYS_LOG_INF("[Event] DOUBLE_CLICK"); break; case EVT_LONG_PRESS: //长按 - // SYS_LOG_INF("[Event] LONG_PRESS"); + SYS_LOG_INF("[Event] LONG_PRESS"); + rgb_Indicator_light_off(0); break; case EVT_SINGLE_LONG_PRESS: //单击后长按 + rgb_Indicator_light_off(0); wifi_mode_switch(NULL); SYS_LOG_INF("[Event] SINGLE_LONG_PRESS"); break; @@ -94,7 +96,8 @@ static void button_scan(button_t *btn) { btn->state = 0; } } else if (btn->tick_cnt >= LONG_PRESS_TICKS) { - // 长按开始 + //长按开始 长按后提示 + rgb_Indicator_light_on(0, RGB_COLOR_CYAN, 100); // 可加 EVT_LONG_PRESS_START 如需区分开始和持续 } break; @@ -123,8 +126,7 @@ static void button_scan(button_t *btn) { // 单击长按后提示 if(btn->tick_cnt > LONG_PRESS_TICKS) { - rgb_color_change(0, RGB_COLOR_CYAN); - rgb_update_cyle(100); + rgb_Indicator_light_on(0, RGB_COLOR_CYAN, 100); } if (!btn->stable_state) { // 第二次松开 -> 双击