修复RGB在按键提示的时候导致的RGB指示问题,以及将功能性函数分离开来
This commit is contained in:
@@ -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)
|
||||
|
||||
41
app/drivers/sertrf/tool.c
Normal file
41
app/drivers/sertrf/tool.c
Normal file
@@ -0,0 +1,41 @@
|
||||
#include "tool.h"
|
||||
|
||||
int time_out(uint32_t* time_start, uint32_t timeout_ms)
|
||||
{
|
||||
uint32_t time_new = os_get_sys_time();
|
||||
if(time_new - *time_start > timeout_ms)
|
||||
{
|
||||
*time_start = time_new;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
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\n",chill_time, now_time - last_time[chill_time], type_cnt_time[chill_time]);
|
||||
cnt[chill_time] = 0;
|
||||
type_cnt_time[chill_time] = 0;
|
||||
}
|
||||
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);
|
||||
}
|
||||
24
app/drivers/sertrf/tool.h
Normal file
24
app/drivers/sertrf/tool.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
#include "os/os.h"
|
||||
#include "sys_log.h"
|
||||
|
||||
/**
|
||||
* @brief 超时判断
|
||||
*
|
||||
*/
|
||||
int time_out(uint32_t* time_start, uint32_t timeout_ms);
|
||||
/**
|
||||
* @brief 打印时间间隔
|
||||
*/
|
||||
void printf_chill_time(uint8_t chill_time, uint16_t type);
|
||||
/**
|
||||
* @brief 字符串转十进制
|
||||
*/
|
||||
uint32_t parse_hex_or_dec(const char *s);
|
||||
Reference in New Issue
Block a user