You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

92 lines
2.3 KiB

#pragma once
#include <stdbool.h>
#include <stdint.h>
#include "board/board.h"
typedef enum {
kplod_connected_event = 0, // 导联连接事件
kplod_disconnected_event, // 导联断开事件
kplod_connecting_event, // 导联连接中事件
kbattery_start_charge_event, // 充电事件
kbattery_charging_event, // 充电中
kbattery_end_charge_event, // 充电结束事件
kevent_tmr_scheduler_event, // 定时器调度事件
kevent_capture_256data_event, // 采样数据回调
kevent_capture_little_data_block_event, // 单次采样数据回调
} app_event_type_t;
typedef struct {
uint16_t data;
} one_frame_data_t;
typedef struct {
app_event_type_t eventType;
union {
uint32_t plod_connected_accumulation_time; // 导联连接累计时间
uint8_t* capture_data_cache; // 实时采样数据,数据长度为256字节
struct {
uint32_t frameIndex;
one_frame_data_t data[LITTLE_DATA_BLOCK_FRAME_NUM];
} little_data_block;
} val;
} app_event_t;
typedef enum {
// 待机
kdevice_state_standby = 0,
// 开机
kdevice_state_poweron,
// 首页
kdevice_state_home,
// 提示用户保持静止
kdevice_state_keep_still,
// 采集中
kdevice_state_sampling,
// 采集完成
kdevice_state_sampling_complete,
// 采集异常
kdevice_state_sampling_error,
// 充电中
kdevice_state_charging,
} device_state_t;
static const char* device_state_to_str(device_state_t ds) {
switch (ds) {
case kdevice_state_standby:
return "standby";
case kdevice_state_poweron:
return "poweron";
case kdevice_state_home:
return "home";
case kdevice_state_keep_still:
return "keep_still";
case kdevice_state_sampling:
return "sampling";
case kdevice_state_sampling_complete:
return "sampling_complete";
case kdevice_state_sampling_error:
return "sampling_error";
case kdevice_state_charging:
return "charging";
default:
return "unknow";
}
}
void app_event_process_cb(void* p_event_data, uint16_t event_size);
void ds_change_to_state(device_state_t state);
uint32_t ds_cur_state_haspassed_ms();
device_state_t ds_now_state();
typedef struct {
bool is_over30s;
} sample_capture_state_t;
sample_capture_state_t* sample_capture_state_get();
void sample_capture_state_reset();
void sample_capture_state_set_is_over30s(bool over30s);