|
@@ -358,7 +358,7 @@ void app_init()
|
|
//charge_init();
|
|
//charge_init();
|
|
//decection_charging_init();
|
|
//decection_charging_init();
|
|
|
|
|
|
- screen_queue = xQueueCreate(25, sizeof(bool));
|
|
|
|
|
|
+ screen_queue = xQueueCreate(25, sizeof(Screen_dis_t));
|
|
|
|
|
|
|
|
|
|
lora_data_queue = xQueueCreate(20, sizeof(LORA_DATA_T));
|
|
lora_data_queue = xQueueCreate(20, sizeof(LORA_DATA_T));
|
|
@@ -467,10 +467,11 @@ if(last_paint_buf_right!=NULL)
|
|
adc1_init();
|
|
adc1_init();
|
|
// extern void dis_right_instructions();
|
|
// extern void dis_right_instructions();
|
|
// dis_right_instructions();
|
|
// dis_right_instructions();
|
|
- bool is_left = false;
|
|
|
|
- if(xQueueSend(screen_queue,&is_left,portMAX_DELAY) != true)
|
|
|
|
|
|
+ screen_dis_info.is_left = false;
|
|
|
|
+ screen_dis_info.is_into_sleep = true;
|
|
|
|
+ if(xQueueSend(screen_queue,&screen_dis_info,portMAX_DELAY) != true)
|
|
{
|
|
{
|
|
- ESP_LOGE(LOG_TAG,"queue:screen_queue");
|
|
|
|
|
|
+ ESP_LOGE(LOG_TAG,"err:screen queue send fail");
|
|
}
|
|
}
|
|
int power_key = 0;
|
|
int power_key = 0;
|
|
int charge_key = 0;
|
|
int charge_key = 0;
|
|
@@ -489,7 +490,7 @@ if(last_paint_buf_right!=NULL)
|
|
Machine_info.batt_precent = read_battery_voltage();
|
|
Machine_info.batt_precent = read_battery_voltage();
|
|
|
|
|
|
Machine_info.last_batt_precent = Machine_info.batt_precent;
|
|
Machine_info.last_batt_precent = Machine_info.batt_precent;
|
|
- is_left = false;
|
|
|
|
|
|
+ screen_dis_info.is_left = false;
|
|
while(1)
|
|
while(1)
|
|
{
|
|
{
|
|
//value++;
|
|
//value++;
|
|
@@ -520,10 +521,10 @@ if(last_paint_buf_right!=NULL)
|
|
|
|
|
|
// extern void dis_right_instructions();
|
|
// extern void dis_right_instructions();
|
|
// dis_right_instructions();
|
|
// dis_right_instructions();
|
|
- is_left = false;
|
|
|
|
- if(xQueueSend(screen_queue,&is_left,portMAX_DELAY) != true)
|
|
|
|
|
|
+
|
|
|
|
+ if(xQueueSend(screen_queue,&screen_dis_info,portMAX_DELAY) != true)
|
|
{
|
|
{
|
|
- ESP_LOGE(LOG_TAG,"queue:screen_queue");
|
|
|
|
|
|
+ ESP_LOGE(LOG_TAG,"err:screen queue send fail");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -858,8 +859,8 @@ extern uint32_t ulp_wakeup_result;
|
|
|
|
|
|
|
|
|
|
#if 1
|
|
#if 1
|
|
- bool is_left = true;
|
|
|
|
- if(xQueueSend(screen_queue,&Machine_info,portMAX_DELAY) != true)
|
|
|
|
|
|
+ screen_dis_info.is_left = true;
|
|
|
|
+ if(xQueueSend(screen_queue,&screen_dis_info,portMAX_DELAY) != true)
|
|
{
|
|
{
|
|
printf("left send fail\r\n");
|
|
printf("left send fail\r\n");
|
|
}
|
|
}
|
|
@@ -1111,8 +1112,8 @@ static void screen_task(void* arg)
|
|
{
|
|
{
|
|
// Paint_leftScreen_main_powerOn();
|
|
// Paint_leftScreen_main_powerOn();
|
|
// Paint_rightScreen_main_powerON();
|
|
// Paint_rightScreen_main_powerON();
|
|
- Paint_leftScreen(Machine_info.power_status,Machine_info.paired,false,false);
|
|
|
|
- Paint_rightScreen(Machine_info.power_status,Machine_info.paired,false,false);
|
|
|
|
|
|
+ Paint_leftScreen(Machine_info.power_status,false);
|
|
|
|
+ Paint_rightScreen(Machine_info.power_status,false);
|
|
}
|
|
}
|
|
else if(reson == ESP_SLEEP_WAKEUP_EXT0)
|
|
else if(reson == ESP_SLEEP_WAKEUP_EXT0)
|
|
{
|
|
{
|
|
@@ -1120,30 +1121,29 @@ static void screen_task(void* arg)
|
|
ESP_LOGW(LOG_TAG,"按键从深睡唤醒,开机刷新屏慕");
|
|
ESP_LOGW(LOG_TAG,"按键从深睡唤醒,开机刷新屏慕");
|
|
// Paint_leftScreen_main_slow(&Machine_info);
|
|
// Paint_leftScreen_main_slow(&Machine_info);
|
|
// Paint_rightScreen_main_slow(&Machine_info);
|
|
// Paint_rightScreen_main_slow(&Machine_info);
|
|
- Paint_leftScreen(Machine_info.power_status,Machine_info.paired,false,false);
|
|
|
|
- Paint_rightScreen(Machine_info.power_status,Machine_info.paired,false,false);
|
|
|
|
|
|
+ Paint_leftScreen(Machine_info.power_status,false);
|
|
|
|
+ Paint_rightScreen(Machine_info.power_status,false);
|
|
}
|
|
}
|
|
- bool is_left = false;
|
|
|
|
|
|
+ screen_dis_info.is_left = false;
|
|
|
|
+ screen_dis_info.is_into_sleep = true;
|
|
Machine_info.left_current_Quick_refresh_time = 1;//开机慢刷
|
|
Machine_info.left_current_Quick_refresh_time = 1;//开机慢刷
|
|
while(1)
|
|
while(1)
|
|
{
|
|
{
|
|
- if(xQueueReceive(screen_queue, &is_left,(TickType_t)portMAX_DELAY))
|
|
|
|
|
|
+ if(xQueueReceive(screen_queue, &screen_dis_info,(TickType_t)portMAX_DELAY))
|
|
{
|
|
{
|
|
font_exit_sleep();
|
|
font_exit_sleep();
|
|
- ESP_LOGD(LOG_TAG,"%s",is_left?"左屏刷新":"右屏刷新");
|
|
|
|
- if(is_left)//刷左屏
|
|
|
|
|
|
+ ESP_LOGI(LOG_TAG,"%s , %s",screen_dis_info.is_left?"左屏刷新":"右屏刷新",screen_dis_info.is_into_sleep?"进入睡眠":"不进睡眠");
|
|
|
|
+ if(screen_dis_info.is_left)//刷左屏
|
|
{
|
|
{
|
|
if(Machine_info.left_current_Quick_refresh_time >= Machine_info.left_max_Quick_refresh_time)
|
|
if(Machine_info.left_current_Quick_refresh_time >= Machine_info.left_max_Quick_refresh_time)
|
|
{
|
|
{
|
|
Machine_info.left_current_Quick_refresh_time = 0;
|
|
Machine_info.left_current_Quick_refresh_time = 0;
|
|
- // Paint_leftScreen_main_slow(&Machine_info);
|
|
|
|
- Paint_leftScreen(Machine_info.power_status,Machine_info.paired,false,false);
|
|
|
|
|
|
+ Paint_leftScreen(Machine_info.power_status,false);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
Machine_info.left_current_Quick_refresh_time++;
|
|
Machine_info.left_current_Quick_refresh_time++;
|
|
- // Paint_leftScreen_main_quick(&Machine_info);
|
|
|
|
- Paint_leftScreen(Machine_info.power_status,Machine_info.paired,true,false);
|
|
|
|
|
|
+ Paint_leftScreen(Machine_info.power_status,true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else//刷右屏
|
|
else//刷右屏
|
|
@@ -1151,21 +1151,21 @@ static void screen_task(void* arg)
|
|
if(Machine_info.right_current_Quick_refresh_time == 0)
|
|
if(Machine_info.right_current_Quick_refresh_time == 0)
|
|
{
|
|
{
|
|
Machine_info.left_current_Quick_refresh_time = 1;
|
|
Machine_info.left_current_Quick_refresh_time = 1;
|
|
- Paint_rightScreen(Machine_info.power_status,Machine_info.paired,true,false);
|
|
|
|
|
|
+ Paint_rightScreen(Machine_info.power_status,true);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- Paint_rightScreen(Machine_info.power_status,Machine_info.paired,false,false);
|
|
|
|
|
|
+ Paint_rightScreen(Machine_info.power_status,false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if((Machine_info.power_status == 1)&&(Machine_info.paired == 1))
|
|
|
|
|
|
+ if((Machine_info.power_status == 1)&&(Machine_info.paired == 1)&& screen_dis_info.is_into_sleep)
|
|
{
|
|
{
|
|
- ESP_LOGW(LOG_TAG,"刷屏进入休眠 %s",is_left?"左屏刷新":"右屏刷新");
|
|
|
|
|
|
+ ESP_LOGW(LOG_TAG,"刷屏进入休眠 %s",screen_dis_info.is_left?"左屏刷新":"右屏刷新");
|
|
sleep_timer_start(100); //进入睡眠
|
|
sleep_timer_start(100); //进入睡眠
|
|
}
|
|
}
|
|
|
|
|
|
- if(Machine_info.power_status == 0 && is_left == false)//展示说明书都是先左后右,等右屏刷完再休眠
|
|
|
|
|
|
+ if(Machine_info.power_status == 0 && screen_dis_info.is_left == false)//展示说明书都是先左后右,等右屏刷完再休眠
|
|
{
|
|
{
|
|
printf("=>screen deep sleep\r\n");
|
|
printf("=>screen deep sleep\r\n");
|
|
uart_wait_tx_idle_polling(CONFIG_ESP_CONSOLE_UART_NUM);
|
|
uart_wait_tx_idle_polling(CONFIG_ESP_CONSOLE_UART_NUM);
|
|
@@ -1194,7 +1194,7 @@ static void button_task(void* arg)
|
|
{
|
|
{
|
|
//update_last_button_info(Machine_info.current_button.button_info);//初始化上个按键为运行,用作paint0703计时
|
|
//update_last_button_info(Machine_info.current_button.button_info);//初始化上个按键为运行,用作paint0703计时
|
|
uint8_t button_info;
|
|
uint8_t button_info;
|
|
- bool is_left = false;
|
|
|
|
|
|
+
|
|
while(1)
|
|
while(1)
|
|
{
|
|
{
|
|
if(xQueueReceive(button_Data_queue, &button_info, (TickType_t)portMAX_DELAY))
|
|
if(xQueueReceive(button_Data_queue, &button_info, (TickType_t)portMAX_DELAY))
|
|
@@ -1216,7 +1216,8 @@ static void button_task(void* arg)
|
|
#endif
|
|
#endif
|
|
if(button_info < 0x12) //左屏慕按键
|
|
if(button_info < 0x12) //左屏慕按键
|
|
{
|
|
{
|
|
- // print_lora();//按键查询lora配置
|
|
|
|
|
|
+ // vTaskDelay(200/ portTICK_PERIOD_MS);
|
|
|
|
+ // print_lora();//按键查询lora配置
|
|
if(Machine_info.btn_dis_flag[button_info-1] == false)
|
|
if(Machine_info.btn_dis_flag[button_info-1] == false)
|
|
{
|
|
{
|
|
printf("按键关闭,默认运行\n");
|
|
printf("按键关闭,默认运行\n");
|
|
@@ -1234,7 +1235,7 @@ static void button_task(void* arg)
|
|
{
|
|
{
|
|
if(Machine_info.paired == 1)
|
|
if(Machine_info.paired == 1)
|
|
{
|
|
{
|
|
- printf("paired add data to list chanl = 0x%02x\r\n",Machine_info.lora_new_channel);
|
|
|
|
|
|
+ // printf("paired add data to list chanl = 0x%02x\r\n",Machine_info.lora_new_channel);
|
|
getRtcTime(&Machine_info); //获取当前时间
|
|
getRtcTime(&Machine_info); //获取当前时间
|
|
//更新当前时间
|
|
//更新当前时间
|
|
Machine_info.current_button.button_info = button_info;
|
|
Machine_info.current_button.button_info = button_info;
|
|
@@ -1298,12 +1299,12 @@ static void button_task(void* arg)
|
|
Machine_info.last_button.button_info = Machine_info.current_button.button_info;
|
|
Machine_info.last_button.button_info = Machine_info.current_button.button_info;
|
|
// Machine_info.left_state = button_info;
|
|
// Machine_info.left_state = button_info;
|
|
Machine_info.left_state = Machine_info.current_button.button_info;
|
|
Machine_info.left_state = Machine_info.current_button.button_info;
|
|
- ESP_LOGE(LOG_TAG,"----Machine_info.left_state = %d",Machine_info.left_state);
|
|
|
|
#if 1
|
|
#if 1
|
|
- bool is_left = true;
|
|
|
|
- if(xQueueSend(screen_queue,&is_left,portMAX_DELAY) != true)
|
|
|
|
|
|
+ screen_dis_info.is_left = true;
|
|
|
|
+ screen_dis_info.is_into_sleep = true;
|
|
|
|
+ if(xQueueSend(screen_queue,&screen_dis_info,portMAX_DELAY) != true)
|
|
{
|
|
{
|
|
- ESP_LOGE(LOG_TAG,"queue:screen_queue");
|
|
|
|
|
|
+ ESP_LOGE(LOG_TAG,"err:screen queue send fail");
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
// Set duty to 50%
|
|
// Set duty to 50%
|
|
@@ -1372,23 +1373,7 @@ static void button_task(void* arg)
|
|
if(Machine_info.power_status == 1) //开机状态
|
|
if(Machine_info.power_status == 1) //开机状态
|
|
{
|
|
{
|
|
Machine_info.power_status = 0;
|
|
Machine_info.power_status = 0;
|
|
- // dis_instructions();
|
|
|
|
-
|
|
|
|
- // bool is_left = true;
|
|
|
|
- // if(xQueueSend(screen_queue,&is_left,portMAX_DELAY) != true)
|
|
|
|
- // {
|
|
|
|
- // ESP_LOGE(LOG_TAG,"queue:screen_queue");
|
|
|
|
- // }
|
|
|
|
- // is_left = false;
|
|
|
|
- // if(xQueueSend(screen_queue,&is_left,portMAX_DELAY) != true)
|
|
|
|
- // {
|
|
|
|
- // ESP_LOGE(LOG_TAG,"queue:screen_queue");
|
|
|
|
- // }
|
|
|
|
- // vTaskDelay(1000 / portTICK_PERIOD_MS);
|
|
|
|
- // sleep_timer_start(100); //开始进入倒计时休眠
|
|
|
|
-
|
|
|
|
- printf("last power on current power off ready sleep\r\n");
|
|
|
|
- // sleep_timer_start(100); //开始进入倒计时休眠 //更改为刷完两个屏幕,倒计时
|
|
|
|
|
|
+ printf("poweron->poweroff\r\n");
|
|
}
|
|
}
|
|
else if(Machine_info.power_status == 0)
|
|
else if(Machine_info.power_status == 0)
|
|
{
|
|
{
|
|
@@ -1407,55 +1392,30 @@ static void button_task(void* arg)
|
|
|
|
|
|
//恢复串口i功能
|
|
//恢复串口i功能
|
|
uart_sleep_out_config();
|
|
uart_sleep_out_config();
|
|
-
|
|
|
|
-
|
|
|
|
- // Paint_leftScreen_main_slow(&Machine_info);
|
|
|
|
- // Paint_rightScreen_main_slow(&Machine_info);
|
|
|
|
- // Paint_leftScreen_main_quick(&Machine_info);
|
|
|
|
- // Paint_rightScreen_main_quick(&Machine_info);
|
|
|
|
- // dis_instructions();
|
|
|
|
- // bool is_left = true;
|
|
|
|
- // if(xQueueSend(screen_queue,&is_left,portMAX_DELAY) != true)
|
|
|
|
- // {
|
|
|
|
- // ESP_LOGE(LOG_TAG,"queue:screen_queue");
|
|
|
|
- // }
|
|
|
|
- // is_left = false;
|
|
|
|
- // if(xQueueSend(screen_queue,&is_left,portMAX_DELAY) != true)
|
|
|
|
- // {
|
|
|
|
- // ESP_LOGE(LOG_TAG,"queue:screen_queue");
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- // if( (Machine_info.power_status == 1) && (Machine_info.paired == 1))
|
|
|
|
- // {
|
|
|
|
- // //判断当前开机 是否配对 继续执行时间片操作
|
|
|
|
- // sleep_timer_start(100); //开始进入倒计时休眠
|
|
|
|
- // }
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
- is_left = true;
|
|
|
|
- if(xQueueSend(screen_queue,&is_left,portMAX_DELAY) != true)
|
|
|
|
|
|
+ screen_dis_info.is_left = true;
|
|
|
|
+ screen_dis_info.is_into_sleep = false;
|
|
|
|
+ if(xQueueSend(screen_queue,&screen_dis_info,portMAX_DELAY) != true)
|
|
{
|
|
{
|
|
- ESP_LOGE(LOG_TAG,"queue:screen_queue");
|
|
|
|
|
|
+ ESP_LOGE(LOG_TAG,"err:screen queue send fail");
|
|
}
|
|
}
|
|
- is_left = false;
|
|
|
|
- if(xQueueSend(screen_queue,&is_left,portMAX_DELAY) != true)
|
|
|
|
|
|
+ screen_dis_info.is_left = false;
|
|
|
|
+ screen_dis_info.is_into_sleep = true;
|
|
|
|
+ if(xQueueSend(screen_queue,&screen_dis_info,portMAX_DELAY) != true)
|
|
{
|
|
{
|
|
- ESP_LOGE(LOG_TAG,"queue:screen_queue");
|
|
|
|
|
|
+ ESP_LOGE(LOG_TAG,"err:screen queue send fail");
|
|
}
|
|
}
|
|
- if(Machine_info.paired || !Machine_info.power_status)
|
|
|
|
- {
|
|
|
|
- sleep_timer_start(100); //开始进入倒计时休眠
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
if(button_info == POWER_ON_INTO_DIS_RIGHT)
|
|
if(button_info == POWER_ON_INTO_DIS_RIGHT)
|
|
{
|
|
{
|
|
- is_left = false;
|
|
|
|
- if(xQueueSend(screen_queue,&is_left,portMAX_DELAY) != true)
|
|
|
|
|
|
+ screen_dis_info.is_left = false;
|
|
|
|
+ if(xQueueSend(screen_queue,&screen_dis_info,portMAX_DELAY) != true)
|
|
{
|
|
{
|
|
- ESP_LOGE(LOG_TAG,"queue:screen_queue");
|
|
|
|
|
|
+ ESP_LOGE(LOG_TAG,"err:screen queue send fail");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1804,7 +1764,7 @@ void read_deal_data_callback_handler()
|
|
user_size = y_ringbuf_get_used_size(lora_ringbuf);
|
|
user_size = y_ringbuf_get_used_size(lora_ringbuf);
|
|
if(user_size>0)
|
|
if(user_size>0)
|
|
{
|
|
{
|
|
- printf("times comming length=%d\r\n",user_size);
|
|
|
|
|
|
+ printf("lora 数据长度 = %d\r\n",user_size);
|
|
#if 0
|
|
#if 0
|
|
if(user_size == 36)
|
|
if(user_size == 36)
|
|
{
|
|
{
|
|
@@ -1821,13 +1781,14 @@ void read_deal_data_callback_handler()
|
|
{
|
|
{
|
|
#if 1
|
|
#if 1
|
|
int len = y_ringbuf_read_clear(lora_ringbuf, result, user_size); //读取并清除数据
|
|
int len = y_ringbuf_read_clear(lora_ringbuf, result, user_size); //读取并清除数据
|
|
- #if 1
|
|
|
|
|
|
+ #if 0
|
|
for (int i = 0; i < user_size; i++)
|
|
for (int i = 0; i < user_size; i++)
|
|
{
|
|
{
|
|
printf("%02x",result[i]);
|
|
printf("%02x",result[i]);
|
|
}
|
|
}
|
|
printf("\r\n");
|
|
printf("\r\n");
|
|
#endif
|
|
#endif
|
|
|
|
+ ESP_LOG_BUFFER_HEX("接收的lora:",result,user_size);
|
|
yc_data.len = user_size;
|
|
yc_data.len = user_size;
|
|
yc_data.data = malloc(sizeof(uint8_t)*user_size);//分配内存
|
|
yc_data.data = malloc(sizeof(uint8_t)*user_size);//分配内存
|
|
memcpy(yc_data.data,result,user_size);
|
|
memcpy(yc_data.data,result,user_size);
|