|
@@ -265,7 +265,7 @@ static void light_sleep_task(void *args)
|
|
|
|
|
|
iot_button_stop();
|
|
iot_button_stop();
|
|
#if 1 // 电源按键
|
|
#if 1 // 电源按键
|
|
- // adc_oneshot_del_unit(adc1_handle);
|
|
|
|
|
|
+ // adc_oneshot_del_unit(adc1_handle);
|
|
gpio_reset_pin(4);
|
|
gpio_reset_pin(4);
|
|
int ext_wakeup_pin_0 = 4;
|
|
int ext_wakeup_pin_0 = 4;
|
|
printf("Enabling EXT0 wakeup on pin GPIO%d\n", ext_wakeup_pin_0);
|
|
printf("Enabling EXT0 wakeup on pin GPIO%d\n", ext_wakeup_pin_0);
|
|
@@ -293,7 +293,7 @@ static void light_sleep_task(void *args)
|
|
|
|
|
|
#endif
|
|
#endif
|
|
esp_sleep_enable_timer_wakeup(TIMER_WAKEUP_TIME_US); // 配置当前休眠的唤醒时间
|
|
esp_sleep_enable_timer_wakeup(TIMER_WAKEUP_TIME_US); // 配置当前休眠的唤醒时间
|
|
- // adc_oneshot_del_unit(adc1_handle);
|
|
|
|
|
|
+ // adc_oneshot_del_unit(adc1_handle);
|
|
|
|
|
|
// extern bool left_refresh_complete;
|
|
// extern bool left_refresh_complete;
|
|
// extern bool right_refresh_complete;
|
|
// extern bool right_refresh_complete;
|
|
@@ -333,17 +333,19 @@ static void light_sleep_task(void *args)
|
|
// OTA 不休眠
|
|
// OTA 不休眠
|
|
if (!is_adv)
|
|
if (!is_adv)
|
|
{
|
|
{
|
|
- 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消息
|
|
|
|
- if (!is_button_timer_active())
|
|
|
|
|
|
+
|
|
|
|
+ if (!is_power_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); // 给出时间片
|
|
vTaskDelay(100 / portTICK_PERIOD_MS); // 给出时间片
|
|
esp_light_sleep_start();
|
|
esp_light_sleep_start();
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- ESP_LOGW(LOG_TAG, "-> btn is active\r\n");
|
|
|
|
|
|
+ ESP_LOGW(LOG_TAG, "power key is press\r\n");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
else
|
|
@@ -377,29 +379,31 @@ static void light_sleep_task(void *args)
|
|
case ESP_SLEEP_WAKEUP_TIMER:
|
|
case ESP_SLEEP_WAKEUP_TIMER:
|
|
|
|
|
|
iot_button_resume();
|
|
iot_button_resume();
|
|
-// wakeup_reason = "timer";
|
|
|
|
-#if LORA_SLEEP_ENABLE
|
|
|
|
- // rtc_gpio_pullup_dis(LORA_POWER_PIN);
|
|
|
|
- // rtc_gpio_deinit(LORA_POWER_PIN);
|
|
|
|
- // rtc_gpio_init(LORA_POWER_PIN);
|
|
|
|
- // rtc_gpio_set_direction(LORA_POWER_PIN, RTC_GPIO_MODE_OUTPUT_ONLY);
|
|
|
|
- // rtc_gpio_pullup_en(LORA_POWER_PIN);
|
|
|
|
- // rtc_gpio_set_level(LORA_POWER_PIN, 1);
|
|
|
|
- lora_set_power_level(1); // 打开lora电源
|
|
|
|
-// rtc_gpio_hold_en(LORA_POWER_PIN);
|
|
|
|
-#endif
|
|
|
|
|
|
+ // // wakeup_reason = "timer";
|
|
|
|
+ // #if LORA_SLEEP_ENABLE
|
|
|
|
+ // // rtc_gpio_pullup_dis(LORA_POWER_PIN);
|
|
|
|
+ // // rtc_gpio_deinit(LORA_POWER_PIN);
|
|
|
|
+ // // rtc_gpio_init(LORA_POWER_PIN);
|
|
|
|
+ // // rtc_gpio_set_direction(LORA_POWER_PIN, RTC_GPIO_MODE_OUTPUT_ONLY);
|
|
|
|
+ // // rtc_gpio_pullup_en(LORA_POWER_PIN);
|
|
|
|
+ // // rtc_gpio_set_level(LORA_POWER_PIN, 1);
|
|
|
|
+ // lora_set_power_level(1); // 打开lora电源
|
|
|
|
+ // // rtc_gpio_hold_en(LORA_POWER_PIN);
|
|
|
|
+ // #endif
|
|
|
|
|
|
-#if FONT_SLEEP_ENABLE // 字库唤醒恢复供电
|
|
|
|
- font_exit_sleep(); // 退出睡眠
|
|
|
|
|
|
+ // #if FONT_SLEEP_ENABLE // 字库唤醒恢复供电
|
|
|
|
+ // font_exit_sleep(); // 退出睡眠
|
|
|
|
|
|
-#endif
|
|
|
|
|
|
+ // #endif
|
|
|
|
|
|
-#if LCD_SLEEP_ENABLE
|
|
|
|
|
|
+ // #if LCD_SLEEP_ENABLE
|
|
|
|
|
|
-#endif
|
|
|
|
|
|
+ // #endif
|
|
|
|
|
|
if (is_first_run == false)
|
|
if (is_first_run == false)
|
|
{
|
|
{
|
|
|
|
+ lora_set_power_level(1); // 打开lora电源
|
|
|
|
+ font_exit_sleep(); // 退出睡眠
|
|
gpio_hold_dis(LORA_TXD_PIN);
|
|
gpio_hold_dis(LORA_TXD_PIN);
|
|
gpio_hold_dis(LORA_RXD_PIN);
|
|
gpio_hold_dis(LORA_RXD_PIN);
|
|
|
|
|
|
@@ -409,17 +413,21 @@ static void light_sleep_task(void *args)
|
|
getRtcTime(&Machine_info);
|
|
getRtcTime(&Machine_info);
|
|
Machine_info.batt_precent = read_battery_voltage();
|
|
Machine_info.batt_precent = read_battery_voltage();
|
|
Machine_info.wait_send_rssi_bat++;
|
|
Machine_info.wait_send_rssi_bat++;
|
|
- printf("唤醒: bat %d wait_send_rssi_bat = %d,\r\n", Machine_info.batt_precent, Machine_info.wait_send_rssi_bat);
|
|
|
|
|
|
+ printf("weakup: bat %d wait_send_rssi_bat = %d,\r\n", Machine_info.batt_precent, Machine_info.wait_send_rssi_bat);
|
|
|
|
+
|
|
|
|
+ // 打印待发数据
|
|
|
|
+ printList(Send_list);
|
|
|
|
|
|
// if(Machine_info.wait_send_rssi_bat>(30*60/TIMER_WAKEUP_TIME_S))//30分钟发一次lora
|
|
// if(Machine_info.wait_send_rssi_bat>(30*60/TIMER_WAKEUP_TIME_S))//30分钟发一次lora
|
|
if (Machine_info.wait_send_rssi_bat > 60) // 30分钟唤醒一次->(30*60/TIMER_WAKEUP_TIME_S) = 60
|
|
if (Machine_info.wait_send_rssi_bat > 60) // 30分钟唤醒一次->(30*60/TIMER_WAKEUP_TIME_S) = 60
|
|
- // if(0)
|
|
|
|
|
|
+ // if (0)
|
|
{
|
|
{
|
|
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_get_chart_data();
|
|
f_send_lora_rssi(Machine_info.rssi);
|
|
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();
|
|
}
|
|
}
|
|
|
|
|
|
if ((Machine_info.last_button.Minute != Machine_info.min) /*||(Machine_info.last_button.Hour != Machine_info.Hour)*/) //
|
|
if ((Machine_info.last_button.Minute != Machine_info.min) /*||(Machine_info.last_button.Hour != Machine_info.Hour)*/) //
|
|
@@ -448,6 +456,7 @@ static void light_sleep_task(void *args)
|
|
|
|
|
|
break;
|
|
break;
|
|
case ESP_SLEEP_WAKEUP_GPIO:
|
|
case ESP_SLEEP_WAKEUP_GPIO:
|
|
|
|
+
|
|
lev_2 = gpio_get_level(2);
|
|
lev_2 = gpio_get_level(2);
|
|
|
|
|
|
{
|
|
{
|
|
@@ -571,6 +580,7 @@ static void light_sleep_task(void *args)
|
|
if (read_battery_voltage() == 0)
|
|
if (read_battery_voltage() == 0)
|
|
{
|
|
{
|
|
printf("-->low batt , power off\r\n");
|
|
printf("-->low batt , power off\r\n");
|
|
|
|
+#if 0
|
|
Machine_info.power_status = 0;
|
|
Machine_info.power_status = 0;
|
|
// dis_instructions(); //进入关机界面
|
|
// dis_instructions(); //进入关机界面
|
|
// screen_dis_info.is_left = true;
|
|
// screen_dis_info.is_left = true;
|
|
@@ -586,6 +596,7 @@ static void light_sleep_task(void *args)
|
|
ESP_LOGE(LOG_TAG, "err:screen queue send fail");
|
|
ESP_LOGE(LOG_TAG, "err:screen queue send fail");
|
|
}
|
|
}
|
|
sleep_timer_start(1000);
|
|
sleep_timer_start(1000);
|
|
|
|
+#endif
|
|
}
|
|
}
|
|
|
|
|
|
lev_2 = gpio_get_level(2);
|
|
lev_2 = gpio_get_level(2);
|