Browse Source

update

3lead_uart_test_ok_version
zhaohe 1 year ago
parent
commit
e9987f833e
  1. 3
      .vscode/settings.json
  2. 4
      README.md
  3. 16
      app/src/one_conduction/config.h
  4. 100
      app/src/one_conduction/display_manager.c
  5. 7
      app/src/one_conduction/display_manager.h
  6. 58
      app/src/one_conduction/font.h
  7. 1
      app/src/one_conduction/heart_wave_sample_service.c
  8. 2
      app/src/one_conduction/one_conduction_board.c
  9. 88
      app/src/one_conduction/one_conduction_main.c
  10. 9
      app/src/one_conduction/sample_data_manager.c
  11. 25
      app/src/one_conduction/sample_data_manager.h
  12. 36
      app/src/one_conduction/zeeprom_fs.c
  13. 9
      app/src/one_conduction/zeeprom_fs.h
  14. 2
      libznordic

3
.vscode/settings.json

@ -84,7 +84,8 @@
"display_manager.h": "c",
"wave_drawer.h": "c",
"sample_data_manager.h": "c",
"zeeprom_fs.h": "c"
"zeeprom_fs.h": "c",
"config.h": "c"
},
"files.encoding": "gbk"
}

4
README.md

@ -216,4 +216,8 @@ readData(){
编程注意事项:
1. 使用了app_timer后,如果在系统中某个位置延时时间过程,会导致系统重启
TODO:
1. eeprom的文件扇区信息没有存储,也就是说每次电池用没了之后,数据会丢失
2. 如果要实现不丢数据,需要在eeprom中存储文件扇区信息,同时由于扇区的大小大于256字节,所以需要优化eeprom的写入函数。
```

16
app/src/one_conduction/config.h

@ -0,0 +1,16 @@
#pragma once
/**
* @brief
*
* 200HZ,16bit
* ->
* 1s => 200*2 => 400BYTE
* 248k
* ->
* 1s => 248*1024/400 => 634_S => 10.5min
*/
#define MAX_STORAGE_TIMEOUT_S (60 * 10)
#define MAX_STORAGE_SIZE (MAX_STORAGE_TIMEOUT_S * 400) // 存储最大限制为 (256-8)kbyte
#define MAX_FILE_NUM 10

100
app/src/one_conduction/display_manager.c

@ -32,62 +32,6 @@ PageState_t* dsp_mgr_get_state(void) { return NULL; }
int compute_x_pos_by_center(int16_t x, int16_t width) { return x - width / 2; }
int compute_y_pos_by_center(int16_t y, int16_t height) { return y - height / 2; }
void dsp_mgr_change_to_samplingError() {
/**
* @brief
* 30[X]
*/
ssd1306_basic_clear();
uint8_t x = 20;
uint8_t y = 32 - font24x24_zh_lib.heightPixel / 2; // 12*4 +12
uint8_t xchange, ychange;
// ssd1306_basic_draw_str(&x, &y, "123", &fontclocklib);
ssd1306_basic_draw_str(x, y, &xchange, &ychange, "不足", &font24x24_zh_lib);
x = x + xchange;
ssd1306_basic_draw_str(x, y, &xchange, &ychange, "30", &font12x24_asiic_lib);
x = x + xchange;
ssd1306_basic_draw_str(x, y, &xchange, &ychange, "", &font24x24_zh_lib);
x = x + xchange;
ssd1306_basic_gram_update();
dsp_mgr_change_to_page(kPage_samplingError);
}
void dsp_mgr_change_to_storaging() {
/**
* @brief
* 1.
* 2.
*/
ssd1306_basic_clear();
uint8_t x = 0;
uint8_t y = 0;
uint8_t xchange, ychange;
// ssd1306_basic_draw_str(&x, &y, "123", &fontclocklib);
ssd1306_basic_draw_str(x, y, &xchange, &ychange, "ooo", &font8x8_xo_lib);
y = y + font8x8_xo_lib.heightPixel;
x = x + font8x8_xo_lib.widthPixel;
ssd1306_basic_draw_str(x, y, &xchange, &ychange, "正在存储", &font24x24_zh_lib);
ssd1306_basic_gram_update();
dsp_mgr_change_to_page(kPage_storaging);
}
void dsp_mgr_change_to_storagingSuc() {
/**
* @brief
* 1.
* 2.
*/
ssd1306_basic_clear();
uint8_t x = 0;
uint8_t y = 0;
uint8_t xchange, ychange;
ssd1306_basic_draw_str(x, y, &xchange, &ychange, "存储成功", &font24x24_zh_lib);
ssd1306_basic_gram_update();
dsp_mgr_change_to_page(kPage_storagingSuc);
}
#define SCREEN_CENTER_X 64
#define SCREEN_CENTER_Y 32
@ -340,6 +284,50 @@ void samplePage_schedule() {
samplePage_update_state(capturetime / 1000, wave_y, heartrate);
}
//
void dsp_mgr_change_to_samplingError() {
/**
* @brief
* 30[X]
*/
ssd1306_basic_clear_gram();
uint8_t x;
uint8_t y;
x = compute_x_pos_by_center(SCREEN_CENTER_X, font24x24_zh_lib.widthPixel * 3 + font12x24_asiic_lib.widthPixel * 2);
y = compute_y_pos_by_center(SCREEN_CENTER_Y, font24x24_zh_lib.heightPixel);
uint8_t xchange, ychange;
ssd1306_basic_draw_str(x, y, &xchange, &ychange, "不足", &font24x24_zh_lib);
x = x + xchange;
ssd1306_basic_draw_str(x, y, &xchange, &ychange, "30", &font12x24_asiic_lib);
x = x + xchange;
ssd1306_basic_draw_str(x, y, &xchange, &ychange, "", &font24x24_zh_lib);
x = x + xchange;
ssd1306_basic_gram_update();
dsp_mgr_change_to_page(kPage_samplingError);
}
void dsp_mgr_change_to_sampleSuc() {
/**
* @brief
* 1.
* 2.
*/
ssd1306_basic_clear();
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();
dsp_mgr_change_to_page(kPage_storagingSuc);
}
/*******************************************************************************
* SCHEDULE *
*******************************************************************************/

7
app/src/one_conduction/display_manager.h

@ -67,12 +67,15 @@ void dsp_mgr_change_to_welcome();
void dsp_mgr_change_to_main();
void dsp_mgr_change_to_chargingPage();
//
void dsp_mgr_change_to_preparePage();
void dsp_mgr_preparePage_set_progress(int progress);
int dsp_mgr_preparePage_get_progress();
//
void dsp_mgr_change_to_sampling(int progress_s, int heartrate);
//
void dsp_mgr_change_to_samplingError();
void dsp_mgr_change_to_storaging();
void dsp_mgr_change_to_storagingSuc();
//
void dsp_mgr_change_to_sampleSuc();

58
app/src/one_conduction/font.h

@ -168,7 +168,7 @@ static FontLibrary_t font12x24_asiic_lib = {
.heightPixel = 24,
};
const uint8_t font24x24_zh_code[] = { //
const uint8_t font24x24_zh_code[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0x38, 0x10, 0x10, 0xF0, 0x90, 0x10, 0x10, 0x10, 0x88, 0xF8, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x0C, 0x06, 0xE7, 0x1C, 0x10, 0x10, 0x10, 0x10, 0x93,
0x71, 0xFF, 0x39, 0x49, 0x89, 0x08, 0x08, 0x0C, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x04, 0x02, 0x01, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x03, 0x07, 0x06, 0x06, 0x04, 0x04, 0x00, /*"保",0*/
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFC, 0xFC, 0xC0, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xC2, 0x63, 0x33, 0xFF, 0x0D, 0x09, 0x08, 0x48,
@ -189,27 +189,53 @@ const uint8_t font24x24_zh_code[] = { //
0x06, 0xFF, 0x02, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x02, 0x01, 0x00, 0x00, 0x10, 0x20, 0x70, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*"牙",8*/
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x10, 0xF0, 0x70, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x0E, 0x08, 0x08, 0x08, 0x04, 0x04, 0x07,
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x06, 0x08, 0x08, 0x18, 0x18, 0x18, 0x10, 0x18, 0x18, 0x18, 0x18, 0x08, 0x08, 0x0C, 0x0E, 0x07, 0x00, 0x00, 0x00, /*"已",9*/
0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x30, 0x10, 0xC0, 0xC0, 0x00, 0x00, 0x40, 0x20, 0x20, 0xA0, 0xF0, 0x30, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x67, 0x74, 0x2C, 0x26, 0x01, 0x00, 0x10, 0x50,
0x48, 0x44, 0xC3, 0xC3, 0x62, 0x24, 0x2C, 0x0C, 0x18, 0x10, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x06, 0x02, 0x02, 0x01, 0x10, 0x18, 0x08, 0x08, 0x08, 0x0F, 0x0B, 0x08, 0x08, 0x08, 0x0C, 0x0C, 0x08, 0x00, 0x00, /*"经",10*/
0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xC0, 0x00, 0x00, 0x40, 0x40, 0xC0, 0xE0, 0x5C, 0x2C, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x08, 0xF8, 0x08, 0x00, 0x40, 0x48, 0x4E, 0x4B,
0x44, 0x45, 0xFF, 0x24, 0x24, 0x24, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0C, 0x04, 0x07, 0x04, 0x04, 0x08, 0x08, 0x08, 0x08, 0x10, 0x10, 0x17, 0x30, 0x30, 0x30, 0x30, 0x30, 0x10, 0x10, 0x00, 0x00, /*"连",10*/
0x44, 0x45, 0xFF, 0x24, 0x24, 0x24, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x08, 0x0C, 0x04, 0x07, 0x04, 0x04, 0x08, 0x08, 0x08, 0x08, 0x10, 0x10, 0x17, 0x30, 0x30, 0x30, 0x30, 0x30, 0x10, 0x10, 0x00, 0x00, /*"连",11*/
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x88, 0x98, 0xD0, 0xC0, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x82, 0xC2, 0x62, 0xFF, 0x11, 0x91, 0x80, 0x80, 0x90,
0x92, 0xF4, 0xB0, 0x98, 0x97, 0x89, 0x48, 0x48, 0x48, 0x40, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x18, 0x3F, 0x0F, 0x00, 0x00, 0x20, 0x20, 0x13, 0x12, 0x0C, 0x06, 0x0F, 0x08, 0x18, 0x30, 0x20, 0x00, 0x00, 0x00, /*"接",11*/
0x92, 0xF4, 0xB0, 0x98, 0x97, 0x89, 0x48, 0x48, 0x48, 0x40, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x18, 0x3F, 0x0F, 0x00, 0x00, 0x20, 0x20, 0x13, 0x12, 0x0C, 0x06, 0x0F, 0x08, 0x18, 0x30, 0x20, 0x00, 0x00, 0x00, /*"接",12*/
0x00, 0x00, 0x00, 0xE0, 0x40, 0x40, 0x80, 0x00, 0xF8, 0x88, 0x40, 0x20, 0x00, 0x80, 0x80, 0x40, 0x40, 0x20, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x80, 0x40, 0x25, 0x1A, 0xFF, 0x12, 0x12, 0x12,
0x00, 0xE0, 0x3F, 0x08, 0x04, 0xFC, 0xFC, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x04, 0x02, 0x02, 0x02, 0x03, 0x02, 0x12, 0x08, 0x06, 0x01, 0x00, 0x00, 0x00, 0x7F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, /*"断",12*/
0x00, 0xE0, 0x3F, 0x08, 0x04, 0xFC, 0xFC, 0x04, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x04, 0x02, 0x02, 0x02, 0x03, 0x02, 0x12, 0x08, 0x06, 0x01, 0x00, 0x00, 0x00, 0x7F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, /*"断",13*/
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x60, 0x60, 0xE0, 0x20, 0x20, 0x20, 0x20, 0xF0, 0x30, 0x30, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0xE8, 0x3F, 0x08, 0x08,
0x04, 0x04, 0xFF, 0x04, 0x04, 0x04, 0x04, 0x04, 0x06, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x08, 0x04, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*"开",13*/
0x04, 0x04, 0xFF, 0x04, 0x04, 0x04, 0x04, 0x04, 0x06, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x08, 0x04, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*"开",14*/
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9C, 0xF8, 0x80, 0x80, 0x80, 0x80, 0xC0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x7F, 0x81, 0x89, 0x49, 0xC8, 0xFF, 0x4C,
0x44, 0x44, 0x40, 0x3C, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0F, 0x18, 0x10, 0x10, 0x30, 0x30, 0x30, 0x10, 0x10, 0x1A, 0x1C, 0x00, 0x00, 0x00, /*"电",14*/
0x44, 0x44, 0x40, 0x3C, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0F, 0x18, 0x10, 0x10, 0x30, 0x30, 0x30, 0x10, 0x10, 0x1A, 0x1C, 0x00, 0x00, 0x00, /*"电",15*/
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x78, 0xA8, 0xA8, 0xA8, 0xA8, 0x88, 0xE4, 0x7C, 0x18, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x14, 0xF4, 0x94, 0x14, 0x52, 0xF2,
0xAA, 0xAA, 0x8A, 0xFA, 0x3A, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x20, 0x24, 0x25, 0x25, 0x25, 0x3F, 0x24, 0x24, 0x27, 0x30, 0x30, 0x30, 0x30, 0x20, 0x00, 0x00, 0x00, 0x00,
/*"量",15*/};
static FontLibrary_t font24x24_zh_lib = {
.font = font24x24_zh_code,
.fontIndex = "保持静止不足秒蓝牙已连接断开电量",
.fontIndexLen = 21,
.fontCode = kgbk,
.isAscii = false,
.widthPixel = 24,
.heightPixel = 24,
0xAA, 0xAA, 0x8A, 0xFA, 0x3A, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x20, 0x24, 0x25, 0x25, 0x25, 0x3F, 0x24, 0x24, 0x27, 0x30, 0x30, 0x30, 0x30, 0x20, 0x00, 0x00, 0x00, 0x00, /*"量",16*/
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x40, 0x40, 0xC0, 0xC6, 0xFC, 0xA0, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x08, 0x24, 0xE6, 0xA3, 0xA1, 0x94, 0xAF,
0x10, 0x11, 0xF3, 0xF6, 0x2C, 0x0C, 0x18, 0x18, 0x18, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x20, 0x20, 0x21, 0x27, 0x24, 0x24, 0x34, 0x12, 0x16, 0x13, 0x10, 0x10, 0x10, 0x10, 0x30, 0x00, 0x00, 0x00, 0x00, /*"查",17*/
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA0, 0x90, 0x90, 0xF0, 0xB8, 0x88, 0x8C, 0xCC, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08, 0x08, 0xC8, 0x78, 0xFC, 0xA7, 0xA4,
0xA4, 0xA4, 0x14, 0x14, 0xF2, 0x22, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x10, 0x10, 0x08, 0x04, 0x02, 0x01, 0x00, 0x00, 0x3F, 0x14, 0x14, 0x14, 0x12, 0x10, 0x30, 0x7F, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*"看",18*/
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x60, 0x38, 0x10, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x38, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0xC6, 0x65, 0x3C, 0x2C, 0x23, 0x01, 0x80, 0x02,
0x22, 0x22, 0x22, 0x22, 0x3F, 0x91, 0x91, 0x91, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0C, 0x04, 0x06, 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x03, 0x1F, 0x09, 0x09, 0x09, 0x08, 0x08, 0x0F, 0x01, 0x00, 0x00, 0x00, /*"结",19*/
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x30, 0xF0, 0x10, 0x90, 0x90, 0xF0, 0xF0, 0xD0, 0x10, 0x88, 0xF8, 0x78, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x60, 0x21, 0x27, 0xA4, 0x64, 0xFF,
0x52, 0x92, 0x12, 0x13, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x10, 0x08, 0x04, 0x06, 0x03, 0x01, 0x00, 0x7F, 0x00, 0x00, 0x01, 0x02, 0x06, 0x0C, 0x18, 0x18, 0x18, 0x10, 0x00, 0x00, /*"果",20*/
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x20, 0xD0, 0x90, 0x18, 0x0C, 0x88, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x60, 0x20, 0x20, 0x20, 0x22, 0x22, 0x33, 0x11,
0xFF, 0x11, 0x11, 0x11, 0x11, 0x10, 0x18, 0x18, 0x18, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x20, 0x60, 0x78, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*"手",21*/
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x86, 0xC2, 0x32, 0x0F, 0xFF, 0x21, 0x61, 0x01, 0x01,
0xFF, 0x01, 0x01, 0x00, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x04, 0x02, 0x01, 0x00, 0x00, 0x3F, 0x0F, 0x00, 0x08, 0x04, 0x03, 0x01, 0x00, 0x00, 0x00, 0x07, 0x06, 0x0C, 0x0C, 0x0C, 0x0F, 0x06, 0x00, /*"机",22*/
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x20, 0x20, 0x50, 0xD0, 0x88, 0x0C, 0x8C, 0x40, 0x70, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x10, 0x11, 0xD0, 0x70, 0x32, 0xFC, 0x30,
0x48, 0x88, 0x88, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x04, 0x02, 0x01, 0x00, 0x00, 0x30, 0x7F, 0x00, 0x00, 0x00, 0x01, 0x03, 0x06, 0x06, 0x0C, 0x0C, 0x04, 0x08, 0x00, 0x00, /*"采",23*/
0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x20, 0xF0, 0x0C, 0x24, 0xA0, 0xA4, 0xEC, 0xE8, 0x90, 0x50, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0xBF, 0x90, 0x90, 0xD2, 0xF2,
0xCF, 0x4B, 0x4A, 0x49, 0x48, 0x48, 0x60, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x10, 0x10, 0x08, 0x04, 0x06, 0x03, 0x01, 0x7F, 0x00, 0x01, 0x02, 0x04, 0x0C, 0x18, 0x18, 0x18, 0x10, 0x10, 0x00, 0x00, /*"集",24*/
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x7C, 0xC0, 0x80, 0x80, 0x88, 0x98, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xFE, 0x42, 0x42, 0x22, 0x22, 0xE1, 0x21,
0x03, 0x1F, 0x70, 0x80, 0xE0, 0x3C, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x08, 0x06, 0x03, 0x00, 0x04, 0x08, 0x1C, 0x07, 0x00, 0x08, 0x04, 0x02, 0x01, 0x07, 0x0C, 0x18, 0x30, 0x70, 0x78, 0x00, 0x00, /*"成",25*/
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x81, 0x81, 0xC1, 0x7F, 0x20, 0x20, 0x20, 0x12,
0x82, 0xE2, 0x3E, 0x07, 0x02, 0x01, 0x01, 0xFF, 0x0F, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x10, 0x10, 0x08, 0x04, 0x03, 0x01, 0x00, 0x04, 0x08, 0x38, 0x1C, 0x0F, 0x01, 0x00, 0x00, 0x00, 0x00, /*"功",26*/
0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x80, 0x80, 0x80, 0x40, 0x48, 0x58, 0x50, 0x40, 0x20, 0x20, 0xA0, 0xE0, 0xC0, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x01, 0x40, 0x60, 0x24, 0xE4, 0x26, 0x22,
0xF2, 0x12, 0x10, 0x10, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x08, 0x04, 0x06, 0x03, 0x00, 0x00, 0x00, 0x1F, 0x30, 0x20, 0x20, 0x20, 0x20, 0x20, 0x30, 0x3E, 0x10, 0x00, 0x00, /*"完",27*/
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x78, 0x10, 0x00, 0x80, 0x80, 0x40, 0x40, 0xA0, 0x38, 0x18, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x18, 0x0C, 0x03, 0xFD, 0x00, 0x00, 0x00, 0xE1, 0xFF,
0x10, 0x88, 0x0F, 0x3C, 0xE4, 0x84, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x1F, 0x00, 0x00, 0x04, 0x0F, 0x03, 0x01, 0x00, 0x04, 0x0C, 0x00, 0x01, 0x06, 0x0C, 0x18, 0x3E, 0x30, 0x00, /*"低",28*/
};
static FontLibrary_t font24x24_zh_lib = {
.font = font24x24_zh_code,
.fontIndex = "保持静止不足秒蓝牙已经连接断开电量查看结果手机采集成功完低",
.fontIndexLen = 88,
.fontCode = kgbk,
.isAscii = false,
.widthPixel = 24,
.heightPixel = 24,
};
#if 0

1
app/src/one_conduction/heart_wave_sample_service.c

@ -82,6 +82,7 @@ void hwss_uninit(void) { nrfx_timer_disable(&m_timer); }
void hwss_start_capture(void) {
m_start_capture_tp = znordic_getpower_on_s();
swap_buffer();
nrfx_timer_enable(&m_timer);
}
void hwss_stop_capture(void) { nrfx_timer_disable(&m_timer); }

2
app/src/one_conduction/one_conduction_board.c

@ -289,7 +289,7 @@ void SingleLeadECG_eeprom_write(uint32_t addr, const uint8_t *data, uint16_t len
// ZASSERT(len == EEPROM_PAGE);
ZASSERT((addr % EEPROM_PAGE) == 0);
ZLOGI_BLOCK("eeprom_write %d %d", addr, len);
// ZLOGI_BLOCK("eeprom_write %d %d", addr, len);
uint8_t deviceSelect = 0;
assign_i2c_add(addr, true, &deviceSelect, &eeprom_cache[0], &eeprom_cache[1]);

88
app/src/one_conduction/one_conduction_main.c

@ -3,12 +3,12 @@
#include "app_event.h"
#include "basic/zble_module.h"
#include "basic/zdatachannel_service.h"
#include "config.h"
#include "display_manager.h"
#include "heart_wave_sample_service.h"
#include "one_conduction_board.h"
#include "sample_data_manager.h"
#include "znordic.h"
typedef enum {
//
kdevice_state_standby = 0,
@ -21,9 +21,9 @@ typedef enum {
//
kdevice_state_sampling,
//
kdevice_state_sampling_end,
// kdevice_state_sampling_end,
//
kdevice_state_storing,
// kdevice_state_storing,
//
kdevice_state_sampling_complete,
//
@ -44,10 +44,6 @@ static const char* device_state_to_str(device_state_t ds) {
return "keep_still";
case kdevice_state_sampling:
return "sampling";
case kdevice_state_sampling_end:
return "sampling_end";
case kdevice_state_storing:
return "storing";
case kdevice_state_sampling_complete:
return "sampling_complete";
case kdevice_state_sampling_error:
@ -67,9 +63,11 @@ ZDATACHANNEL_DEF(m_zhrs, 2 /*
APP_TIMER_DEF(m_state_machine_driver_tmr); //
APP_TIMER_DEF(m_plod_state_event_detect_tmr); //
APP_TIMER_DEF(m_charge_event_detect_tmr); //
extern uint32_t g_nrf_log_tx_pin;
static device_state_t m_device_state = kdevice_state_standby; //
static uint32_t m_change_to_cur_state_tp = 0; //
extern uint32_t g_nrf_log_tx_pin;
static device_state_t m_device_state = kdevice_state_standby; //
static uint32_t m_change_to_cur_state_tp = 0; //
static int m_cur_fd;
static sample_data_filename_t sampledata_file_name;
#define SCHED_MAX_EVENT_DATA_SIZE MAX(sizeof(app_event_t), APP_TIMER_SCHED_EVENT_DATA_SIZE)
@ -291,7 +289,8 @@ void app_event_process_cb(void* p_event_data, uint16_t event_size) {
*******************************************************************************/
if (cur_state_haspassed_ms() >= (500 * 5)) {
/**
* @brief
* @brief 2500ms后
*
* 1.
* 2.
* 3.
@ -299,6 +298,18 @@ void app_event_process_cb(void* p_event_data, uint16_t event_size) {
state_machine_change_to_state(kdevice_state_sampling);
dsp_mgr_change_to_sampling(0, 0);
hwss_start_capture();
static ztm_t tm;
memset(&sampledata_file_name, 0, sizeof(sampledata_file_name));
znordic_rtc_gettime(&tm);
sampledata_file_name.year = tm.tm_year;
sampledata_file_name.month = tm.tm_mon;
sampledata_file_name.day = tm.tm_mday;
sampledata_file_name.hour = tm.tm_hour;
sampledata_file_name.min = tm.tm_min;
sampledata_file_name.sec = tm.tm_sec;
m_cur_fd = sample_data_mgr_open(&sampledata_file_name, kwrflag_write_only);
} else if (cur_state_haspassed_ms() >= (500 * 4)) {
if (dsp_mgr_preparePage_get_progress() != 4) {
dsp_mgr_preparePage_set_progress(4);
@ -321,6 +332,61 @@ void app_event_process_cb(void* p_event_data, uint16_t event_size) {
/*******************************************************************************
* *
*******************************************************************************/
/**
* @brief
*
* --->
* 30
* --->
* 30
* --->
*/
if (p_event->eventType == kevent_capture_data_event) {
if (hwss_has_captured_time_ms() <= (MAX_STORAGE_TIMEOUT_S * 1000)) {
sample_data_mgr_write(m_cur_fd, p_event->val.capture_data_cache, 256);
} else {
//
/*******************************************************************************
* *
*******************************************************************************/
sample_data_mgr_close(m_cur_fd);
state_machine_change_to_state(kdevice_state_sampling_complete);
hwss_stop_capture();
}
} else if (!m_plod_state_connected_state || p_event->eventType == kplod_disconnected_event) {
if (hwss_has_captured_time_ms() < 30000) {
// 30
/*******************************************************************************
* *
*******************************************************************************/
sample_data_mgr_close(m_cur_fd);
sample_data_mgr_delete_file(&sampledata_file_name);
dsp_mgr_change_to_samplingError();
state_machine_change_to_state(kdevice_state_sampling_error);
hwss_stop_capture();
} else {
// 30
/*******************************************************************************
* *
*******************************************************************************/
sample_data_mgr_close(m_cur_fd);
dsp_mgr_change_to_sampleSuc();
state_machine_change_to_state(kdevice_state_sampling_complete);
hwss_stop_capture();
}
}
} else if (m_device_state == kdevice_state_sampling_complete) {
if (cur_state_haspassed_ms() >= 2000) {
ZLOGI("cur_state_haspassed_ms() %d> 2000", cur_state_haspassed_ms());
state_machine__change_to_home_state();
}
} else if (m_device_state == kdevice_state_sampling_error) {
if ((cur_state_haspassed_ms() >= 2000) || (cur_state_haspassed_ms() >= 1000 && m_plod_state_connected_state)) {
ZLOGI("cur_state_haspassed_ms() %d> 2000", cur_state_haspassed_ms());
state_machine__change_to_home_state();
}
}
#if 0

9
app/src/one_conduction/sample_data_manager.c

@ -25,7 +25,7 @@ sample_data_fileinfo_list_t* sample_data_mgr_get_fileinfo_list() { //
sample_data_fileinfo_t* fileinfo = &fileinfocache[i];
fileinfo->fileuuid = sectorinfo->fileuuid;
memcpy(fileinfo->filename, sectorinfo->filename, sizeof(fileinfo->filename));
fileinfo->size = zeeprom_fs_get_filesize(fileinfo->fileuuid);
fileinfo->size = zeeprom_fs_get_filesize_by_fileuuid(fileinfo->fileuuid);
fileinfo_list.fileinfo[fileinfo_list.count] = fileinfo;
fileinfo_list.count++;
@ -72,7 +72,8 @@ int32_t sample_data_mgr_open(sample_data_filename_t* filename, wrflag_t flag) {
}
return zeeprom_fs_open((uint8_t*)filename, flag);
}
int32_t sample_data_mgr_close(int32_t fileId) { return zeeprom_fs_close(fileId); }
int32_t sample_data_mgr_write(int32_t fileId, const uint8_t* data, int32_t size) { return zeeprom_fs_write(fileId, data, size); }
int32_t sample_data_mgr_read(int32_t fileId, uint8_t* data, int32_t size) { return zeeprom_fs_read(fileId, data, size); }
int32_t sample_data_mgr_close(int32_t fd) { return zeeprom_fs_close(fd); }
int32_t sample_data_mgr_write(int32_t fd, const uint8_t* data, int32_t size) { return zeeprom_fs_write(fd, data, size); }
int32_t sample_data_mgr_read(int32_t fd, uint8_t* data, int32_t size) { return zeeprom_fs_read(fd, data, size); }
int32_t sample_data_mgr_get_file_size_by_fd(int32_t fd) { return zeeprom_fs_get_filesize_by_fd(fd); }
int32_t sample_data_mgr_delete_file(sample_data_filename_t* filename) { return zeeprom_fs_delete_by_name((uint8_t*)filename); }

25
app/src/one_conduction/sample_data_manager.h

@ -1,19 +1,21 @@
#pragma once
#include <stdint.h>
#include "zeeprom_fs.h"
#include "config.h"
void sample_data_mgr_init();
#define FILE_MAX_COUNT 10
#define FILE_MAX_COUNT MAX_FILE_NUM
typedef struct {
uint8_t year;
uint8_t month;
uint8_t day;
uint8_t hour;
uint8_t min;
uint8_t sec;
uint8_t placeholder[2];
uint16_t year;
uint8_t month;
uint8_t day;
uint8_t hour;
uint8_t min;
uint8_t sec;
uint8_t placeholder[2];
} sample_data_filename_t;
typedef struct {
@ -33,9 +35,10 @@ void sample_data_mgr_uninit();
sample_data_fileinfo_list_t* sample_data_mgr_get_fileinfo_list();
int32_t sample_data_mgr_open(sample_data_filename_t* filename, wrflag_t flag);
int32_t sample_data_mgr_close(int32_t fileId);
int32_t sample_data_mgr_close(int32_t fd);
int32_t sample_data_mgr_write(int32_t fileId, const uint8_t* data, int32_t size);
int32_t sample_data_mgr_read(int32_t fileId, uint8_t* data, int32_t size);
int32_t sample_data_mgr_write(int32_t fd, const uint8_t* data, int32_t size);
int32_t sample_data_mgr_read(int32_t fd, uint8_t* data, int32_t size);
int32_t sample_data_mgr_get_file_size_by_fd(int32_t fd);
int32_t sample_data_mgr_delete_file(sample_data_filename_t* filename);

36
app/src/one_conduction/zeeprom_fs.c

@ -39,15 +39,19 @@ static int32_t compute_checksum(uint8_t* data, uint16_t len);
/*******************************************************************************
* CODE *
*******************************************************************************/
int zeeprom_fs_init() { //
static bool m_eeprom_header_inited = false;
int zeeprom_fs_init() { //
SingleLeadECG_eeprom_init();
zeeprom_read(0, (uint8_t*)&m_eeprom_header, sizeof(m_eeprom_header));
int32_t checksum_val = compute_checksum((uint8_t*)&m_eeprom_header, sizeof(m_eeprom_header) - sizeof(m_eeprom_header.checksum));
if (checksum_val != m_eeprom_header.checksum) {
memset(&m_eeprom_header, 0, sizeof(m_eeprom_header));
if (!m_eeprom_header_inited) {
zeeprom_read(0, (uint8_t*)&m_eeprom_header, sizeof(m_eeprom_header));
int32_t checksum_val = compute_checksum((uint8_t*)&m_eeprom_header, sizeof(m_eeprom_header) - sizeof(m_eeprom_header.checksum));
if (checksum_val != m_eeprom_header.checksum) {
memset(&m_eeprom_header, 0, sizeof(m_eeprom_header));
}
}
m_is_init = true;
m_is_init = true;
m_eeprom_header_inited = true;
return 0;
}
int zeeprom_fs_uinit() { //
@ -199,15 +203,22 @@ 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;
zeeprom_write(0, (uint8_t*)&m_eeprom_header, sizeof(m_eeprom_header));
// 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);
return 0;
}
int zeeprom_fs_get_filesize_by_fd(int fd) {
ZASSERT(m_is_init);
filehandler_t* fileHander = filehandler_find(fd);
if (!fileHander) return 0;
return fileHander->file_size;
}
int zeeprom_fs_read(int fileid, uint8_t* data, int32_t size) {
ZASSERT(m_is_init);
@ -277,9 +288,8 @@ int zeeprom_fs_delete_the_oldest_file() {
return 0;
}
int zeeprom_fs_get_filesize(int32_t fileuuid) {
int zeeprom_fs_get_filesize_by_fileuuid(int32_t fileuuid) {
ZASSERT(m_is_init);
return sector_mgr_file_get_size(fileuuid);
}

9
app/src/one_conduction/zeeprom_fs.h

@ -50,12 +50,12 @@ zeeprom_header_t* zeeprom_fs_get_header();
int zeeprom_fs_open(uint8_t* filename, wrflag_t flag);
int zeeprom_fs_close(int fileid);
int zeeprom_fs_close(int fd);
int zeeprom_fs_write(int fileid, const uint8_t* data, int32_t size);
int zeeprom_fs_read(int fileid, uint8_t* data, int32_t size);
int zeeprom_fs_write(int fd, const uint8_t* data, int32_t size);
int zeeprom_fs_read(int fd, uint8_t* data, int32_t size);
int zeeprom_fs_get_filesize(int32_t fileuuid);
int zeeprom_fs_get_filesize_by_fd(int fd);
int zeeprom_fs_get_file_num();
int zeeprom_fs_delete_the_oldest_file();
@ -63,3 +63,4 @@ int zeeprom_fs_delete(int32_t fileuuid);
int zeeprom_fs_delete_by_name(uint8_t* filename);
int zeeprom_fs_dump_sector_state();
int zeeprom_fs_get_filesize_by_fileuuid(int32_t fileuuid);

2
libznordic

@ -1 +1 @@
Subproject commit 0252fc4554585e8924e6e8ba9b2749e0b29c59d3
Subproject commit 1eb8d83d8d82aecd5a0da03be2a9399e061f91a8
Loading…
Cancel
Save