修复RGB在按键提示的时候导致的RGB指示问题,以及将功能性函数分离开来

This commit is contained in:
OPTOC
2025-10-20 12:00:32 +08:00
parent a3e823c57a
commit ce9fac6b32
5 changed files with 93 additions and 43 deletions

View File

@@ -174,7 +174,8 @@ void task_thread(void* arg)
switch(get_protocol_status())
{
case PROTOCOL_STATUS_OK:
rgb_color_change(1, sertrf.device.last_color);
// rgb_color_change(1, sertrf.device.last_color);
rgb_color_change(1, RGB_COLOR_ORANGE);
break;
case PROTOCOL_STATUS_NO_DATA:
rgb_color_change(1, RGB_COLOR_RAD);
@@ -243,45 +244,17 @@ void pc_link_rgb_color(device_t* device)
last_connect = device->connect_pc;
last_wifi_mode = device->init_device.wifi_mode;
}
if(device->connect_pc == DISCONNECT)
{
rgb_update_cyle(0,50);
}
else if(device->connect_pc){
rgb_update_cyle(0,888);
}else{
rgb_update_cyle(0,500);
}
}
void printf_chill_time(uint8_t chill_time, uint16_t type)
{
static size_t last_time[24] = {0};
static uint16_t cnt[24] = {0};
static uint32_t type_cnt_time[24] = {0};
size_t now_time = os_get_sys_time();
cnt[chill_time]++;
type_cnt_time[chill_time] += now_time - last_time[chill_time];
if(cnt[chill_time] % type == 0 && type_cnt_time[chill_time] / type >= now_time - last_time[chill_time] - 1)
{
SYS_LOG_INF("TIME_CHILL%d : %d : %d",chill_time, now_time - last_time[chill_time], type_cnt_time[chill_time]);
cnt[chill_time] = 0;
type_cnt_time[chill_time] = 0;
if(device->connect_pc == DISCONNECT)
{
rgb_update_cyle(0,50);
}
else if(device->connect_pc){
rgb_update_cyle(0,888);
}else{
rgb_update_cyle(0,500);
}
}
else if(cnt[chill_time] % type == 0)
{
SYS_LOG_WRN("TIME_CHILL%d : %d : %d",chill_time, now_time - last_time[chill_time], type_cnt_time[chill_time]);
cnt[chill_time] = 0;
type_cnt_time[chill_time] = 0;
}
last_time[chill_time] = now_time;
}
uint32_t parse_hex_or_dec(const char *s) {
if (!s) return 0;
if (s[0] == '0' && (s[1]=='x' || s[1]=='X')) return (uint32_t)strtoul(s+2, NULL, 16);
return (uint32_t)strtoul(s, NULL, 0);
}
int resend_send(void* data, uint16_t len, int timeout)