Browse Source

update

master
zhaohe 1 year ago
parent
commit
2009e35a62
  1. 2
      app/src/board/board.h
  2. 17
      app/src/board/board_button.c
  3. 8
      app/src/device_ctrl_service.c
  4. 14
      app/src/heart_wave_sample_service.c
  5. 10
      sample_bin_parser/.clang-format
  6. 62
      sample_bin_parser/.vscode/settings.json
  7. 1
      sample_bin_parser/README.md
  8. 54
      sample_bin_parser/sample_bin_parse.cpp
  9. BIN
      sample_bin_parser/sample_bin_parse.exe

2
app/src/board/board.h

@ -58,7 +58,7 @@
#define HEART_WAVE_SAMPLE_SERVICE_CACHE_SIZE (3 * 3 * 256)
#define FILE_MAX_COUNT 1
#define SDCARD_MAX_FILE_SIZE (uint32_t)(3 * 1024 * 1024 * 1024)
#define SDCARD_MAX_FILE_SIZE (uint32_t)(3.5 * 1024 * 1024 * 1024)
//
#define SAMPLE_RATE 500
#define SAMPLE_PRECISION 24

17
app/src/board/board_button.c

@ -14,16 +14,21 @@ void button_process_handler(uint8_t pin_no, uint8_t button_action) {
}
static app_button_cfg_t buttons[] = {
{BUTTON_PIN, false, NRF_GPIO_PIN_PULLUP, button_process_handler},
{BUTTON_PIN, true, NRF_GPIO_PIN_PULLUP, button_process_handler},
};
void BoardButton_Init(board_button_cb_t cb) { //
m_cb = cb;
ZERROR_CHECK(app_button_init(buttons, ARRAY_SIZE(buttons), BUTTON_DETECTION_DELAY));
// ZERROR_CHECK(app_button_init(buttons, ARRAY_SIZE(buttons), BUTTON_DETECTION_DELAY));
}
void BoardButton_load() {
// ZERROR_CHECK(app_button_enable());
}
void BoardButton_unload() {
// ZERROR_CHECK(app_button_disable());
}
void BoardButton_load() { ZERROR_CHECK(app_button_enable()); }
void BoardButton_unload() { ZERROR_CHECK(app_button_disable()); }
void BoardButton_enable_sense() {
app_button_disable();
nrf_gpio_cfg_sense_input(BUTTON_PIN, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
// app_button_disable();
nrf_gpio_cfg_sense_input(BUTTON_PIN, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_LOW);
// nrf_gpio_cfg_sense_input(BUTTON_PIN, NRF_GPIO_PIN_PULLDOWN, NRF_GPIO_PIN_SENSE_HIGH);
}

8
app/src/device_ctrl_service.c

@ -72,6 +72,7 @@ static void poweroff() {
// 使
BoardButton_enable_sense();
app_timer_stop_all();
//
sd_power_system_off();
NVIC_SystemReset();
@ -137,6 +138,12 @@ static void prvf_change_to_sample_state() { //
static void app_event_listener(void* p_event_data, uint16_t event_size) { //
app_event_t* event = (app_event_t*)p_event_data;
static bool inited;
if (!inited) {
nrf_gpio_cfg_input(BUTTON_PIN, NRF_GPIO_PIN_NOPULL);
inited = true;
}
ZLOGI("button %d", nrf_gpio_pin_read(BUTTON_PIN));
/*******************************************************************************
* *
@ -156,6 +163,7 @@ static void app_event_listener(void* p_event_data, uint16_t event_size) { //
if (m_device_state == kdevice_state_standby) {
//
}
//
else if (m_device_state == kdevice_state_ready) {
if (!zble_module_is_connected() && DeviceCtrl_cur_state_haspassed_ms() > APP_AUTO_SLEEP_TIMEOUT_MS) {

14
app/src/heart_wave_sample_service.c

@ -49,8 +49,11 @@ static ads1293_t m_ads1293_1;
static const nrf_drv_spi_t spi = NRF_DRV_SPI_INSTANCE(ADS1293_SPI_INSTANCE); /**< SPI instance. */
static bool m_ads1293_driver_is_inited = false;
static uint32_t m_frame_index;
static uint32_t m_frame_filter_index;
static bool m_work_flag;
#define FRAME_FILTER_INDEX_NUM 10
static uint8_t m_frame_buffer_a[HEART_WAVE_SAMPLE_SERVICE_CACHE_SIZE];
static uint8_t m_frame_buffer_b[HEART_WAVE_SAMPLE_SERVICE_CACHE_SIZE];
static uint8_t* m_frame_buffer;
@ -261,6 +264,10 @@ static void ads1293_sample_one_frame() {
if (!m_work_flag) {
return;
}
if (m_frame_filter_index < FRAME_FILTER_INDEX_NUM) {
m_frame_filter_index++;
return;
}
m_frame_index++;
// ¼ì²é»º³åÇøÊÇ·ñΪ¿Õ
if (!m_frame_buffer) prvf_buffer_switch();
@ -353,14 +360,17 @@ void hwss_unload(void) {
void hwss_start_capture(void) {
m_drop_state_triggered = false;
m_work_flag = true;
m_frame_index = 0;
m_frame_filter_index = 0;
ads1293_start_conversion(&m_ads1293_0);
ads1293_start_conversion(&m_ads1293_1);
nrfx_timer_enable(&m_timer);
}
void hwss_stop_capture(void) {
nrfx_timer_disable(&m_timer);
m_work_flag = false;
m_work_flag = false;
m_frame_index = 0;
m_frame_filter_index = 0;
ads1293_stop_conversion(&m_ads1293_0);
ads1293_stop_conversion(&m_ads1293_1);
}

10
sample_bin_parser/.clang-format

@ -0,0 +1,10 @@
# Defines the Chromium style for automatic reformatting.
# http://clang.llvm.org/docs/ClangFormatStyleOptions.html
Language: Cpp
BasedOnStyle: Google
ColumnLimit: 160
AlignConsecutiveMacros: true
AlignConsecutiveDeclarations: true
AlignConsecutiveAssignments: true
AlignOperands: true

62
sample_bin_parser/.vscode/settings.json

@ -0,0 +1,62 @@
{
"files.associations": {
"*.hpp": "cpp",
"fstream": "cpp",
"iostream": "cpp",
"string": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"*.tcc": "cpp",
"cctype": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"compare": "cpp",
"concepts": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"list": "cpp",
"map": "cpp",
"set": "cpp",
"unordered_map": "cpp",
"vector": "cpp",
"exception": "cpp",
"algorithm": "cpp",
"functional": "cpp",
"iterator": "cpp",
"memory": "cpp",
"memory_resource": "cpp",
"numeric": "cpp",
"random": "cpp",
"string_view": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"utility": "cpp",
"initializer_list": "cpp",
"iosfwd": "cpp",
"istream": "cpp",
"limits": "cpp",
"new": "cpp",
"numbers": "cpp",
"ostream": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"typeinfo": "cpp",
"thread": "cpp",
"ctime": "cpp",
"ratio": "cpp",
"semaphore": "cpp",
"stop_token": "cpp",
"condition_variable": "cpp",
"mutex": "cpp"
},
"files.encoding": "gbk"
}

1
sample_bin_parser/README.md

@ -0,0 +1 @@
g++ -static -static-libgcc -static-libstdc++ -lwsock32 -lstdc++ .\sample_bin_parse.cpp -o sample_bin_parse.exe

54
sample_bin_parser/sample_bin_parse.cpp

@ -0,0 +1,54 @@
#include <fstream>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <set>
#include <sstream>
#include <string>
#include <thread>
#include <vector>
//
#include <winsock2.h>
//
#include <Windows.h>
//
#include <stdio.h>
#pragma comment(lib, "ws2_32.lib")
#define PORT 8988
int main(int argc, char *argv[]) {
// 打开 0.bin
// 读取 0.bin 到数组中
// 每次读9byte
// 3byte 3byte 3byte
// 存放到0.csv中
std::ifstream ifs("0.bin", std::ios::binary);
if (!ifs) {
std::cerr << "open 0.bin failed" << std::endl;
return -1;
}
std::ofstream ofs("0.csv", std::ios::binary | std::ios::trunc);
if (!ofs) {
std::cerr << "open 0.csv failed" << std::endl;
return -1;
}
char buf[9];
while (ifs.read(buf, 9)) {
unsigned int a = 0;
unsigned int b = 0;
unsigned int c = 0;
a = (unsigned char)buf[0] | (unsigned char)buf[1] << 8 | (unsigned char)buf[2] << 16;
b = (unsigned char)buf[3] | (unsigned char)buf[4] << 8 | (unsigned char)buf[5] << 16;
c = (unsigned char)buf[6] | (unsigned char)buf[7] << 8 | (unsigned char)buf[8] << 16;
ofs << a << "," << b << "," << c << std::endl;
}
return 0;
}

BIN
sample_bin_parser/sample_bin_parse.exe

Loading…
Cancel
Save