From 070ed790481b5bf87ec4066878098711a43d3dee Mon Sep 17 00:00:00 2001 From: zhaohe Date: Thu, 9 May 2024 19:54:54 +0800 Subject: [PATCH] v2 --- app/src/app_service/beep_ctrl.h | 3 +- .../app_service/display_ctrl_service/display_mgr.c | 43 +++++++++++++++++++--- app/src/app_service/ecg_service/ecg_service.c | 2 +- app/src/aproject_config/config.h | 4 +- app/src/one_conduction_main.c | 12 +++--- screen_res/font/data/config/array2ImgFrom.table | 13 ++++--- screen_res/font/data/config/arrayCfg.table | 2 +- screen_res/font/data/config/bottomFrom.table | 3 +- scripter/flash.bat | 38 +++++++++++++++++-- temp.txt | 1 + 10 files changed, 94 insertions(+), 27 deletions(-) create mode 100644 temp.txt diff --git a/app/src/app_service/beep_ctrl.h b/app/src/app_service/beep_ctrl.h index f62416b..5b75af1 100644 --- a/app/src/app_service/beep_ctrl.h +++ b/app/src/app_service/beep_ctrl.h @@ -10,7 +10,8 @@ #define START_SAMPLE_EFFECT kBoardBeepEffect_oneShortLongBeep #define STOP_SAMPLE_EFFECT kBoardBeepEffect_oneShortLongBeep #define POWER_ON_EFFECT kBoardBeepEffect_oneShortBeep -#define LEAD_OFF_EFFECT kBoardBeepEffect_continuousShortBeep +#define LEAD_OFF_EFFECT kBoardBeepEffect_threeShortBeep +#define LEAD_OFF_RECOVER_EFFECT kBoardBeepEffect_oneShortBeep typedef enum { kBoardBeepEffect_none = 0, diff --git a/app/src/app_service/display_ctrl_service/display_mgr.c b/app/src/app_service/display_ctrl_service/display_mgr.c index 14a8217..08fc40d 100644 --- a/app/src/app_service/display_ctrl_service/display_mgr.c +++ b/app/src/app_service/display_ctrl_service/display_mgr.c @@ -11,9 +11,9 @@ #include "ssd1306/driver_ssd1306_basic.h" #include "ssd1306/wave_drawer.h" // +#include "app_service/beep_ctrl.h" #include "app_service/ecg_service/ecg_service.h" #include "ssd1306_if_impl.h" - /*********************************************************************************************************************** * MARCO * ***********************************************************************************************************************/ @@ -165,11 +165,32 @@ typedef struct { int heartrate_x; int heartrate_y; + + bool in_error_page; } sample_page_state_t; sample_page_state_t m_sample_page_state; +static void page_sampling_show_error_info() { + if (m_sample_page_state.in_error_page) { + return; + } + m_sample_page_state.in_error_page = true; + 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); + + ssd1306_basic_gram_update(); +} + static void page_sampling_load() { - sample_page_state_t* sps = &m_sample_page_state; + m_sample_page_state.in_error_page = false; + sample_page_state_t* sps = &m_sample_page_state; sps->progress_x = SMAPLE_PAGE_START_X + 10; sps->progress_y = SMAPLE_PAGE_START_Y + 3; @@ -208,7 +229,8 @@ static void page_sampling_load() { void samplePage_update_state(int progress_s, int wave_y, bool leadoff, int heartrate, bool updateHeart, bool update_screen) { // - sample_page_state_t* sps = &m_sample_page_state; + m_sample_page_state.in_error_page = false; + sample_page_state_t* sps = &m_sample_page_state; uint8_t xchange, ychange; static bool heart_logo_state = false; @@ -259,7 +281,18 @@ static void page_sampling_tmr_cb() { heartrate = 0; } - samplePage_update_state(capturetime / 1000, wave_y, leadoff, heartrate, count % 15 == 0, count % 5 == 0); + if (leadoff) { + if (!m_sample_page_state.in_error_page) { + beep_set_effect(LEAD_OFF_EFFECT); + page_sampling_show_error_info(); + } + } else { + if (m_sample_page_state.in_error_page) { + beep_set_effect(LEAD_OFF_RECOVER_EFFECT); + page_sampling_load(); + } + samplePage_update_state(capturetime / 1000, wave_y, leadoff, heartrate, count % 15 == 0, count % 5 == 0); + } } /*********************************************************************************************************************** @@ -337,7 +370,7 @@ static void page_prepare_sample_show(int progress) { if (progress == 0) { ssd1306_basic_draw_str(x, y, &xchange, &ychange, "·ÅÉÏË«ÊÖ", &font24x24_zh_lib); - }else{ + } else { ssd1306_basic_draw_str(x, y, &xchange, &ychange, "±£³Ö¾²Ö¹", &font24x24_zh_lib); } diff --git a/app/src/app_service/ecg_service/ecg_service.c b/app/src/app_service/ecg_service/ecg_service.c index 0e394ef..51636ae 100644 --- a/app/src/app_service/ecg_service/ecg_service.c +++ b/app/src/app_service/ecg_service/ecg_service.c @@ -227,7 +227,7 @@ static void leadoff_state_process(ads129x_capture_data_t* capture_data) { } if (leadoff != m_leadoffstate) { - if (m_leadoffstate && un_leadoffcnt > 1500) { + if (m_leadoffstate && un_leadoffcnt > 500) { m_leadoffstate = false; } else { m_leadoffstate = true; diff --git a/app/src/aproject_config/config.h b/app/src/aproject_config/config.h index 0fff750..a38cad7 100644 --- a/app/src/aproject_config/config.h +++ b/app/src/aproject_config/config.h @@ -7,10 +7,10 @@ #define CATEGORY "M1003" // µ¥µ¼Áª #define MANUFACTURER_NAME "iflytop" -#define FIRMWARE_VERSION (1) +#define FIRMWARE_VERSION (2) #define BLESTACK_VERSION 1 #define BOOTLOADER_VERSION 1 -#define HARDWARE_VERSION (1) +#define HARDWARE_VERSION (2) #define APP_COMPANY_IDENTIFIER 0xFFFF diff --git a/app/src/one_conduction_main.c b/app/src/one_conduction_main.c index a2fd1e6..52ba86d 100644 --- a/app/src/one_conduction_main.c +++ b/app/src/one_conduction_main.c @@ -348,12 +348,9 @@ void on_zapp_ebus_event(void* p_event_data, uint16_t event_size) { 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); - } else { + if (!ecg_leadoff_detect() && zapp_state_machine_haspassed_ms() > 1500) { + m_capture_prepare_progress++; if (m_capture_prepare_progress < 4) { - m_capture_prepare_progress++; dsp_mgr_page_sample_prepare_set_progress(m_capture_prepare_progress); } else { /** @@ -362,6 +359,9 @@ void on_zapp_ebus_event(void* p_event_data, uint16_t event_size) { zapp_state_machine_change_state(kstate_capture); beep_set_effect(POWER_ON_EFFECT); } + } else { + m_capture_prepare_progress = 0; + dsp_mgr_page_sample_prepare_set_progress(m_capture_prepare_progress); } } } @@ -457,7 +457,7 @@ void one_conduction_main() { dsp_mgr_init(); ecg_service_init(); - zapp_state_machine_change_state(kstate_prepare_capture); + // zapp_state_machine_change_state(kstate_prepare_capture); zble_module_start_adv(); zapp_start_schedule(); diff --git a/screen_res/font/data/config/array2ImgFrom.table b/screen_res/font/data/config/array2ImgFrom.table index d596e6c..ccb015a 100644 --- a/screen_res/font/data/config/array2ImgFrom.table +++ b/screen_res/font/data/config/array2ImgFrom.table @@ -1,16 +1,17 @@ { edtOffset="0"; -rdScanModeH=0; -afterLoad=null; cmbbxMode=1; rdScanModeVH=1; -rdByteLsb=1; rdComVcc=0; edtImgW='8\r\n'; edtImgH="16"; -rdScanModeHV=0; edtArray=' { 0x08,0xF8,0x08,0x08,0x08,0xC8,0x18,0x00,0x00,0x3F,0x21,0x21,0x21,0x23,0x30,0x00, }/* 0, "中",Size:100, 25×25 */'; -rdByteMsb=0; rdScanModeV=0; -rdComGnd=1 +rdComGnd=1; +rdScanModeHV=0; +afterLoad=null; +beforeSave=null; +rdByteLsb=1; +rdByteMsb=0; +rdScanModeH=0 } \ No newline at end of file diff --git a/screen_res/font/data/config/arrayCfg.table b/screen_res/font/data/config/arrayCfg.table index 2691e5f..b7423d1 100644 --- a/screen_res/font/data/config/arrayCfg.table +++ b/screen_res/font/data/config/arrayCfg.table @@ -1,6 +1,6 @@ { +scanMode="VH"; isByteMsb=0; txtLineCharMaxNum=20; -scanMode="VH"; isCommonGnd=1 } \ No newline at end of file diff --git a/screen_res/font/data/config/bottomFrom.table b/screen_res/font/data/config/bottomFrom.table index 1fcf310..90c3fc1 100644 --- a/screen_res/font/data/config/bottomFrom.table +++ b/screen_res/font/data/config/bottomFrom.table @@ -1,3 +1,4 @@ { -afterLoad=null +afterLoad=null; +beforeSave=null } \ No newline at end of file diff --git a/scripter/flash.bat b/scripter/flash.bat index e4e6655..846cef2 100644 --- a/scripter/flash.bat +++ b/scripter/flash.bat @@ -1,14 +1,42 @@ - @echo off -echo "Start flashing..." +setlocal EnableDelayedExpansion + + +nrfjprog --memrd 0x10001080 > _temp.txt +set /p lot_string=<_temp.txt +nrfjprog --memrd 0x10001084 > _temp.txt +set /p id_string=<_temp.txt + +del _temp.txt + +for /L %%i in (0,1,7) do ( + set "hex_digit=!lot_string:~12,1!" + set "lot_num=!lot_num!!hex_digit!" + set "lot_string=!lot_string:~1!" +) + +for /L %%i in (0,1,7) do ( + set "hex_digit=!id_string:~12,1!" + set "id_num=!id_num!!hex_digit!" + set "id_string=!id_string:~1!" +) + +echo lot_num: %lot_num% id_num: %id_num% + +nrfjprog --eraseall -f NRF52 + +@REM ÉÕ¼lot +nrfjprog -f nrf52 --memwr 0x10001080 --val 0x%lot_num% +@REM ÉÕ¼ID +nrfjprog -f nrf52 --memwr 0x10001084 --val 0x%id_num% -call scripter\unlock.bat -nrfjprog --program output/app_whole.hex -f NRF52 %ÉÕ¼% +nrfjprog --program output/app_whole.hex --verify -f NRF52 %ÉÕ¼% if %errorlevel% neq 0 ( echo EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE echo E ÉÕ¼ʧ°Ü E echo EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE + endlocal exit /b 1 ) nrfjprog --reset -f NRF52 %¸´Î»% @@ -16,6 +44,7 @@ if %errorlevel% neq 0 ( echo EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE echo E ¸´Î»Ê§°Ü E echo EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE + endlocal exit /b 1 ) @@ -25,3 +54,4 @@ echo - done echo --------------------------------------------------------------- +endlocal \ No newline at end of file diff --git a/temp.txt b/temp.txt new file mode 100644 index 0000000..e8a35cb --- /dev/null +++ b/temp.txt @@ -0,0 +1 @@ +0x10001084: FFFFFFFF |....|