Browse Source

每30分钟同类型lora消息未发送,不重复加入链表

wanghechen 10 months ago
parent
commit
f91071d258

+ 29 - 18
components/EPD/EPD.c

@@ -11,7 +11,7 @@
 // #include "../components/../main/user_sleep.h"
 // #include "../components/../main/user_sleep.h"
 #include "esp_timer.h"
 #include "esp_timer.h"
 
 
-uint8_t current_display = 0;
+bool is_epd_ok = false;
 
 
 #include "../../main/user_sleep.h"
 #include "../../main/user_sleep.h"
 #include "esp_sleep.h"
 #include "esp_sleep.h"
@@ -79,7 +79,11 @@ void epd_spi_write(struct EPD_INFO_SET* epd_pin_set,unsigned char value)
 }
 }
 
 
 #endif
 #endif
-
+esp_err_t user_spi_device_queue_trans(spi_device_handle_t handle, spi_transaction_t *trans_desc, TickType_t ticks_to_wait)
+{
+    is_epd_ok = false;
+    return spi_device_queue_trans(handle, trans_desc, ticks_to_wait);
+}
 /*********************************************************************************
 /*********************************************************************************
  * function   :   SPI_Write
  * function   :   SPI_Write
  * Description :  spi写入数据
  * Description :  spi写入数据
@@ -283,12 +287,27 @@ void epd_init_cmd(screen_t screen)
         }
         }
     }
     }
 }
 }
-
+esp_err_t user_spi_get_result(spi_device_handle_t spi)
+{
+    spi_transaction_t *rtrans = NULL;
+    return spi_device_get_trans_result(spi, &rtrans, 10000);
+}
 static void spi_get_result(spi_device_handle_t spi)
 static void spi_get_result(spi_device_handle_t spi)
 {
 {
     spi_transaction_t *rtrans = NULL;
     spi_transaction_t *rtrans = NULL;
     esp_err_t ret;
     esp_err_t ret;
-    spi_device_get_trans_result(spi, &rtrans, portMAX_DELAY);
+    ret = spi_device_get_trans_result(spi, &rtrans, portMAX_DELAY);
+    if (ret == ESP_OK)
+    {
+        is_epd_ok = true;
+        // printf("->%s\n", esp_err_to_name(ret));
+    }
+    else
+    {
+        printf("->%s\n", esp_err_to_name(ret));
+        is_epd_ok = false;
+    }
+
     // assert(ret==ESP_OK);
     // assert(ret==ESP_OK);
 }
 }
 
 
@@ -305,7 +324,7 @@ void epd_cmd(spi_device_handle_t spi, const uint8_t cmd, bool keep_cs_active)
     {
     {
         t.flags = SPI_TRANS_CS_KEEP_ACTIVE; // Keep CS active after data transfer
         t.flags = SPI_TRANS_CS_KEEP_ACTIVE; // Keep CS active after data transfer
     }
     }
-    ret = spi_device_queue_trans(spi, &t, portMAX_DELAY);
+    ret = user_spi_device_queue_trans(spi, &t, portMAX_DELAY);
 
 
     // assert(ret==ESP_OK);            //Should have had no issues.
     // assert(ret==ESP_OK);            //Should have had no issues.
     spi_get_result(spi);
     spi_get_result(spi);
@@ -331,12 +350,8 @@ void epd_data(spi_device_handle_t spi, const uint8_t *data, int len)
             t.length = SPI_MAX_LEN * 8;                           // Len is in bytes, transaction length is in bits.
             t.length = SPI_MAX_LEN * 8;                           // Len is in bytes, transaction length is in bits.
             t.tx_buffer = data + i;                               // Data
             t.tx_buffer = data + i;                               // Data
             t.user = (void *)1;                                   // D/C needs to be set to 1
             t.user = (void *)1;                                   // D/C needs to be set to 1
-            ret = spi_device_queue_trans(spi, &t, portMAX_DELAY); // Transmit!
+            ret = user_spi_device_queue_trans(spi, &t, portMAX_DELAY); // Transmit!
             // assert(ret==ESP_OK);            //Should have had no issues.
             // assert(ret==ESP_OK);            //Should have had no issues.
-            if (ret != ESP_OK)
-            {
-                printf("spi_device_queue_trans err:ret =%d", ret);
-            }
             spi_get_result(spi);
             spi_get_result(spi);
         }
         }
         i -= SPI_MAX_LEN;
         i -= SPI_MAX_LEN;
@@ -344,12 +359,8 @@ void epd_data(spi_device_handle_t spi, const uint8_t *data, int len)
         t.length = (len - i) * 8;                             // Len is in bytes, transaction length is in bits.
         t.length = (len - i) * 8;                             // Len is in bytes, transaction length is in bits.
         t.tx_buffer = data + i;                               // Data
         t.tx_buffer = data + i;                               // Data
         t.user = (void *)1;                                   // D/C needs to be set to 1
         t.user = (void *)1;                                   // D/C needs to be set to 1
-        ret = spi_device_queue_trans(spi, &t, portMAX_DELAY); // Transmit!
-        // assert(ret==ESP_OK);            //Should have had no issues.
-        if (ret != ESP_OK)
-        {
-            printf("spi_device_queue_trans err:ret =%d", ret);
-        }
+        ret = user_spi_device_queue_trans(spi, &t, portMAX_DELAY); // Transmit!
+        assert(ret == ESP_OK);                                // Should have had no issues.
         spi_get_result(spi);
         spi_get_result(spi);
         return;
         return;
     }
     }
@@ -358,7 +369,7 @@ void epd_data(spi_device_handle_t spi, const uint8_t *data, int len)
     t.length = len * 8;                                   // Len is in bytes, transaction length is in bits.
     t.length = len * 8;                                   // Len is in bytes, transaction length is in bits.
     t.tx_buffer = data;                                   // Data
     t.tx_buffer = data;                                   // Data
     t.user = (void *)1;                                   // D/C needs to be set to 1
     t.user = (void *)1;                                   // D/C needs to be set to 1
-    ret = spi_device_queue_trans(spi, &t, portMAX_DELAY); // Transmit!
+    ret = user_spi_device_queue_trans(spi, &t, portMAX_DELAY); // Transmit!
     // assert(ret==ESP_OK);            //Should have had no issues.
     // assert(ret==ESP_OK);            //Should have had no issues.
     if (ret != ESP_OK)
     if (ret != ESP_OK)
     {
     {
@@ -433,7 +444,7 @@ void epd_write_data(screen_t screen, const uint8_t *data, int len)
 bool epd_check_status(screen_t screen)
 bool epd_check_status(screen_t screen)
 {
 {
 
 
-#if 1//死等
+#if 0 // 死等
     if(screen == SCREEN_LEFT)
     if(screen == SCREEN_LEFT)
     {
     {
         while(!gpio_get_level(PIN_L_BUSY))
         while(!gpio_get_level(PIN_L_BUSY))

+ 1 - 1
components/EPD/include/EPD.h

@@ -101,7 +101,7 @@ void deepsleep_epd_powerOn_refresh_sleep(screen_t screen);
 bool epd_cache_quick(screen_t screen,const unsigned char* old,const unsigned char* new);
 bool epd_cache_quick(screen_t screen,const unsigned char* old,const unsigned char* new);
 void epd_powerOn_refresh_sleep(screen_t screen);
 void epd_powerOn_refresh_sleep(screen_t screen);
 
 
-
+esp_err_t user_spi_get_result(spi_device_handle_t spi);
 
 
 #else /*HARDWARE_SPI*/
 #else /*HARDWARE_SPI*/
 
 

+ 4 - 0
components/c_linked_list/list.c

@@ -6,6 +6,10 @@
 #include<stdbool.h>
 #include<stdbool.h>
 #include "esp_heap_caps.h"
 #include "esp_heap_caps.h"
 
 
+
+//添加消息池,防止lora消息没发出去一直增加
+RTC_FAST_ATTR LORA_POOL_t lora_pool[LORA_INFO_END];
+
 #if 1
 #if 1
 Node *newNode(int x,int cmd,char *data,int len) 
 Node *newNode(int x,int cmd,char *data,int len) 
 #else
 #else

+ 23 - 0
components/c_linked_list/list.h

@@ -2,6 +2,29 @@
 #include <stdlib.h>
 #include <stdlib.h>
 #ifndef __LIST_H__
 #ifndef __LIST_H__
 #define __LIST_H__
 #define __LIST_H__
+#include "stdbool.h"
+#include "esp_attr.h"
+typedef enum {
+	LORA_INFO_NONE = 0,
+
+    LORA_INFO_VERSION,
+    LORA_INFO_GET_CHART,
+    LORA_INFO_RSSI,
+    LORA_INFO_BATT,
+    LORA_INFO_REPLY,
+	LORA_INFO_GET_TIME,
+	LORA_INFO_STATUS,
+	LORA_INFO_DUR,
+	LORA_INFO_END,
+} LORA_INFO_TYPE_e;
+
+typedef struct queue
+{
+	bool flag;
+	uint8_t num;
+}LORA_POOL_t;
+extern RTC_FAST_ATTR LORA_POOL_t lora_pool[LORA_INFO_END];
+
 
 
 typedef struct node {
 typedef struct node {
 	int n;              /* data field(s) */
 	int n;              /* data field(s) */

+ 21 - 21
main/ulp_riscv_adc_example_main.c

@@ -89,15 +89,15 @@ static void light_sleep_task(void *args)
     // }
     // }
     extern bool is_adv;
     extern bool is_adv;
     int bat_times = 0;
     int bat_times = 0;
-
+    extern bool is_epd_ok;
     int lev_2 = 0;
     int lev_2 = 0;
     while (true)
     while (true)
     {
     {
-        if (is_key_press())
+        if (is_key_press() || !is_epd_ok)
         {
         {
-            // ESP_LOGI(LOG_TAG,"按键按下不进行休眠操作");
+            ESP_LOGI(LOG_TAG,"is_key_press() || !is_epd_ok");
             vTaskDelay(1000 / portTICK_PERIOD_MS);
             vTaskDelay(1000 / portTICK_PERIOD_MS);
-            continue; // 按键按下不进行休眠操作
+            continue; 
         }
         }
         extern bool is_sleep;
         extern bool is_sleep;
         if (is_sleep == true)
         if (is_sleep == true)
@@ -113,7 +113,7 @@ static void light_sleep_task(void *args)
 
 
             is_first_run = false;
             is_first_run = false;
 
 
-            ESP_LOGE(LOG_TAG, "start light_sleep ,is_first_run = %d\r\n", is_first_run);
+            // ESP_LOGE(LOG_TAG, "start light_sleep ,is_first_run = %d\r\n", is_first_run);
 
 
             if (Machine_info.power_status == 0) // 关机状态
             if (Machine_info.power_status == 0) // 关机状态
             {
             {
@@ -216,13 +216,13 @@ static void light_sleep_task(void *args)
 
 
                 // if (!is_key_press())
                 // if (!is_key_press())
                 // {
                 // {
-                    printf("=>deep sleep\r\n");
-                    uart_wait_tx_idle_polling(1); // 抛出剩余串口1消息
-                    uart_wait_tx_idle_polling(CONFIG_ESP_CONSOLE_UART_NUM);
-                    iot_button_stop();
-                    adc_oneshot_del_unit(adc1_handle);
-                    vTaskDelay(100/ portTICK_PERIOD_MS);
-                    esp_deep_sleep_start();
+                printf("=>deep sleep\r\n");
+                uart_wait_tx_idle_polling(1); // 抛出剩余串口1消息
+                uart_wait_tx_idle_polling(CONFIG_ESP_CONSOLE_UART_NUM);
+                iot_button_stop();
+                adc_oneshot_del_unit(adc1_handle);
+                vTaskDelay(100 / portTICK_PERIOD_MS);
+                esp_deep_sleep_start();
                 // }
                 // }
 
 
                 // esp_light_sleep_start();
                 // esp_light_sleep_start();
@@ -317,11 +317,11 @@ static void light_sleep_task(void *args)
 
 
                     // if (!is_key_press())
                     // if (!is_key_press())
                     // {
                     // {
-                        ESP_LOGW(LOG_TAG, "-> sleep\r\n");
-                        uart_wait_tx_idle_polling(1);                           // 抛出剩余串口1消息
-                        uart_wait_tx_idle_polling(CONFIG_ESP_CONSOLE_UART_NUM); // 抛出剩余串口0消息
-                        vTaskDelay(100/ portTICK_PERIOD_MS);
-                        esp_light_sleep_start();
+                    ESP_LOGW(LOG_TAG, "-> sleep\r\n");
+                    uart_wait_tx_idle_polling(1);                           // 抛出剩余串口1消息
+                    uart_wait_tx_idle_polling(CONFIG_ESP_CONSOLE_UART_NUM); // 抛出剩余串口0消息
+                    vTaskDelay(100 / portTICK_PERIOD_MS);
+                    esp_light_sleep_start();
                     // }
                     // }
                     // else
                     // else
                     // {
                     // {
@@ -404,8 +404,8 @@ static void light_sleep_task(void *args)
                 {
                 {
                     ESP_LOGE(LOG_TAG, "-> 30minite send lora info");
                     ESP_LOGE(LOG_TAG, "-> 30minite send lora info");
                     Machine_info.wait_send_rssi_bat = 0;
                     Machine_info.wait_send_rssi_bat = 0;
-                    f_send_get_chart_data();
-                    f_send_lora_rssi(Machine_info.rssi);
+                    // f_send_get_chart_data();
+                    // f_send_lora_rssi(Machine_info.rssi);
                     f_send_battary_vaule(Machine_info.batt_precent);
                     f_send_battary_vaule(Machine_info.batt_precent);
                     // f_send_get_time();
                     // f_send_get_time();
                 }
                 }
@@ -453,7 +453,7 @@ static void light_sleep_task(void *args)
                             is_first_charge = true;
                             is_first_charge = true;
 
 
                             gpio_hold_dis(PIN_R_CS);
                             gpio_hold_dis(PIN_R_CS);
-                            set_screen_dis_info_and_send_queue(true, false, false, false,100);
+                            set_screen_dis_info_and_send_queue(true, false, false, false, 100);
                             printf("charge in\r\n");
                             printf("charge in\r\n");
                         }
                         }
                     }
                     }
@@ -464,7 +464,7 @@ static void light_sleep_task(void *args)
                             Machine_info.is_charge = false; // 拔掉充电
                             Machine_info.is_charge = false; // 拔掉充电
                             is_first_charge = false;
                             is_first_charge = false;
                             gpio_hold_dis(PIN_R_CS);
                             gpio_hold_dis(PIN_R_CS);
-                            set_screen_dis_info_and_send_queue(true, false, false, false,100);
+                            set_screen_dis_info_and_send_queue(true, false, false, false, 100);
                             // sleep_timer_start(1000);
                             // sleep_timer_start(1000);
 
 
                             // user_compare(last_batt_precent,Machine_info.batt_precent);//刷完左屏,比较一次电量。电量图标不同则刷一次右屏
                             // user_compare(last_batt_precent,Machine_info.batt_precent);//刷完左屏,比较一次电量。电量图标不同则刷一次右屏

+ 164 - 152
main/yc_protocol.c

@@ -103,8 +103,8 @@ void reset_default(bool is_dis, uint8_t power_status)
     }
     }
 
 
     // xQueueReset(screen_queue);
     // xQueueReset(screen_queue);
-    set_screen_dis_info_and_send_queue(false, true, false, false,100);
-    set_screen_dis_info_and_send_queue(true, false, false, false,100);
+    set_screen_dis_info_and_send_queue(false, true, false, false, 100);
+    set_screen_dis_info_and_send_queue(true, false, false, false, 100);
 }
 }
 
 
 /*
 /*
@@ -155,11 +155,10 @@ void print_systenInfo(void)
     printf("\r\n%s\r\n", InfoBuffer);
     printf("\r\n%s\r\n", InfoBuffer);
 #endif
 #endif
 }
 }
-void send_update_status(void);
-void send_status_duration(void);
+void f_send_update_status(void);
+void f_send_status_duration(void);
 
 
-
-void set_screen_dis_info_and_send_queue(bool is_into_sleep, bool is_left, bool is_change_power, bool is_dont_dis,int ms)
+void set_screen_dis_info_and_send_queue(bool is_into_sleep, bool is_left, bool is_change_power, bool is_dont_dis, int ms)
 {
 {
     screen_dis_info.is_into_sleep = is_into_sleep;
     screen_dis_info.is_into_sleep = is_into_sleep;
     screen_dis_info.is_left = is_left;
     screen_dis_info.is_left = is_left;
@@ -175,9 +174,9 @@ void terminal_send_data(void)
 {
 {
     // send_rssi();
     // send_rssi();
     // vTaskDelay(100 / portTICK_PERIOD_MS);
     // vTaskDelay(100 / portTICK_PERIOD_MS);
-    send_status_duration();
+    f_send_status_duration();
     // vTaskDelay(50 / portTICK_PERIOD_MS);
     // vTaskDelay(50 / portTICK_PERIOD_MS);
-    send_update_status();
+    f_send_update_status();
     // vTaskDelay(100 / portTICK_PERIOD_MS);
     // vTaskDelay(100 / portTICK_PERIOD_MS);
 }
 }
 void update_last_button_info(uint8_t btn)
 void update_last_button_info(uint8_t btn)
@@ -226,20 +225,20 @@ void screen_display(void)
      * happened. */
      * happened. */
     if (bits == 3)
     if (bits == 3)
     {
     {
-        // xQueueReset(screen_queue);
-        set_screen_dis_info_and_send_queue(false, true, false, false,100);
-        set_screen_dis_info_and_send_queue(true, false, false, false,100);
+        // xQueueReset(screen_queue);    
+        Machine_info.left_current_Quick_refresh_time = 5; // 刷两个屏最好为慢刷
+        set_screen_dis_info_and_send_queue(false, true, false, false, 100);
+        set_screen_dis_info_and_send_queue(true, false, false, false, 100);
     }
     }
     else if (bits & RIGHT_SCREEN_BIT)
     else if (bits & RIGHT_SCREEN_BIT)
     {
     {
         ESP_LOGE(LOG_TAG, "RIGHT_SCREEN_BIT");
         ESP_LOGE(LOG_TAG, "RIGHT_SCREEN_BIT");
-
-        set_screen_dis_info_and_send_queue(true, false, false, false,100);
+        set_screen_dis_info_and_send_queue(true, false, false, false, 100);
     }
     }
     else if (bits & LEFT_SCREEN_BIT)
     else if (bits & LEFT_SCREEN_BIT)
     {
     {
         ESP_LOGE(LOG_TAG, "LEFT_SCREEN_BIT");
         ESP_LOGE(LOG_TAG, "LEFT_SCREEN_BIT");
-        set_screen_dis_info_and_send_queue(true, true, false, false,100);
+        set_screen_dis_info_and_send_queue(true, true, false, false, 100);
     }
     }
     else
     else
     {
     {
@@ -337,7 +336,7 @@ static int time_synchronization_func(const LORA_DATA_T *buf)
 
 
     getRtcTime(&Machine_info);
     getRtcTime(&Machine_info);
 
 
-    xEventGroupSetBits(screen_event, RIGHT_SCREEN_BIT);
+    // xEventGroupSetBits(screen_event, RIGHT_SCREEN_BIT);
     // printf("msg h = %02X,msg l = %02X\r\n",buf->data_buf[13],buf->data_buf[14]);
     // printf("msg h = %02X,msg l = %02X\r\n",buf->data_buf[13],buf->data_buf[14]);
     int msg_id = (buf->data_buf[13] >> 8) | buf->data_buf[14]; // 获取当前消息id 用于删除
     int msg_id = (buf->data_buf[13] >> 8) | buf->data_buf[14]; // 获取当前消息id 用于删除
     // printf("msg_id =%X\r\n",msg_id);
     // printf("msg_id =%X\r\n",msg_id);
@@ -1344,17 +1343,17 @@ static void hardware_gwpair_func(const LORA_DATA_T *buf)
     Machine_info.rssi = set_lora(Machine_info.lora_new_channel, Machine_info.eflagID);
     Machine_info.rssi = set_lora(Machine_info.lora_new_channel, Machine_info.eflagID);
     f_send_version();
     f_send_version();
     f_send_reply_status(0x01); // 回复在线状态
     f_send_reply_status(0x01); // 回复在线状态
-    send_update_status();
+    f_send_update_status();
     // f_send_lora_rssi(Machine_info.rssi);
     // f_send_lora_rssi(Machine_info.rssi);
-    f_send_lora_rssi(100); // 刚配完直接发100
+    // f_send_lora_rssi(100); // 刚配完直接发100
     f_send_battary_vaule(Machine_info.batt_precent);
     f_send_battary_vaule(Machine_info.batt_precent);
 
 
-#if 1
+#if 0
     f_send_get_chart_data();
     f_send_get_chart_data();
 #endif
 #endif
 
 
 #if USER_LIGHT_SLEEP_ENABLE || USER_DEEP_SLEEP_ENABLE
 #if USER_LIGHT_SLEEP_ENABLE || USER_DEEP_SLEEP_ENABLE
-    set_screen_dis_info_and_send_queue(false, true, false, true,100);
+    set_screen_dis_info_and_send_queue(false, true, false, true, 100);
 #endif
 #endif
 
 
     // printf("start timer id = %d,%d\r\n",Machine_info.eflagID,Machine_info.eflagID * TIMER_CAN_SEND_TIME);
     // printf("start timer id = %d,%d\r\n",Machine_info.eflagID,Machine_info.eflagID * TIMER_CAN_SEND_TIME);
@@ -1467,13 +1466,22 @@ static void hardware_ack_delete_msg_id(const LORA_DATA_T *buf)
 
 
     // int current =  countNodes(Send_list);   //获取当前节点数据
     // int current =  countNodes(Send_list);   //获取当前节点数据
     Node *find = findNode(Send_list, msg_id);
     Node *find = findNode(Send_list, msg_id);
-    printf("delete list node bofore = %d\r\n", msg_id);
 
 
     if (find != NULL)
     if (find != NULL)
     {
     {
         // printf("delete list node bofore = %d\r\n",msg_id);
         // printf("delete list node bofore = %d\r\n",msg_id);
         // printList(Send_list);
         // printList(Send_list);
-        Send_list = deleteNode(Send_list, msg_id);
+
+        for(int i=0;i< LORA_INFO_END;i++)
+        {
+            if(lora_pool[i].num == msg_id)
+            {
+                lora_pool[LORA_INFO_VERSION].flag = false;
+                Send_list = deleteNode(Send_list, msg_id);
+                ESP_LOGE(LOG_TAG,"delete msg_id %d",msg_id);
+            }
+        }
+        
         // printf("delete list node msg_id = %d\r\n",msg_id);
         // printf("delete list node msg_id = %d\r\n",msg_id);
 
 
         // printf("delete list node after = %d\r\n",msg_id);
         // printf("delete list node after = %d\r\n",msg_id);
@@ -1484,19 +1492,19 @@ static void hardware_ack_delete_msg_id(const LORA_DATA_T *buf)
         ESP_LOGE(LOG_TAG, "delete fail");
         ESP_LOGE(LOG_TAG, "delete fail");
     }
     }
 
 
-    display_flag = 0;
+    // display_flag = 0;
 }
 }
 
 
 void business_logic_func(const LORA_DATA_T *buf, uint8_t cmd_index, int msg)
 void business_logic_func(const LORA_DATA_T *buf, uint8_t cmd_index, int msg)
 {
 {
-    int cmd = 0;    // 当前的命令
+    // int cmd = 0;    // 当前的命令
     int msg_id = 0; // 消息的id
     int msg_id = 0; // 消息的id
 // bool is_rsp_ack = false;
 // bool is_rsp_ack = false;
 #if 0
 #if 0
     printf("cmd = %02X\r\n",buf->data_buf[cmd_index]);
     printf("cmd = %02X\r\n",buf->data_buf[cmd_index]);
 #endif
 #endif
 
 
-    cmd = buf->data_buf[cmd_index];
+    // cmd = buf->data_buf[cmd_index];
 
 
     switch (buf->data_buf[cmd_index])
     switch (buf->data_buf[cmd_index])
     {
     {
@@ -1615,8 +1623,8 @@ void business_logic_func(const LORA_DATA_T *buf, uint8_t cmd_index, int msg)
         // 重置快刷
         // 重置快刷
         Machine_info.left_current_Quick_refresh_time = 0;
         Machine_info.left_current_Quick_refresh_time = 0;
         Machine_info.right_current_Quick_refresh_time = 0;
         Machine_info.right_current_Quick_refresh_time = 0;
-        set_screen_dis_info_and_send_queue(false, true, false, false,100);
-        set_screen_dis_info_and_send_queue(false, false, false, false,100);
+        set_screen_dis_info_and_send_queue(false, true, false, false, 100);
+        set_screen_dis_info_and_send_queue(false, false, false, false, 100);
         break;
         break;
 
 
     case PROTOCOL_HARDWARE_UNGWPAIRED: // 取消配网
     case PROTOCOL_HARDWARE_UNGWPAIRED: // 取消配网
@@ -1626,7 +1634,7 @@ void business_logic_func(const LORA_DATA_T *buf, uint8_t cmd_index, int msg)
 
 
     case PROTOCOL_RSPONSIBLE_ACK:
     case PROTOCOL_RSPONSIBLE_ACK:
 
 
-        printf("receive gateway ack delete data in list\r\n");
+        // printf("receive gateway ack delete data in list\r\n");
         hardware_ack_delete_msg_id(buf);
         hardware_ack_delete_msg_id(buf);
 
 
         break;
         break;
@@ -2158,68 +2166,68 @@ bool subcontract(YC_DATA_T *data)
     return refresh_flag;
     return refresh_flag;
 }
 }
 
 
-// len:有效数据长度,不是总长//
-static void protocol_package(char cmd, const uint8_t *info, int len)
-{
-#define __PACKAGE 15
-    uint8_t *__str = (uint8_t *)malloc(sizeof(uint8_t) * (__PACKAGE + len) * 2);
-
-    __str[0] = 0x5a;
-    __str[1] = 0x51;
-
-    __str[2] = 0x00;
-
-    __str[3] = mac_addr[0];
-    __str[4] = mac_addr[1];
-    __str[5] = mac_addr[2];
-    __str[6] = mac_addr[3];
-    __str[7] = mac_addr[4];
-    __str[8] = mac_addr[5];
-
-    __str[9] = Machine_info.eflagID;
-
-    __str[10] = cmd;
-#if 0
-    __str[11] = 0x01;//当前只为一包
-    __str[12] = 0x01;//当前只为一包
-#else
-
-    // 随机数
-    srand((unsigned int)time(NULL));
-    int time_rand = rand() % 65535 + 1; // 生成1~100的随机数
-    __str[11] = (time_rand >> 8) & 0xFF;
-    __str[12] = time_rand & 0xFF;
-#endif
-    // 分包
-    __str[13] = (len >> 8) & 0xFF;
-    __str[14] = len & 0xFF;
-
-    memcpy(__str + __PACKAGE, info, len);
-    int i = 0, sum = 0;
-    for (i = 0; i < len + __PACKAGE; i++)
-    {
-        sum += __str[i];
-    }
-    __str[2] = sum & 0xFF;
+// // len:有效数据长度,不是总长//
+// static void protocol_package(char cmd, const uint8_t *info, int len)
+// {
+// #define __PACKAGE 15
+//     uint8_t *__str = (uint8_t *)malloc(sizeof(uint8_t) * (__PACKAGE + len) * 2);
+
+//     __str[0] = 0x5a;
+//     __str[1] = 0x51;
+
+//     __str[2] = 0x00;
+
+//     __str[3] = mac_addr[0];
+//     __str[4] = mac_addr[1];
+//     __str[5] = mac_addr[2];
+//     __str[6] = mac_addr[3];
+//     __str[7] = mac_addr[4];
+//     __str[8] = mac_addr[5];
+
+//     __str[9] = Machine_info.eflagID;
+
+//     __str[10] = cmd;
+// #if 0
+//     __str[11] = 0x01;//当前只为一包
+//     __str[12] = 0x01;//当前只为一包
+// #else
+
+//     // 随机数
+//     srand((unsigned int)time(NULL));
+//     int time_rand = rand() % 65535 + 1; // 生成1~100的随机数
+//     __str[11] = (time_rand >> 8) & 0xFF;
+//     __str[12] = time_rand & 0xFF;
+// #endif
+//     // 分包
+//     __str[13] = (len >> 8) & 0xFF;
+//     __str[14] = len & 0xFF;
+
+//     memcpy(__str + __PACKAGE, info, len);
+//     int i = 0, sum = 0;
+//     for (i = 0; i < len + __PACKAGE; i++)
+//     {
+//         sum += __str[i];
+//     }
+//     __str[2] = sum & 0xFF;
 
 
-    printf("crc=%02x ", __str[2]);
+//     printf("crc=%02x ", __str[2]);
 
 
-    printf("-->package:");
-    for (i = 0; i < len + __PACKAGE; i++)
-    {
-        printf("%02x ", __str[i]);
-    }
-    printf("\n");
+//     printf("-->package:");
+//     for (i = 0; i < len + __PACKAGE; i++)
+//     {
+//         printf("%02x ", __str[i]);
+//     }
+//     printf("\n");
 
 
-    changebintotxt(__str, len + __PACKAGE);
+//     changebintotxt(__str, len + __PACKAGE);
 
 
-#if 0
-    Send_list = postInsert(Send_list, time_rand,cmd,(char *)__str,(int)(len+__PACKAGE)*2);//len*2
-#else
-    lora_send_data((char *)__str, len + __PACKAGE);
-#endif
-    free(__str);
-}
+// #if 0
+//     Send_list = postInsert(Send_list, time_rand,cmd,(char *)__str,(int)(len+__PACKAGE)*2);//len*2
+// #else
+//     lora_send_data((char *)__str, len + __PACKAGE);
+// #endif
+//     free(__str);
+// }
 
 
 int txttobin(uint8_t *strlorabuf)
 int txttobin(uint8_t *strlorabuf)
 {
 {
@@ -2300,6 +2308,10 @@ void changebintotxt(uint8_t *strb, int len)
 ******************************/
 ******************************/
 void f_send_get_time(void)
 void f_send_get_time(void)
 {
 {
+    if (lora_pool[LORA_INFO_GET_TIME].flag == true)
+    {
+        return;
+    }
     uint8_t strlorabuf[200];
     uint8_t strlorabuf[200];
     uint8_t strnum[20];
     uint8_t strnum[20];
 
 
@@ -2338,10 +2350,16 @@ void f_send_get_time(void)
     len = strlen((char *)strlorabuf);
     len = strlen((char *)strlorabuf);
 
 
     // lora_send_data((char *)strlorabuf,len);
     // lora_send_data((char *)strlorabuf,len);
-    Send_list = postInsert(Send_list, Machine_info.msg_id, Machine_info.msg_id, (char *)strlorabuf, len); // 插入数据
+    lora_pool[LORA_INFO_GET_TIME].num = Machine_info.msg_id;
+    lora_pool[LORA_INFO_GET_TIME].flag = true;
+    Send_list = postInsert(Send_list, Machine_info.msg_id, LORA_INFO_GET_TIME, (char *)strlorabuf, len); // 插入数据
 }
 }
 void f_send_get_chart_data(void)
 void f_send_get_chart_data(void)
 {
 {
+        if (lora_pool[LORA_INFO_GET_CHART].flag == true)
+    {
+        return;
+    }
     ESP_LOGW(LOG_TAG, "f_send_get_chart_data");
     ESP_LOGW(LOG_TAG, "f_send_get_chart_data");
     uint8_t strlorabuf[200];
     uint8_t strlorabuf[200];
 
 
@@ -2379,11 +2397,16 @@ void f_send_get_chart_data(void)
     len = strlen((char *)strlorabuf);
     len = strlen((char *)strlorabuf);
 
 
     // lora_send_data((char *)strlorabuf,len);
     // lora_send_data((char *)strlorabuf,len);
-    Send_list = postInsert(Send_list, Machine_info.msg_id, Machine_info.msg_id, (char *)strlorabuf, len); // 插入数据
+    lora_pool[LORA_INFO_GET_CHART].num = Machine_info.msg_id;
+    lora_pool[LORA_INFO_GET_CHART].flag = true;
+    Send_list = postInsert(Send_list, Machine_info.msg_id, LORA_INFO_GET_CHART, (char *)strlorabuf, len); // 插入数据
 }
 }
 void f_send_version(void)
 void f_send_version(void)
 {
 {
-
+    if (lora_pool[LORA_INFO_VERSION].flag == true)
+    {
+        return;
+    }
     ESP_LOGW(LOG_TAG, "f_send_version");
     ESP_LOGW(LOG_TAG, "f_send_version");
     uint8_t strlorabuf[200];
     uint8_t strlorabuf[200];
 
 
@@ -2423,11 +2446,16 @@ void f_send_version(void)
     strcat((char *)strlorabuf, (char *)Machine_info.cid);
     strcat((char *)strlorabuf, (char *)Machine_info.cid);
     len = strlen((char *)strlorabuf);
     len = strlen((char *)strlorabuf);
 
 
-    Send_list = postInsert(Send_list, Machine_info.msg_id, Machine_info.msg_id, (char *)strlorabuf, len); // 插入数据
+    lora_pool[LORA_INFO_VERSION].num = Machine_info.msg_id;
+    lora_pool[LORA_INFO_VERSION].flag = true;
+    Send_list = postInsert(Send_list, Machine_info.msg_id, LORA_INFO_VERSION, (char *)strlorabuf, len); // 插入数据
 }
 }
 void f_send_lora_rssi(int rssi)
 void f_send_lora_rssi(int rssi)
 {
 {
-
+    if (lora_pool[LORA_INFO_RSSI].flag == true)
+    {
+        return;
+    }
     // ESP_LOGW(LOG_TAG,"f_send_lora_rssi:rssi = %d",rssi);
     // ESP_LOGW(LOG_TAG,"f_send_lora_rssi:rssi = %d",rssi);
     uint8_t strlorabuf[200];
     uint8_t strlorabuf[200];
 
 
@@ -2465,12 +2493,17 @@ void f_send_lora_rssi(int rssi)
     strcat((char *)strlorabuf, (char *)Machine_info.cid);
     strcat((char *)strlorabuf, (char *)Machine_info.cid);
     len = strlen((char *)strlorabuf);
     len = strlen((char *)strlorabuf);
 
 
-    Send_list = postInsert(Send_list, Machine_info.msg_id, Machine_info.msg_id, (char *)strlorabuf, len); // 插入数据
+    lora_pool[LORA_INFO_RSSI].num = Machine_info.msg_id;
+    lora_pool[LORA_INFO_RSSI].flag = true;
+    Send_list = postInsert(Send_list, Machine_info.msg_id, LORA_INFO_RSSI, (char *)strlorabuf, len); // 插入数据
 }
 }
 
 
 void f_send_battary_vaule(int battry)
 void f_send_battary_vaule(int battry)
 {
 {
-
+    if (lora_pool[LORA_INFO_BATT].flag == true)
+    {
+        return;
+    }
     uint8_t strlorabuf[200];
     uint8_t strlorabuf[200];
 
 
     int crc16 = 0, i = 0, len = 0;
     int crc16 = 0, i = 0, len = 0;
@@ -2507,12 +2540,18 @@ void f_send_battary_vaule(int battry)
     strcat((char *)strlorabuf, (char *)Machine_info.cid);
     strcat((char *)strlorabuf, (char *)Machine_info.cid);
     len = strlen((char *)strlorabuf);
     len = strlen((char *)strlorabuf);
 
 
-    Send_list = postInsert(Send_list, Machine_info.msg_id, Machine_info.msg_id, (char *)strlorabuf, len); // 插入数据
+    lora_pool[LORA_INFO_BATT].num = Machine_info.msg_id;
+    lora_pool[LORA_INFO_BATT].flag = true;
+    Send_list = postInsert(Send_list, Machine_info.msg_id, LORA_INFO_BATT, (char *)strlorabuf, len); // 插入数据
+
 }
 }
 
 
 void f_send_reply_status(int status)
 void f_send_reply_status(int status)
 {
 {
-
+    if (lora_pool[LORA_INFO_BATT].flag == true)
+    {
+        return;
+    }
     uint8_t strlorabuf[200];
     uint8_t strlorabuf[200];
 
 
     int crc16 = 0, i = 0, len = 0;
     int crc16 = 0, i = 0, len = 0;
@@ -2549,7 +2588,9 @@ void f_send_reply_status(int status)
     strcat((char *)strlorabuf, (char *)Machine_info.cid);
     strcat((char *)strlorabuf, (char *)Machine_info.cid);
     len = strlen((char *)strlorabuf);
     len = strlen((char *)strlorabuf);
 
 
-    Send_list = postInsert(Send_list, Machine_info.msg_id, Machine_info.msg_id, (char *)strlorabuf, len); // 插入数据
+    lora_pool[LORA_INFO_REPLY].num = Machine_info.msg_id;
+    lora_pool[LORA_INFO_REPLY].flag = true;
+    Send_list = postInsert(Send_list, Machine_info.msg_id, LORA_INFO_REPLY, (char *)strlorabuf, len); // 插入数据
 }
 }
 
 
 // 唤醒时发送是否可以接收数据命令
 // 唤醒时发送是否可以接收数据命令
@@ -2618,16 +2659,6 @@ void send_can_I_receive()
 //       lora_send_data((char *)strlorabuf,7);
 //       lora_send_data((char *)strlorabuf,7);
 //  }
 //  }
 
 
-void send_rssi(void)
-{
-    char rssi = Machine_info.rssi;
-#if 0
-    protocol_package(0x05,&rssi,1);
-#else
-
-    f_send_lora_rssi(rssi);
-#endif
-}
 // 4bytes、32bit数据大小端转化
 // 4bytes、32bit数据大小端转化
 #define L2B32(Little) (Little = ((Little & 0xff) << 24) | (((Little) & 0xff00) << 8) | (((Little) & 0xff0000) >> 8) | ((Little >> 24) & 0xff))
 #define L2B32(Little) (Little = ((Little & 0xff) << 24) | (((Little) & 0xff00) << 8) | (((Little) & 0xff0000) >> 8) | ((Little >> 24) & 0xff))
 
 
@@ -2693,34 +2724,12 @@ uint8_t change_btn(uint8_t btn)
     return btn_tmp;
     return btn_tmp;
 }
 }
 /*发送状态持续的时间  状态持续时长(0x0E)*/
 /*发送状态持续的时间  状态持续时长(0x0E)*/
-void send_status_duration(void)
+void f_send_status_duration(void)
 {
 {
-#if 0
-    uint8_t* dur = (uint8_t*)malloc(sizeof(uint8_t)*(12));
-
-    memcpy(dur,&last_button_info.button_info,1);
-    memcpy(dur+1,&last_button_info.Year,2);
-    memcpy(dur+3,&last_button_info.Month,1);
-    memcpy(dur+4,&last_button_info.Day,1);
-    memcpy(dur+5,&last_button_info.Hour,1);
-    memcpy(dur+6,&last_button_info.Minute,1);
-    memcpy(dur+7,&last_button_info.Second,1);
-
-    uint32_t tmp = last_button_info.time_min;
-    L2B32(tmp);
-    memcpy(dur+8,&tmp,4);
-
-    ESP_LOGW(LOG_TAG,"log  -->btn = %d [%d-%d-%d]%d:%d:%d   <%04ld>",\
-                    last_button_info.button_info, last_button_info.Year,\
-                    last_button_info.Month,last_button_info.Day,\
-                    last_button_info.Hour, last_button_info.Minute,\
-                    last_button_info.Second,last_button_info.time_min);
-
-    protocol_package(0x0E,dur,12);
-    last_button_info.time_min = 0;
-    free(dur);
-#else
-
+    if (lora_pool[LORA_INFO_DUR].flag == true)
+    {
+        return;
+    }
     uint8_t strlorabuf[200];
     uint8_t strlorabuf[200];
 
 
     int crc16 = 0, i = 0, len = 0;
     int crc16 = 0, i = 0, len = 0;
@@ -2793,27 +2802,28 @@ void send_status_duration(void)
     len = strlen((char *)strlorabuf);
     len = strlen((char *)strlorabuf);
 
 
 #if 0
 #if 0
-  lora_send_data((char *)strlorabuf,len);
+  lora_send_data((char *)strlorabuf,len);/直接发送
 
 
 #else
 #else
-
     // printList(Send_list);
     // printList(Send_list);
-
-    Send_list = postInsert(Send_list, Machine_info.msg_id, Machine_info.msg_id, (char *)strlorabuf, len); // 插入数据
+    lora_pool[LORA_INFO_DUR].flag =true;
+    lora_pool[LORA_INFO_DUR].num = Machine_info.msg_id;
+    Send_list = postInsert(Send_list, Machine_info.msg_id , LORA_INFO_DUR, (char *)strlorabuf, len); // 插入数据
 
 
 #endif
 #endif
 
 
     // lora_send_data((char *)strlorabuf,len);
     // lora_send_data((char *)strlorabuf,len);
 
 
     last_button_info.time_min = 0;
     last_button_info.time_min = 0;
-
-#endif
 }
 }
 
 
 /*当前最新的状态*/
 /*当前最新的状态*/
-void send_update_status(void)
+void f_send_update_status(void)
 {
 {
-
+    if (lora_pool[LORA_INFO_STATUS].flag == true)
+    {
+        return;
+    }
 #if 0
 #if 0
     uint8_t* update = (uint8_t*)malloc(sizeof(uint8_t)*(12));
     uint8_t* update = (uint8_t*)malloc(sizeof(uint8_t)*(12));
     memset(&new_button_info,0,sizeof(Button_Time_t));
     memset(&new_button_info,0,sizeof(Button_Time_t));
@@ -2927,7 +2937,9 @@ void send_update_status(void)
 #if 0
 #if 0
     lora_send_data((char *)strlorabuf,len);
     lora_send_data((char *)strlorabuf,len);
 #else
 #else
-    Send_list = postInsert(Send_list, Machine_info.msg_id, Machine_info.msg_id, (char *)strlorabuf, len); // 插入数据
+    lora_pool[LORA_INFO_STATUS].num = Machine_info.msg_id;
+    lora_pool[LORA_INFO_STATUS].flag = true;
+    Send_list = postInsert(Send_list, Machine_info.msg_id, LORA_INFO_STATUS, (char *)strlorabuf, len); // 插入数据
 
 
 #endif
 #endif
 
 
@@ -2936,15 +2948,15 @@ void send_update_status(void)
 #endif
 #endif
 }
 }
 
 
-void send_ACK(char cmd, bool flag)
-{
-    uint8_t ack = 0;
-    if (flag)
-        ack = 0x01;
-    else
-        ack = 0x00;
-    protocol_package(cmd, &ack, 1);
-}
+// void send_ACK(char cmd, bool flag)
+// {
+//     uint8_t ack = 0;
+//     if (flag)
+//         ack = 0x01;
+//     else
+//         ack = 0x00;
+//     protocol_package(cmd, &ack, 1);
+// }
 
 
 void adc1_init(void)
 void adc1_init(void)
 {
 {
@@ -3551,7 +3563,7 @@ void lora_rev_cmd_send_ack()
 }
 }
 void right_screen_send()
 void right_screen_send()
 {
 {
-    set_screen_dis_info_and_send_queue(true, false, false, false,100);
+    set_screen_dis_info_and_send_queue(true, false, false, false, 100);
 }
 }
 void user_compare(int last, int now) // 这个函数用来比较rssi和 电量变化 刷右屏//
 void user_compare(int last, int now) // 这个函数用来比较rssi和 电量变化 刷右屏//
 {
 {
@@ -3655,6 +3667,6 @@ void user_compare_power_off(int last, int now) // 这个函数用来比较关机
     if (is_dis)
     if (is_dis)
     {
     {
 
 
-        set_screen_dis_info_and_send_queue(true, false, false, false,100);
+        set_screen_dis_info_and_send_queue(true, false, false, false, 100);
     }
     }
 }
 }

+ 4 - 4
main/yc_protocol.h

@@ -285,9 +285,8 @@ void uincode2gbk(char *str, uint16_t len, char *out_buffer);
 void qrcode_protocol_create(char *result, Machine_info_t info);
 void qrcode_protocol_create(char *result, Machine_info_t info);
 bool subcontract(YC_DATA_T *data);
 bool subcontract(YC_DATA_T *data);
 
 
-void send_rssi(void);
-void send_status(void);
-void send_ACK(char cmd, bool flag);
+// void send_status(void);
+// void send_ACK(char cmd, bool flag);
 
 
 void loro_gwpair_ack(int destaddr, int sourceaddr, int cmd, int st, char *strd);
 void loro_gwpair_ack(int destaddr, int sourceaddr, int cmd, int st, char *strd);
 
 
@@ -308,6 +307,7 @@ void f_send_get_chart_data(void);
 void f_send_lora_rssi(int rssi);
 void f_send_lora_rssi(int rssi);
 void f_send_battary_vaule(int battry);
 void f_send_battary_vaule(int battry);
 void f_send_reply_status(int status);
 void f_send_reply_status(int status);
+void f_send_get_time(void);
 
 
 void set_status_heights(void);
 void set_status_heights(void);
 void user_compare(int last, int now);
 void user_compare(int last, int now);
@@ -315,7 +315,7 @@ void user_compare(int last, int now);
 void user_compare_power_off(int last, int now); // 这个函数用来比较关机状态时电量变化 刷右屏//
 void user_compare_power_off(int last, int now); // 这个函数用来比较关机状态时电量变化 刷右屏//
 
 
 void right_screen_send();
 void right_screen_send();
-void f_send_get_time(void);
+
 void set_screen_dis_info_and_send_queue(bool is_into_sleep,bool is_left,bool is_change_power,bool is_dont_dis,int ms);
 void set_screen_dis_info_and_send_queue(bool is_into_sleep,bool is_left,bool is_change_power,bool is_dont_dis,int ms);
 // /* 链表节点结构体 */
 // /* 链表节点结构体 */
 // struct ListNode {
 // struct ListNode {

+ 23 - 40
main/yc_terminal.c

@@ -395,7 +395,7 @@ if(tmp_paint_buf!=NULL)
         adc1_init();
         adc1_init();
         // extern void dis_right_instructions();
         // extern void dis_right_instructions();
         // dis_right_instructions();
         // dis_right_instructions();
-        set_screen_dis_info_and_send_queue(true, false, false, false,100);
+        set_screen_dis_info_and_send_queue(true, false, false, false, 100);
         int power_key = 0;
         int power_key = 0;
         int charge_key = 0;
         int charge_key = 0;
 
 
@@ -442,7 +442,7 @@ if(tmp_paint_buf!=NULL)
                 // extern void dis_right_instructions();
                 // extern void dis_right_instructions();
                 // dis_right_instructions();
                 // dis_right_instructions();
 
 
-                set_screen_dis_info_and_send_queue(true, false, false, false,100);
+                set_screen_dis_info_and_send_queue(true, false, false, false, 100);
 
 
                 printf("start power off\r\n");
                 printf("start power off\r\n");
                 uart_wait_tx_idle_polling(CONFIG_ESP_CONSOLE_UART_NUM);
                 uart_wait_tx_idle_polling(CONFIG_ESP_CONSOLE_UART_NUM);
@@ -724,7 +724,7 @@ if(tmp_paint_buf!=NULL)
                 beep_blink(30, 1);
                 beep_blink(30, 1);
 
 
 #if 1
 #if 1
-                set_screen_dis_info_and_send_queue(true, true, false, false,100);
+                set_screen_dis_info_and_send_queue(true, true, false, false, 100);
 #endif
 #endif
 
 
                 while (1)
                 while (1)
@@ -851,13 +851,13 @@ static void screen_task(void *arg)
     Screen_dis_t screen_rev_info;
     Screen_dis_t screen_rev_info;
     screen_rev_info.is_left = false;
     screen_rev_info.is_left = false;
     screen_rev_info.is_into_sleep = true;
     screen_rev_info.is_into_sleep = true;
-    Machine_info.left_current_Quick_refresh_time = 1; // 开机慢刷
+
     while (1)
     while (1)
     {
     {
         if (xQueueReceive(screen_queue, &screen_rev_info, (TickType_t)portMAX_DELAY))
         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",
             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");
+                     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)
             if (screen_rev_info.is_dont_dis)
             {
             {
                 ESP_LOGE(LOG_TAG, "goto -> dont_dis");
                 ESP_LOGE(LOG_TAG, "goto -> dont_dis");
@@ -892,38 +892,22 @@ static void screen_task(void *arg)
                 }
                 }
             }
             }
         dont_dis:
         dont_dis:
+            // ESP_LOGE(LOG_TAG, "%d %d %d", Machine_info.power_status, Machine_info.paired, screen_rev_info.is_into_sleep);
             if ((Machine_info.power_status == 1) && (Machine_info.paired == 1) && screen_rev_info.is_into_sleep)
             if ((Machine_info.power_status == 1) && (Machine_info.paired == 1) && screen_rev_info.is_into_sleep)
             {
             {
-                // ESP_LOGD(LOG_TAG, "100ms sleep  %s", screen_rev_info.is_left ? "left" : "right");
+                ESP_LOGD(LOG_TAG, "100ms sleep  %s", screen_rev_info.is_left ? "left" : "right");
                 if (screen_rev_info.is_change_power)
                 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");
+                    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; // 关机
                     Machine_info.power_status = 0; // 关机
                 }
                 }
                 sleep_timer_start(screen_rev_info.sleep_ms); // 进入睡眠
                 sleep_timer_start(screen_rev_info.sleep_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           //电源按键
-            // //                 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));
-
-            // //                 esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
-            // //                 ESP_ERROR_CHECK( esp_sleep_enable_ulp_wakeup());
-            // // #endif
-            // //                 esp_deep_sleep_start();
-            //             }
+            if (Machine_info.power_status == 0) // 展示说明书都是先左后右,等右屏刷完再休眠
+            {
+                sleep_timer_start(1000); // 进入睡眠
+            }
         }
         }
     }
     }
 }
 }
@@ -964,7 +948,7 @@ static void button_task(void *arg)
                     button_info = STATE_OPERATION; // 按键关闭,默认运行
                     button_info = STATE_OPERATION; // 按键关闭,默认运行
                     if ((Machine_info.power_status == 1) && (Machine_info.paired == 1))
                     if ((Machine_info.power_status == 1) && (Machine_info.paired == 1))
                     {
                     {
-                        set_screen_dis_info_and_send_queue(false, false, false, true,100);
+                        set_screen_dis_info_and_send_queue(false, false, false, true, 100);
                         // sleep_timer_start(100); // 进入睡眠
                         // sleep_timer_start(100); // 进入睡眠
                     }
                     }
                 }
                 }
@@ -1034,7 +1018,7 @@ static void button_task(void *arg)
                     // 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;
 #if 1
 #if 1
-                    set_screen_dis_info_and_send_queue(true, true, false, false,100);
+                    set_screen_dis_info_and_send_queue(true, true, false, false, 100);
 #endif
 #endif
 
 
                     beep_blink(30, 1);
                     beep_blink(30, 1);
@@ -1046,7 +1030,7 @@ static void button_task(void *arg)
                 {
                 {
                     printf("repeat ,goto sleep !\r\n");
                     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);
+                    set_screen_dis_info_and_send_queue(false, false, false, true, 1000);
                 }
                 }
             }
             }
             else // 右屏幕按键触发
             else // 右屏幕按键触发
@@ -1061,8 +1045,7 @@ static void button_task(void *arg)
                     {
                     {
                         // 判断当前开机 是否配对 继续执行时间片操作
                         // 判断当前开机 是否配对 继续执行时间片操作
                         // sleep_timer_start(100); // 开始进入倒计时休眠
                         // sleep_timer_start(100); // 开始进入倒计时休眠
-                        set_screen_dis_info_and_send_queue(false, false, false, true,1000);
-                        
+                        set_screen_dis_info_and_send_queue(false, false, false, true, 1000);
                     }
                     }
                 }
                 }
 
 
@@ -1074,7 +1057,7 @@ static void button_task(void *arg)
                 if (button_info == POWER_ON_INTO_STATUS_CHANGE_VALUE) // power 长按触发
                 if (button_info == POWER_ON_INTO_STATUS_CHANGE_VALUE) // power 长按触发
                 {
                 {
                     extern bool is_sleep;
                     extern bool is_sleep;
-                    is_sleep = false;//强制不休眠
+                    is_sleep = false; // 强制不休眠
                     beep_blink(1000, 1);
                     beep_blink(1000, 1);
 
 
                     if (Machine_info.power_status == 1) // 开机状态
                     if (Machine_info.power_status == 1) // 开机状态
@@ -1082,8 +1065,8 @@ static void button_task(void *arg)
                         // Machine_info.power_status = 0;
                         // Machine_info.power_status = 0;
                         // screen_dis_info.is_change_power = true;
                         // screen_dis_info.is_change_power = true;
                         xQueueReset(screen_queue);
                         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);//关机
+                        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");
                         printf("poweron->poweroff\r\n");
                     }
                     }
                     else if (Machine_info.power_status == 0)
                     else if (Machine_info.power_status == 0)
@@ -1101,8 +1084,8 @@ static void button_task(void *arg)
 
 
                         // 恢复串口i功能
                         // 恢复串口i功能
                         uart_sleep_out_config();
                         uart_sleep_out_config();
-                        set_screen_dis_info_and_send_queue(false, true, false, false,100);
-                        set_screen_dis_info_and_send_queue(true, false, false, false,100);
+                        set_screen_dis_info_and_send_queue(false, true, false, false, 100);
+                        set_screen_dis_info_and_send_queue(true, false, false, false, 100);
                     }
                     }
                 }
                 }
 
 
@@ -1110,8 +1093,8 @@ static void button_task(void *arg)
                 {
                 {
                     xQueueReset(screen_queue);
                     xQueueReset(screen_queue);
                     Machine_info.left_current_Quick_refresh_time = 5;
                     Machine_info.left_current_Quick_refresh_time = 5;
-                    set_screen_dis_info_and_send_queue(false, true, false, false,100);
-                    set_screen_dis_info_and_send_queue(true, false, false, false,100);
+                    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模式
                 if (button_info == POWER_ON_INTO_OTA_VALUE) // 进入OTA模式