Procházet zdrojové kódy

1.添加电源健按三次刷右屏2.修改ota结束保存逻辑

wanghechen před 10 měsíci
rodič
revize
f6f7cd1473

+ 2 - 1
components/button/include/user_button.h

@@ -118,7 +118,8 @@ typedef enum
 
 
 
-#define POWER_KEY_PRSSS_SETTING_MODE 2   //进入设置模式
+#define POWER_KEY_PRSSS_BLE_OTA_MODE 2   //进入设置模式
+#define POWER_KEY_PRSSS_DIS_RIGHT 3   
 #define POWER_KEY_PRSSS_COUNT_RESET  4   //电源键多次按键恢复出厂
 
 

+ 16 - 5
components/button/user_button.c

@@ -242,7 +242,7 @@ void power_button_init(adc_oneshot_unit_handle_t adc_handle)
         power_button_mult_time = btn_cfg.event_data.multiple_clicks.clicks ;
         iot_button_register_event_cb(user_powerbutton_handle[i], btn_cfg, power_button_multi_press_cb, power_button_mult_time);
 
-        btn_cfg.event_data.multiple_clicks.clicks = POWER_KEY_PRSSS_SETTING_MODE;
+        btn_cfg.event_data.multiple_clicks.clicks = POWER_KEY_PRSSS_BLE_OTA_MODE;
         power_button_mult_time = btn_cfg.event_data.multiple_clicks.clicks ;
         iot_button_register_event_cb(user_powerbutton_handle[i], btn_cfg, power_button_multi_press_cb, power_button_mult_time);            
 
@@ -307,7 +307,12 @@ void power_button_init(adc_oneshot_unit_handle_t adc_handle)
         power_button_mult_time = btn_cfg.event_data.multiple_clicks.clicks ;
         iot_button_register_event_cb(user_powerbutton_handle[i], btn_cfg, power_button_multi_press_cb, power_button_mult_time);
 
-        btn_cfg.event_data.multiple_clicks.clicks = POWER_KEY_PRSSS_SETTING_MODE;
+
+        btn_cfg.event_data.multiple_clicks.clicks = POWER_KEY_PRSSS_DIS_RIGHT;
+        power_button_mult_time = btn_cfg.event_data.multiple_clicks.clicks ;
+        iot_button_register_event_cb(user_powerbutton_handle[i], btn_cfg, power_button_multi_press_cb, power_button_mult_time);
+
+        btn_cfg.event_data.multiple_clicks.clicks = POWER_KEY_PRSSS_BLE_OTA_MODE;
         power_button_mult_time = btn_cfg.event_data.multiple_clicks.clicks ;
         iot_button_register_event_cb(user_powerbutton_handle[i], btn_cfg, power_button_multi_press_cb, power_button_mult_time);            
 
@@ -371,11 +376,13 @@ static void power_long_press_hold_cb(void *arg,void *usr_data)
 {
     //设置的长按开始时间后开始计算hold_cnt  长按开始时间设置为1s,cnt计算时间间隔(SERIAL_TICKS)也设置为1s
     uint16_t hold_cnt = iot_button_get_long_press_hold_cnt((button_handle_t)arg);
+    ESP_LOGE(LOG_TAG," BUTTON_LONG_PRESS_HOLD[%d],count is [%d]\n", iot_button_get_ticks_time((button_handle_t)arg), hold_cnt);
+
     switch ((int)hold_cnt)
     {
-    case 0:
+    case 1:
     {
-         ESP_LOGE(LOG_TAG,"case 0:");
+         ESP_LOGE(LOG_TAG,"case 1");
          button_info = POWER_ON_INTO_DIS_RIGHT;
         if(xQueueSend(button_Data_queue,&button_info,0) != true)
             {
@@ -555,7 +562,7 @@ static void power_button_multi_press_cb(void *arg,void *usr_data)
     }
     switch ((int)usr_data)
     {
-        case POWER_KEY_PRSSS_SETTING_MODE:
+        case POWER_KEY_PRSSS_BLE_OTA_MODE:
         if(!is_setting && !is_reset_net) //当前非配置模式
         {
             is_setting = true;
@@ -563,6 +570,10 @@ static void power_button_multi_press_cb(void *arg,void *usr_data)
             printf("短按2次\r\n");
         }
         break;
+        case POWER_KEY_PRSSS_DIS_RIGHT:
+            printf("短按3次\r\n");
+            send_button_key_queue((uint8_t)POWER_ON_INTO_DIS_RIGHT);
+        break;
         case  POWER_KEY_PRSSS_COUNT_RESET:
             if(!is_setting && !is_reset_net)
             {

+ 5 - 3
main/esp_ble_ota.c

@@ -228,7 +228,7 @@ ota_task(void *arg)
         {   
             extern bool is_conn;
             ESP_LOGI(TAG,"is_conn = %s",is_conn?"true":"false");
-            ESP_LOGI(TAG," [%02x] [%02x]   --- [%02x] [%02x]",data[0],data[1],ota_timeout_data[0],ota_timeout_data[1]);
+            // ESP_LOGI(TAG," [%02x] [%02x]   --- [%02x] [%02x]",data[0],data[1],ota_timeout_data[0],ota_timeout_data[1]);
             if(!is_conn && (data[0] == 0x65)&& (data[1] == 0x72)&&(data[2] == 0x72))//
             {
                 goto OTA_ERROR;
@@ -267,8 +267,10 @@ ota_task(void *arg)
     }
     ESP_LOGE(TAG, "存数据 esp_restart");
     #include "SPIFFS.h"
-    extern Machine_info_t   Machine_info;
-    spiffs_write(&Machine_info);
+    // extern Machine_info_t   Machine_info;
+    // spiffs_write(&Machine_info);
+    extern void reset_default(bool is_dis);
+    reset_default(false);
     esp_restart();
 
 OTA_ERROR:

+ 7 - 3
main/ulp_riscv_adc_example_main.c

@@ -102,7 +102,7 @@ static void light_sleep_task(void *args)
     // {
     //  esp_light_sleep_start();  //进入休眠
     // }
-
+    extern bool is_adv;
     int bat_times = 0;
 
     int lev_2  = 0;
@@ -364,7 +364,7 @@ static void light_sleep_task(void *args)
                             //gpio_hold_en(4);
 
                             //vTaskDelay(100/ portTICK_PERIOD_MS);
-                            extern bool is_adv;
+
                             //OTA 不休眠
                             if(!is_adv){
                                 esp_light_sleep_start();
@@ -605,7 +605,11 @@ static void light_sleep_task(void *args)
              break;
             case ESP_SLEEP_WAKEUP_EXT0:
 
-            iot_button_resume();
+            if(!is_adv)
+            {
+                iot_button_resume();
+            }
+
             printf("ESP_SLEEP_WAKEUP_EXT0 \r\n");
             break;
             default:

+ 1 - 1
main/user_config.h

@@ -119,5 +119,5 @@ void Paint_rightScreen_main_slow(Machine_info_t* info);
 void dis_instructions();
 
 void esp_ble_ota(void);
-void reset_default();
+void reset_default(bool is_dis);
 #endif

+ 1 - 1
main/user_sleep.h

@@ -3,7 +3,7 @@
 
 
 
-#define TIMER_WAKEUP_TIME_US    (6 * 1000 * 1000)     //定义的唤醒的时间         单位s
+#define TIMER_WAKEUP_TIME_US    (30 * 1000 * 1000)     //定义的唤醒的时间         单位s
 #define TIMER_CAN_SEND_TIME     (200)                 //定义可以唤醒lora工作的时间单位ms
 #define LORA_POWER_TIME         (2000)
 

+ 9 - 3
main/yc_protocol.c

@@ -88,7 +88,7 @@ RTC_FAST_ATTR Person_t  person[5]=
 
 
 
-void reset_default()
+void reset_default(bool is_dis)
 {
     
     extern Machine_info_t default_info;
@@ -102,6 +102,10 @@ void reset_default()
     tmp.rssi = Machine_info.rssi;
     memcpy(&Machine_info,&tmp,sizeof(Machine_info_t));//恢复默认
     spiffs_write(&Machine_info);//保存Machine_info
+    if(!is_dis)
+    {
+        return;
+    }
     Paint_leftScreen_main_quick(&Machine_info);
     Paint_rightScreen_main_quick(&Machine_info);
 }
@@ -1670,7 +1674,7 @@ static void hardware_ungwpair_func(const LORA_DATA_T* buf)
      dymatic_change_device_id(0x00000001);
      dymatic_change_dst_device_id(0xFFFFFFFF);
     //切换信道
-    reset_default();
+    reset_default(true);
     vTaskDelay(300 / portTICK_PERIOD_MS);
     Machine_info.lora_new_channel = LORA_CHANENL;
     // dymatic_change_chanel(Machine_info.lora_factory_channel);  //切换信道
@@ -1833,8 +1837,10 @@ void business_logic_func(const LORA_DATA_T* buf,uint8_t cmd_index,int msg)
         break;   
 
     case PROTOCOL_HARDWARE_GWPAIRED:  //配网 暂时单独发送ack 
-    reset_default();
+    reset_default(false);
     hardware_gwpair_func(buf);
+    Paint_leftScreen_main_quick(&Machine_info);
+    Paint_rightScreen_main_quick(&Machine_info);
     break;
 
     case PROTOCOL_HARDWARE_UNGWPAIRED: //取消配网

+ 2 - 4
main/yc_terminal.c

@@ -1761,7 +1761,6 @@ static void button_task(void* arg)
 
 
 
-
                 if(button_info == POWER_ON_INTO_RESET_VALUE) //进入配网模式
                 {
                     beep_blink(2000,1);
@@ -1790,9 +1789,8 @@ static void button_task(void* arg)
                     // // spiffs_read(&Machine_info);
 
 
-                    vTaskDelay(300 / portTICK_PERIOD_MS);
-                    reset_default();
-
+                    // vTaskDelay(300 / portTICK_PERIOD_MS);
+                    reset_default(true);
                     reset_lora();
                     vTaskDelay(300 / portTICK_PERIOD_MS);
                 }