|
@@ -57,7 +57,7 @@ QueueHandle_t wakeup_queue;
|
|
|
|
|
|
QueueHandle_t Send_Data_queue; // 发送链表任务
|
|
|
|
|
|
-SemaphoreHandle_t button_semaphore; // 刷新屏幕时都得加上按键互斥锁
|
|
|
+// SemaphoreHandle_t button_semaphore; // 刷新屏幕时都得加上按键互斥锁
|
|
|
|
|
|
// SemaphoreHandle_t screen_semaphore; //刷新屏幕时都得加上互斥锁
|
|
|
|
|
@@ -395,12 +395,7 @@ if(tmp_paint_buf!=NULL)
|
|
|
adc1_init();
|
|
|
// extern void dis_right_instructions();
|
|
|
// dis_right_instructions();
|
|
|
- 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, "err:screen queue send fail");
|
|
|
- }
|
|
|
+ set_screen_dis_info_and_send_queue(true, false, false, false,100);
|
|
|
int power_key = 0;
|
|
|
int charge_key = 0;
|
|
|
|
|
@@ -447,16 +442,13 @@ if(tmp_paint_buf!=NULL)
|
|
|
// extern void dis_right_instructions();
|
|
|
// dis_right_instructions();
|
|
|
|
|
|
- if (xQueueSend(screen_queue, &screen_dis_info, portMAX_DELAY) != true)
|
|
|
- {
|
|
|
- ESP_LOGE(LOG_TAG, "err:screen queue send fail");
|
|
|
- }
|
|
|
+ set_screen_dis_info_and_send_queue(true, false, false, false,100);
|
|
|
|
|
|
printf("start power off\r\n");
|
|
|
uart_wait_tx_idle_polling(CONFIG_ESP_CONSOLE_UART_NUM);
|
|
|
|
|
|
#if 1 // 电源按键
|
|
|
- // adc_oneshot_del_unit(adc1_handle);
|
|
|
+ // adc_oneshot_del_unit(adc1_handle);
|
|
|
gpio_reset_pin(4);
|
|
|
int ext_wakeup_pin_0 = 4;
|
|
|
printf("Enabling EXT0 wakeup on pin GPIO%d\n", ext_wakeup_pin_0);
|
|
@@ -547,7 +539,7 @@ if(tmp_paint_buf!=NULL)
|
|
|
uart_wait_tx_idle_polling(CONFIG_ESP_CONSOLE_UART_NUM);
|
|
|
|
|
|
#if 1 // 电源按键
|
|
|
- // adc_oneshot_del_unit(adc1_handle);
|
|
|
+ // adc_oneshot_del_unit(adc1_handle);
|
|
|
gpio_reset_pin(4);
|
|
|
int ext_wakeup_pin_0 = 4;
|
|
|
printf("Enabling EXT0 wakeup on pin GPIO%d\n", ext_wakeup_pin_0);
|
|
@@ -609,7 +601,7 @@ if(tmp_paint_buf!=NULL)
|
|
|
uart_wait_tx_idle_polling(CONFIG_ESP_CONSOLE_UART_NUM);
|
|
|
|
|
|
#if 1 // 电源按键
|
|
|
- // adc_oneshot_del_unit(adc1_handle);
|
|
|
+ // adc_oneshot_del_unit(adc1_handle);
|
|
|
gpio_reset_pin(4);
|
|
|
int ext_wakeup_pin_0 = 4;
|
|
|
printf("Enabling EXT0 wakeup on pin GPIO%d\n", ext_wakeup_pin_0);
|
|
@@ -732,11 +724,7 @@ if(tmp_paint_buf!=NULL)
|
|
|
beep_blink(30, 1);
|
|
|
|
|
|
#if 1
|
|
|
- screen_dis_info.is_left = true;
|
|
|
- if (xQueueSend(screen_queue, &screen_dis_info, portMAX_DELAY) != true)
|
|
|
- {
|
|
|
- printf("left send fail\r\n");
|
|
|
- }
|
|
|
+ set_screen_dis_info_and_send_queue(true, true, false, false,100);
|
|
|
#endif
|
|
|
|
|
|
while (1)
|
|
@@ -868,8 +856,16 @@ static void screen_task(void *arg)
|
|
|
{
|
|
|
if (xQueueReceive(screen_queue, &screen_rev_info, (TickType_t)portMAX_DELAY))
|
|
|
{
|
|
|
+ ESP_LOGW(LOG_TAG, "screen_rev_info==>%s , %s ,%s ,%s", screen_rev_info.is_left ? "left refreshing" : "right refreshing", screen_rev_info.is_into_sleep ? "into sleep" : "not sleep",
|
|
|
+ screen_rev_info.is_change_power?"change power":"not change power",screen_rev_info.is_dont_dis?"dont dis":"dis");
|
|
|
+ if (screen_rev_info.is_dont_dis)
|
|
|
+ {
|
|
|
+ ESP_LOGE(LOG_TAG, "goto -> dont_dis");
|
|
|
+ goto dont_dis;
|
|
|
+ }
|
|
|
+
|
|
|
font_exit_sleep();
|
|
|
- ESP_LOGI(LOG_TAG, "%s , %s", screen_rev_info.is_left ? "left refreshing" : "right refreshing", screen_rev_info.is_into_sleep ? "into sleep" : "not sleep");
|
|
|
+
|
|
|
if (screen_rev_info.is_left) // 刷左屏
|
|
|
{
|
|
|
if (Machine_info.left_current_Quick_refresh_time >= Machine_info.left_max_Quick_refresh_time)
|
|
@@ -895,11 +891,16 @@ static void screen_task(void *arg)
|
|
|
Paint_rightScreen(Machine_info.power_status, false);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ dont_dis:
|
|
|
if ((Machine_info.power_status == 1) && (Machine_info.paired == 1) && screen_rev_info.is_into_sleep)
|
|
|
{
|
|
|
- ESP_LOGW(LOG_TAG, "100ms sleep %s", screen_rev_info.is_left ? "left" : "right");
|
|
|
- sleep_timer_start(100); // 进入睡眠
|
|
|
+ // ESP_LOGD(LOG_TAG, "100ms sleep %s", screen_rev_info.is_left ? "left" : "right");
|
|
|
+ if (screen_rev_info.is_change_power)
|
|
|
+ {
|
|
|
+ ESP_LOGE(LOG_TAG,"=============power_status %s======== set power off",Machine_info.power_status?"is power on":"is power off");
|
|
|
+ Machine_info.power_status = 0; // 关机
|
|
|
+ }
|
|
|
+ sleep_timer_start(screen_rev_info.sleep_ms); // 进入睡眠
|
|
|
}
|
|
|
|
|
|
// if(Machine_info.power_status == 0 )//展示说明书都是先左后右,等右屏刷完再休眠
|
|
@@ -951,7 +952,7 @@ static void button_task(void *arg)
|
|
|
Machine_info.rssi,
|
|
|
Machine_info.paired ? "paired" : "not pair");
|
|
|
|
|
|
- // print_lora_set_info();
|
|
|
+ // print_lora_set_info();
|
|
|
#endif
|
|
|
if (button_info < 0x12) // 左屏慕按键
|
|
|
{
|
|
@@ -963,7 +964,8 @@ static void button_task(void *arg)
|
|
|
button_info = STATE_OPERATION; // 按键关闭,默认运行
|
|
|
if ((Machine_info.power_status == 1) && (Machine_info.paired == 1))
|
|
|
{
|
|
|
- sleep_timer_start(100); // 进入睡眠
|
|
|
+ set_screen_dis_info_and_send_queue(false, false, false, true,100);
|
|
|
+ // sleep_timer_start(100); // 进入睡眠
|
|
|
}
|
|
|
}
|
|
|
Machine_info.current_button.button_info = button_info;
|
|
@@ -1032,12 +1034,7 @@ static void button_task(void *arg)
|
|
|
// Machine_info.left_state = button_info;
|
|
|
Machine_info.left_state = Machine_info.current_button.button_info;
|
|
|
#if 1
|
|
|
- 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, "err:screen queue send fail");
|
|
|
- }
|
|
|
+ set_screen_dis_info_and_send_queue(true, true, false, false,100);
|
|
|
#endif
|
|
|
|
|
|
beep_blink(30, 1);
|
|
@@ -1048,7 +1045,8 @@ static void button_task(void *arg)
|
|
|
else // 和上个按键重复,唤醒原因为ulp唤醒,不进入休眠
|
|
|
{
|
|
|
printf("repeat ,goto sleep !\r\n");
|
|
|
- sleep_timer_start(100); // 开始进入倒计时休眠
|
|
|
+ // sleep_timer_start(100); // 开始进入倒计时休眠
|
|
|
+ set_screen_dis_info_and_send_queue(false, false, false, true,1000);
|
|
|
}
|
|
|
}
|
|
|
else // 右屏幕按键触发
|
|
@@ -1062,23 +1060,30 @@ static void button_task(void *arg)
|
|
|
if ((Machine_info.power_status == 1) && (Machine_info.paired == 1))
|
|
|
{
|
|
|
// 判断当前开机 是否配对 继续执行时间片操作
|
|
|
- sleep_timer_start(100); // 开始进入倒计时休眠
|
|
|
+ // sleep_timer_start(100); // 开始进入倒计时休眠
|
|
|
+ set_screen_dis_info_and_send_queue(false, false, false, true,1000);
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (button_info == POWER_OFF_PRESS_VALUE) // power 关机时短按
|
|
|
- {
|
|
|
- sleep_timer_start(100); // 开始进入倒计时休眠
|
|
|
- }
|
|
|
+ // if (button_info == POWER_OFF_PRESS_VALUE) // power 关机时短按
|
|
|
+ // {
|
|
|
+ // sleep_timer_start(100); // 开始进入倒计时休眠
|
|
|
+ // }
|
|
|
|
|
|
if (button_info == POWER_ON_INTO_STATUS_CHANGE_VALUE) // power 长按触发
|
|
|
{
|
|
|
-
|
|
|
+ extern bool is_sleep;
|
|
|
+ is_sleep = false;//强制不休眠
|
|
|
beep_blink(1000, 1);
|
|
|
|
|
|
if (Machine_info.power_status == 1) // 开机状态
|
|
|
{
|
|
|
- Machine_info.power_status = 0;
|
|
|
+ // Machine_info.power_status = 0;
|
|
|
+ // screen_dis_info.is_change_power = true;
|
|
|
+ xQueueReset(screen_queue);
|
|
|
+ set_screen_dis_info_and_send_queue(false, true, false, false,100);
|
|
|
+ set_screen_dis_info_and_send_queue(true, false, true, false,1000);//关机
|
|
|
printf("poweron->poweroff\r\n");
|
|
|
}
|
|
|
else if (Machine_info.power_status == 0)
|
|
@@ -1096,38 +1101,17 @@ static void button_task(void *arg)
|
|
|
|
|
|
// 恢复串口i功能
|
|
|
uart_sleep_out_config();
|
|
|
- }
|
|
|
- xQueueReset(screen_queue);
|
|
|
- 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, "err:screen queue send fail");
|
|
|
- }
|
|
|
- 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, "err:screen queue send fail");
|
|
|
+ set_screen_dis_info_and_send_queue(false, true, false, false,100);
|
|
|
+ set_screen_dis_info_and_send_queue(true, false, false, false,100);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (button_info == POWER_ON_INTO_DIS_RIGHT)
|
|
|
{
|
|
|
xQueueReset(screen_queue);
|
|
|
- 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, "err:screen queue send fail");
|
|
|
- }
|
|
|
- screen_dis_info.is_left = false;
|
|
|
- screen_dis_info.is_into_sleep = true;
|
|
|
Machine_info.left_current_Quick_refresh_time = 5;
|
|
|
- if (xQueueSend(screen_queue, &screen_dis_info, portMAX_DELAY) != true)
|
|
|
- {
|
|
|
- ESP_LOGE(LOG_TAG, "err:screen queue send fail");
|
|
|
- }
|
|
|
+ set_screen_dis_info_and_send_queue(false, true, false, false,100);
|
|
|
+ set_screen_dis_info_and_send_queue(true, false, false, false,100);
|
|
|
}
|
|
|
|
|
|
if (button_info == POWER_ON_INTO_OTA_VALUE) // 进入OTA模式
|
|
@@ -1448,7 +1432,7 @@ void read_deal_data_callback_handler()
|
|
|
user_size = y_ringbuf_get_used_size(lora_ringbuf);
|
|
|
if (user_size > 0)
|
|
|
{
|
|
|
- printf("-->lora len = %d\r\n", user_size);
|
|
|
+ ESP_LOGI(LOG_TAG, "-->lora len = %d\r\n", user_size);
|
|
|
#if 0
|
|
|
if(user_size == 36)
|
|
|
{
|