Prechádzať zdrojové kódy

修改关机不刷屏问题

wanghechen 8 mesiacov pred
rodič
commit
5b39348ce4

+ 1 - 1
.gitignore

@@ -3,7 +3,7 @@ build
 managed_components
 sdkconfig.old
 python_Tool
-.vscode
+# .vscode
 README.en.md
 # Prerequisites
 *.d

+ 21 - 0
.vscode/c_cpp_properties.json

@@ -0,0 +1,21 @@
+{
+    "configurations": [
+        {
+            "name": "Win32",
+            "includePath": [
+                "${workspaceFolder}/**",
+                "D:/espidf/Espressif/frameworks/esp-idf-v5.0.2/**"
+            ],
+            "defines": [
+                "_DEBUG",
+                "UNICODE",
+                "_UNICODE"
+            ],
+            "compilerPath": "C:\\mingw64\\bin\\gcc.exe",
+            "cStandard": "c17",
+            "cppStandard": "gnu++14",
+            "intelliSenseMode": "windows-gcc-x64"
+        }
+    ],
+    "version": 4
+}

+ 40 - 0
.vscode/settings.json

@@ -0,0 +1,40 @@
+{
+    "files.associations": {
+        "spiffs.h": "c",
+        "inttypes.h": "c",
+        "esp_sleep.h": "c",
+        "timers.h": "c",
+        "esp_timer.h": "c",
+        "user_time.h": "c",
+        "functional": "c",
+        "complex": "c",
+        "random": "c",
+        "array": "c",
+        "string": "c",
+        "string_view": "c",
+        "chrono": "c",
+        "limits": "c",
+        "user_config.h": "c",
+        "yc_protocol.h": "c",
+        "user_sleep.h": "c",
+        "istream": "c",
+        "ostream": "c",
+        "ratio": "c",
+        "tuple": "c",
+        "type_traits": "c",
+        "utility": "c",
+        "bitset": "c",
+        "algorithm": "c",
+        "unistd.h": "c",
+        "time.h": "c",
+        "_timeval.h": "c",
+        "esp_attr.h": "c",
+        "stdbool.h": "c",
+        "y_ringbuf.h": "c",
+        "assert.h": "c",
+        "esp_compiler.h": "c",
+        "*.tcc": "c",
+        "unordered_map": "c",
+        "iot_button.h": "c"
+    }
+}

+ 2 - 2
components/EPD/EPD.c

@@ -1169,7 +1169,7 @@ IRAM_ATTR bool epd_cache_quick(screen_t screen, const unsigned char *old, const
     bool ret = false;
     if ((screen == SCREEN_LEFT) && (old != NULL))
     {
-        printf("SCREEN_LEFT quick\r\n");
+        // printf("SCREEN_LEFT quick\r\n");
         // Reset the display
         gpio_set_level(PIN_L_RST, 0);
         vTaskDelay(10 / portTICK_PERIOD_MS);
@@ -1190,7 +1190,7 @@ IRAM_ATTR bool epd_cache_quick(screen_t screen, const unsigned char *old, const
 
     if ((screen == SCREEN_RIGHT) && (old != NULL))
     {
-        printf("SCREEN_RIGHT quick\r\n");
+        // printf("SCREEN_RIGHT quick\r\n");
         gpio_set_level(PIN_R_RST, 0);
         vTaskDelay(10 / portTICK_PERIOD_MS);
         gpio_set_level(PIN_R_RST, 1);

+ 5 - 120
components/LORA/LORA.c

@@ -31,7 +31,7 @@ SemaphoreHandle_t debug_Mutex;
 
 extern struct RINGBUF_st;
 RINGBUF_st *lora_ringbuf;
-uint8_t rssi;
+
 uart_status_t lora_uart_status = uart_idle;
 // 声明一个TimerHandle_t类型的变量,用于存储定时器句柄
 TimerHandle_t lora_uart_Timerout;
@@ -40,11 +40,10 @@ bool is_change_chanel = false;
 
 static const char *LOG_TAG = "LORA";
 
-// static char lora_rx_buf[32] = {};
 
 uint8_t rawData_16[1024];
 extern QueueHandle_t lora_data_queue;
-uint8_t rec_rssi;
+// uint8_t rec_rssi;
 static const int LORA_BUF_SIZE = 1024;
 
 static bool half_packet_flag = false;
@@ -53,14 +52,12 @@ static QueueHandle_t lora_queue;
 
 LORA_CFG_T lora_cfg_data;
 
-uint8_t lora_rssi_data = 0;
+// uint8_t lora_rssi_data = 0;
 uint8_t lora_software_version = 0;
 
 bool is_uart_wake = false;
 
-// static int lora_analytic_data(const uint8_t* data_buf,int len);
-static int lora_set_receive(const uint8_t *data, size_t len);
-static int send_lora_queue(const uint8_t *data_buf, int len);
+
 static esp_err_t uart_wakeup_config(void);
 
 // #if USER_QIXIN   //添加的初始化代码
@@ -2516,12 +2513,7 @@ static void uart_event_task(void *pvParameters)
 
         printf("uart data len = %d\r\n", event.size);
 
-#if 0
-                    ESP_LOGD(LOG_TAG, "[UART DATA]: %d", event.size);
-                    uart_read_bytes(UART_NUM_1, dtmp, event.size, portMAX_DELAY);
-                    ESP_LOGD(LOG_TAG, "[uart_rx] = %s",dtmp);
-                    send_lora_queue(dtmp,event.size);
-#else
+
         if (event.size > 0)
         {
           // 启动定时器,第二个参数为定时器超时时间,设置为0表示立即启动
@@ -2561,7 +2553,6 @@ static void uart_event_task(void *pvParameters)
           y_ringbuf_write_remalloc_memory(lora_ringbuf, dtmp, receive_len);
         }
 
-#endif
         // lora_set_receive(dtmp,event.size);
         // lora_analytic_data(dtmp,event.size);
         // rx_to_rawData(dtmp,rawData_16);
@@ -2881,112 +2872,6 @@ int lora_send_data(const char *lora_data, int lora_data_len)
 {
   return uart_write_bytes(UART_NUM_1, (const char *)lora_data, lora_data_len);
 }
-static int lora_set_receive(const uint8_t *data, size_t len)
-{
-  // ESP_LOGI(LOG_TAG,"data len:[%d]",len);
-  if (len == 0x04) // 0x03+1
-  {
-
-    switch (data[1])
-    {
-    case 0x55:
-      ESP_LOGD(LOG_TAG, "lora set is ok");
-      break;
-    case 0xee:
-      ESP_LOGE(LOG_TAG, "lora set is fail");
-      break;
-    case 0x07:
-      rec_rssi = data[2];
-      ESP_LOGW(LOG_TAG, "rssi:%02x", data[2]);
-      break;
-    case 0x25:
-      ESP_LOGW(LOG_TAG, "version:%02x", data[2]);
-      break;
-    default:
-
-      break;
-    }
-    return -1;
-  }
-  else if (len == 0x16) // 0x15+1
-  {
-    if (data[1] != 0x24)
-    {
-      ESP_LOGE(LOG_TAG, "get lora cfg is fail");
-      return -1;
-    }
-
-    ESP_LOGI(LOG_TAG, "get lora cfg is ok");
-    lora_cfg_data.version = data[2];
-    lora_cfg_data.wireless_ch = data[12];
-    lora_cfg_data.wireless_freq_range = data[13];
-    lora_cfg_data.wireless_tx_power = data[14];
-    lora_cfg_data.wireless_bps = data[15];
-    lora_cfg_data.serial_bps = data[16];
-    lora_cfg_data.packet_fmt = data[17];
-    lora_cfg_data.auto_ack = data[18];
-    lora_cfg_data.outdir = data[19];
-    lora_cfg_data.wireless_ch_interval_bandwidth = data[20];
-    return -1;
-  }
-  return 1;
-}
-// static int lora_analytic_data(const uint8_t* data_buf,int len)
-// {
-//     LORA_DATA_T tmp_data;
-
-//     memcpy((char*)tmp_data.data_buf,(char*)data_buf,len);
-//     tmp_data.data_len = len;
-//     if((tmp_data.data_buf[2] == 0x5a) && (tmp_data.data_buf[3] == 0x51))
-//     {
-//         // if(tmp_data.data_buf[11] != 0x01)
-//         // {
-//         //     ESP_LOGE(LOG_TAG," err:eflag:0x%02x",tmp_data.data_buf[9]);
-//         //     printf("row:");
-//         //     for(int i=0;i<len;i++)
-//         //     {
-//         //         printf("0x%02x ",tmp_data.data_buf[i]);
-//         //     }
-//         //     printf("\n");
-//         //     return -1;
-//         // }
-
-//         // ESP_LOGD(LOG_TAG,"data is ok terminal number is %d,len is %d",tmp_data.data_buf[11],len);
-//         if(xQueueSend(lora_data_queue,&tmp_data,0) != true)
-//         {
-//             ESP_LOGE(LOG_TAG,"lora queue send is fail");
-//             return -1;
-//         }
-//         return 1;
-//     }
-
-//     return 1;
-// }
-static int send_lora_queue(const uint8_t *data_buf, int len)
-{
-
-  if (1 != lora_set_receive(data_buf, len))
-  {
-    return -1;
-  }
-  LORA_DATA_T tmp_data;
-
-  memcpy((char *)tmp_data.data_buf, (char *)data_buf, len);
-  tmp_data.data_len = len;
-
-  if (xQueueSend(lora_data_queue, &tmp_data, 0) != true)
-  {
-    ESP_LOGE(LOG_TAG, "lora queue send is fail");
-    return -1;
-  }
-  return 1;
-}
-
-void lora_send_queue_callback(uint8_t *data_buf, int len)
-{
-
-  send_lora_queue(data_buf, len);
-}
 
 void print_lora_set_info(void)
 {

+ 0 - 3
components/LORA/include/LORA.h

@@ -64,8 +64,6 @@ extern uint8_t lora_rssi_data;
 extern uint8_t lora_software_version;
 
 
-void lora_send_queue_callback(uint8_t* data_buf,int len);
-
 void lora_init(void);
 
 void lora_uart_pin_init(void);
@@ -201,7 +199,6 @@ typedef struct
 	uint8_t cmd_type;
 }Lora_t;
 
-extern uint8_t rssi;
 
 void lora_init();
 

BIN
components/USER_SPIFFS/spiffs/yc_data.bin


+ 1 - 1
main/ulp_riscv_adc_example_main.c

@@ -548,7 +548,7 @@ static void light_sleep_task(void *args)
         {
             if (read_battery_voltage() == 0)
             {
-                printf("-->low batt , power off\r\n");
+                ESP_LOGE(LOG_TAG,"-->low batt!!!! , power off\r\n");
 #if 0
                 set_screen_dis_info_and_send_queue(false, false, false, false,100);
                 set_screen_dis_info_and_send_queue(true, false, true, false,100);

+ 2 - 2
main/user_sleep.c

@@ -118,7 +118,7 @@ void sleep_timer_start(int ms)
     // 在这里可以改变定时器的超时时间
     // 第一个参数是定时器句柄,第二个参数是新的超时时间(以时钟节拍为单位)
     xTimerChangePeriod(sleep_timer, pdMS_TO_TICKS(ms), 0);
-
+    is_sleep = false;
     xTimerStart(sleep_timer, 0); // 开始定时器
     // xTimerStart(sleep_Timerout, 0);
     ESP_LOGI(LOG_TAG, "#############%s##############reset   sleep_timer [%d]", is_sleep ? "true" : "false", ms);
@@ -193,7 +193,7 @@ void Already_send_timer_callback(void *arg)
     // printf("sleep time = %d\r\n",(TIMER_WAKEUP_TIME_US*Machine_info.eflagID)/1000);
 
 #if 1
-    set_screen_dis_info_and_send_queue(true, false, false, true, 100);
+    sleep_timer_start(100); // 进入睡眠
 #endif
 
 #else

+ 1 - 49
main/yc_paint.c

@@ -681,50 +681,6 @@ static uint8_t *partial_right1_quick(Machine_info_t *info)
     Paint_DrawRectangle(457, 27, 462, 41, WHITE, 1, 1);
 #endif
 
-#if 0
-    //rssi
-    switch (Machine_info.rssi)
-    {
-        case 0:
-        Paint_DrawRectangle(480-57-32,42-3,391+5,42,WHITE,1,0 );
-        Paint_DrawRectangle(480-57-24,42-8,399+5,42,WHITE,1,0 );
-        Paint_DrawRectangle(480-57-16,42-13,407+5,42,WHITE,1,0 );
-        Paint_DrawRectangle(480-57-8,42-18,415+5,42,WHITE,1,0 );
-            break;
-        case 1 ... 24:
-        Paint_DrawRectangle(480-57-32,42-3,391+5,42,WHITE,1,1 );
-        Paint_DrawRectangle(480-57-24,42-8,399+5,42,WHITE,1,0 );
-        Paint_DrawRectangle(480-57-16,42-13,407+5,42,WHITE,1,0 );
-        Paint_DrawRectangle(480-57-8,42-18,415+5,42,WHITE,1,0 );
-            break;
-        case 25 ... 49:
-        Paint_DrawRectangle(480-57-32,42-3,391+5,42,WHITE,1,1 );
-        Paint_DrawRectangle(480-57-24,42-8,399+5,42,WHITE,1,1 );
-        Paint_DrawRectangle(480-57-16,42-13,407+5,42,WHITE,1,0 );
-        Paint_DrawRectangle(480-57-8,42-18,415+5,42,WHITE,1,0 );
-            break;
-        case 50 ... 74:
-        Paint_DrawRectangle(480-57-32,42-3,391+5,42,WHITE,1,1 );
-        Paint_DrawRectangle(480-57-24,42-8,399+5,42,WHITE,1,1 );
-        Paint_DrawRectangle(480-57-16,42-13,407+5,42,WHITE,1,1 );
-        Paint_DrawRectangle(480-57-8,42-18,415+5,42,WHITE,1,0 );
-            break;
-        case 75 ... 100:
-        Paint_DrawRectangle(480-57-32,42-3,391+5,42,WHITE,1,1 );
-        Paint_DrawRectangle(480-57-24,42-8,399+5,42,WHITE,1,1 );
-        Paint_DrawRectangle(480-57-16,42-13,407+5,42,WHITE,1,1 );
-        Paint_DrawRectangle(480-57-8,42-18,415+5,42,WHITE,1,1 );
-            break;
-        default:
-        ESP_LOGW(LOG_TAG," err:rssi ");
-        Paint_DrawRectangle(480-57-32,42-3,391+5,42,WHITE,1,1 );
-        Paint_DrawRectangle(480-57-24,42-8,399+5,42,WHITE,1,1 );
-        Paint_DrawRectangle(480-57-16,42-13,407+5,42,WHITE,1,1 );
-        Paint_DrawRectangle(480-57-8,42-18,415+5,42,WHITE,1,1 );
-            break;
-    }
-
-#else
 
     // 添加在线离线
     uint8_t online[6] = {0xd4, 0xda, 0xcf, 0xdf, 0x00, 0x00};  // 在线
@@ -740,11 +696,7 @@ static uint8_t *partial_right1_quick(Machine_info_t *info)
         Paint_DrawString_CN(480 - 50 - BAT_X_OFFSET - 50 + 3, 25, (char *)outline, &chinese_type_16, FONT_BACKGROUND, FONT_FOREGROUND);
     }
 
-// Paint_DrawRectangle(480-57-32,40-3,391+5,40,WHITE,1,1 );
-// Paint_DrawRectangle(480-57-24,40-8,399+5,40,WHITE,1,1 );
-// Paint_DrawRectangle(480-57-16,40-13,407+5,40,WHITE,1,1 );
-// Paint_DrawRectangle(480-57-8,40-18,415+5,40,WHITE,1,0 );
-#endif
+
 
     memcpy(partial_right1_buf, Paint_info.Image, sizeof(uint8_t) * 480 * RIGHT1_HIGHT / 8);
     return partial_right1_buf;

+ 4 - 6
main/yc_protocol.c

@@ -173,7 +173,7 @@ void set_screen_dis_info_and_send_queue(bool is_into_sleep, bool is_left, bool i
 }
 void terminal_send_data(void)
 {
-    // send_rssi();
+
     // vTaskDelay(100 / portTICK_PERIOD_MS);
     f_send_status_duration();
     // vTaskDelay(50 / portTICK_PERIOD_MS);
@@ -698,7 +698,7 @@ static void set_button_anotherName(void) // cmd 0x0d操作
     {
 
         Machine_info.btn_dis_flag[tmp - 1] = false;
-        ESP_LOGE(LOG_TAG, "按键状态关闭,清空按键文字 状态%d", tmp);
+        ESP_LOGD(LOG_TAG, "按键状态关闭,清空按键文字 状态%d", tmp);
         switch (terminal_info.status_setting[0]) // 按键状态关闭,清空按键文字
         {
         case 0x00:
@@ -720,7 +720,7 @@ static void set_button_anotherName(void) // cmd 0x0d操作
             memset(Machine_info.btn_shutDown_info, 0, 6);
             break;
         default:
-            ESP_LOGE(LOG_TAG, "err:按键状态%d", __LINE__);
+            ESP_LOGD(LOG_TAG, "err:按键状态%d", __LINE__);
             break;
         }
     }
@@ -730,7 +730,7 @@ static void set_button_anotherName(void) // cmd 0x0d操作
         // ESP_LOGW(LOG_TAG,"别名:[%02x %02x %02x %02x]",terminal_info.status_setting[2],terminal_info.status_setting[3],terminal_info.status_setting[4],terminal_info.status_setting[5]);
         if ((terminal_info.status_setting[2] == 0x00) && (terminal_info.status_setting[3] == 0x00))
         { // 别名为两个字,这判断第一个字为空,为空就赋值初始化的按键信息
-            ESP_LOGE(LOG_TAG, "button is open[other name is NULL] %d", terminal_info.status_setting[0]);
+            ESP_LOGD(LOG_TAG, "button is open[other name is NULL] %d", terminal_info.status_setting[0]);
             switch (terminal_info.status_setting[0])
             {
             case 0x00: // 运行
@@ -1345,8 +1345,6 @@ static void hardware_gwpair_func(const LORA_DATA_T *buf)
     f_send_version();
     f_send_reply_status(0x01); // 回复在线状态
     f_send_update_status();
-    // f_send_lora_rssi(Machine_info.rssi);
-    // f_send_lora_rssi(100); // 刚配完直接发100
     f_send_battary_vaule(Machine_info.batt_precent);
 
 #if 0

+ 21 - 34
main/yc_terminal.c

@@ -10,7 +10,7 @@
 #include "freertos/event_groups.h"
 #include "esp_timer.h"
 #include "esp_err.h"
-
+#include "iot_button.h"
 #include "user_config.h"
 
 #include "LED.h"
@@ -829,7 +829,7 @@ if(tmp_paint_buf!=NULL)
 }
 static void screen_task(void *arg)
 {
-    // Machine_info.rssi = 100;        // 没有获取到真数据,默认100
+    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))
@@ -865,8 +865,8 @@ static void screen_task(void *arg)
             {
                 if (screen_rev_info.is_change_power)
                 {
-                    ESP_LOGE(LOG_TAG, "=============power_status %s========  set power off", Machine_info.power_status ? "is power on" : "is power off");
-                    Machine_info.power_status = 0; // 关机
+                    ESP_LOGE(LOG_TAG, "power_status:%s", Machine_info.power_status ? "now[poweron],after[poweroff]" : "now[poweroff],after[poweron]");
+                    Machine_info.power_status = !Machine_info.power_status; // 关机
                 }
                 if (Machine_info.left_current_Quick_refresh_time >= Machine_info.left_max_Quick_refresh_time)
                 {
@@ -897,10 +897,10 @@ static void screen_task(void *arg)
             if ((Machine_info.power_status == 1) /*&& (Machine_info.paired == 1) */ && screen_rev_info.is_into_sleep)
             {
                 ESP_LOGW(LOG_TAG, "%dms sleep  %s", screen_rev_info.sleep_ms, screen_rev_info.is_left ? "left" : "right");
-                if (screen_rev_info.sleep_ms == 1)
-                    sleep_timer_start(100); // 进入睡眠
-                else
-                    sleep_timer_start(screen_rev_info.sleep_ms); // 进入睡眠
+                // if (screen_rev_info.sleep_ms == 1)
+                //     sleep_timer_start(100); // 进入睡眠
+                // else
+                sleep_timer_start(screen_rev_info.sleep_ms); // 进入睡眠
             }
 
             if (Machine_info.power_status == 0) // 展示说明书都是先左后右,等右屏刷完再休眠
@@ -1028,7 +1028,7 @@ static void button_task(void *arg)
                 {
                     printf("repeat ,goto sleep !\r\n");
                     // sleep_timer_start(100); // 开始进入倒计时休眠
-                    set_screen_dis_info_and_send_queue(false, false, false, true, 1000);
+                    set_screen_dis_info_and_send_queue(true, false, false, true, 100);
                 }
             }
             else // 右屏幕按键触发
@@ -1060,19 +1060,18 @@ static void button_task(void *arg)
 
                     if (Machine_info.power_status == 1) // 开机状态
                     {
+                        printf("poweron->poweroff\r\n");
+                        lora_set_power_level(0); // 关机关闭lora防止lora消息刷屏
                         // Machine_info.power_status = 0;
                         // screen_dis_info.is_change_power = true;
                         xQueueReset(screen_queue);
-                        set_screen_dis_info_and_send_queue(false, true, true, false, 100);// 关机
-                        set_screen_dis_info_and_send_queue(true, false, false, false, 1000); 
-                        printf("poweron->poweroff\r\n");
+                        set_screen_dis_info_and_send_queue(false, true, true, false, 5000); // 关机
+                        set_screen_dis_info_and_send_queue(true, false, false, false, 5000);
                     }
-                    else if (Machine_info.power_status == 0)
+                    else if (Machine_info.power_status == 0) // 关机后还未进入休眠直接长按开机
                     {
-                        printf("power on\r\n");
+                        printf("button power on\r\n");
                         Machine_info.power_status = 1;
-                        lora_set_power_level(1);
-                        font_exit_sleep();
 
                         gpio_hold_dis(LORA_TXD_PIN);
                         gpio_hold_dis(LORA_RXD_PIN);
@@ -1080,10 +1079,13 @@ static void button_task(void *arg)
                         gpio_hold_dis(PIN_L_CS);
                         gpio_hold_dis(PIN_R_CS);
 
-                        // 恢复串口i功能
-                        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);
+
+                        lora_set_power_level(1);
+                        // 恢复串口i功能
+                        uart_sleep_out_config();
+                        font_exit_sleep();
                     }
                 }
 
@@ -1099,7 +1101,7 @@ static void button_task(void *arg)
                 {
                     beep_blink(50, 3);
                     printf("into ota mode\r\n");
-#include "iot_button.h"
+
                     iot_button_stop();
                     esp_ble_ota();
                 }
@@ -1113,22 +1115,12 @@ static void button_task(void *arg)
                     lora_set_power_level(1);
                     uart_sleep_out_config();
 
-#include "user_sleep.h"
-                    // #include "esp_sleep.h"
-
                     extern void sleep_timer_stop();
                     extern void Already_send_timer_stop();
 
                     sleep_timer_stop();
                     Already_send_timer_stop();
 
-                    // //修改信道前修改设备ID 及 设备ID
-                    // dymatic_change_device_id(0x00000001);
-                    // dymatic_change_dst_device_id(0xFFFFFFFF);
-                    // //切换信道
-                    // dymatic_change_chanel(Machine_info.lora_factory_channel);  //切换信道
-                    // // spiffs_read(&Machine_info);
-
                     vTaskDelay(300 / portTICK_PERIOD_MS);
                     reset_default(true, 1);
                     reset_lora(LORA_CHANENL);
@@ -1404,11 +1396,6 @@ void read_deal_data_callback_handler()
     {
         if (xQueueReceive(lora_dealhandle, &length, portMAX_DELAY) == pdPASS)
         {
-            if (rssi != 0)
-            {
-                Machine_info.rssi = rssi;
-            }
-
             // printf("deal data\r\n");
             user_size = y_ringbuf_get_used_size(lora_ringbuf);
             if (user_size > 0)

BIN
yc_data.bin