当解析不出飞控数据时闪红灯

This commit is contained in:
OPTOC
2025-09-04 16:01:12 +08:00
parent 2e5b3416a6
commit bd9ffa3de2
9 changed files with 112 additions and 22 deletions

View File

@@ -27,6 +27,12 @@ void sertrf_start(void)
NULL,
4096,
20);
os_thread_create(&sertrf.task_thread,
"task_thread",
task_thread,
NULL,
2048,
10);
}
void embedded_thread(void* arg)
{
@@ -54,15 +60,52 @@ void embedded_thread(void* arg)
embedded_device_write(&sertrf.device, data, pc_size);
}
// printf_chill_time(10,1000);
pc_link_rgb_color(&sertrf.device);
//需要添加一些延时,否则会卡死,导致看门狗复位
// vTaskDelay(( TickType_t ) 1000 / configTICK_RATE_HZ);
os_thread_sleep(1);
}
}
void task_thread(void* arg)
{
while(true)
{
size_t start_time = os_get_sys_time();
pc_link_rgb_color(&sertrf.device);
if(sertrf.device.connect_pc > DISCONNECT)
{
size_t end_time = 0;
if(start_time - end_time > 1000)
{
switch(get_protocol_status())
{
case PROTOCOL_STATUS_OK:
rgb_color_change(0, sertrf.device.last_color);
break;
case PROTOCOL_STATUS_NO_DATA:
rgb_color_change(0, RGB_COLOR_RAD);
break;
case PROTOCOL_STATUS_TYPE_IDLE:
rgb_color_change(0, RGB_COLOR_RAD);
break;
case PROTOCOL_STATUS_ANALYSIS_ERROR:
rgb_color_change(0, RGB_COLOR_RAD);
break;
default:
break;
}
end_time = os_get_sys_time();
}
}
os_thread_sleep(100);
}
}
void pc_link_rgb_color(device_t* device)
{
static uint8_t last_connect = 255, last_wifi_mode = 0;
uint8_t new_color = 0;
if(device->connect_pc != last_connect || last_wifi_mode != device->init_device.wifi_mode)
{
switch (device->connect_pc)
@@ -70,34 +113,39 @@ void pc_link_rgb_color(device_t* device)
case DISCONNECT:
{
if(device->init_device.wifi_mode == WIFI_NETIF_MODE_AP)
rgb_color_change(0, RGB_COLOR_GREEN_WHITE);
new_color = RGB_COLOR_GREEN_WHITE;
else
rgb_color_change(0, RGB_COLOR_GREEN_PURPLE);
new_color = RGB_COLOR_GREEN_PURPLE;
break;
}
case CONNECT_WIFI_TCP:
{
if(device->init_device.wifi_mode == WIFI_NETIF_MODE_AP)
rgb_color_change(0, RGB_COLOR_WHITE);
new_color = RGB_COLOR_WHITE;
else
rgb_color_change(0, RGB_COLOR_PURPLE);
new_color = 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);
new_color = RGB_COLOR_WHITE;
else
rgb_color_change(0, RGB_COLOR_PURPLE);
new_color = RGB_COLOR_PURPLE;
break;
}
case CONNECT_BLE:
rgb_color_change(0, RGB_COLOR_GREEN);
new_color = RGB_COLOR_GREEN;
break;
}
if(device->last_color != new_color)
rgb_color_change(0,new_color);
device->last_color = new_color;
last_connect = device->connect_pc;
last_wifi_mode = device->init_device.wifi_mode;
}