瀏覽代碼

修改按键触发方式,优化log

wanghechen 8 月之前
父節點
當前提交
df9583448e

+ 2 - 2
components/Decection/Decection.c

@@ -74,7 +74,7 @@ int adc_read_power_pin(adc_oneshot_unit_handle_t adc_handle)
     #if 0
         ESP_LOGI(TAG,"batt_percent = [%d],voltage[0][0] = [%d]",batt_percent, voltage[0][0]);
     #else
-        printf("batt_percent = [%d],voltage[0][0] = [%d],adc value %d\r\n",batt_percent, voltage[0][0],(int)battery_percentage);
+        // printf("batt_percent = [%d],voltage[0][0] = [%d],adc value %d\r\n",batt_percent, voltage[0][0],(int)battery_percentage);
     #endif
     return batt_percent;
 }
@@ -141,7 +141,7 @@ extern adc_oneshot_unit_handle_t adc1_handle;
 
 int read_battery_voltage()
 {
-    printf("读电量\n");
+    // printf("读电量\n");
     return adc_read_power_pin(adc1_handle);
 }
 

+ 0 - 3
components/EPD/EPD.c

@@ -737,9 +737,6 @@ void epd_sleep(screen_t screen)
 
 IRAM_ATTR void epd_display(screen_t screen,const unsigned char* picData)
 {
-
-
-
     epd_write_cmd(screen,0x13,false);
     epd_check_status(screen);
     epd_write_data(screen,picData,38880);

+ 2 - 1
components/LORA/LORA.c

@@ -1109,7 +1109,7 @@ void lora_receive_callback_handler()
 
 
                         //printf("string =%s\r\n",data);
-                        printf("->Lora_UART_Mode %.*s\n", user_size, data);
+                        printf(" -> Lora_UART_Mode %.*s\n", user_size, data);
                         //发送消息处理
                         #if 0
                         xQueueSend(lora_dealhandle, &length, portMAX_DELAY);
@@ -2708,6 +2708,7 @@ int get_lora_busy_pin()
 
 void lora_set_power_level(int level)
 {
+  ESP_LOGW(LOG_TAG,"设置lora电源 %s",level?"打开":"关闭");
   #if 0
     gpio_set_level(LORA_POWER_PIN,level);
   #else

+ 3 - 3
components/button/user_button.c

@@ -162,9 +162,9 @@ bool is_btn_timeout(void)
     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);
+    // 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))
     {
         ESP_LOGW(LOG_TAG,"发送-----现在按键时间: %04d-%02d-%02d %02d:%02d:%02d\n",

+ 10 - 9
main/ulp_riscv_adc_example_main.c

@@ -365,8 +365,8 @@ static void light_sleep_task(void *args)
                             //OTA 不休眠
                             if(!is_adv){
                                 ESP_LOGW(LOG_TAG,"-> sleep\r\n");
-                                uart_wait_tx_idle_polling(CONFIG_ESP_CONSOLE_UART_NUM);
-                                uart_wait_tx_idle_polling(1);
+                                uart_wait_tx_idle_polling(1);//抛出剩余串口1消息
+                                uart_wait_tx_idle_polling(CONFIG_ESP_CONSOLE_UART_NUM);//抛出剩余串口0消息
                                 if(!is_button_timer_active())
                                 {
                                     vTaskDelay(100/ portTICK_PERIOD_MS);//给出时间片
@@ -448,9 +448,10 @@ static void light_sleep_task(void *args)
                     printf("唤醒: bat %d wait_send_rssi_bat = %d,\r\n",Machine_info.batt_precent,Machine_info.wait_send_rssi_bat);
 
                     // if(Machine_info.wait_send_rssi_bat>(30*60/TIMER_WAKEUP_TIME_S))//30分钟发一次lora
-                    if(Machine_info.wait_send_rssi_bat>60)
+                    if(Machine_info.wait_send_rssi_bat>60)//30分钟唤醒一次->(30*60/TIMER_WAKEUP_TIME_S) = 60
+                    //if(0)
                     {
-                        ESP_LOGW(LOG_TAG,"30分钟发送数据"); 
+                        ESP_LOGE(LOG_TAG,"-> 30minite send lora info"); 
                         Machine_info.wait_send_rssi_bat = 0;
                         f_send_get_chart_data();
                         f_send_lora_rssi(Machine_info.rssi);
@@ -588,11 +589,11 @@ static void light_sleep_task(void *args)
             {
                 iot_button_resume();
             }
-            // if(Machine_info.paired && Machine_info.power_status )
-            // {
-            //     vTaskDelay(2000/ portTICK_PERIOD_MS);
-            //     is_sleep = true;//配对且开机,进入休眠
-            // }
+            if(Machine_info.paired && Machine_info.power_status )
+            {
+                vTaskDelay(2000/ portTICK_PERIOD_MS);
+                is_sleep = true;//配对且关机,进入休眠
+            }
 
             break;
             default:

+ 10 - 9
main/yc_protocol.c

@@ -137,7 +137,7 @@ void  print_systenInfo(void)
 {
     printf("=================================\r\n");
     printf("=================================\r\n");
-    printf("=================================\r\n");
+    printf("=======%s======\r\n","2024.1.4 [11时] burn");//打印烧录时间
     printf("=================================\r\n");
     printf("=================================\r\n");
     printf("========version V %d.%d.%d==========\r\n",VERSION_X,VERSION_Y,VERSION_Z);
@@ -360,17 +360,18 @@ static int time_synchronization_func(const LORA_DATA_T* buf)
 
 
 
-        printf("TIMER SYNC YEAR = %d,MONTH =%d,DAY=%d,HOUR=%d,MIN=%d,SEC =%d\r\n",
-        Machine_info.year,
-        Machine_info.month,
-        Machine_info.day,
-        Machine_info.hour,
-        Machine_info.min,
-        Machine_info.sec);
+    printf("TIMER SYNC YEAR = %d,MONTH =%d,DAY=%d,HOUR=%d,MIN=%d,SEC =%d\r\n",
+    Machine_info.year,
+    Machine_info.month,
+    Machine_info.day,
+    Machine_info.hour,
+    Machine_info.min,
+    Machine_info.sec);
 
 
-        getRtcTime(&Machine_info);
+    getRtcTime(&Machine_info);
 
+    xEventGroupSetBits(screen_event, RIGHT_SCREEN_BIT);
     //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 用于删除
     //printf("msg_id =%X\r\n",msg_id);

+ 37 - 28
main/yc_terminal.c

@@ -676,10 +676,11 @@ extern uint32_t ulp_wakeup_result;
 
                 adc_oneshot_del_unit(adc1_handle);  //删除adc使用
                 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();  //返回唤醒的原因
+                ESP_LOGW(LOG_TAG,"power on- reson = %d\r\n",reson);
                 /* ULP Risc-V read and detected a temperature above the limit */
                 if (reson == ESP_SLEEP_WAKEUP_EXT0)
                 {
@@ -1124,16 +1125,17 @@ static void screen_task(void* arg)
         Paint_leftScreen(Machine_info.power_status,false);
         Paint_rightScreen(Machine_info.power_status,false);
     }
-    screen_dis_info.is_left = false;
-    screen_dis_info.is_into_sleep = true;
+    Screen_dis_t screen_rev_info;
+    screen_rev_info.is_left = false;
+    screen_rev_info.is_into_sleep = true;
     Machine_info.left_current_Quick_refresh_time = 1;//开机慢刷
     while(1)
     {
-        if(xQueueReceive(screen_queue, &screen_dis_info,(TickType_t)portMAX_DELAY))
+        if(xQueueReceive(screen_queue, &screen_rev_info,(TickType_t)portMAX_DELAY))
         {
             font_exit_sleep();
-            ESP_LOGI(LOG_TAG,"%s , %s",screen_dis_info.is_left?"左屏刷新":"右屏刷新",screen_dis_info.is_into_sleep?"进入睡眠":"不进睡眠");
-            if(screen_dis_info.is_left)//刷左屏
+            ESP_LOGI(LOG_TAG,"%s , %s",screen_rev_info.is_left?"左屏刷新":"右屏刷新",screen_rev_info.is_into_sleep?"进入睡眠":"不进睡眠");
+            if(screen_rev_info.is_left)//刷左屏
             {
                 if(Machine_info.left_current_Quick_refresh_time >=  Machine_info.left_max_Quick_refresh_time)
                 {
@@ -1150,7 +1152,7 @@ static void screen_task(void* arg)
             {
                 if(Machine_info.right_current_Quick_refresh_time ==  0)
                 {
-                    Machine_info.left_current_Quick_refresh_time = 1;
+                    Machine_info.right_current_Quick_refresh_time = 1;
                     Paint_rightScreen(Machine_info.power_status,true);
                 }
                 else
@@ -1159,32 +1161,32 @@ static void screen_task(void* arg)
                 }
             }
 
-            if((Machine_info.power_status == 1)&&(Machine_info.paired == 1)&& screen_dis_info.is_into_sleep)
+            if((Machine_info.power_status == 1)&&(Machine_info.paired == 1)&& screen_rev_info.is_into_sleep)
             {
-                ESP_LOGW(LOG_TAG,"刷屏进入休眠 %s",screen_dis_info.is_left?"左屏刷新":"右屏刷新");
+                ESP_LOGW(LOG_TAG,"刷屏进入休眠 %s",screen_rev_info.is_left?"左屏刷新":"右屏刷新");
                 sleep_timer_start(100);  //进入睡眠
             }
 
-            if(Machine_info.power_status == 0 && screen_dis_info.is_left == false)//展示说明书都是先左后右,等右屏刷完再休眠
+            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();
+//                 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();
             }
         }
     }
@@ -1412,7 +1414,14 @@ static void button_task(void* arg)
 
                 if(button_info == POWER_ON_INTO_DIS_RIGHT) 
                 {
+                    screen_dis_info.is_left = true;
+                    if(xQueueSend(screen_queue,&screen_dis_info,portMAX_DELAY) != true)
+                    {
+                        ESP_LOGE(LOG_TAG,"err:screen queue send fail");
+                    } 
                     screen_dis_info.is_left = false;
+                    screen_dis_info.is_into_sleep = true;
+                    Machine_info.left_current_Quick_refresh_time = 5;
                     if(xQueueSend(screen_queue,&screen_dis_info,portMAX_DELAY) != true)
                     {
                         ESP_LOGE(LOG_TAG,"err:screen queue send fail");
@@ -1788,7 +1797,7 @@ void read_deal_data_callback_handler()
                     }
                     printf("\r\n");
     #endif
-                    ESP_LOG_BUFFER_HEX("接收的lora",result,user_size);
+                    ESP_LOG_BUFFER_HEX("接收的lora",result,user_size);
                     yc_data.len =  user_size;
                     yc_data.data = malloc(sizeof(uint8_t)*user_size);//分配内存
                     memcpy(yc_data.data,result,user_size);