zhaohe 1 year ago
parent
commit
d6f195c7b3
  1. 14
      README.md
  2. 26
      app/src/basic/qrs_time_domain_zh.c
  3. 2
      app/src/basic/version.h
  4. 2
      app/src/board/board_battery_state.c
  5. 39
      app/src/heart_wave_sample_service.c
  6. 1
      app/src/heart_wave_sample_service.h
  7. 5
      app/src/one_conduction_main.c
  8. 6
      app/src/zeeprom_fs.c
  9. 2
      libznordic
  10. 1
      scripter/flash.bat
  11. 43
      scripter/flash_with_id.bat

14
README.md

@ -20,7 +20,12 @@ V6:
V7:
1. 优化电池电量显示
V8:
1. 优化心电波形显示
2. 优化心率显示
3. 解决存储不自动清空的BUG。
4. 解决偶尔关机时,设备启动失败的异常。
5. 优化电池电量范围
测试:
@ -33,4 +38,11 @@ V7:
```
单导:休眠527ua
日志打开:
sdk_config.h
#ifndef NRF_LOG_ENABLED
#define NRF_LOG_ENABLED 0
#endif
```

26
app/src/basic/qrs_time_domain_zh.c

@ -4,7 +4,7 @@
#include <stdint.h>
#include <string.h>
#define HEART_RATE_FILTER_SIZE 5
#define HEART_RATE_FILTER_SIZE 10
typedef struct {
uint16_t data[HEART_RATE_FILTER_SIZE];
@ -34,11 +34,11 @@ static uint16_t HeartRateMedianFilter_process(uint16_t data) {
pfilter->data[pfilter->index] = data;
pfilter->index++;
pfilter->cnt++;
if (pfilter->index >= 5) {
if (pfilter->index >=HEART_RATE_FILTER_SIZE) {
pfilter->index = 0;
}
if (pfilter->cnt < 5) {
if (pfilter->cnt <HEART_RATE_FILTER_SIZE) {
return data;
}
@ -70,15 +70,15 @@ static uint16_t HeartRateMeanFilter_process(uint16_t data) {
pfilter->index++;
pfilter->cnt++;
if (pfilter->index >= 5) {
if (pfilter->index >= HEART_RATE_FILTER_SIZE) {
pfilter->index = 0;
}
if (pfilter->cnt < 5) {
if (pfilter->cnt < HEART_RATE_FILTER_SIZE) {
return data;
}
return pfilter->sum / 5;
return pfilter->sum / HEART_RATE_FILTER_SIZE;
}
static uint16_t m_data[TABLE_SIZE];
@ -93,7 +93,7 @@ static uint32_t m_max_val_in_m_data;
static bool m_findpeak = false;
static uint16_t pQRS_median_filter_cache[5];
static uint16_t pQRS_median_filter_cache[HEART_RATE_FILTER_SIZE];
static uint16_t pQRS_median_filter_cache_index = 0;
static uint16_t pQRS_median_filter_cache_cnt = 0;
@ -105,18 +105,18 @@ static uint16_t pQRS_median_filter(uint16_t indata) {
pQRS_median_filter_cache[pQRS_median_filter_cache_index] = indata;
pQRS_median_filter_cache_index++;
pQRS_median_filter_cache_cnt++;
if (pQRS_median_filter_cache_index >= 5) {
if (pQRS_median_filter_cache_index >= HEART_RATE_FILTER_SIZE) {
pQRS_median_filter_cache_index = 0;
}
if (pQRS_median_filter_cache_cnt < 5) {
if (pQRS_median_filter_cache_cnt < HEART_RATE_FILTER_SIZE) {
return indata;
}
static uint16_t process_cache[5];
memcpy(process_cache, pQRS_median_filter_cache, 5 * sizeof(uint16_t));
for (uint8_t i = 0; i < 5; i++) {
for (uint8_t j = i + 1; j < 5; j++) {
static uint16_t process_cache[HEART_RATE_FILTER_SIZE];
memcpy(process_cache, pQRS_median_filter_cache, HEART_RATE_FILTER_SIZE * sizeof(uint16_t));
for (uint8_t i = 0; i < HEART_RATE_FILTER_SIZE; i++) {
for (uint8_t j = i + 1; j < HEART_RATE_FILTER_SIZE; j++) {
if (process_cache[i] > process_cache[j]) {
uint16_t temp = process_cache[i];
process_cache[i] = process_cache[j];

2
app/src/basic/version.h

@ -2,7 +2,7 @@
#define CATEGORY "M1001" // 데돔젬
#define MANUFACTURER_NAME "iflytop"
#define FIRMWARE_VERSION (7)
#define FIRMWARE_VERSION (8)
#define BLESTACK_VERSION 1
#define BOOTLOADER_VERSION 1
#define HARDWARE_VERSION (1)

2
app/src/board/board_battery_state.c

@ -65,7 +65,7 @@ static int16_t battery_level_filter(int16_t nowlevel) {
int16_t BoardBattery_get_battery_level() {
static const float maxv = 4.15;
static const float minv = 3.6;
static const float minv = 3.75;
int16_t rawval = BoardBattery_get_adc_val();

39
app/src/heart_wave_sample_service.c

@ -15,7 +15,8 @@ static uint16_t m_capture_buffer_index = 0;
volatile static float m_sensor_display_data = 0; // 0->100
static uint32_t m_start_capture_tp;
static uint32_t m_frame_index = 0;
static uint32_t m_frame_index = 0;
static bool m_prepare_capture = false;
static one_frame_data_t m_sensor_little_frame_cache[LITTLE_DATA_BLOCK_FRAME_NUM];
static uint32_t m_little_frame_index;
@ -126,11 +127,11 @@ uint16_t getRecommendedMagnification() {
// return 0;
uint16_t max = QRS_getMaxValueLastVal();
if (max == 0) {
return 1;
return 15;
}
// 3750.0f
if (max <= (3750 / 2)) {
return 1;
return 15;
}
float af = (3750 / 2) / (max - 3750 / 2);
if (af > 15) {
@ -149,15 +150,17 @@ void nrfx_timer_event_handler(nrf_timer_event_t event_type, void* p_context) {
// QRS_getMaxValueLastVal();
int16_t lowpassf_val = LPFilter_Update(&m_lpfilter_01, val);
QRS_processData(lowpassf_val);
float val_af100 = (float)lowpassf_val / 3750.0f * 100; // 3.6v,3.3v
m_frame_index++;
float val_af100 = (float)lowpassf_val / 3750.0f * 100; // 3.6v,3.3v
val_af100 = amp_val(val_af100, 50, getRecommendedMagnification());
val_af100 = LPFilter_Update(&m_lpfilter_02, val_af100);
m_sensor_display_data = val_af100;
if (m_prepare_capture) return;
/*******************************************************************************
* *
*******************************************************************************/
m_frame_index++;
if (m_capture_buffer == NULL) {
swap_buffer();
}
@ -210,19 +213,31 @@ void hwss_init(void) {
}
}
void hwss_uninit(void) { nrfx_timer_disable(&m_timer); }
void hwss_start_capture(void) {
void hwss_start_prepare_capture(void) {
m_start_capture_tp = znordic_getpower_on_s();
swap_buffer();
m_frame_index = 0;
LPFilter_Init(&m_lpfilter_01, 15, 0.002);
LPFilter_Init(&m_lpfilter_02, 15, 0.002);
m_prepare_capture = true;
m_frame_index = 0;
swap_buffer();
LPFilter_Init(&m_lpfilter_01, 30, 0.002);
LPFilter_Init(&m_lpfilter_02, 30, 0.002);
QRS_resetBuf();
prvf_light_block_cache_clear();
nrfx_timer_enable(&m_timer);
}
void hwss_start_capture(void) {
m_start_capture_tp = znordic_getpower_on_s();
m_prepare_capture = false;
// swap_buffer();
// m_frame_index = 0;
// LPFilter_Init(&m_lpfilter_01, 30, 0.002);
// LPFilter_Init(&m_lpfilter_02, 30, 0.002);
// QRS_resetBuf();
// prvf_light_block_cache_clear();
// nrfx_timer_enable(&m_timer);
}
void hwss_stop_capture(void) {
nrfx_timer_disable(&m_timer);
m_frame_index = 0;

1
app/src/heart_wave_sample_service.h

@ -13,3 +13,4 @@ void hwss_stop_capture(void);
float hwss_read_val(void);
float hwss_read_heart_rate(void);
int hwss_has_captured_time_ms();
void hwss_start_prepare_capture(void);

5
app/src/one_conduction_main.c

@ -84,6 +84,7 @@ static void power_off() {
BoardLight_unload();
BoardBeepCtrl_unload();
zble_module_disconnect();
ble_cmder_stop_adv();
ble_cmder_uninit();
m_poweronflag = false;
@ -226,7 +227,7 @@ static void app_event_listener(void* p_event_data, uint16_t event_size) {
if (!BoardBattery_get_charging_state()) {
ds_change_to_state(kdevice_state_keep_still);
dsp_mgr_change_to_preparePage();
// hwss_pre_start_capture();
hwss_start_prepare_capture();
}
}
@ -254,7 +255,7 @@ static void app_event_listener(void* p_event_data, uint16_t event_size) {
if (!BoardEcgSensor_plod_get_connected_state_after_filter()) {
//
state_machine__change_to_home_state();
// hwss_stop_capture();
hwss_stop_capture();
} else {
/*******************************************************************************
* *

6
app/src/zeeprom_fs.c

@ -203,9 +203,9 @@ int zeeprom_fs_close(int fileid) {
return -1;
}
// sector_mgr_close_sector(fileHander->fileuuid);
// int32_t checksum_val = compute_checksum((uint8_t*)&m_eeprom_header, sizeof(m_eeprom_header) - sizeof(m_eeprom_header.checksum));
// m_eeprom_header.checksum = checksum_val;
sector_mgr_close_sector(fileHander->fileuuid);
int32_t checksum_val = compute_checksum((uint8_t*)&m_eeprom_header, sizeof(m_eeprom_header) - sizeof(m_eeprom_header.checksum));
m_eeprom_header.checksum = checksum_val;
// zeeprom_write(0, (uint8_t*)&m_eeprom_header, sizeof(m_eeprom_header));
filehandler_rlease(fileid);

2
libznordic

@ -1 +1 @@
Subproject commit a5cc5239adb61162d87d7109c9e6710d70c58d36
Subproject commit 9f78147bbb47a49e378efcab6fd1c5f282931d7b

1
scripter/flash.bat

@ -1,4 +1,5 @@
@echo off
echo "Start flashing..."
call scripter\unlock.bat

43
scripter/flash_with_id.bat

@ -0,0 +1,43 @@
@echo off
echo "Start flashing..."
call scripter\unlock.bat
@REM 烧录整体镜像
nrfjprog --eraseall -f NRF52 %全擦除%
if %errorlevel% neq 0 (
echo EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
echo E 擦除失败 E
echo EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
exit /b 1
)
@REM 烧录lot
nrfjprog -f nrf52 --memwr 0x10001080 --val %1
@REM 烧录ID
nrfjprog -f nrf52 --memwr 0x10001084 --val %2
nrfjprog --program output/app_whole.hex --verify -f NRF52 %烧录%
if %errorlevel% neq 0 (
echo EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
echo E 烧录失败 E
echo EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
exit /b 1
)
nrfjprog --reset -f NRF52 %复位%
if %errorlevel% neq 0 (
echo EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
echo E 复位失败 E
echo EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
exit /b 1
)
echo ---------------------------------------------------------------
echo - done
echo ---------------------------------------------------------------
Loading…
Cancel
Save