Explorar o código

203.12.30 将两个屏幕任务合并

wanghechen hai 10 meses
pai
achega
e3ead0e199

+ 2 - 8
components/Decection/Decection.c

@@ -63,9 +63,9 @@ int adc_read_power_pin(adc_oneshot_unit_handle_t adc_handle)
     float result_voltage = (float)(voltage[0][0]) / 1000.0/*4095.0 * 3.3*/; // 假设ADC参考电压为3.3V
     float battery_percentage = ((result_voltage - 1.8) / (2.2 - 1.8)) * 100.0;
     // 限制电量范围在0%到100%之间
-    if (battery_percentage < 0) {
+    if (battery_percentage <= 0) {
     battery_percentage = 0;
-    } else if (battery_percentage > 100) {
+    } else if (battery_percentage >= 100) {
     battery_percentage = 100;
     }
 
@@ -210,7 +210,6 @@ int decection_state_1(void)
 #include "freertos/task.h"
 #include "freertos/queue.h"
 #include "SPIFFS.h"
-extern QueueHandle_t right_screen_queue;
 extern RTC_FAST_ATTR Machine_info_t   Machine_info;
 static void IRAM_ATTR gpio_isr_handler(void* arg)
 {
@@ -231,11 +230,6 @@ static void IRAM_ATTR gpio_isr_handler(void* arg)
 
         default :break;
     }
-    // if(Machine_info.power_status!=0)
-    // {
-    //     xQueueSendFromISR(right_screen_queue, &Machine_info, NULL);
-    // }
-
 }
 
 void decection_charging_init(void)

+ 0 - 254
components/EPD/EPD.c

@@ -12,13 +12,6 @@
 #include "esp_timer.h"
 
 
-TimerHandle_t left_display_timer;
-
-TimerHandle_t right_display_timer;
-
-
-bool left_refresh_complete = false;
-bool right_refresh_complete = false;
 
 
 uint8_t current_display = 0;
@@ -34,138 +27,15 @@ uint8_t current_display = 0;
 
 
 
-void left_slow_timerout_Callback(TimerHandle_t xTimer) {
-    // 在这里执行定时器超时后的任务
-    // 注意:回调函数中不要执行耗时的操作,避免影响其他任务的运行
-
-
-    //if(current_display == SCREEN_LEFT)
-    {
-         left_refresh_complete = true;   
-    }
-
-    //     if(current_display == SCREEN_RIGHT)
-    // {
-    //     right_refresh_complete = true;
-    // }
-
-}
-
-
-
-
-void right_slow_timerout_Callback(TimerHandle_t xTimer) {
-    // 在这里执行定时器超时后的任务
-    // 注意:回调函数中不要执行耗时的操作,避免影响其他任务的运行
-
-
-    // if(current_display == SCREEN_LEFT)
-    // {
-    //      left_refresh_complete = true;   
-    // }
 
-       // if(current_display == SCREEN_RIGHT)
-    {
-        right_refresh_complete = true;
-    }
 
-}
 
 
 
 
 
 
-/*********************************************************************************
-* function   :   refresh_timer_start     
-* Description :  
-* Input       :  
-* Output      :  
-* Author      :  祁鑫                  Data : 2023 10.18
-**********************************************************************************/	
-void left_refresh_timer_start(int ms)
-{
 
-    xTimerStop(left_display_timer, 0);   //停止定时器
-    // 在这里可以改变定时器的超时时间
-    // 第一个参数是定时器句柄,第二个参数是新的超时时间(以时钟节拍为单位)
-    xTimerChangePeriod(left_display_timer, pdMS_TO_TICKS(ms), 0);
-    xTimerStart(left_display_timer, 0); //开始定时器
-  
-}
-
-/*********************************************************************************
-* function   :   refresh_timer_stop     
-* Description :  
-* Input       :  
-* Output      :  
-* Author      :  祁鑫                  Data : 2023 10.18
-**********************************************************************************/	
-void left_refresh_timer_stop(void)
-{
-    xTimerStop(left_display_timer, 0);   //停止定时器
-}
-
-
-
-
-
-/*********************************************************************************
-* function   :   refresh_timer_start     
-* Description :  
-* Input       :  
-* Output      :  
-* Author      :  祁鑫                  Data : 2023 10.18
-**********************************************************************************/	
-void right_refresh_timer_start(int ms)
-{
-
-    xTimerStop(right_display_timer, 0);   //停止定时器
-    // 在这里可以改变定时器的超时时间
-    // 第一个参数是定时器句柄,第二个参数是新的超时时间(以时钟节拍为单位)
-    xTimerChangePeriod(right_display_timer, pdMS_TO_TICKS(ms), 0);
-    xTimerStart(right_display_timer, 0); //开始定时器
-  
-}
-
-/*********************************************************************************
-* function   :   refresh_timer_stop     
-* Description :  
-* Input       :  
-* Output      :  
-* Author      :  祁鑫                  Data : 2023 10.18
-**********************************************************************************/	
-void right_refresh_timer_stop(void)
-{
-    xTimerStop(right_display_timer, 0);   //停止定时器
-}
-
-
-
-bool left_refresh_timer_isActive()
-{
-    if(xTimerIsTimerActive(left_display_timer) != pdFALSE)
-    {
-        return true;
-    }else
-    {
-        return false;
-    }
-
-}
-
-
-bool right_refresh_timer_isActive()
-{
-    if(xTimerIsTimerActive(right_display_timer) != pdFALSE)
-    {
-        return true;
-    }else
-    {
-        return false;
-    }
-
-}
 
 
 	
@@ -412,30 +282,6 @@ free(old_buffer);
 #else
 
 #endif
-
-
-
-
-    left_display_timer = xTimerCreate(
-    "right_display_timer",        // 定时器名称(可以为NULL)
-    pdMS_TO_TICKS(2000),      // 定时器超时时间(以毫秒为单位)
-    pdFALSE,                  // 定时器为周期性(pdTRUE)还是单次(pdFALSE)
-    0,                        // 定时器ID(可以为0)
-    left_slow_timerout_Callback    // 定时器回调函数
-    );
-
-
-    right_display_timer = xTimerCreate(
-    "right_display_timer",        // 定时器名称(可以为NULL)
-    pdMS_TO_TICKS(2000),      // 定时器超时时间(以毫秒为单位)
-    pdFALSE,                  // 定时器为周期性(pdTRUE)还是单次(pdFALSE)
-    0,                        // 定时器ID(可以为0)
-    right_slow_timerout_Callback    // 定时器回调函数
-    );
-
-
-
-  
 }
 
 
@@ -892,19 +738,6 @@ void epd_sleep(screen_t screen)
 IRAM_ATTR void epd_display(screen_t screen,const unsigned char* picData)
 {
 
-    #if SOFTWARE_SPI_ENABLE
-    if(screen == SCREEN_LEFT)
-    {
-         left_refresh_complete = false;   
-    }
-
-
-    if(screen == SCREEN_RIGHT)
-    {
-        right_refresh_complete = false;
-    }
-
-    #endif
 
 
     epd_write_cmd(screen,0x13,false);
@@ -920,41 +753,6 @@ IRAM_ATTR void epd_display(screen_t screen,const unsigned char* picData)
     epd_check_status(screen);
     epd_sleep(screen);
 
-
-
-#if SOFTWARE_SPI_ENABLE
-    current_display = screen;
-    //vTaskDelay(0000 / portTICK_PERIOD_MS);
-
-
-  if(screen == SCREEN_LEFT)
-  {
-    left_refresh_timer_start(2000);
-  }
-
-
-  if(screen == SCREEN_LEFT)
-  {
-    right_refresh_timer_start(2000);
-  }
-#else
- current_display = screen;
-    //vTaskDelay(0000 / portTICK_PERIOD_MS);
-
-
-  if(screen == SCREEN_LEFT)
-  {
-    left_refresh_timer_start(2000);
-  }
-
-
-  if(screen == SCREEN_LEFT)
-  {
-    right_refresh_timer_start(2000);
-  }
-
-#endif
-
 }
 #if 1
 void epd_cache(screen_t screen,const unsigned char* picData)
@@ -1457,31 +1255,6 @@ void test()
 IRAM_ATTR bool epd_cache_quick(screen_t screen,const unsigned char* old,const unsigned char* new)
 {
  bool ret = false;
-    #if SOFTWARE_SPI_ENABLE
-    if(screen == SCREEN_LEFT)
-    {
-         left_refresh_complete = false;   
-    }
-
-    if(screen == SCREEN_RIGHT)
-    {
-        right_refresh_complete = false;
-    }
-    #else
-
-    if(screen == SCREEN_LEFT)
-    {
-         left_refresh_complete = false;   
-    }
-
-    if(screen == SCREEN_RIGHT)
-    {
-        right_refresh_complete = false;
-    }
-
-
-    #endif
-
     if((screen == SCREEN_LEFT)&&(old!=NULL))
     {
         printf("epd_cache_quick\r\n");
@@ -1579,34 +1352,7 @@ IRAM_ATTR bool epd_cache_quick(screen_t screen,const unsigned char* old,const un
     }
 #else
 
-#if SOFTWARE_SPI_ENABLE
-    current_display = screen;
-    //vTaskDelay(0000 / portTICK_PERIOD_MS);
-  if(screen == SCREEN_LEFT)
-  {
-    left_refresh_timer_start(1000);
-  }
-
-
-  if(screen == SCREEN_LEFT)
-  {
-    right_refresh_timer_start(1000);
-  }
- #else
-      current_display = screen;
-    //vTaskDelay(0000 / portTICK_PERIOD_MS);
-  if(screen == SCREEN_LEFT)
-  {
-    left_refresh_timer_start(500);
-  }
-
 
-  if(screen == SCREEN_LEFT)
-  {
-    right_refresh_timer_start(500);
-  }
-
-#endif
 
 
 

+ 0 - 2
components/EPD/include/EPD.h

@@ -101,8 +101,6 @@ void deepsleep_epd_powerOn_refresh_sleep(screen_t screen);
 bool epd_cache_quick(screen_t screen,const unsigned char* old,const unsigned char* new);
 void epd_powerOn_refresh_sleep(screen_t screen);
 
-bool left_refresh_timer_isActive();
-bool right_refresh_timer_isActive();
 
 
 #else /*HARDWARE_SPI*/

+ 6 - 7
components/button/user_button.c

@@ -158,11 +158,14 @@ bool is_btn_timeout(void)
 {
     struct timeval now_time;
     gettimeofday(&now_time, NULL);
-    ESP_LOGW(LOG_TAG,"is_send_lora= %s now_time =  %lld,last =  %lld,\n",is_send_lora?"ture":"false",now_time.tv_sec, btn_last_time.tv_sec);
+    ESP_LOGD(LOG_TAG,"is_send_lora= %s now_time =  %lld,last =  %lld,\n",is_send_lora?"ture":"false",now_time.tv_sec, btn_last_time.tv_sec);
+
+    struct tm* tmp = localtime(&now_time.tv_sec);
+    ESP_LOGI(LOG_TAG,"时间: %04d-%02d-%02d %02d:%02d:%02d\n",
+    tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
+    tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
     if(((now_time.tv_sec - btn_last_time.tv_sec) > 30)&&(is_send_lora))
     {
-        struct tm* tmp = localtime(&now_time.tv_sec);
-        // printf("btn_last_time: %lld\n", btn_last_time.tv_sec);
         ESP_LOGW(LOG_TAG,"发送-----现在按键时间: %04d-%02d-%02d %02d:%02d:%02d\n",
         tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday,
         tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
@@ -577,10 +580,6 @@ static void user_button_single_click_cb(void *arg,void *usr_data)
         return;
     }
 
-        if(left_refresh_timer_isActive() == true)
-        {
-            return;
-        }
     
     if(xQueueSend(button_Data_queue,&button_info,0) != true)
     {

+ 8 - 40
main/ulp_riscv_adc_example_main.c

@@ -331,7 +331,7 @@ static void light_sleep_task(void *args)
                             extern bool right_refresh_complete;
 
 
-                            #if 1
+                            #if 0
                             while(1)
                             {
 
@@ -568,44 +568,8 @@ static void light_sleep_task(void *args)
             case ESP_SLEEP_WAKEUP_ULP:
              //wakeup_reason = "ulp";
                iot_button_resume();
-
-
+                is_sleep = true;//常按会进休眠,然后ulp唤醒,设置is_sleep = true,再次进入休眠
                 printf("ULP SLEEP WAKE UP\r\n");
-
-                #if 0
-                    int btn = left_adc_wake_btn_send();
-
-
-                    if(btn !=0xff)
-                    {
-                        Machine_info.left_state = btn;
-                        // Set duty to 50%
-                        ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LEDC_CHANNEL, LEDC_DUTY));
-                        // Update duty to apply the new value
-                        ESP_ERROR_CHECK(ledc_update_duty(LEDC_MODE, LEDC_CHANNEL));
-                        vTaskDelay(30 / portTICK_PERIOD_MS);
-                        ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LEDC_CHANNEL, 0));
-                        // Update duty to apply the new value
-                        ESP_ERROR_CHECK(ledc_update_duty(LEDC_MODE, LEDC_CHANNEL));
-
-
-                        extern QueueHandle_t left_screen_queue;
-                    
-                        #if 1
-                            if(xQueueSend(left_screen_queue,&Machine_info,portMAX_DELAY) != true)
-                            {
-                                printf("left send fail\r\n");
-                            } 
-                        #endif 
-
-
-                    }
-
-                 #endif
-
-
-
-
              break;
             case ESP_SLEEP_WAKEUP_EXT0:
 
@@ -613,6 +577,10 @@ static void light_sleep_task(void *args)
             {
                 iot_button_resume();
             }
+            else if(Machine_info.paired && Machine_info.power_status)
+            {
+                is_sleep = true;//配对且开机,进入休眠
+            }
 
             printf("ESP_SLEEP_WAKEUP_EXT0 \r\n");
             break;
@@ -637,9 +605,9 @@ static void light_sleep_task(void *args)
 
         }else if(Machine_info.power_status == 1)  //开机的情况
         {
-            if(read_battery_voltage()<10)
+            if(read_battery_voltage() == 0)
             {
-                printf("low batt ready power off\r\n");
+                printf("-->low batt , power off\r\n");
                 Machine_info.power_status = 0;
                 dis_instructions();  //进入关机界面
                 sleep_timer_start(1000);

+ 1 - 1
main/user_sleep.c

@@ -194,7 +194,7 @@ void Already_send_timer_callback(void* arg)
                 {
                     vTaskDelay(50 / portTICK_PERIOD_MS);
                     lora_send_data((char *)Send_list->data,Send_list->len);
-                    printf("list have data send one data\r\n");
+                    printf("->发送一条消息给网关\r\n");
                 }else
                 {
                     printf("list not have data\r\n");

+ 41 - 171
main/yc_protocol.c

@@ -58,9 +58,9 @@ extern char str_waitMaterials[6];//待料
 extern char str_breakDown[6];//故障
 
 
-extern QueueHandle_t left_screen_queue;
+extern QueueHandle_t screen_queue;
 uint8_t mac_addr[6];
-extern QueueHandle_t right_screen_queue;
+
 
 extern QueueHandle_t yc_data_queue;
 extern YC_DATA_T yc_data;
@@ -210,24 +210,9 @@ void update_last_button_info(uint8_t btn)
 }
 void screen_display(void)
 {
-
+    bool is_left = false;
     font_exit_sleep();
-    // ESP_LOGW(LOG_TAG,"display_flag =%d\r\n",display_flag);
-    // if(display_flag == 1)
-    // {
-    //     if(xQueueSend(left_screen_queue,&Machine_info,portMAX_DELAY) != true)
-    //     {
-    //         ESP_LOGE(LOG_TAG,"queue:left_screen_queue");
-    //     }
-    // }
-    // //vTaskDelay(1000 / portTICK_PERIOD_MS);
-    // else if(display_flag == 2)
-    // {
-    //     if(xQueueSend(right_screen_queue,&Machine_info,portMAX_DELAY) != true)
-    //     {
-    //         ESP_LOGE(LOG_TAG,"queue:right_screen_queue");
-    //     }
-    // }
+
     EventBits_t bits = xEventGroupWaitBits(screen_event,
             LEFT_SCREEN_BIT | RIGHT_SCREEN_BIT,
             pdTRUE,
@@ -239,142 +224,32 @@ void screen_display(void)
     if(bits == 3){
 
         printf("--------------------left right all screen---------------\r\n");
-        while(1)
-        {                         
-            if( (right_refresh_timer_isActive() == false) )
-            {
-                printf("right refresh complete %s\r\n",right_refresh_timer_isActive()?"true":"false");
-                break;
-            }
-                vTaskDelay(100/ portTICK_PERIOD_MS);
-        }
-
-
-        while(1)
-        {                         
-            if( (left_refresh_timer_isActive() == false) )
-            {
-                printf("2left refresh complete %s\r\n",left_refresh_timer_isActive()?"true":"false");
-                break;
-            }
-                vTaskDelay(100/ portTICK_PERIOD_MS);
-        }
-
-        //Paint_leftScreen_main_quick(&Machine_info);
-
-        if(xQueueSend(left_screen_queue,&Machine_info,portMAX_DELAY) != true)
+        is_left = false;
+        if(xQueueSend(screen_queue,&is_left,portMAX_DELAY) != true)
         {
-            ESP_LOGE(LOG_TAG,"queue:right_screen_queue");
-        }
-
-
-
-
-        vTaskDelay(2000/ portTICK_PERIOD_MS);
-        // while(1)
-        // {                         
-        //     if( (left_refresh_timer_isActive() == false) )
-        //     {
-        //         printf("left refresh complete %s\r\n",left_refresh_timer_isActive()?"true":"false");
-        //         break;
-        //     }
-        //         vTaskDelay(100/ portTICK_PERIOD_MS);
-        // }
-
-        
-              while(1)
-        {                         
-            if( (right_refresh_timer_isActive() == false) )
-            {
-                printf("right refresh complete %s\r\n",right_refresh_timer_isActive()?"true":"false");
-                break;
-            }
-                vTaskDelay(100/ portTICK_PERIOD_MS);
+            ESP_LOGE(LOG_TAG,"queue:screen_queue");
         }
-
-        //Paint_rightScreen_main_quick(&Machine_info);
-
-        if(xQueueSend(right_screen_queue,&Machine_info,portMAX_DELAY) != true)
+        is_left = true;
+        if(xQueueSend(screen_queue,&is_left,portMAX_DELAY) != true)
         {
-            ESP_LOGE(LOG_TAG,"queue:right_screen_queue");
+            ESP_LOGE(LOG_TAG,"queue:screen_queue");
         }
 
-        // while(1)
-        // {                         
-        //     if( (right_refresh_timer_isActive() == false) )
-        //     {
-        //         printf("right refresh complete %s\r\n",right_refresh_timer_isActive()?"true":"false");
-        //         break;
-        //     }
-        //         vTaskDelay(100/ portTICK_PERIOD_MS);
-        // }
-
     }
     else if (bits & RIGHT_SCREEN_BIT) {
         ESP_LOGE(LOG_TAG,"RIGHT_SCREEN_BIT");
-
-            while(1)
-        {                         
-            if( (left_refresh_timer_isActive() == false) )
-            {
-                printf("3left refresh complete %s\r\n",left_refresh_timer_isActive()?"true":"false");
-                break;
-            }
-                vTaskDelay(100/ portTICK_PERIOD_MS);
-        }
-
-
-
-        
-                while(1)
-        {                         
-            if( (right_refresh_timer_isActive() == false) )
-            {
-                printf("4left refresh complete %s\r\n",right_refresh_timer_isActive()?"true":"false");
-                break;
-            }
-                vTaskDelay(100/ portTICK_PERIOD_MS);
-        }
-
-
-
-
-        if(xQueueSend(right_screen_queue,&Machine_info,portMAX_DELAY) != true)
+        is_left = false;
+        if(xQueueSend(screen_queue,&is_left,portMAX_DELAY) != true)
         {
-            ESP_LOGE(LOG_TAG,"queue:right_screen_queue");
+            ESP_LOGE(LOG_TAG,"queue:screen_queue");
         }
     } 
     else if (bits & LEFT_SCREEN_BIT) {
-        
-
-
-                    while(1)
-        {                         
-            if( (left_refresh_timer_isActive() == false) )
-            {
-                printf("5left refresh complete %s\r\n",left_refresh_timer_isActive()?"true":"false");
-                break;
-            }
-                vTaskDelay(100/ portTICK_PERIOD_MS);
-        }
-
-
-                while(1)
-        {                         
-            if( (right_refresh_timer_isActive() == false) )
-            {
-                printf("6left refresh complete %s\r\n",right_refresh_timer_isActive()?"true":"false");
-                break;
-            }
-                vTaskDelay(100/ portTICK_PERIOD_MS);
-        }
-
-
-        
         ESP_LOGE(LOG_TAG,"LEFT_SCREEN_BIT");
-        if(xQueueSend(left_screen_queue,&Machine_info,portMAX_DELAY) != true)
+        is_left = true;
+        if(xQueueSend(screen_queue,&is_left,portMAX_DELAY) != true)
         {
-            ESP_LOGE(LOG_TAG,"queue:left_screen_queue");
+            ESP_LOGE(LOG_TAG,"queue:screen_queue");
         }
     } else {
         ESP_LOGE(LOG_TAG, "UNEXPECTED EVENT");
@@ -974,7 +849,7 @@ static int status_setting_func(const LORA_DATA_T* buf)
 
     memset(terminal_info.status_setting,0x00,sizeof(terminal_info.status_setting));
     memcpy(terminal_info.status_setting,buf->data_buf+DATA_START_LEN,len);  //别名 
-    ESP_LOGE(LOG_TAG,"len = %d ",len);
+    // ESP_LOGE(LOG_TAG,"len = %d ",len);
     ESP_LOG_BUFFER_HEX(LOG_TAG,terminal_info.status_setting,10);
     set_button_anotherName();
     //当前按键状态关闭了
@@ -1051,7 +926,6 @@ static int announcement_func(const LORA_DATA_T* buf)
     // printf("setting gong gao %s",Machine_info.announcement);
     // printf("\n");
 
-    // display_flag = RIGHT_FLAG;
     xEventGroupSetBits(screen_event, RIGHT_SCREEN_BIT);
 
      //printf("msg h = %02X,msg l = %02X\r\n",buf->data_buf[13],buf->data_buf[14]);
@@ -1098,8 +972,7 @@ static int capacity_statistics_func(const LORA_DATA_T* buf)
     //printf("msg_id =%X\r\n",msg_id);
     set_statisticsData(terminal_info.capacity_statistics);
 
-        // display_flag = RIGHT_FLAG;
-        xEventGroupSetBits(screen_event, RIGHT_SCREEN_BIT);
+    xEventGroupSetBits(screen_event, RIGHT_SCREEN_BIT);
 
     return msg_id;     
 }
@@ -1112,8 +985,7 @@ static int responsible_person_synchronize_info_func(const LORA_DATA_T* buf)
     int msg_id = ( buf->data_buf[13]>>8)| buf->data_buf[14];  //获取当前消息id 用于删除
     //printf("msg_id =%X\r\n",msg_id);
 
-        // display_flag = RIGHT_FLAG;
-        xEventGroupSetBits(screen_event, RIGHT_SCREEN_BIT);
+    xEventGroupSetBits(screen_event, RIGHT_SCREEN_BIT);
 
     return msg_id;    
 
@@ -1170,7 +1042,7 @@ static int station_name_func(const LORA_DATA_T* buf)
         uincode2gbk((char*)terminal_info.station_name,FONT_MAX_LEN*2,(char*)Machine_info.station_name);
         strcat((char *)Machine_info.station_name,"...");
     }
-    // display_flag = RIGHT_FLAG;
+
     xEventGroupSetBits(screen_event, RIGHT_SCREEN_BIT);
 
     int msg_id = ( buf->data_buf[13]>>8)| buf->data_buf[14];  //获取当前消息id 用于删除
@@ -1184,7 +1056,6 @@ static int station_number_func(const LORA_DATA_T* buf)
 
     uincode2gbk((char*)terminal_info.station_number,len,(char*)Machine_info.station_number);
 
-    // display_flag = RIGHT_FLAG;
     xEventGroupSetBits(screen_event, RIGHT_SCREEN_BIT);
 
     int msg_id = ( buf->data_buf[13]>>8)| buf->data_buf[14];  //获取当前消息id 用于删除
@@ -1677,30 +1548,28 @@ static void hardware_ungwpair_func(const LORA_DATA_T* buf)
 static void hardware_ack_delete_msg_id(const LORA_DATA_T* buf)
 {
 
-         int msg_id = ( buf->data_buf[11]>>8)| buf->data_buf[12];  //获取当前消息id 用于删除当前链表的数据
-
-
-         int current =  countNodes(Send_list);   //获取当前节点数据
-
-
-         Node *find  = findNode(Send_list,msg_id);
+    int msg_id = ( buf->data_buf[11]>>8)| buf->data_buf[12];  //获取当前消息id 用于删除当前链表的数据
+    ESP_LOG_BUFFER_HEX("ACK",buf->data_buf,buf->data_len);
 
+    int current =  countNodes(Send_list);   //获取当前节点数据
+    Node *find  = findNode(Send_list,msg_id);
+    printf("delete list node bofore = %d\r\n",msg_id);
 
-         if(find != NULL)
-        {
-            // printf("delete list node bofore = %d\r\n",msg_id);
-            // printList(Send_list);
-            Send_list =  deleteNode(Send_list,msg_id);
-            // printf("delete list node msg_id = %d\r\n",msg_id);
+    if(find != NULL)
+    {
+    // printf("delete list node bofore = %d\r\n",msg_id);
+    // printList(Send_list);
+        Send_list =  deleteNode(Send_list,msg_id);
+    // printf("delete list node msg_id = %d\r\n",msg_id);
 
-            // printf("delete list node after = %d\r\n",msg_id);
-            // printList(Send_list);
+    // printf("delete list node after = %d\r\n",msg_id);
+    // printList(Send_list);
 
-        }
-        else
-        {
-            ESP_LOGE(LOG_TAG,"delete fail");
-        }
+    }
+    else
+    {
+    ESP_LOGE(LOG_TAG,"delete fail");
+    }
 
 
   display_flag = 0;
@@ -3885,9 +3754,10 @@ void lora_rev_cmd_send_ack()
 }
 void right_screen_send()
 {
-    if(xQueueSend(right_screen_queue,&Machine_info,portMAX_DELAY) != true)
+    bool is_left = false;
+    if(xQueueSend(screen_queue,&is_left,portMAX_DELAY) != true)
     {
-        ESP_LOGE(LOG_TAG,"queue:right_screen_queue");
+        ESP_LOGE(LOG_TAG,"queue:screen_queue");
     } 
 }
 void user_compare(int last,int now)//这个函数用来比较rssi和 电量变化 刷右屏//

+ 213 - 568
main/yc_terminal.c

@@ -48,8 +48,8 @@ YC_DATA_T yc_data;
 //ListNode *list_head = NULL;
 
 adc_oneshot_unit_handle_t adc1_handle;
-QueueHandle_t left_screen_queue;
-QueueHandle_t right_screen_queue;
+
+QueueHandle_t screen_queue;
 QueueHandle_t lora_data_queue;
 QueueHandle_t yc_data_queue;
 QueueHandle_t button_Data_queue;
@@ -88,8 +88,9 @@ extern RINGBUF_st *lora_ringbuf;
 // static void board_init(void);
 // static void info_init(void);
 
-static void left_screen_task(void* arg);
-static void right_screen_task(void* arg);
+// static void left_screen_task(void* arg);
+// static void right_screen_task(void* arg);
+static void screen_task(void* arg);
 static void unpack_task(void* arg);
 static void lora_task(void* arg);
 static void button_task(void* arg);
@@ -355,8 +356,8 @@ void app_init()
 //charge_init();
 //decection_charging_init();
 
-    left_screen_queue   =   xQueueCreate(10, sizeof(Machine_info_t));
-    right_screen_queue  =   xQueueCreate(10, sizeof(Machine_info_t));
+    screen_queue   =   xQueueCreate(10, sizeof(bool));
+
 
     lora_data_queue     =   xQueueCreate(20, sizeof(LORA_DATA_T));
 
@@ -495,79 +496,16 @@ if(last_paint_buf_right!=NULL)
 
                 if(Machine_info.batt_precent <96)
                 {   
-                        user_compare_power_off(Machine_info.last_batt_precent,Machine_info.batt_precent);
-                        printf("charge_key is %s,batt=%d,last batt=%d\r\n",!charge_key?"charge in":"charge out",Machine_info.batt_precent,Machine_info.last_batt_precent);
-                        
-                        value_count++;
-
-                if(value_count>60)
-                {
-                    Machine_info.last_batt_precent = Machine_info.batt_precent;
-                    value_count = 0;
-                }
-
-                            #if 0
-                            power_key = gpio_get_level(4);
-
-                    vTaskDelay(4000 / portTICK_PERIOD_MS);
+                    user_compare_power_off(Machine_info.last_batt_precent,Machine_info.batt_precent);
+                    printf("charge_key is %s,batt=%d,last batt=%d\r\n",!charge_key?"charge in":"charge out",Machine_info.batt_precent,Machine_info.last_batt_precent);
                     
-                    if( 0  == gpio_get_level(4))
-                    {
-                        uart_wait_tx_idle_polling(CONFIG_ESP_CONSOLE_UART_NUM);
-                        printf("power on\r\n");
-
-                                #if 1//USER_DEEP_SLEEP_ENABLE
-                                reson  = is_wake_up_reson();  //返回唤醒的原因
-                                /* ULP Risc-V read and detected a temperature above the limit */
-                                if (reson == ESP_SLEEP_WAKEUP_EXT0)
-                                {
-
-                                    if(Machine_info.power_status == 0)
-                                    {
-                                        Machine_info.power_status  = 1; //开机
-
-
-                                        lora_set_power_level(1); //打开lora电源
-
-
-
-
-                                        
-
-                                                // Set duty to 50%
-                                        ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LEDC_CHANNEL, LEDC_DUTY));
-                                        // Update duty to apply the new value
-                                        ESP_ERROR_CHECK(ledc_update_duty(LEDC_MODE, LEDC_CHANNEL));
-
-                                        vTaskDelay(1000/ portTICK_PERIOD_MS);
-
-                                        ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LEDC_CHANNEL, 0));
-                                        // Update duty to apply the new value
-                                        ESP_ERROR_CHECK(ledc_update_duty(LEDC_MODE, LEDC_CHANNEL));
-
-                                        Machine_info.left_current_Quick_refresh_time = 5;
-                                        vTaskDelay(1000/ portTICK_PERIOD_MS);
-
-                                        if(xQueueSend(left_screen_queue,&Machine_info,portMAX_DELAY) != true)
-                                        {
-                                            printf("left send fail\r\n");
-                                        } 
-
-                                        }else if(Machine_info.power_status == 1)
-                                        {
-                                            printf("aready power on\r\n");
-
-                                        }
-                                    
-                                }
-                                #endif
-
-
-
-                                break;
-                            }
-                            #endif
+                    value_count++;
 
+                    if(value_count>60)
+                    {
+                        Machine_info.last_batt_precent = Machine_info.batt_precent;
+                        value_count = 0;
+                    }
                 }
 
             }else            //未充电
@@ -620,7 +558,7 @@ if(last_paint_buf_right!=NULL)
 }
 
 
-xTaskCreate( left_screen_task, "left_screen_task", 25*1024, NULL, configMAX_PRIORITIES - 1, NULL);
+// xTaskCreate( left_screen_task, "left_screen_task", 25*1024, NULL, configMAX_PRIORITIES - 1, NULL);
 
 
 
@@ -751,11 +689,11 @@ extern uint32_t ulp_wakeup_result;
 
                         Machine_info.left_current_Quick_refresh_time = 5;
                         vTaskDelay(1000/ portTICK_PERIOD_MS);
-                        printf("开机刷屏\r\n");
-                        if(xQueueSend(left_screen_queue,&Machine_info,portMAX_DELAY) != true)
-                        {
-                            printf("left send fail\r\n");
-                        }
+                        // printf("开机刷屏\r\n");
+                        // if(xQueueSend(screen_queue,&Machine_info,portMAX_DELAY) != true)
+                        // {
+                        //     printf("left send fail\r\n");
+                        // }
                     }else if(Machine_info.power_status == 1){
                         printf("aready power on\r\n");
                     }
@@ -821,86 +759,74 @@ extern uint32_t ulp_wakeup_result;
                 printf("left key press power off\r\n");
                 uart_wait_tx_idle_polling(CONFIG_ESP_CONSOLE_UART_NUM);
 
-                #if 1    
-
-
+#if 1    
+            font_into_sleep();
+            #include "EPD.h"
+            epd_sleep(SCREEN_LEFT);
+            epd_sleep(SCREEN_RIGHT);
 
+            //gpio_hold_en(PIN_L_CS);
+            //gpio_hold_en(PIN_R_CS);
 
+            // gpio_set_level(PIN_L_CS,1);
+            // gpio_set_level(PIN_R_CS,1);
+            //gpio_reset_pin(46);
 
 
-                              font_into_sleep();
-                                #include "EPD.h"
-                                epd_sleep(SCREEN_LEFT);
-                                epd_sleep(SCREEN_RIGHT);
+            //uart_wait_tx_idle_polling(CONFIG_ESP_CONSOLE_UART_NUM);
+            //ESP_ERROR_CHECK(uart_wait_tx_done(UART_NUM_1,portMAX_DELAY));
+            esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_TIMER);
 
-                                //gpio_hold_en(PIN_L_CS);
-                                //gpio_hold_en(PIN_R_CS);
+            // gpio_set_level(LORA_TXD_PIN, 0);
+            // gpio_set_level(LORA_RXD_PIN, 0);
 
-                                // gpio_set_level(PIN_L_CS,1);
-                                // gpio_set_level(PIN_R_CS,1);
-                                //gpio_reset_pin(46);
+            //uart_sleep_in_config();
+            uart_driver_delete(UART_NUM_1);
+            gpio_reset_pin(LORA_TXD_PIN);
+            gpio_reset_pin(LORA_RXD_PIN);
 
-                               
-                                //uart_wait_tx_idle_polling(CONFIG_ESP_CONSOLE_UART_NUM);
-                                //ESP_ERROR_CHECK(uart_wait_tx_done(UART_NUM_1,portMAX_DELAY));
-                                esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_TIMER);
+            gpio_config_t io_conf = {};
+            io_conf.pin_bit_mask = (1<<LORA_TXD_PIN);
+            io_conf.mode = GPIO_MODE_OUTPUT;
+            io_conf.pull_up_en = false;
+            gpio_config(&io_conf);
 
-                                // gpio_set_level(LORA_TXD_PIN, 0);
-                                // gpio_set_level(LORA_RXD_PIN, 0);
-
-                                //uart_sleep_in_config();
-                                uart_driver_delete(UART_NUM_1);
-                                gpio_reset_pin(LORA_TXD_PIN);
-                                gpio_reset_pin(LORA_RXD_PIN);
-
-                                gpio_config_t io_conf = {};
-                                io_conf.pin_bit_mask = (1<<LORA_TXD_PIN);
-                                io_conf.mode = GPIO_MODE_OUTPUT;
-                                io_conf.pull_up_en = false;
-                                gpio_config(&io_conf);
-
-                                io_conf.pin_bit_mask = (1<<LORA_RXD_PIN);
-                                io_conf.mode = GPIO_MODE_OUTPUT;
-                                io_conf.pull_up_en = false;
-                                gpio_config(&io_conf);
-                            
-                                gpio_set_level(LORA_TXD_PIN, 0);
-                                gpio_set_level(LORA_RXD_PIN, 0);
-                                gpio_hold_en(LORA_TXD_PIN);
-                                gpio_hold_en(LORA_RXD_PIN);
-                
-                
-                
-                
-                  //电源按键
-                 // 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);
-                ESP_ERROR_CHECK(esp_sleep_enable_ext0_wakeup(ext_wakeup_pin_0, 0));
+            io_conf.pin_bit_mask = (1<<LORA_RXD_PIN);
+            io_conf.mode = GPIO_MODE_OUTPUT;
+            io_conf.pull_up_en = false;
+            gpio_config(&io_conf);
 
-                // Configure pullup/downs via RTCIO to tie wakeup pins to inactive level during deepsleep.
-                // EXT0 resides in the same power domain (RTC_PERIPH) as the RTC IO pullup/downs.
-                // No need to keep that power domain explicitly, unlike EXT1.
-                ESP_ERROR_CHECK(rtc_gpio_pullup_en(ext_wakeup_pin_0));
-                ESP_ERROR_CHECK(rtc_gpio_pulldown_dis(ext_wakeup_pin_0));
-
-
-                //充电按键
-                gpio_reset_pin(2);
-                const int ext_wakeup_pin_1 = 2;
-                const uint64_t ext_wakeup_pin_1_mask = 1ULL << ext_wakeup_pin_1;
-                printf("Enabling EXT1 wakeup on pins GPIO%d\r\n",ext_wakeup_pin_1);
-                ESP_ERROR_CHECK(esp_sleep_enable_ext1_wakeup(ext_wakeup_pin_1_mask, ESP_EXT1_WAKEUP_ALL_LOW));
+            gpio_set_level(LORA_TXD_PIN, 0);
+            gpio_set_level(LORA_RXD_PIN, 0);
+            gpio_hold_en(LORA_TXD_PIN);
+            gpio_hold_en(LORA_RXD_PIN);
+            
+            //电源按键
+                // 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);
+            ESP_ERROR_CHECK(esp_sleep_enable_ext0_wakeup(ext_wakeup_pin_0, 0));
 
+            // Configure pullup/downs via RTCIO to tie wakeup pins to inactive level during deepsleep.
+            // EXT0 resides in the same power domain (RTC_PERIPH) as the RTC IO pullup/downs.
+            // No need to keep that power domain explicitly, unlike EXT1.
+            ESP_ERROR_CHECK(rtc_gpio_pullup_en(ext_wakeup_pin_0));
+            ESP_ERROR_CHECK(rtc_gpio_pulldown_dis(ext_wakeup_pin_0));
 
 
+            //充电按键
+            gpio_reset_pin(2);
+            const int ext_wakeup_pin_1 = 2;
+            const uint64_t ext_wakeup_pin_1_mask = 1ULL << ext_wakeup_pin_1;
+            printf("Enabling EXT1 wakeup on pins GPIO%d\r\n",ext_wakeup_pin_1);
+            ESP_ERROR_CHECK(esp_sleep_enable_ext1_wakeup(ext_wakeup_pin_1_mask, ESP_EXT1_WAKEUP_ALL_LOW));
 
-                esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
-                ESP_ERROR_CHECK( esp_sleep_enable_ulp_wakeup());
+            esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
+            ESP_ERROR_CHECK( esp_sleep_enable_ulp_wakeup());
 
 
-                #endif
+#endif
                 esp_deep_sleep_start();
             }else 
             {
@@ -922,7 +848,8 @@ extern uint32_t ulp_wakeup_result;
 
                 
                     #if 1
-                        if(xQueueSend(left_screen_queue,&Machine_info,portMAX_DELAY) != true)
+                    bool is_left = true;
+                        if(xQueueSend(screen_queue,&Machine_info,portMAX_DELAY) != true)
                         {
                             printf("left send fail\r\n");
                         } 
@@ -1030,8 +957,8 @@ extern uint32_t ulp_wakeup_result;
 
 xTaskCreate( button_task,"button_task",5*2048, NULL, configMAX_PRIORITIES, NULL);
 
-xTaskCreate( right_screen_task, "right_screen_task",15*1024, NULL, configMAX_PRIORITIES - 2, NULL);
-
+// xTaskCreate( right_screen_task, "right_screen_task",15*1024, NULL, configMAX_PRIORITIES - 2, NULL);
+xTaskCreate( screen_task, "screen_task",40*1024, NULL, configMAX_PRIORITIES - 2, NULL);
 
 printf("=================================UPDATE OK===========================\r\n");
 
@@ -1165,371 +1092,88 @@ print_systenInfo();
     
 // }
 
-
-
-static void left_screen_task(void* arg)
+static void screen_task(void* arg)
 {
-
-    extern bool is_sleep;
-
-  
-
-     #if USER_NOT_SLEEP_ENABLE || USER_LIGHT_SLEEP_ENABLE
-
-        int  reson = is_wake_up_reson();  //返回唤醒的原因
-        if ((reson != ESP_SLEEP_WAKEUP_ULP) && (reson != ESP_SLEEP_WAKEUP_TIMER)&&(reson != ESP_SLEEP_WAKEUP_EXT0)) 
-        {
-            Paint_leftScreen_main_powerOn();
-        }
-
-     #endif
-
-
-
-    Machine_info_t info;   
-
-
-    // if(reson == ESP_SLEEP_WAKEUP_EXT0)
-    // {
-    //     //开机刷新左屏慕
-    //      Paint_leftScreen_main_slow(&info);
-    // }
-
-
-
-
+    Machine_info.rssi = 100;//没有获取到真数据,默认100
+    int  reson = is_wake_up_reson();  //返回唤醒的原因
+    ESP_LOGW(LOG_TAG,"screen_task  %d",reson);
+    if ((reson != ESP_SLEEP_WAKEUP_ULP) && (reson != ESP_SLEEP_WAKEUP_TIMER)&&(reson != ESP_SLEEP_WAKEUP_EXT0)) 
+    {
+        Paint_leftScreen_main_powerOn();
+        Paint_rightScreen_main_powerON();
+    }
+    else if(reson == ESP_SLEEP_WAKEUP_EXT0)
+    {
+        //开机刷新左屏慕
+         Paint_leftScreen_main_slow(&Machine_info);
+         Paint_rightScreen_main_slow(&Machine_info);
+    }
+    bool is_left = false;
     while(1)
     {
-        if(xQueueReceive(left_screen_queue, &info,(TickType_t)portMAX_DELAY))
+        if(xQueueReceive(screen_queue, &is_left,(TickType_t)portMAX_DELAY))
         {
-
             font_exit_sleep();
-
-            printf("left 拿锁\n");
-            if(xSemaphoreTake(screen_semaphore, portMAX_DELAY) == true)
-            // if(1)
+            ESP_LOGD(LOG_TAG,"%s",is_left?"左屏刷新":"右屏刷新");
+            if(is_left)//刷左屏
             {
                 if(Machine_info.left_current_Quick_refresh_time >=  Machine_info.left_max_Quick_refresh_time)
                 {
                     Machine_info.left_current_Quick_refresh_time = 0;
-                    Paint_leftScreen_main_slow(&info);
+                    Paint_leftScreen_main_slow(&Machine_info);
                 }
                 else
                 {
-                    // printf("left_current_Quick_refresh_time = %d,Machine_info.left_max_Quick_refresh_time= %d\r\n",Machine_info.left_current_Quick_refresh_time,Machine_info.left_max_Quick_refresh_time);
                     Machine_info.left_current_Quick_refresh_time++;
-                    Paint_leftScreen_main_quick(&info);
+                    Paint_leftScreen_main_quick(&Machine_info);
                 }
-                printf("left 还锁\n");
-                xSemaphoreGive(screen_semaphore);
             }
-            else
+            else//刷右屏
             {
-                ESP_LOGE(LOG_TAG,"left 拿锁失败 \n");
+                Paint_rightScreen_main_slow(&Machine_info);
             }
 
-
-
-            while(1)
-        {                         
-            if( (left_refresh_timer_isActive() == false) )
+            if((Machine_info.power_status == 1)&&(Machine_info.paired == 1))
             {
-                printf("7left refresh complete %s\r\n",left_refresh_timer_isActive()?"true":"false");
-                break;
-            }
-                vTaskDelay(100/ portTICK_PERIOD_MS);
-        }
-
-
-
-
-
-            if(
-                (Machine_info.power_status == 1)&&
-
-                (Machine_info.paired == 1)  //已配对
-
-            )
-            {
-
+                ESP_LOGW(LOG_TAG,"刷屏进入休眠 %s",is_left?"左屏刷新":"右屏刷新");
                 sleep_timer_start(100);  //进入睡眠
-
             }
 
-if(Machine_info.power_status == 0)
-{
-
-
-    
-                                printf("=>deep sleep\r\n");
-                                uart_wait_tx_idle_polling(CONFIG_ESP_CONSOLE_UART_NUM);
-                                 //vTaskDelay(100/ portTICK_PERIOD_MS);
-
+            if(Machine_info.power_status == 0)
+            {
+                printf("=>screen deep sleep\r\n");
+                uart_wait_tx_idle_polling(CONFIG_ESP_CONSOLE_UART_NUM);
 #if 1           //电源按键
-                           // 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);
-                            ESP_ERROR_CHECK(esp_sleep_enable_ext0_wakeup(ext_wakeup_pin_0, 0));
-
-                            // Configure pullup/downs via RTCIO to tie wakeup pins to inactive level during deepsleep.
-                            // EXT0 resides in the same power domain (RTC_PERIPH) as the RTC IO pullup/downs.
-                            // No need to keep that power domain explicitly, unlike EXT1.
-                            ESP_ERROR_CHECK(rtc_gpio_pullup_en(ext_wakeup_pin_0));
-                            ESP_ERROR_CHECK(rtc_gpio_pulldown_dis(ext_wakeup_pin_0));
-
+                gpio_reset_pin(4);
+                int ext_wakeup_pin_0 = 4;
+                printf("Enabling EXT0 wakeup on pin GPIO%d\n", ext_wakeup_pin_0);
+                ESP_ERROR_CHECK(esp_sleep_enable_ext0_wakeup(ext_wakeup_pin_0, 0));
 
-                            esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
-                            ESP_ERROR_CHECK( esp_sleep_enable_ulp_wakeup());
+                // Configure pullup/downs via RTCIO to tie wakeup pins to inactive level during deepsleep.
+                // EXT0 resides in the same power domain (RTC_PERIPH) as the RTC IO pullup/downs.
+                // No need to keep that power domain explicitly, unlike EXT1.
+                ESP_ERROR_CHECK(rtc_gpio_pullup_en(ext_wakeup_pin_0));
+                ESP_ERROR_CHECK(rtc_gpio_pulldown_dis(ext_wakeup_pin_0));
 
+                esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
+                ESP_ERROR_CHECK( esp_sleep_enable_ulp_wakeup());
 #endif
-                                //adc_oneshot_del_unit(adc1_handle);
-                                esp_deep_sleep_start();
-
-
-}
-
-
-
-                        // if(Machine_info.paired == 1)  //已配对
-                        // {
-                        //             if(is_sleep == false)  //已经进入sleep定时器
-                        //             {
-                        //                 printf("已配对 进入睡眠\n");
-                        //                 sleep_timer_start(100);  //进入睡眠
-                        //             }
-                        // }
-
-
-       
-
-            #if  0
-                            int reson  = is_wake_up_reson();  //返回唤醒的原因
-                            /* ULP Risc-V read and detected a temperature above the limit */
-                            if (reson == ESP_SLEEP_WAKEUP_ULP || reson == ESP_SLEEP_WAKEUP_TIMER) {
-                                 //lora_set_power_level(0);
-
-
-                                #if 0
-                                font_into_sleep();   //关闭外设电源
-                                epd_sleep(SCREEN_LEFT);
-                                epd_sleep(SCREEN_RIGHT);
-                                #endif
-
-
-                                #if USER_LIGHT_SLEEP_ENABLE
-
-                               
-
-                                if(is_sleep == true)  //已经进入sleep定时器
-                                {
-                                    printf("display refresh commplete ready sleep\r\n");
-
-
-                                        if(Machine_info.paired == 1)  //已配对
-                                       {
-                                            //if(is_sleep == false)  //已经进入sleep定时器
-                                            {
-                                                       sleep_timer_start(100);  //进入睡眠
-                                            }
-                                       }
-                                }else
-                                {
-                                    printf("display refresh commplete not into sleep\r\n");
-
-                                }
-                                //esp_sleep_enable_timer_wakeup(TIMER_WAKEUP_TIME_US);  //配置当前休眠的唤醒时间
-                                //esp_light_sleep_start();
-                                #endif
-
-                                #if USER_DEEP_SLEEP_ENABLE
-                                //esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_TIMER);
-                                //重新配置休眠唤醒时间
-                                //esp_sleep_enable_timer_wakeup(TIMER_WAKEUP_TIME_US);  //配置当前休眠的唤醒时间
-                                //esp_deep_sleep_start();
-                                #endif
-                            }else 
-                            {
-                                if(Machine_info.paired == 1)  //已配对
-                                {
-                                    if(is_sleep == false)  //已经进入sleep定时器
-                                    {
-                                        printf("已配对 进入睡眠\n");
-                                        sleep_timer_start(100);  //进入睡眠
-                                    }
-                                }
-                            }
-            #endif                    
-        }
-        
-    }
-}
-
-static void right_screen_task(void* arg)
-{
-
-    extern bool is_sleep;
-
-      #if USER_DEEP_SLEEP_ENABLE
-
-        int  reson = is_wake_up_reson();  //返回唤醒的原因
-        if ((reson != ESP_SLEEP_WAKEUP_ULP) && (reson != ESP_SLEEP_WAKEUP_TIMER)) 
-        {
-            vTaskDelay(1000 / portTICK_PERIOD_MS);
-            Paint_rightScreen_main_powerON();
-        } 
-     #endif
-
-
-    // #if USER_NOT_SLEEP_ENABLE || USER_LIGHT_SLEEP_ENABLE
-
-    //     //vTaskDelay(1000 / portTICK_PERIOD_MS);
-    //     Paint_rightScreen_main_powerON();
-
-    //  #endif
-
-
-
-
-             int  reson = is_wake_up_reson();  //返回唤醒的原因
-        //if ((reson != ESP_SLEEP_WAKEUP_ULP) && (reson != ESP_SLEEP_WAKEUP_TIMER)&&(reson != ESP_SLEEP_WAKEUP_EXT0)) 
-        {
-            Paint_rightScreen_main_powerON();
-        }
-
-         vTaskDelay(3000 / portTICK_PERIOD_MS);
-
-
-    Machine_info.rssi = 100;//没有获取到真数据,默认100
-
-    Machine_info_t info;
-    while(1)
-    {
-        if(xQueueReceive(right_screen_queue, &info, (TickType_t)portMAX_DELAY))
-        {
-            font_exit_sleep();
-            ESP_LOGD(LOG_TAG,"right_screen_task");
-
-
-            // printf("refresh %d,max %d\r\n",Machine_info.right_current_Quick_refresh_time,Machine_info.right_max_Quick_refresh_time);
-
-
-            printf("right 拿锁\n");
-            if(xSemaphoreTake(screen_semaphore, portMAX_DELAY) == true)
-            // if(1)
-            {
-                if(Machine_info.right_current_Quick_refresh_time >=  Machine_info.right_max_Quick_refresh_time)
-                {
-                    Machine_info.right_current_Quick_refresh_time = 0;
-                    Paint_rightScreen_main_slow(&info);
-                }else
-                {
-                    Machine_info.right_current_Quick_refresh_time++;
-                    // Paint_rightScreen_main_quick(&info);
-                    Paint_rightScreen_main_slow(&info);
-                }
-                printf("right 还锁\n");
-                xSemaphoreGive(screen_semaphore);
-            }
-            else
-            {
-                ESP_LOGE(LOG_TAG,"right 拿锁失败 \n");
-            }
-
-
-
-         while(1)
-        {                         
-            if( (right_refresh_timer_isActive() == false) )
-            {
-                printf("8left refresh complete %s\r\n",right_refresh_timer_isActive()?"true":"false");
-                break;
+                esp_deep_sleep_start();
             }
-                vTaskDelay(100/ portTICK_PERIOD_MS);
-        }
-
-
-
-            #if  1
-                            int reson  = is_wake_up_reson();  //返回唤醒的原因
-                            /* ULP Risc-V read and detected a temperature above the limit */
-                            if (reson == ESP_SLEEP_WAKEUP_ULP || reson == ESP_SLEEP_WAKEUP_TIMER) {
-                                 //lora_set_power_level(0);
-
-
-
-                                 
-                                #if USER_LIGHT_SLEEP_ENABLE
-
-                               
-
-                                if(is_sleep == true)  //已经进入sleep定时器
-                                {
-                                    printf("display right refresh commplete ready sleep\r\n");
-
-                                         if(Machine_info.paired == 1)  //已配对
-                                       {
-                                            //if(is_sleep == false)  //已经进入sleep定时器
-                                            {
-                                                       sleep_timer_start(100);  //进入睡眠
-                                            }
-                                       }
-                                }else
-                                {
-                                    printf("display right refresh commplete not into sleep\r\n");
-
-                                }
-                                //esp_sleep_enable_timer_wakeup(TIMER_WAKEUP_TIME_US);  //配置当前休眠的唤醒时间
-                                //esp_light_sleep_start();
-                                #endif
-
-
-
-                                #if 0
-                                font_into_sleep();   //关闭外设电源
-                                epd_sleep(SCREEN_LEFT);
-                                epd_sleep(SCREEN_RIGHT);
-                                #endif
-
-                                #if USER_LIGHT_SLEEP_ENABLE
-                                //esp_sleep_enable_timer_wakeup(TIMER_WAKEUP_TIME_US);  //配置当前休眠的唤醒时间
-                                //esp_light_sleep_start();
-                                #endif
-
-                                #if USER_DEEP_SLEEP_ENABLE
-                                //重新配置休眠唤醒时间
-                                //esp_sleep_enable_timer_wakeup(TIMER_WAKEUP_TIME_US);  //配置当前休眠的唤醒时间
-                                //esp_deep_sleep_start();
-                                #endif
-                            }else 
-                            {
-                                       if(Machine_info.paired == 1)  //已配对
-                                       {
-                                            if(is_sleep == false)  //已经进入sleep定时器
-                                            {
-                                                sleep_timer_start(100);  //进入睡眠
-                                            }
-                                       }
-
-
-                                printf("sleep = %d\r\n",is_sleep);
-                            }
-            #endif           
-
-
-
         }
     }
 }
+
 static void button_task(void* arg)
 {
     //update_last_button_info(Machine_info.current_button.button_info);//初始化上个按键为运行,用作paint0703计时
     uint8_t button_info;
+    bool is_left = false;
     while(1)
     {
         if(xQueueReceive(button_Data_queue, &button_info, (TickType_t)portMAX_DELAY))
         {
-            
+#if 1
             ESP_LOGI(LOG_TAG,"btn_flag[%d][%d][%d][%d][%d][%d],button_info = [%d]%s ",Machine_info.btn_dis_flag[0],\
             Machine_info.btn_dis_flag[1],Machine_info.btn_dis_flag[2],Machine_info.btn_dis_flag[3],Machine_info.btn_dis_flag[4],\
             Machine_info.btn_dis_flag[5],button_info,Machine_info.power_status?"开机":"关机");
@@ -1543,7 +1187,7 @@ static void button_task(void* arg)
                                 Machine_info.Duration_time,\
                                 Machine_info.rssi,\
                                 Machine_info.paired?"已配网":"未配网");
-
+#endif
             if(button_info < 0x12)  //左屏慕按键
             {
                 if(Machine_info.btn_dis_flag[button_info-1] == false)
@@ -1557,102 +1201,102 @@ static void button_task(void* arg)
 
                 }
                 Machine_info .current_button.button_info =  button_info;
-            //判断当前的按键状态 设置为当前状态后 再次按键不处理
-            printf("last btn = %d ,curr btn = %d\n",Machine_info.last_button.button_info , Machine_info.current_button.button_info);
-            if(Machine_info.last_button.button_info !=  Machine_info.current_button.button_info)
-            {        
-                    if(Machine_info.paired == 1)
-                    {
-                        printf("paired add data to list chanl = 0x%02x\r\n",Machine_info.lora_new_channel);
-                        getRtcTime(&Machine_info);  //获取当前时间
-                        //更新当前时间
-                        Machine_info.current_button.button_info = button_info;
-                        Machine_info.current_button.Year = Machine_info.year;
-                        Machine_info.current_button.Month = Machine_info.month;
-                        Machine_info.current_button.Day = Machine_info.day;
-                        Machine_info.current_button.Hour = Machine_info.hour;
-                        Machine_info.current_button.Minute = Machine_info.min;
-                        Machine_info.current_button.Second = Machine_info.sec;
-
-                        long long  current_Duration_time  =   calculate_minutes_difference
-                        (
-                            Machine_info.last_button.Year,
-                            Machine_info.last_button.Month ,
-                            Machine_info.last_button.Day ,
-                            Machine_info.last_button.Hour ,
-                            Machine_info.last_button.Minute ,
-                            Machine_info.last_button.Second ,
-
-                            Machine_info.current_button.Year,
-                            Machine_info.current_button.Month ,
-                            Machine_info.current_button.Day ,
-                            Machine_info.current_button.Hour ,
-                            Machine_info.current_button.Minute ,
-                            Machine_info.current_button.Second
-                        );
-
-
-                        Machine_info.Duration_time = current_Duration_time;//持续时长
-
-                        printf("Machine_info.Duration_time = %ld\r\n",Machine_info.Duration_time);
-                        
-                        reset_btn_last_time();
-                       #if 0
-                                printf("list before\r\n");
-                                printList(Send_list);
+                //判断当前的按键状态 设置为当前状态后 再次按键不处理
+                printf("last btn = %d ,curr btn = %d\n",Machine_info.last_button.button_info , Machine_info.current_button.button_info);
+                if(Machine_info.last_button.button_info !=  Machine_info.current_button.button_info)
+                {        
+                        if(Machine_info.paired == 1)
+                        {
+                            printf("paired add data to list chanl = 0x%02x\r\n",Machine_info.lora_new_channel);
+                            getRtcTime(&Machine_info);  //获取当前时间
+                            //更新当前时间
+                            Machine_info.current_button.button_info = button_info;
+                            Machine_info.current_button.Year = Machine_info.year;
+                            Machine_info.current_button.Month = Machine_info.month;
+                            Machine_info.current_button.Day = Machine_info.day;
+                            Machine_info.current_button.Hour = Machine_info.hour;
+                            Machine_info.current_button.Minute = Machine_info.min;
+                            Machine_info.current_button.Second = Machine_info.sec;
+
+                            long long  current_Duration_time  =   calculate_minutes_difference
+                            (
+                                Machine_info.last_button.Year,
+                                Machine_info.last_button.Month ,
+                                Machine_info.last_button.Day ,
+                                Machine_info.last_button.Hour ,
+                                Machine_info.last_button.Minute ,
+                                Machine_info.last_button.Second ,
+
+                                Machine_info.current_button.Year,
+                                Machine_info.current_button.Month ,
+                                Machine_info.current_button.Day ,
+                                Machine_info.current_button.Hour ,
+                                Machine_info.current_button.Minute ,
+                                Machine_info.current_button.Second
+                            );
+
+
+                            Machine_info.Duration_time = current_Duration_time;//持续时长
+
+                            printf("Machine_info.Duration_time = %ld\r\n",Machine_info.Duration_time);
+                            
+                            reset_btn_last_time();
+                        #if 0
+                                    printf("list before\r\n");
+                                    printList(Send_list);
 
-                                    if(Machine_info.Duration_time == 0)
-                                    {
-                                        deleteNode_head(Send_list);
-                                    }
+                                        if(Machine_info.Duration_time == 0)
+                                        {
+                                            deleteNode_head(Send_list);
+                                        }
 
-                                printf("list after\r\n");
-                                printList(Send_list);
-                       #endif
+                                    printf("list after\r\n");
+                                    printList(Send_list);
+                        #endif
 
 
-                        
-                        
+                            
+                            
 
-                        set_status_heights();
-                         Machine_info.Duration_time = 0;
+                            set_status_heights();
+                            Machine_info.Duration_time = 0;
 
-                        //更新上次的状态
-                        update_last_button_info(Machine_info.last_button.button_info);
-                    }else
-                    {
-                        //  f_send_get_chart_data();
-                        printf("not add data to list\r\n");
-                    }
+                            //更新上次的状态
+                            update_last_button_info(Machine_info.last_button.button_info);
+                        }else
+                        {
+                            printf("not add data to list\r\n");
+                        }
 
-                    Machine_info.last_button.button_info =  Machine_info.current_button.button_info;
-                    // Machine_info.left_state = 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(xQueueSend(left_screen_queue,&Machine_info,portMAX_DELAY) != true)
-                    {
-                        ESP_LOGE(LOG_TAG,"queue:left_screen_queue");
-                    } 
-#endif 
-                    // Set duty to 50%
-                    ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LEDC_CHANNEL, LEDC_DUTY));
-                    // Update duty to apply the new value
-                    ESP_ERROR_CHECK(ledc_update_duty(LEDC_MODE, LEDC_CHANNEL));
-                    vTaskDelay(30 / portTICK_PERIOD_MS);
-                    ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LEDC_CHANNEL, 0));
-                    // Update duty to apply the new value
-                    ESP_ERROR_CHECK(ledc_update_duty(LEDC_MODE, LEDC_CHANNEL));
+                        Machine_info.last_button.button_info =  Machine_info.current_button.button_info;
+                        // Machine_info.left_state = 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
+                        bool is_left = true;
+                        if(xQueueSend(screen_queue,&is_left,portMAX_DELAY) != true)
+                        {
+                            ESP_LOGE(LOG_TAG,"queue:screen_queue");
+                        } 
+    #endif 
+                        // Set duty to 50%
+                        ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LEDC_CHANNEL, LEDC_DUTY));
+                        // Update duty to apply the new value
+                        ESP_ERROR_CHECK(ledc_update_duty(LEDC_MODE, LEDC_CHANNEL));
+                        vTaskDelay(30 / portTICK_PERIOD_MS);
+                        ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LEDC_CHANNEL, 0));
+                        // Update duty to apply the new value
+                        ESP_ERROR_CHECK(ledc_update_duty(LEDC_MODE, LEDC_CHANNEL));
 
 
-                    //printList(Send_list);
-                    //printList(list_head);
-            }
-            else//和上个按键重复,唤醒原因为ulp唤醒,不进入休眠
-            {
-                printf("和上个按键重复,唤醒原因为ulp唤醒,不进入休眠\r\n");
-                sleep_timer_start(100); //开始进入倒计时休眠 
-            }
+                        //printList(Send_list);
+                        //printList(list_head);
+                }
+                else//和上个按键重复,唤醒原因为ulp唤醒,不进入休眠
+                {
+                    printf("和上个按键重复,唤醒原因为ulp唤醒,不进入休眠\r\n");
+                    sleep_timer_start(100); //开始进入倒计时休眠 
+                }
             }else //右屏幕按键触发
             {
 
@@ -1744,9 +1388,10 @@ static void button_task(void* arg)
 
                 if(button_info == POWER_ON_INTO_DIS_RIGHT) 
                 {
-                    if(xQueueSend(right_screen_queue,&Machine_info,portMAX_DELAY) != true)
+                    is_left = false;
+                    if(xQueueSend(screen_queue,&is_left,portMAX_DELAY) != true)
                     {
-                        ESP_LOGE(LOG_TAG,"queue:right_screen_queue");
+                        ESP_LOGE(LOG_TAG,"queue:screen_queue");
                     } 
                 }