Browse Source

update

master
zhaohe 1 year ago
parent
commit
968e830932
  1. 3
      .vscode/settings.json
  2. 6
      README.md
  3. 10
      app/src/app_basic_service/basic/event.h
  4. 6
      app/src/app_basic_service/basic/state.h
  5. 19
      app/src/app_basic_service/zapp.c
  6. 7
      app/src/app_basic_service/zapp.h
  7. 54
      app/src/app_service/display_ctrl_service/display_mgr.c
  8. 3
      app/src/app_service/display_ctrl_service/display_mgr.h
  9. 96
      app/src/app_service/display_ctrl_service/font.h
  10. 4
      app/src/app_service/ecg_service/ads129x_type.h
  11. 4
      app/src/app_service/ecg_service/algo/zsimple_qrs.h
  12. 20
      app/src/app_service/ecg_service/ecg_algo.c
  13. 7
      app/src/app_service/ecg_service/ecg_algo.h
  14. 68
      app/src/app_service/ecg_service/ecg_service.c
  15. 3
      app/src/app_service/ecg_service/ecg_service.h
  16. 2
      app/src/ble_data_processer_utils.c
  17. 263
      app/src/one_conduction_main.c
  18. BIN
      screen_res/PCtoLCD2002完美版.zip
  19. BIN
      screen_res/Snipaste_2024-01-26_20-00-58.png
  20. BIN
      screen_res/heartPulse.bmp
  21. 0
      screen_res/logo/Image2Lcd/Img2Lcd.exe
  22. 0
      screen_res/logo/Image2Lcd/Img2Lcd_chs.chm
  23. 0
      screen_res/logo/Image2Lcd/Img2Lcd_cht.chm
  24. 0
      screen_res/logo/Image2Lcd/emenu.dll
  25. 0
      screen_res/logo/Image2Lcd/sss.dll
  26. 0
      screen_res/logo/Image2Lcd/unins000.dat
  27. 0
      screen_res/logo/Image2Lcd/unins000.exe
  28. 0
      screen_res/logo/img2lcd_cfg.png
  29. 0
      screen_res/logo/logo_mono.bmp
  30. BIN
      screen_res/汉字生成/PC2LCD2021.exe
  31. BIN
      screen_res/汉字生成/字库生成配置.png
  32. BIN
      screen_res/汉字生成/字库生成配置2.png

3
.vscode/settings.json

@ -217,7 +217,8 @@
"nrf_fstorage_sd.h": "c",
"nrf_fstorage.h": "c",
"zdata_statistics.h": "c",
"iflytop_simple_filter.h": "c"
"iflytop_simple_filter.h": "c",
"state.h": "c"
},
"files.encoding": "gbk"
}

6
README.md

@ -91,6 +91,12 @@ State
全部使能
状态切换:
prepare:
```
```

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

@ -8,15 +8,19 @@
#define ECG_DATA_REPORT_FRAME_NUM 64 // ecg每次上报的帧数
typedef enum {
kappevent_tmr_scheduler_event,
kappevent_tmr_1s_scheduler_event,
kappevent_battery_start_charge, //
kappevent_battery_end_charge, //
kappevent_start_capture, //
kappevent_stop_capture, //
kappevent_start_capture, //
kappevent_stop_capture, //
kecg_data_report_event, // ecg数据上报事件
kappevent_state_machine_state_enter,
kappevent_state_machine_state_exit,
} app_event_type_t;
typedef struct {

6
app/src/app_basic_service/basic/state.h

@ -8,7 +8,9 @@ typedef enum {
kstate_welcomPage,
kstate_mainPage,
kstate_capture,
kstate_prepare_capture,
kstate_charging,
kstate_test,
} device_state_t;
static const char* device_state_to_str(device_state_t ds) {
@ -21,8 +23,12 @@ static const char* device_state_to_str(device_state_t ds) {
return "kstate_mainPage";
case kstate_capture:
return "kstate_capture";
case kstate_prepare_capture:
return "kstate_prepare_capture";
case kstate_charging:
return "kstate_charging";
case kstate_test:
return "kstate_test";
default:
return "unknown";
}

19
app/src/app_basic_service/zapp.c

@ -54,7 +54,7 @@ static void state_machine_driver_tmr_cb(void* p_context) { //
wd_feed();
static app_event_t appevent;
static uint8_t event_hang_up = 0;
appevent.eventType = kappevent_tmr_scheduler_event;
appevent.eventType = kappevent_tmr_1s_scheduler_event;
zapp_ebus_push_event_ext(&event_hang_up, &appevent);
}
@ -101,24 +101,29 @@ void zapp_start_schedule() { ZERROR_CHECK(app_timer_start(m_state_machine_driver
***********************************************************************************************************************/
void zapp_state_machine_reg_state_change_listener(on_state_change_t listener) { m_onstate_change = listener; }
// kappevent_state_machine_state_enter
// kappevent_state_machine_state_exit
#if 1
static void _zapp_state_machine_change_state(void* tostate_) {
device_state_t tostate = (device_state_t)tostate_;
ZLOGI("change state from %s to %s", device_state_to_str(m_device_state), device_state_to_str(tostate));
device_state_t nowstate = m_device_state;
m_device_state = tostate;
if (m_onstate_change) {
m_onstate_change(nowstate, m_device_state);
m_onstate_change(kstate_event_exit, m_device_state);
m_device_state = tostate;
m_onstate_change(kstate_event_enter, m_device_state);
}
m_change_to_cur_state_tp = znordic_getpower_on_ms();
}
#endif
void zapp_state_machine_change_state(device_state_t tostate) { //
uint32_t ret = zapp_exec_in_main_context(NULL, _zapp_state_machine_change_state, (void*)tostate);
if(ret != 0){
uint32_t ret = zapp_exec_in_main_context(NULL, _zapp_state_machine_change_state, (void*)tostate);
if (ret != 0) {
ZLOGE("zapp_state_machine_change_state failed");
ZASSERT(0);
}
}
device_state_t zapp_state_machine_now_state() { return m_device_state; }
uint32_t zapp_state_machine_haspassed_ms() { return znordic_haspassed_ms(m_change_to_cur_state_tp); }

7
app/src/app_basic_service/zapp.h

@ -7,7 +7,12 @@
#include "basic/gstate.h"
#include "basic/state.h"
typedef void (*on_state_change_t)(device_state_t from, device_state_t to);
typedef enum {
kstate_event_exit,
kstate_event_enter,
}state_machine_event_t;
typedef void (*on_state_change_t)(state_machine_event_t event, device_state_t page);
typedef void (*app_event_listener_t)(void* p_event_data, uint16_t event_size);
void zapp_early_init();

54
app/src/app_service/display_ctrl_service/display_mgr.c

@ -312,6 +312,46 @@ static void page_charging_page_tmr_cb() {
}
/***********************************************************************************************************************
* ²ÉÑù×¼±¸Ò³Ãæ *
***********************************************************************************************************************/
#if 1
static int m_prepare_page_progress = 0;
static void page_prepare_sample_show(int progress) {
m_prepare_page_progress = progress;
ssd1306_basic_clear_gram();
uint8_t x = 0;
uint8_t y = 0;
uint8_t xchange, ychange;
x = compute_x_pos_by_center(SCREEN_CENTER_X, font24x24_zh_lib.widthPixel * 4);
y = compute_y_pos_by_center(SCREEN_CENTER_Y, font24x24_zh_lib.heightPixel);
ssd1306_basic_draw_str(x, y, &xchange, &ychange, "±£³Ö¾²Ö¹", &font24x24_zh_lib);
if (progress == 0) {
ssd1306_basic_draw_str(x - font8x8_xo_lib.widthPixel, y - font8x8_xo_lib.heightPixel, &xchange, &ychange, "xxxx", &font8x8_xo_lib);
} else if (progress == 1) {
ssd1306_basic_draw_str(x - font8x8_xo_lib.widthPixel, y - font8x8_xo_lib.heightPixel, &xchange, &ychange, "oxxx", &font8x8_xo_lib);
} else if (progress == 2) {
ssd1306_basic_draw_str(x - font8x8_xo_lib.widthPixel, y - font8x8_xo_lib.heightPixel, &xchange, &ychange, "ooxx", &font8x8_xo_lib);
} else if (progress == 3) {
ssd1306_basic_draw_str(x - font8x8_xo_lib.widthPixel, y - font8x8_xo_lib.heightPixel, &xchange, &ychange, "ooox", &font8x8_xo_lib);
} else if (progress == 4) {
ssd1306_basic_draw_str(x - font8x8_xo_lib.widthPixel, y - font8x8_xo_lib.heightPixel, &xchange, &ychange, "oooo", &font8x8_xo_lib);
}
ssd1306_basic_gram_update();
}
static void page_sample_prepare_load() { page_prepare_sample_show(0); }
static void page_sample_prepare_unload() {}
static uint32_t page_sample_prepare_get_scheduler_period() { return 800; }
static void page_sample_prepare_tmr_cb() {
// m_prepare_page_progress++;
// if (m_prepare_page_progress > 4) m_prepare_page_progress = 4;
// page_sampling_error_show(m_prepare_page_progress);
}
#endif
/***********************************************************************************************************************
* EXTERN *
***********************************************************************************************************************/
@ -325,12 +365,17 @@ static void dsp_mgr_schedule_tmr_cb(void* p_context) { //
void dsp_mgr_init(void) {
ssd1306_if_init();
// kpage_samplePrepare
// page_samplePrepare
_PAGE_REG(page_poweroff);
_PAGE_REG(page_welcome);
_PAGE_REG(page_main);
_PAGE_REG(page_sampling);
_PAGE_REG(page_sampling_error);
_PAGE_REG(page_charging_page);
_PAGE_REG(page_sample_prepare);
ZERROR_CHECK(app_timer_create(&m_dsp_mgr_schedule_tmr, APP_TIMER_MODE_REPEATED, dsp_mgr_schedule_tmr_cb));
}
@ -341,11 +386,16 @@ void dsp_mgr_load(void) {
m_module_load = true;
}
void dsp_mgr_unload(void) {
m_module_load = false;
m_page = kpage_poweroff;
m_page = kpage_poweroff;
app_timer_stop(m_dsp_mgr_schedule_tmr);
ssd1306_if_unload();
}
void dsp_mgr_change_page(page_t page) { _page_change(page); }
/***********************************************************************************************************************
* UTILS *
***********************************************************************************************************************/
void dsp_mgr_page_sample_prepare_set_progress(uint16_t progress) { page_prepare_sample_show(progress); }

3
app/src/app_service/display_ctrl_service/display_mgr.h

@ -17,6 +17,7 @@ typedef enum {
kpage_poweroff,
kpage_welcome,
kpage_main,
kpage_sample_prepare,
kpage_sampling,
kpage_sampling_error,
kpage_charging_page,
@ -28,3 +29,5 @@ void dsp_mgr_load(void);
void dsp_mgr_unload(void);
void dsp_mgr_change_page(page_t page);
void dsp_mgr_page_sample_prepare_set_progress(uint16_t progress);

96
app/src/app_service/display_ctrl_service/font.h

@ -2,102 +2,6 @@
#include <stdint.h>
#include "ssd1306/fontlib.h"
#if 0
const uint8_t fontclocklib_code[] = {
0x00, 0x00, 0x00, 0x00, 0x7F, 0x80, 0x01, 0xFF, 0xE0, 0x03, 0xFF, 0xF0, 0x07, 0x80, 0x78, 0x06, //
0x00, 0x18, 0x04, 0x00, 0x08, 0x06, 0x00, 0x18, 0x07, 0x80, 0x78, 0x03, 0xFF, 0xF0, 0x01, 0xFF, //
0xE0, 0x00, 0x7F, 0x80, //
0x00, 0x00, 0x00, 0x02, 0x00, 0x10, 0x02, 0x00, 0x10, 0x02, 0x00, 0x10, 0x07, 0xFF, 0xF0, 0x0F, //
0xFF, 0xF0, 0x0F, 0xFF, 0xF0, 0x00, 0x00, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, //
0x00, 0x00, 0x00, 0x00, //
0x03, 0x80, 0x70, 0x07, 0x80, 0xF0, 0x0D, 0x81, 0xB0, 0x08, 0x03, 0x30, 0x08, 0x06, 0x30, 0x08, //
0x0C, 0x30, 0x0C, 0x38, 0x30, 0x0F, 0xF8, 0x30, 0x07, 0xF1, 0xF0, 0x03, 0xC1, 0xF0, 0x00, 0x00, //
0x00, 0x00, 0x00, 0x00, //
0x03, 0x81, 0xC0, 0x07, 0x81, 0xE0, 0x0F, 0x81, 0xF0, 0x08, 0x10, 0x10, 0x08, 0x10, 0x10, 0x0C, //
0x30, 0x10, 0x0F, 0xF8, 0x30, 0x07, 0xEF, 0xF0, 0x03, 0xCF, 0xE0, 0x00, 0x03, 0xC0, 0x00, 0x00, //
0x00, 0x00, 0x00, 0x00, //
0x00, 0x06, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x3A, 0x00, 0x00, 0xE2, 0x00, 0x01, 0xC2, 0x10, 0x07, //
0x02, 0x10, 0x0F, 0xFF, 0xF0, 0x1F, 0xFF, 0xF0, 0x1F, 0xFF, 0xF0, 0x00, 0x02, 0x10, 0x00, 0x02, //
0x10, 0x00, 0x00, 0x00, //
0x00, 0x01, 0xC0, 0x0F, 0xF9, 0xE0, 0x0F, 0xF9, 0xB0, 0x0C, 0x30, 0x10, 0x0C, 0x20, 0x10, 0x0C, //
0x20, 0x10, 0x0C, 0x30, 0x70, 0x0C, 0x3F, 0xF0, 0x0C, 0x1F, 0xE0, 0x0C, 0x0F, 0x80, 0x00, 0x00, //
0x00, 0x00, 0x00, 0x00, //
0x00, 0x7F, 0x00, 0x03, 0xFF, 0xC0, 0x07, 0xFF, 0xE0, 0x07, 0x18, 0x70, 0x0C, 0x30, 0x30, 0x08, //
0x20, 0x10, 0x08, 0x20, 0x10, 0x0E, 0x30, 0x30, 0x0E, 0x3F, 0xE0, 0x06, 0x1F, 0xE0, 0x00, 0x0F, //
0x80, 0x00, 0x00, 0x00, //
0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x0F, 0x80, 0x00, 0x0E, 0x00, 0x00, 0x0C, 0x01, 0xF0, 0x0C, //
0x0F, 0xF0, 0x0C, 0x3F, 0xF0, 0x0D, 0xF0, 0x00, 0x0F, 0xC0, 0x00, 0x0E, 0x00, 0x00, 0x0C, 0x00, //
0x00, 0x00, 0x00, 0x00, //
0x03, 0xC3, 0xC0, 0x07, 0xEF, 0xE0, 0x0F, 0xEF, 0xE0, 0x0C, 0x78, 0x30, 0x08, 0x30, 0x10, 0x08, //
0x38, 0x10, 0x08, 0x18, 0x10, 0x0C, 0x3C, 0x30, 0x0F, 0xEF, 0xF0, 0x07, 0xE7, 0xE0, 0x03, 0x83, //
0xC0, 0x00, 0x00, 0x00, //
0x01, 0xF0, 0x00, 0x07, 0xF8, 0x60, 0x07, 0xFC, 0x70, 0x0E, 0x0C, 0x70, 0x08, 0x04, 0x10, 0x08, //
0x04, 0x10, 0x08, 0x0C, 0x30, 0x0E, 0x19, 0xE0, 0x07, 0xFF, 0xE0, 0x03, 0xFF, 0x80, 0x00, 0xFE, //
0x00, 0x00, 0x00, 0x00, //
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x70, 0x00, //
0xE0, 0x70, 0x00, 0xE0, 0x70, 0x00, 0xE0, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //
0x00, 0x00, 0x00, 0x00, //
};
static FontLibrary_t fontclocklib = {
.font = fontclocklib_code,
.fontIndex = "0123456789:",
.fontIndexLen = 12,
.fontCode = kgbk,
.isAscii = true,
.widthPixel = 24,
.heightPixel = 24,
};
#endif
// DB 00H 00H 07H F0H 0FH F8H 18H 0CH 10H 04H 18H 0CH 0FH F8H 07H F0H;"0",0
// DB 10H 08H 10H 08H 3FH F8H 3FH F8H 00H 08H 00H 08H 00H 00H 00H 00H;"1",1
// DB 1CH 18H 3CH 38H 20H 68H 20H C8H 23H 88H 3FH 18H 1CH 18H 00H 00H;"2",2
// DB 18H 30H 38H 38H 22H 08H 22H 08H 27H 18H 3DH F0H 18H E0H 00H 00H;"3",3
// DB 01H C0H 07H C0H 0EH 48H 18H 48H 3FH F8H 3FH F8H 00H 48H 00H 00H;"4",4
// DB 3FH 30H 3FH 38H 23H 08H 22H 08H 23H 18H 21H F0H 20H E0H 00H 00H;"5",5
// DB 0FH E0H 1FH F0H 33H 18H 22H 08H 33H 18H 31H F0H 00H E0H 00H 00H;"6",6
// DB 38H 00H 38H 00H 21H F8H 27H F8H 3EH 00H 38H 00H 20H 00H 00H 00H;"7",7
// DB 1CH 70H 3EH F8H 23H 88H 21H 08H 23H 88H 3EH F8H 1CH 70H 00H 00H;"8",8
// DB 0EH 00H 1FH 18H 31H 98H 20H 88H 31H 98H 1FH F0H 0FH E0H 00H 00H;"9",9
// DB 00H 00H 00H 00H 06H 18H 06H 18H 06H 18H 00H 00H 00H 00H 00H 00H;":",10
#if 0
//32*32
const uint8_t fontclocklib_code[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0x40, 0x40, 0xC0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFE, 0xFF, 0x0F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0xFF, 0xFE, 0xF0,
0x00, 0x00, 0x1F, 0xFF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x06, 0x04, 0x04, 0x06, 0x07, 0x03, 0x01, 0x00, 0x00, /*"0",0*/
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x06, 0x07, 0x07, 0x07, 0x06, 0x04, 0x04, 0x04, 0x00, 0x00, /*"1",1*/
0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0x40, 0x40, 0x40, 0x40, 0xC0, 0xC0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x1F, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC1, 0xFF, 0x7F, 0x3E, 0x00,
0x00, 0x00, 0x00, 0x80, 0xC0, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x07, 0x07, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x07, 0x07, 0x01, 0x00, /*"2",2*/
0x00, 0x00, 0x00, 0x80, 0x80, 0xC0, 0x40, 0x40, 0x40, 0xC0, 0xC0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x0F, 0x00, 0x80, 0x80, 0x80, 0xC0, 0xE1, 0x7F, 0x3F, 0x1E, 0x00, 0x00,
0x00, 0x00, 0xE0, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0xFF, 0xFE, 0x78, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x06, 0x04, 0x04, 0x04, 0x04, 0x06, 0x03, 0x03, 0x01, 0x00, 0x00, /*"3",3*/
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0, 0x70, 0x3C, 0x0E, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00,
0x00, 0x10, 0x1C, 0x1E, 0x13, 0x11, 0x10, 0x10, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x0F, 0x0F, 0x0F, 0x0F, 0x08, 0x08, 0x08, /*"4",4*/
0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xC7, 0x60, 0x20, 0x20, 0x20, 0x60, 0xE0, 0xC0, 0x80, 0x00, 0x00,
0x00, 0x00, 0xE0, 0xE1, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0xFF, 0x7E, 0x00, 0x00, 0x00, 0x01, 0x03, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x06, 0x03, 0x03, 0x01, 0x00, 0x00, /*"5",5*/
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0x40, 0x40, 0x40, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFC, 0xFE, 0x8F, 0x81, 0xC0, 0x40, 0x40, 0x40, 0xC0, 0xC3, 0x83, 0x03, 0x00,
0x00, 0x00, 0x3F, 0xFF, 0xFF, 0xC3, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x06, 0x04, 0x04, 0x04, 0x06, 0x03, 0x03, 0x01, 0x00, /*"6",6*/
0x00, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x03, 0x01, 0x00, 0x00, 0x80, 0xE0, 0x78, 0x1E, 0x07, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFC, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*"7",7*/
0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0x40, 0x40, 0x40, 0xC0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x3F, 0x7F, 0xF1, 0xE0, 0xC0, 0x80, 0x80, 0x80, 0xE1, 0x7F, 0x3F, 0x1E, 0x00,
0x00, 0xF8, 0xFC, 0xFE, 0x07, 0x03, 0x01, 0x01, 0x01, 0x03, 0x07, 0x0F, 0xFE, 0xFC, 0xF8, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x06, 0x04, 0x04, 0x04, 0x04, 0x06, 0x03, 0x03, 0x01, 0x00, 0x00, /*"8",8*/
0x00, 0x00, 0x00, 0x80, 0x80, 0xC0, 0x40, 0x40, 0x40, 0x40, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x83, 0xFF, 0xFE, 0xF8, 0x00,
0x00, 0x00, 0x81, 0x83, 0x87, 0x06, 0x04, 0x04, 0x04, 0x06, 0x83, 0xF3, 0xFF, 0x7F, 0x0F, 0x00, 0x00, 0x00, 0x03, 0x03, 0x07, 0x04, 0x04, 0x04, 0x06, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, /*"9",9*/
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xE0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x81, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x07, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, /*":",10*/
};
static FontLibrary_t fontclocklib = {
.font = fontclocklib_code,
.fontIndex = "0123456789:",
.fontIndexLen = 12,
.fontCode = kgbk,
.isAscii = true,
.widthPixel = 16,
.heightPixel = 32,
};
#endif
// 24*24
const uint8_t fontclocklib_code[] = {

4
app/src/app_service/ecg_service/ads129x_type.h

@ -47,8 +47,8 @@ typedef struct {
uint8_t gpio0;
uint8_t gpio1;
uint32_t ch1data;
uint32_t ch2data;
int32_t ch1data;
int32_t ch2data;
} ads129x_capture_data_t;

4
app/src/app_service/ecg_service/algo/zsimple_qrs.h

@ -9,10 +9,10 @@
/**
* @brief
* 200,0.3s0.15s
* 200,0.3s0.25s
*
*/
#define PEAK_MIN_INTERVAL 0.15
#define PEAK_MIN_INTERVAL 0.25
#define HEART_RATE_BUF_SIZE 10

20
app/src/app_service/ecg_service/ecg_algo.c

@ -13,6 +13,7 @@ int32_t m_data_statistics_buf[STATISTICS_BUF_SIZE]; //
zdata_statistics_t m_data_statistics;
zsimple_qrs_t m_qrs;
int32_t data_af_high_pass_filter;
int32_t reportdata;
int32_t displaydata;
@ -26,9 +27,11 @@ int32_t maxval;
int32_t minval;
int32_t nowval100;
void ecg_algo_process_data(int32_t indata) {
float data = indata;
float data = indata;
data = HPFilterExt_update(&m_hp_filter, data);
data_af_high_pass_filter = data;
data = LPFilterExt_update(&m_lp_filter, data);
data = HPFilterExt_update(&m_hp_filter, data);
data = NOTCHFilterExt_update(&m_notch_filter, data);
reportdata = data;
@ -48,11 +51,13 @@ void ecg_algo_process_data(int32_t indata) {
displaydata = nowval100;
} else {
maxval = 0;
minval = 0;
displaydata = 50;
}
}
void ecg_algo_reset() {
LPFilterExt_init(&m_lp_filter, 40, SAMPLE_PERIOD_S, 9, true);
LPFilterExt_init(&m_lp_filter, 40, SAMPLE_PERIOD_S, 13, true);
HPFilterExt_init(&m_hp_filter, 1, SAMPLE_PERIOD_S, 1, true);
NOTCHFilterExt_init(&m_notch_filter, 50, 10, SAMPLE_PERIOD_S, 3, false);
zdata_statistics_clear(&m_data_statistics);
@ -62,3 +67,12 @@ void ecg_algo_reset() {
int32_t ecg_algo_get_report_data() { return reportdata; }
int32_t ecg_algo_get_display_data() { return displaydata; }
int32_t ecg_algo_get_heart_rate() { return zsimple_qrs_get_heartrate(&m_qrs); }
int32_t ecg_algo_get_raw_data() { return data_af_high_pass_filter; }
int32_t ecg_algo_get_max_data() { return maxval; }
int32_t ecg_algo_get_min_data() { return minval; }
int32_t ecg_algo_get_peak2peak() { return maxval - minval; }
int32_t ecg_algo_get_data_after_high_pass_filter_data() { return data_af_high_pass_filter; }
// maxval
// minval

7
app/src/app_service/ecg_service/ecg_algo.h

@ -4,7 +4,7 @@
#include "app_basic_service/zapp.h"
#define SAMPLE_PERIOD_S ( (float)(1.0/SAMPLE_RATE))
#define SAMPLE_PERIOD_S ((float)(1.0 / SAMPLE_RATE))
#define STATISTICS_BUF_SIZE ((int32_t)(2 / SAMPLE_PERIOD_S))
void ecg_algo_init();
@ -14,3 +14,8 @@ void ecg_algo_reset();
int32_t ecg_algo_get_report_data();
int32_t ecg_algo_get_display_data();
int32_t ecg_algo_get_heart_rate();
int32_t ecg_algo_get_data_after_high_pass_filter_data();
int32_t ecg_algo_get_max_data();
int32_t ecg_algo_get_min_data();
int32_t ecg_algo_get_peak2peak();

68
app/src/app_service/ecg_service/ecg_service.c

@ -14,6 +14,8 @@ static nrf_drv_spi_t ads129x_spi = NRF_DRV_SPI_INSTANCE(ADS1291_SPI_INSTA
static nrf_drv_spi_config_t ads129x_spi_config;
static bool m_testmode_flag;
static bool m_report_data_in_raw_mode_flag;
static bool m_leadoffstate;
uint8_t m_leadoff_raw_state;
/***********************************************************************************************************************
* PRIVATE_FUNC *
@ -191,6 +193,51 @@ static bool ads129x_ping() {
* PUBLIC_FUNC *
***********************************************************************************************************************/
static void leadoff_state_process(ads129x_capture_data_t* capture_data) {
/**
* @brief
* ecg脱落检测逻辑
* 1. 15000
* 2. ecg_leadoff状态被触发
* 3. 500
*
* 1.5s内均非脱落状态
*
*
* 2ms, 1.5s = 750
*/
static uint32_t un_leadoffcnt = 0;
bool leadoff = false;
if (ecg_algo_get_peak2peak() > 15000) {
leadoff = true;
}
if (ecg_algo_get_peak2peak() < 500) {
leadoff = true;
}
if (ecg_algo_get_data_after_high_pass_filter_data() > 25000 || ecg_algo_get_data_after_high_pass_filter_data() < -25000) {
leadoff = true;
}
// if (capture_data->loffstate & 0x3) {
// leadoff = true;
// }
if (leadoff) {
un_leadoffcnt = 0;
} else {
un_leadoffcnt++;
}
if (leadoff != m_leadoffstate) {
if (m_leadoffstate && un_leadoffcnt > 750) {
m_leadoffstate = false;
} else {
m_leadoffstate = true;
}
}
}
static void ads1291_ready_pin_irq(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) {
static ads129x_capture_data_t capture_data;
//
@ -198,15 +245,21 @@ static void ads1291_ready_pin_irq(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t a
//
ecg_algo_process_data(capture_data.ch1data);
leadoff_state_process(&capture_data);
//
one_frame_t frame;
if (m_report_data_in_raw_mode_flag) {
frame.data = capture_data.ch1data;
frame.data = ecg_algo_get_data_after_high_pass_filter_data();
} else {
frame.data = ecg_algo_get_report_data();
}
frame.leadoff = capture_data.loffstate;
if (m_leadoffstate) {
frame.leadoff = 0x3;
} else {
frame.leadoff = 0;
}
m_leadoff_raw_state = capture_data.loffstate;
ecg_data_mgr_push_one_frame(frame);
}
@ -279,7 +332,7 @@ void ecg_service_load() {
regcache.loff = 0xF1;
regcache.ch1set = 0x00;
regcache.ch2set = 0x81;
regcache.rld_sens = 0x20;
regcache.rld_sens = 0x00;
regcache.loff_sens = 0x03;
ads129x_write_regs(&regcache);
@ -311,8 +364,10 @@ void ecg_service_unload() {
}
static uint32_t ecg_service_captured_time = 0;
static bool m_work_state;
void ecg_service_start_capture() { //
if (m_work_state) return;
void ecg_service_start_capture() { //
ecg_data_mgr_clear_buffer();
if (m_testmode_flag) {
@ -329,9 +384,12 @@ void ecg_service_start_capture() { //
ads129x_send_cmd(ADS129X_COMMAND_START); /* 发送开始数据转换(等效于拉高START引脚) */
ecg_service_captured_time = znordic_getpower_on_ms();
m_leadoffstate = true;
m_work_state = true;
}
void ecg_service_stop_capture() { //
ads129x_send_cmd(ADS129X_COMMAND_STOP); /* 发送停止数据转换(等效于拉低START引脚) */
m_work_state = false;
}
uint32_t ecg_service_has_captured_time() { return znordic_haspassed_ms(ecg_service_captured_time); }
void ecg_service_subic_write_reg(uint8_t addr, uint8_t val) {
@ -354,3 +412,5 @@ void ecg_service_set_in_test_mode(bool testmode) {
}
void ecg_service_set_report_data_in_raw_mode(bool rawmode) { m_report_data_in_raw_mode_flag = rawmode; }
bool ecg_leadoff_detect() { return m_leadoffstate; }

3
app/src/app_service/ecg_service/ecg_service.h

@ -37,3 +37,6 @@ uint8_t ecg_service_subic_read_reg(uint8_t addr);
void ecg_service_set_in_test_mode(bool testmode);
void ecg_service_set_report_data_in_raw_mode(bool rawmode);
bool ecg_leadoff_detect();

2
app/src/ble_data_processer_utils.c

@ -58,7 +58,7 @@ void report_ecg_data(app_event_t* data) {
for (int i = 0; i < ECG_DATA_REPORT_FRAME_NUM; i++) {
leadoffstate |= data->val.ecg_data_report_event.ecgData->frame[i].leadoff;
}
reportpacket->leadoff_state = leadoffstate & 0x3;
zdatachannel_data_send2(blereportbuf, //
sizeof(m1003_heartrate_report_packet_t) + ECG_DATA_REPORT_FRAME_NUM * sizeof(reportpacket->frame[0]));
}

263
app/src/one_conduction_main.c

@ -24,7 +24,8 @@
* GLOBAL *
***********************************************************************************************************************/
static bool m_poweron_flag;
static bool m_poweron_flag;
static uint16_t m_capture_prepare_progress = 0;
/*******************************************************************************
* UTILS *
@ -199,8 +200,6 @@ void one_conduction_process_rx_packet(uint8_t* rx, int len) {
send_success_receipt(rxheader, 0);
}
else if (cmd == ify_hrs_cmd_ecg_subic_read_reg) {
uint8_t addr = *(uint8_t*)rxheader->data;
uint8_t val = ecg_service_subic_read_reg(addr);
@ -221,75 +220,6 @@ void one_conduction_process_rx_packet(uint8_t* rx, int len) {
}
/***********************************************************************************************************************
* *
***********************************************************************************************************************/
void on_state_change(device_state_t from, device_state_t to) {
if (from == to) return;
/**
* @brief 退
*/
if (from == kstate_standby) {
/**
* @brief
*/
ZLOGI("power on");
hardware_power_mgr_main_power_supply_set(true);
battery_mgr_service_change_state_to_poweron();
beep_load();
light_ctrl_load();
dsp_mgr_load();
dsp_mgr_change_page(kpage_welcome);
ecg_service_load();
m_poweron_flag = true;
if (zble_module_is_connected()) {
light_ctrl_set_green_light_effect(kLightEffect_slowFlash);
}
} else if (from == kstate_welcomPage) {
} else if (from == kstate_mainPage) {
} else if (from == kstate_capture) {
ecg_service_stop_capture();
beep_set_effect(STOP_SAMPLE_EFFECT);
} else if (from == kstate_charging) {
}
/**
* @brief
*/
if (to == kstate_standby) {
/**
* @brief
*/
ZLOGI("power off");
dsp_mgr_change_page(kpage_poweroff);
battery_mgr_service_change_state_to_standy();
beep_unload();
light_ctrl_unload();
dsp_mgr_unload();
ecg_service_unload();
// battery_mgr_service_change_state_to_standy();
hardware_power_mgr_main_power_supply_set(false);
m_poweron_flag = false;
} 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);
ecg_service_start_capture();
beep_set_effect(START_SAMPLE_EFFECT);
} else if (to == kstate_charging) {
dsp_mgr_change_page(kpage_charging_page);
}
}
/***********************************************************************************************************************
* *
***********************************************************************************************************************/
@ -300,22 +230,61 @@ 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 (p_event->eventType == kappevent_tmr_scheduler_event) {
if (p_event->eventType == kappevent_tmr_1s_scheduler_event) {
// ZLOGI("tmr event. %d %d %d", nowval100, minval, maxval);
ZLOGI("tmr event.");
// ZLOGI("tmr event.");
}
app_event_type_t event = p_event->eventType;
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 (!device_info_get_active_flag() && zapp_state_machine_haspassed_ms() >= 60000) {
ZLOGI_BLOCK("rtc not setted, power system off");
ZERROR_CHECK(sd_power_system_off());
if (event == kappevent_state_machine_state_enter) {
/**
* @brief
*/
ZLOGI("power off");
dsp_mgr_change_page(kpage_poweroff);
battery_mgr_service_change_state_to_standy();
beep_unload();
light_ctrl_unload();
dsp_mgr_unload();
ecg_service_unload();
// battery_mgr_service_change_state_to_standy();
hardware_power_mgr_main_power_supply_set(false);
m_poweron_flag = false;
} else if (event == kappevent_state_machine_state_exit) {
/**
* @brief
*/
ZLOGI("power on");
hardware_power_mgr_main_power_supply_set(true);
battery_mgr_service_change_state_to_poweron();
beep_load();
light_ctrl_load();
dsp_mgr_load();
ecg_service_load();
m_poweron_flag = true;
if (zble_module_is_connected()) {
light_ctrl_set_green_light_effect(kLightEffect_slowFlash);
}
} else {
if (p_event->eventType == kappevent_battery_start_charge) {
zapp_state_machine_change_state(kstate_charging);
} else if (!device_info_get_active_flag() && 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) {
@ -323,11 +292,17 @@ void on_zapp_ebus_event(void* p_event_data, uint16_t event_size) {
* @brief
* 1.5s切换到主页面
*/
if (p_event->eventType == kappevent_start_capture) {
zapp_state_machine_change_state(kstate_capture);
} else if (zapp_state_machine_haspassed_ms() >= 2000) {
zapp_state_machine_change_state(kstate_mainPage);
beep_set_effect(POWER_ON_EFFECT);
if (event == kappevent_state_machine_state_enter) {
dsp_mgr_change_page(kpage_welcome);
} else if (event == kappevent_state_machine_state_exit) {
} else {
if (p_event->eventType == kappevent_start_capture) {
zapp_state_machine_change_state(kstate_prepare_capture);
} else if (zapp_state_machine_haspassed_ms() >= 2000) {
zapp_state_machine_change_state(kstate_mainPage);
beep_set_effect(POWER_ON_EFFECT);
}
}
} else if (zapp_state_machine_now_state() == kstate_mainPage) {
@ -338,40 +313,120 @@ void on_zapp_ebus_event(void* p_event_data, uint16_t event_size) {
* 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);
if (event == kappevent_state_machine_state_enter) {
dsp_mgr_change_page(kpage_main);
} else if (event == kappevent_state_machine_state_exit) {
} else {
if (zble_module_has_disconnected_ms() >= 3000) {
zapp_state_machine_change_state(kstate_standby);
} else if (event == kappevent_start_capture) {
zapp_state_machine_change_state(kstate_prepare_capture);
} else if (event == kappevent_battery_start_charge) {
zapp_state_machine_change_state(kstate_charging);
}
}
} else if (zapp_state_machine_now_state() == kstate_capture) {
} else if (zapp_state_machine_now_state() == kstate_prepare_capture) {
/**
* @brief
* 1. ->MainPage
* 2. ->
* 3. leadoff状态
*/
if (event == kappevent_state_machine_state_enter) {
m_capture_prepare_progress = 0;
dsp_mgr_change_page(kpage_sample_prepare);
ecg_service_start_capture();
beep_set_effect(START_SAMPLE_EFFECT);
} else if (event == kappevent_state_machine_state_exit) {
} else {
if (zble_module_has_disconnected_ms() >= 1000) {
ecg_service_stop_capture();
zapp_state_machine_change_state(kstate_standby);
} else if (event == kappevent_stop_capture) {
ecg_service_stop_capture();
zapp_state_machine_change_state(kstate_mainPage);
} else {
if (event == kappevent_tmr_1s_scheduler_event) {
if (ecg_leadoff_detect()) {
m_capture_prepare_progress = 0;
dsp_mgr_page_sample_prepare_set_progress(m_capture_prepare_progress / 2);
} else {
if (m_capture_prepare_progress < 4 * 2) {
m_capture_prepare_progress++;
dsp_mgr_page_sample_prepare_set_progress(m_capture_prepare_progress / 2);
} else {
zapp_state_machine_change_state(kstate_capture);
}
}
}
}
}
if (zble_module_has_disconnected_ms() >= 1000) {
zapp_state_machine_change_state(kstate_standby);
} else if (p_event->eventType == kappevent_stop_capture) {
zapp_state_machine_change_state(kstate_mainPage);
} else if (p_event->eventType == kecg_data_report_event) {
report_ecg_data(p_event);
} else if (zapp_state_machine_now_state() == kstate_capture) {
/**
* @brief
* 1. ->MainPage
* 2. ->
*/
if (event == kappevent_state_machine_state_enter) {
ecg_service_start_capture();
dsp_mgr_change_page(kpage_sampling);
} else if (event == kappevent_state_machine_state_exit) {
ecg_service_stop_capture();
beep_set_effect(STOP_SAMPLE_EFFECT);
} else {
if (zble_module_has_disconnected_ms() >= 1000) {
zapp_state_machine_change_state(kstate_standby);
} else if (event == kappevent_stop_capture) {
zapp_state_machine_change_state(kstate_mainPage);
} else if (event == kecg_data_report_event) {
report_ecg_data(p_event);
}
}
} 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);
if (event == kappevent_state_machine_state_enter) {
dsp_mgr_change_page(kpage_charging_page);
} else if (event == kappevent_state_machine_state_exit) {
} else {
if (event == kappevent_battery_end_charge) {
if (!zble_module_is_connected()) {
zapp_state_machine_change_state(kstate_standby);
} else {
zapp_state_machine_change_state(kstate_mainPage);
}
}
}
} else if (zapp_state_machine_now_state() == kstate_test) {
// extern int32_t maxval;
// extern int32_t minval;
extern uint8_t m_leadoff_raw_state;
ZLOGI("tmr event. %d %x", ecg_leadoff_detect(), m_leadoff_raw_state);
}
}
/***********************************************************************************************************************
* *
***********************************************************************************************************************/
void on_state_change(state_machine_event_t event, device_state_t state) {
/**
* @brief 退
*/
static app_event_t appevent;
if (event == kstate_event_enter) {
appevent.eventType = kappevent_state_machine_state_enter;
on_zapp_ebus_event(&appevent, sizeof(app_event_t));
} else {
appevent.eventType = kappevent_state_machine_state_exit;
on_zapp_ebus_event(&appevent, sizeof(app_event_t));
}
}
@ -398,7 +453,7 @@ void one_conduction_main() {
dsp_mgr_init();
ecg_service_init();
// zapp_state_machine_change_state(kstate_standby);
// zapp_state_machine_change_state(kstate_test);
zble_module_start_adv();
zapp_start_schedule();

BIN
screen_res/PCtoLCD2002完美版.zip

BIN
screen_res/Snipaste_2024-01-26_20-00-58.png

Before

Width: 482  |  Height: 281  |  Size: 17 KiB

BIN
screen_res/heartPulse.bmp

0
screen_res/Image2Lcd/Img2Lcd.exe → screen_res/logo/Image2Lcd/Img2Lcd.exe

0
screen_res/Image2Lcd/Img2Lcd_chs.chm → screen_res/logo/Image2Lcd/Img2Lcd_chs.chm

0
screen_res/Image2Lcd/Img2Lcd_cht.chm → screen_res/logo/Image2Lcd/Img2Lcd_cht.chm

0
screen_res/Image2Lcd/emenu.dll → screen_res/logo/Image2Lcd/emenu.dll

0
screen_res/Image2Lcd/sss.dll → screen_res/logo/Image2Lcd/sss.dll

0
screen_res/Image2Lcd/unins000.dat → screen_res/logo/Image2Lcd/unins000.dat

0
screen_res/Image2Lcd/unins000.exe → screen_res/logo/Image2Lcd/unins000.exe

0
screen_res/img2lcd_cfg.png → screen_res/logo/img2lcd_cfg.png

Before

Width: 716  |  Height: 524  |  Size: 23 KiB

After

Width: 716  |  Height: 524  |  Size: 23 KiB

0
screen_res/logo_mono.bmp → screen_res/logo/logo_mono.bmp

BIN
screen_res/汉字生成/PC2LCD2021.exe

BIN
screen_res/汉字生成/字库生成配置.png

After

Width: 1532  |  Height: 697  |  Size: 456 KiB

BIN
screen_res/汉字生成/字库生成配置2.png

After

Width: 1526  |  Height: 751  |  Size: 73 KiB

Loading…
Cancel
Save