添加STAwifi模式以及修改灯状态
This commit is contained in:
@@ -12,6 +12,9 @@ void sertrf_init(void)
|
||||
}
|
||||
//RGB灯
|
||||
work_rgb_led_start();
|
||||
//按键初始化
|
||||
button_work_init();
|
||||
//线程启动
|
||||
sertrf_start();
|
||||
}
|
||||
void sertrf_start(void)
|
||||
@@ -35,37 +38,90 @@ void embedded_thread(void* arg)
|
||||
// SYS_LOG_INF("data : %s", data);
|
||||
pc_device_write(&sertrf.device, data, embedded_size);
|
||||
}
|
||||
embedded_size = pc_device_get_rx_length(&sertrf.device);
|
||||
if(embedded_size > 0)
|
||||
|
||||
uint32_t pc_size = pc_device_get_rx_length(&sertrf.device);
|
||||
|
||||
if(pc_size > 0)
|
||||
{
|
||||
uint8_t data[embedded_size];
|
||||
pc_device_read(&sertrf.device, data, embedded_size);
|
||||
uint8_t data[pc_size];
|
||||
pc_device_read(&sertrf.device, data, pc_size);
|
||||
// SYS_LOG_INF("data : %s", data);
|
||||
embedded_device_write(&sertrf.device, data, embedded_size);
|
||||
embedded_device_write(&sertrf.device, data, pc_size);
|
||||
}
|
||||
pc_link_rgb_color(sertrf.device.connect_pc);
|
||||
// printf_chill_time(10,1000);
|
||||
pc_link_rgb_color(&sertrf.device);
|
||||
//需要添加一些延时,否则会卡死,导致看门狗复位
|
||||
// vTaskDelay(( TickType_t ) 1000 / configTICK_RATE_HZ);
|
||||
os_thread_sleep(1);
|
||||
}
|
||||
}
|
||||
void pc_link_rgb_color(uint8_t connect)
|
||||
void pc_link_rgb_color(device_t* device)
|
||||
{
|
||||
static uint8_t last_connect = 0;
|
||||
if(connect != last_connect)
|
||||
static uint8_t last_connect = 0, last_wifi_mode = 0;
|
||||
if(device->connect_pc != last_connect || last_wifi_mode != device->init_device.wifi_mode)
|
||||
{
|
||||
switch (connect)
|
||||
switch (device->connect_pc)
|
||||
{
|
||||
case DISCONNECT:
|
||||
rgb_color_change(0, RGB_COLOR_RAD);
|
||||
{
|
||||
if(device->init_device.wifi_mode == WIFI_NETIF_MODE_AP)
|
||||
rgb_color_change(0, RGB_COLOR_BLUE);
|
||||
else
|
||||
rgb_color_change(0, RGB_COLOR_ORANGE);
|
||||
|
||||
break;
|
||||
case CONNECT_WIFI:
|
||||
}
|
||||
case CONNECT_WIFI_TCP:
|
||||
{
|
||||
if(device->init_device.wifi_mode == WIFI_NETIF_MODE_AP)
|
||||
rgb_color_change(0, RGB_COLOR_WHITE);
|
||||
else
|
||||
rgb_color_change(0, RGB_COLOR_PURPLE);
|
||||
|
||||
break;
|
||||
}
|
||||
case CONNECT_WIFI_UDP:
|
||||
{
|
||||
if(device->init_device.wifi_mode == WIFI_NETIF_MODE_AP)
|
||||
rgb_color_change(0, RGB_COLOR_WHITE);
|
||||
else
|
||||
rgb_color_change(0, RGB_COLOR_PURPLE);
|
||||
|
||||
break;
|
||||
}
|
||||
case CONNECT_BLE:
|
||||
rgb_color_change(0, RGB_COLOR_GREEN);
|
||||
break;
|
||||
case CONNECT_BLE:
|
||||
rgb_color_change(0, RGB_COLOR_BLUE);
|
||||
break;
|
||||
}
|
||||
last_connect = connect;
|
||||
last_connect = device->connect_pc;
|
||||
last_wifi_mode = device->init_device.wifi_mode;
|
||||
}
|
||||
if(device->connect_pc){
|
||||
rgb_update_cyle(0);
|
||||
}else{
|
||||
rgb_update_cyle(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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user