|
|
@ -86,6 +86,18 @@ static void power_off() { |
|
|
|
ble_cmder_uninit(); |
|
|
|
m_poweronflag = false; |
|
|
|
} |
|
|
|
void ENTER_DEEP_SLEEP() { |
|
|
|
// 进入深度睡眠前,使能唤醒引脚 |
|
|
|
BoardEcgSensor_set_sence_state(); |
|
|
|
BoardBattery_sence_gpio_init_before_sleep(); |
|
|
|
// nrf_sdh_disable_request(); |
|
|
|
app_timer_stop_all(); |
|
|
|
nrf_sdh_suspend(); |
|
|
|
sd_power_system_off(); |
|
|
|
NVIC_SystemReset(); |
|
|
|
} |
|
|
|
|
|
|
|
static void check_battery_level() {} |
|
|
|
/******************************************************************************* |
|
|
|
* 状态切换方法 * |
|
|
|
*******************************************************************************/ |
|
|
@ -132,17 +144,6 @@ static void state_machine__change_to_home_state() { |
|
|
|
dsp_mgr_change_to_main(); |
|
|
|
} |
|
|
|
|
|
|
|
void ENTER_DEEP_SLEEP() { |
|
|
|
// 进入深度睡眠前,使能唤醒引脚 |
|
|
|
BoardEcgSensor_set_sence_state(); |
|
|
|
BoardBattery_sence_gpio_init_before_sleep(); |
|
|
|
// nrf_sdh_disable_request(); |
|
|
|
app_timer_stop_all(); |
|
|
|
nrf_sdh_suspend(); |
|
|
|
sd_power_system_off(); |
|
|
|
NVIC_SystemReset(); |
|
|
|
} |
|
|
|
|
|
|
|
static void app_event_listener(void* p_event_data, uint16_t event_size) { |
|
|
|
if (!p_event_data) return; |
|
|
|
app_event_t* p_event = (app_event_t*)p_event_data; |
|
|
@ -166,7 +167,11 @@ static void app_event_listener(void* p_event_data, uint16_t event_size) { |
|
|
|
|
|
|
|
// 导联连接事件触发 --> 切换到开机中页面 |
|
|
|
else if (BoardEcgSensor_plod_get_connected_state()) { |
|
|
|
state_machine__change_to_poweroning_state(); |
|
|
|
if (BoardBattery_get_battery_level() > APP_WORK_BATTERY_LEVEL) { |
|
|
|
state_machine__change_to_poweroning_state(); |
|
|
|
} else { |
|
|
|
BoardLight_blockFlash(3, 100); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 10秒后,如果RTC未被设置过,则进入超低功耗 |
|
|
@ -174,6 +179,9 @@ static void app_event_listener(void* p_event_data, uint16_t event_size) { |
|
|
|
if (!znordic_rtc_has_setted()) { |
|
|
|
ENTER_DEEP_SLEEP(); |
|
|
|
} |
|
|
|
if(APP_BATTERY_PROTECT_LEVEL > BoardBattery_get_battery_level()){ |
|
|
|
ENTER_DEEP_SLEEP(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -211,8 +219,15 @@ static void app_event_listener(void* p_event_data, uint16_t event_size) { |
|
|
|
// 如果用户继续保持静止,切换到采集页面 |
|
|
|
else if (BoardEcgSensor_plod_get_connected_state_after_filter() && ds_cur_state_haspassed_ms() > 1500) { |
|
|
|
// dsp_mgr_change_to_preparePage |
|
|
|
ds_change_to_state(kdevice_state_keep_still); |
|
|
|
dsp_mgr_change_to_preparePage(); |
|
|
|
if (!BoardBattery_get_charging_state()) { |
|
|
|
ds_change_to_state(kdevice_state_keep_still); |
|
|
|
dsp_mgr_change_to_preparePage(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 低电量,设备直接进入深度睡眠 |
|
|
|
else if (BoardBattery_get_battery_level() < APP_AUTO_STANDY_BATTERY_LEVEL) { |
|
|
|
state_machine__change_to_standby_state(); |
|
|
|
} |
|
|
|
// ZLOGI("bt:%d plod:%d has_disc:%d state:%d", zdatachannel_is_connected(), BoardEcgSensor_plod_get_connected_state_after_filter(), plod_state_has_disconnected_ms(), ds_cur_state_haspassed_ms()); |
|
|
|
} |
|
|
@ -382,6 +397,13 @@ void one_conduction_main() { |
|
|
|
BoardLight_Init(); |
|
|
|
BoardLight_load(); |
|
|
|
|
|
|
|
BoardBattery_load(); |
|
|
|
if (BoardBattery_get_battery_level() < APP_WORK_BATTERY_LEVEL) { |
|
|
|
BoardLight_blockFlash(3, 100); |
|
|
|
// 系统进入深度睡眠,进入深度睡眠前,使能唤醒引脚 |
|
|
|
ENTER_DEEP_SLEEP(); |
|
|
|
} |
|
|
|
|
|
|
|
ZERROR_CHECK(app_timer_create(&m_state_machine_driver_tmr, APP_TIMER_MODE_REPEATED, state_machine_driver_tmr_cb)); |
|
|
|
ZERROR_CHECK(app_timer_start(m_state_machine_driver_tmr, APP_TIMER_TICKS(300), NULL)); |
|
|
|
|
|
|
|