Browse Source

update

master
zhaohe 1 year ago
parent
commit
e3f5e580bb
  1. 2
      app/config/sdk_config.h
  2. 4
      app/src/app_basic_service/basic/event.h
  3. 4
      app/src/app_service/battery_mgr_service.c
  4. 12
      app/src/app_service/beep_ctrl.h
  5. 2
      app/src/app_service/display_ctrl_service/ssd1306_if_impl.c
  6. 158
      app/src/one_conduction_main.c
  7. 2
      libznordic

2
app/config/sdk_config.h

@ -5,7 +5,7 @@
#define NRF_LOG_BACKEND_UART_TX_PIN 41 #define NRF_LOG_BACKEND_UART_TX_PIN 41
// #define NRF_LOG_BACKEND_UART_TX_PIN 6 // #define NRF_LOG_BACKEND_UART_TX_PIN 6
#define APP_TIMER_CONFIG_USE_SCHEDULER 1
#define APP_TIMER_CONFIG_USE_SCHEDULER 0
// #define NRF_LOG_BACKEND_UART_BAUDRATE 121634816 // 400800 baud // #define NRF_LOG_BACKEND_UART_BAUDRATE 121634816 // 400800 baud
#define NRF_LOG_BACKEND_UART_BAUDRATE 268435456 // 1000000 baud #define NRF_LOG_BACKEND_UART_BAUDRATE 268435456 // 1000000 baud

4
app/src/app_basic_service/basic/event.h

@ -13,6 +13,10 @@ typedef enum {
kecg_data_report_event, // ecg数据上报事件 kecg_data_report_event, // ecg数据上报事件
kappevent_battery_start_charge, // kappevent_battery_start_charge, //
kappevent_battery_end_charge, // kappevent_battery_end_charge, //
kappevent_start_capture,
kappevent_stop_capture,
} app_event_type_t; } app_event_type_t;
typedef struct { typedef struct {

4
app/src/app_service/battery_mgr_service.c

@ -96,7 +96,9 @@ void battery_mgr_service_init() {
/** /**
* @brief 500ms启动定时器500ms检查一次当前是否正在充电 * @brief 500ms启动定时器500ms检查一次当前是否正在充电
*/ */
nrf_gpio_cfg_input(BATTERY_CHARGE_DETECT_PIN, NRF_GPIO_PIN_PULLUP);
// nrf_gpio_cfg_input(BATTERY_CHARGE_DETECT_PIN, NRF_GPIO_PIN_PULLUP);
nrf_gpio_cfg_sense_input(BATTERY_CHARGE_DETECT_PIN, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_NOSENSE);
app_timer_create(&battery_state_detect_tmr, APP_TIMER_MODE_REPEATED, module_tmr_cb); app_timer_create(&battery_state_detect_tmr, APP_TIMER_MODE_REPEATED, module_tmr_cb);
m_state = kstandy; m_state = kstandy;
} }

12
app/src/app_service/beep_ctrl.h

@ -6,15 +6,21 @@
#include "aproject_config/config.h" #include "aproject_config/config.h"
#include "znordic.h" #include "znordic.h"
#define START_SAMPLE_EFFECT kBoardBeepEffect_oneShortLongBeep
#define STOP_SAMPLE_EFFECT kBoardBeepEffect_oneShortLongBeep
#define POWER_ON_EFFECT kBoardBeepEffect_oneShortBeep
#define LEAD_OFF_EFFECT kBoardBeepEffect_continuousShortBeep
typedef enum { typedef enum {
kBoardBeepEffect_none = 0, kBoardBeepEffect_none = 0,
// //
kBoardBeepEffect_oneShortBeep, kBoardBeepEffect_oneShortBeep,
//
// ,
kBoardBeepEffect_oneShortLongBeep, kBoardBeepEffect_oneShortLongBeep,
//
// ,
kBoardBeepEffect_threeShortBeep, kBoardBeepEffect_threeShortBeep,
//
// ,
kBoardBeepEffect_continuousShortBeep, kBoardBeepEffect_continuousShortBeep,
} board_beep_effect_t; } board_beep_effect_t;

2
app/src/app_service/display_ctrl_service/ssd1306_if_impl.c

@ -35,7 +35,7 @@ void ssd1306_if_load() {
znrf_gpio_cfg_output(SCREEN_A0PIN, NRF_GPIO_PIN_NOPULL); znrf_gpio_cfg_output(SCREEN_A0PIN, NRF_GPIO_PIN_NOPULL);
nrf_gpio_pin_clear(SCREEN_RESET_PIN); nrf_gpio_pin_clear(SCREEN_RESET_PIN);
nrf_gpio_pin_clear(SCREEN_POWER_PIN);
nrf_gpio_pin_set(SCREEN_POWER_PIN);
nrf_gpio_pin_clear(SCREEN_A0PIN); nrf_gpio_pin_clear(SCREEN_A0PIN);
// //
// OLED驱动程序 : https://iflytop1.feishu.cn/wiki/OQ4Iwv0DpiQDJvkjftjcQHJBnCg // OLED驱动程序 : https://iflytop1.feishu.cn/wiki/OQ4Iwv0DpiQDJvkjftjcQHJBnCg

158
app/src/one_conduction_main.c

@ -14,6 +14,7 @@
#include "app_service/display_ctrl_service/display_mgr.h" #include "app_service/display_ctrl_service/display_mgr.h"
#include "app_service/ecg_service/ecg_service.h" #include "app_service/ecg_service/ecg_service.h"
#include "app_service/light_ctrl.h" #include "app_service/light_ctrl.h"
#include "zble_module.h"
/*********************************************************************************************************************** /***********************************************************************************************************************
* GLOBAL * * GLOBAL *
@ -21,6 +22,7 @@
static uint8_t bletxbuf[255]; static uint8_t bletxbuf[255];
static uint8_t blereportbuf[255]; static uint8_t blereportbuf[255];
static bool m_poweron_flag;
/******************************************************************************* /*******************************************************************************
* UTILS * * UTILS *
@ -48,9 +50,35 @@ static void send_success_receipt(ify_hrs_packet_t* rxpacket, int32_t emptydatasi
zdatachannel_data_send2(bletxbuf, sendlen); zdatachannel_data_send2(bletxbuf, sendlen);
} }
/*******************************************************************************
* *
*******************************************************************************/
/***********************************************************************************************************************
* *
***********************************************************************************************************************/
static void process_on_connect(void* arg) {
if (zapp_state_machine_now_state() == kstate_standby) {
zapp_state_machine_change_state(kstate_welcomPage);
}
if (m_poweron_flag) {
light_ctrl_set_green_light_effect(kLightEffect_slowFlash);
}
}
static void process_on_disconnect(void* arg) {
if (m_poweron_flag) {
light_ctrl_set_green_light_effect(kLightEffect_quickFlash);
}
}
void on_zble_event(zble_event_t* event) {
if (event->eventType == kzble_event_connected) {
zapp_exec_in_main_context(NULL, process_on_connect, NULL);
} else if (event->eventType == kzble_event_disconnected) {
zapp_exec_in_main_context(NULL, process_on_disconnect, NULL);
}
}
/***********************************************************************************************************************
* *
***********************************************************************************************************************/
void one_conduction_process_rx_packet(uint8_t* rx, int len) { void one_conduction_process_rx_packet(uint8_t* rx, int len) {
/** /**
* @brief * @brief
@ -155,14 +183,39 @@ void one_conduction_process_rx_packet(uint8_t* rx, int len) {
zdatachannel_data_send2(bletxbuf, sendlen); zdatachannel_data_send2(bletxbuf, sendlen);
} }
/***********************************************************************************************************************
* *
***********************************************************************************************************************/
else if (cmd == ify_hrs_cmd_start_realtime_preview) {
if (zapp_state_machine_now_state() != kstate_mainPage) {
send_error_receipt(rxheader, kifyhrs_ecode_device_busy);
return;
}
static app_event_t event;
event.eventType = kappevent_start_capture;
zapp_ebus_push_event(&event);
send_success_receipt(rxheader, 0);
}
else if (cmd == ify_hrs_cmd_stop_realtime_preview) {
if (zapp_state_machine_now_state() != kstate_mainPage) {
send_error_receipt(rxheader, kifyhrs_ecode_device_busy);
return;
}
static app_event_t event;
event.eventType = kappevent_stop_capture;
zapp_ebus_push_event(&event);
send_success_receipt(rxheader, 0);
}
else { else {
send_error_receipt(rxheader, kifyhrs_ecode_cmd_not_support); send_error_receipt(rxheader, kifyhrs_ecode_cmd_not_support);
} }
} }
/***********************************************************************************************************************
* *
***********************************************************************************************************************/
void on_state_change(device_state_t from, device_state_t to) { void on_state_change(device_state_t from, device_state_t to) {
/** /**
* @brief * @brief
@ -177,6 +230,11 @@ void on_state_change(device_state_t from, device_state_t to) {
dsp_mgr_load(); dsp_mgr_load();
// dsp_mgr_change_page(kpage_welcome); // dsp_mgr_change_page(kpage_welcome);
ecg_service_load(); ecg_service_load();
m_poweron_flag = true;
if (zble_module_is_connected()) {
light_ctrl_set_green_light_effect(kLightEffect_slowFlash);
}
} }
/** /**
@ -194,18 +252,87 @@ void on_state_change(device_state_t from, device_state_t to) {
// battery_mgr_service_change_state_to_standy(); // battery_mgr_service_change_state_to_standy();
hardware_power_mgr_main_power_supply_set(false); hardware_power_mgr_main_power_supply_set(false);
m_poweron_flag = false;
} }
if (to == kstate_welcomPage) {
// dsp_mgr_change_page(kpage_welcome);
zapp_state_machine_change_state(kstate_standby);
if (to == kstate_standby) {
dsp_mgr_change_page(kpage_poweroff);
} else if (to == kstate_welcomPage) {
dsp_mgr_change_page(kpage_welcome);
} else if (to == kstate_mainPage) {
dsp_mgr_change_page(kpage_main);
} else if (to == kstate_capture) {
dsp_mgr_change_page(kpage_sampling);
} else if (to == kstate_charging) {
dsp_mgr_change_page(kpage_charging_page);
} }
} }
void on_zapp_ebus_event(void* p_event_data, uint16_t event_size) {
/***********************************************************************************************************************
* *
***********************************************************************************************************************/
void on_zapp_ebus_event(void* p_event_data, uint16_t event_size) {
if (!p_event_data) return;
app_event_t* p_event = (app_event_t*)p_event_data;
if (zapp_state_machine_now_state() == kstate_standby) {
/**
* @brief
* 1.
*
*/
if (p_event->eventType == kappevent_battery_start_charge) {
zapp_state_machine_change_state(kstate_charging);
} else if (!znordic_rtc_has_setted() && zapp_state_machine_haspassed_ms() >= 60000) {
ZLOGI_BLOCK("rtc not setted, power system off");
ZERROR_CHECK(sd_power_system_off());
}
} else if (zapp_state_machine_now_state() == kstate_welcomPage) {
/**
* @brief
* 1.5s切换到主页面
*/
if (zapp_state_machine_haspassed_ms() >= 1500) {
zapp_state_machine_change_state(kstate_mainPage);
beep_set_effect(POWER_ON_EFFECT);
}
} else if (zapp_state_machine_now_state() == kstate_mainPage) {
/**
* @brief
* 1. ->
* 2. ->
* 3. ->
*
*/
if (zble_module_has_disconnected_ms() >= 3000) {
zapp_state_machine_change_state(kstate_standby);
} else if (p_event->eventType == kappevent_start_capture) {
zapp_state_machine_change_state(kstate_capture);
} else if (p_event->eventType == kappevent_battery_start_charge) {
zapp_state_machine_change_state(kstate_charging);
}
} else if (zapp_state_machine_now_state() == kstate_capture) {
/**
* @brief
* 1. ->MainPage
*/
if (p_event->eventType == kappevent_stop_capture) {
zapp_state_machine_change_state(kstate_mainPage);
}
} else if (zapp_state_machine_now_state() == kstate_charging) {
/**
* @brief
* 1. ->
*/
if (p_event->eventType == kappevent_battery_end_charge) {
if (!zble_module_is_connected()) {
zapp_state_machine_change_state(kstate_standby);
} else {
zapp_state_machine_change_state(kstate_mainPage);
}
}
}
} }
void one_conduction_main() { void one_conduction_main() {
@ -215,17 +342,20 @@ void one_conduction_main() {
ZLOG_FLUSH(); ZLOG_FLUSH();
zapp_ebus_reg_event_listener(on_zapp_ebus_event); zapp_ebus_reg_event_listener(on_zapp_ebus_event);
zapp_state_machine_reg_state_change_listener(on_state_change); zapp_state_machine_reg_state_change_listener(on_state_change);
zble_module_reglistener(on_zble_event);
adc_mgr_init(); adc_mgr_init();
hardware_power_mgr_init(); hardware_power_mgr_init();
battery_mgr_service_init(); battery_mgr_service_init();
battery_mgr_service_load();
light_ctrl_init(); light_ctrl_init();
beep_init(); beep_init();
dsp_mgr_init(); dsp_mgr_init();
ecg_service_init(); ecg_service_init();
zapp_state_machine_change_state(kstate_welcomPage);
// zapp_state_machine_change_state(kstate_standby);
zble_module_start_adv(); zble_module_start_adv();
zapp_start_schedule(); zapp_start_schedule();

2
libznordic

@ -1 +1 @@
Subproject commit 1d9ac0bb2d87ce60cbe742d2ddffa0b91c68acdd
Subproject commit 6fb5f63c43ea9866bef9eacd918ddd00468fa4f6
Loading…
Cancel
Save