添加提示状态灯
This commit is contained in:
@@ -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};
|
||||
@@ -206,3 +208,25 @@ 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;
|
||||
}
|
||||
@@ -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,
|
||||
@@ -55,3 +56,5 @@ 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);
|
||||
void rgb_Indicator_light_on(uint8_t index, uint8_t color, uint16_t cyle);
|
||||
void rgb_Indicator_light_off(uint8_t index);
|
||||
@@ -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) {
|
||||
// 第二次松开 -> 双击
|
||||
|
||||
Reference in New Issue
Block a user