启动阈值调整
This commit is contained in:
@ -202,7 +202,9 @@ void cfg_file_parse(u8 idx)
|
||||
log_info("read bt name err");
|
||||
} else if (ret >= LOCAL_NAME_LEN) {
|
||||
memset(bt_cfg.edr_name, 0x00, LOCAL_NAME_LEN);
|
||||
memcpy(bt_cfg.edr_name, tmp, LOCAL_NAME_LEN);
|
||||
// memcpy(bt_cfg.edr_name, tmp, LOCAL_NAME_LEN);
|
||||
extern char xt_ble_new_name[9];
|
||||
memcpy(bt_cfg.edr_name, xt_ble_new_name, LOCAL_NAME_LEN);
|
||||
bt_cfg.edr_name[LOCAL_NAME_LEN - 1] = 0;
|
||||
} else {
|
||||
memset(bt_cfg.edr_name, 0x00, LOCAL_NAME_LEN);
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
// 加速度模长与重力的差值大于此值,认为开始运动;降低阈值,让“油门”更灵敏,以便能捕捉到真实的慢速启动
|
||||
#define START_SKIING_ACC_THRESHOLD 0.5f
|
||||
// 陀螺仪方差阈值,以允许启动瞬间的正常抖动,但仍能过滤掉混乱的、非滑雪的晃动。
|
||||
#define SKIING_GYR_VARIANCE_THRESHOLD 20.0f
|
||||
#define SKIING_GYR_VARIANCE_THRESHOLD 15.0f
|
||||
|
||||
// --- 滑雪过程 ---
|
||||
//加速度 模长,低于此值视为 在做匀速运动
|
||||
@ -268,7 +268,7 @@ static void update_state_machine(skiing_tracker_t *tracker, const float *acc_dev
|
||||
case STATIC:
|
||||
//不break,会往下执行,判断是否进入非匀速状态
|
||||
case ROTATING: // 从静止或原地旋转可以启动
|
||||
if (fabsf(acc_magnitude - G_ACCELERATION) > START_SKIING_ACC_THRESHOLD && gyr_variance < SKIING_GYR_VARIANCE_THRESHOLD) {
|
||||
if (fabsf(acc_magnitude - G_ACCELERATION) > START_SKIING_ACC_THRESHOLD && gyr_variance > SKIING_GYR_VARIANCE_THRESHOLD) {
|
||||
tracker->state = NO_CONSTANT_SPEED;
|
||||
} else if (gyr_magnitude > ROTATION_GYR_MAG_THRESHOLD && acc_variance < ROTATING_ACC_VARIANCE_THRESHOLD) {
|
||||
tracker->state = ROTATING;
|
||||
@ -357,7 +357,7 @@ void skiing_tracker_update(skiing_tracker_t *tracker, float *acc_g, float *gyr_d
|
||||
float acc_horizontal_mag = sqrtf(tracker->acc_world_filtered[0] * tracker->acc_world_filtered[0] +
|
||||
tracker->acc_world_filtered[1] * tracker->acc_world_filtered[1]);
|
||||
// --- 根据状态进行计算 ---
|
||||
if (tracker->state == NO_CONSTANT_SPEED) {
|
||||
if (tracker->state == NO_CONSTANT_SPEED) { //非匀速
|
||||
if (acc_horizontal_mag > ACC_DEAD_ZONE_THRESHOLD) {
|
||||
// 只有当水平加速度足够大时,才进行速度积分
|
||||
tracker->velocity[0] += tracker->acc_world_filtered[0] * dt;
|
||||
@ -382,7 +382,7 @@ void skiing_tracker_update(skiing_tracker_t *tracker, float *acc_g, float *gyr_d
|
||||
//保持上次的速度不变。只更新距离
|
||||
tracker->distance += tracker->speed * dt;
|
||||
|
||||
}else if(tracker->state == WHEEL){ //匀速
|
||||
}else if(tracker->state == WHEEL){ //转弯
|
||||
//暂时:保持上次的速度不变。只更新距离
|
||||
tracker->distance += tracker->speed * dt;
|
||||
}else{
|
||||
@ -520,8 +520,8 @@ BLE_send_data_t sensor_processing_task(signed short* acc_data_buf, signed short*
|
||||
static float gyr_data_dps[3];
|
||||
|
||||
// const float delta_time = DELTA_TIME+0.01f;
|
||||
// const float delta_time = DELTA_TIME + 0.005f;
|
||||
const float delta_time = DELTA_TIME+0.01f;
|
||||
const float delta_time = DELTA_TIME + 0.005f;
|
||||
// const float delta_time = DELTA_TIME;
|
||||
BLE_send_data_t BLE_send_data;
|
||||
|
||||
if (!initialized) {
|
||||
|
||||
@ -10,6 +10,9 @@ typedef enum {
|
||||
ROTATING, // 正在原地旋转
|
||||
WHEEL, // 转弯
|
||||
FALLEN, // 已摔倒
|
||||
TAKING_OFF, // 起跳冲击阶段
|
||||
IN_AIR, // 空中失重阶段
|
||||
LANDING, // 落地冲击阶段
|
||||
STOP_DETECTION, // 停止检测
|
||||
UNKNOWN // 未知状态
|
||||
} skiing_state_t;
|
||||
|
||||
@ -263,7 +263,7 @@ static BLE_send_data_t sensor_send_buffer[SENSOR_DATA_BUFFER_SIZE]; // 存放ble
|
||||
*/
|
||||
void sensor_read_data(){
|
||||
|
||||
// xlog("=======sensor_read_data START\n");
|
||||
xlog("=======sensor_read_data START\n");
|
||||
static signed short combined_raw_data[6];
|
||||
static int initialized = 0;
|
||||
static int calibration_done = 0;
|
||||
@ -275,6 +275,7 @@ void sensor_read_data(){
|
||||
|
||||
static sensor_data_t tmp;
|
||||
SL_SC7U22_RawData_Read(tmp.acc_data,tmp.gyr_data);
|
||||
xlog("=======sensor_read_data middle 1\n");
|
||||
memcpy(&combined_raw_data[0], tmp.acc_data, 3 * sizeof(signed short));
|
||||
memcpy(&combined_raw_data[3], tmp.gyr_data, 3 * sizeof(signed short));
|
||||
|
||||
@ -291,7 +292,7 @@ void sensor_read_data(){
|
||||
memcpy(tmp.gyr_data, &combined_raw_data[3], 3 * sizeof(signed short));
|
||||
circle_buffer_write(&sensor_read, &tmp);
|
||||
}
|
||||
// xlog("=======sensor_read_data END\n");
|
||||
xlog("=======sensor_read_data END\n");
|
||||
|
||||
}
|
||||
|
||||
@ -391,7 +392,56 @@ void BLE_send_data(){
|
||||
#endif
|
||||
}
|
||||
|
||||
//iic测试调用的
|
||||
#if 1
|
||||
extern char xt_Check_Flag = 10;
|
||||
static u16 xt_iic_test_id;
|
||||
char log_buffer_1[100];
|
||||
extern char sen_log_buffer_1[100];
|
||||
extern char sen_log_buffer_2[100];
|
||||
extern char sen_log_buffer_3[100];
|
||||
extern char sen_log_buffer_4[100];
|
||||
extern char sen_log_buffer_5[100];
|
||||
extern char w_log_buffer_1[100];
|
||||
extern char w_log_buffer_2[100];
|
||||
extern char w_log_buffer_3[100];
|
||||
extern char w_log_buffer_4[100];
|
||||
extern char w_log_buffer_5[100];
|
||||
void xt_iic_test(){
|
||||
|
||||
char log_buffer[100];
|
||||
send_data_to_ble_client(&log_buffer_1,strlen(log_buffer_1));
|
||||
extern char iic_read_len;
|
||||
extern char iic_write_result;
|
||||
int num_chars_written = snprintf(log_buffer, sizeof(log_buffer),"SL_SC7U22_Check=0x%d,%d,%d\n", xt_Check_Flag, iic_read_len, iic_write_result);
|
||||
extern void send_data_to_ble_client(const u8* data, u16 length);
|
||||
send_data_to_ble_client(&log_buffer,strlen(log_buffer));
|
||||
|
||||
if(sen_log_buffer_1 != NULL)
|
||||
send_data_to_ble_client(&sen_log_buffer_1,strlen(sen_log_buffer_1));
|
||||
if(sen_log_buffer_2 != NULL)
|
||||
send_data_to_ble_client(&sen_log_buffer_2,strlen(sen_log_buffer_2));
|
||||
if(sen_log_buffer_3 != NULL)
|
||||
send_data_to_ble_client(&sen_log_buffer_3,strlen(sen_log_buffer_3));
|
||||
if(sen_log_buffer_4 != NULL)
|
||||
send_data_to_ble_client(&sen_log_buffer_4,strlen(sen_log_buffer_4));
|
||||
if(sen_log_buffer_5 != NULL)
|
||||
send_data_to_ble_client(&sen_log_buffer_5,strlen(sen_log_buffer_5));
|
||||
|
||||
if(w_log_buffer_1 != NULL)
|
||||
send_data_to_ble_client(&w_log_buffer_1,strlen(w_log_buffer_1));
|
||||
if(w_log_buffer_2 != NULL)
|
||||
send_data_to_ble_client(&w_log_buffer_2,strlen(w_log_buffer_2));
|
||||
if(w_log_buffer_3 != NULL)
|
||||
send_data_to_ble_client(&w_log_buffer_3,strlen(w_log_buffer_3));
|
||||
if(w_log_buffer_4 != NULL)
|
||||
send_data_to_ble_client(&w_log_buffer_4,strlen(w_log_buffer_4));
|
||||
if(w_log_buffer_5 != NULL)
|
||||
send_data_to_ble_client(&w_log_buffer_5,strlen(w_log_buffer_5));
|
||||
|
||||
// SL_SC7U22_Config();
|
||||
}
|
||||
#endif
|
||||
|
||||
void xtell_task_create(void){
|
||||
|
||||
@ -405,7 +455,9 @@ void xtell_task_create(void){
|
||||
int ret = hw_iic_init(0);
|
||||
xlog("init iic result:%d\n", ret); //返回0成功
|
||||
#else
|
||||
soft_iic_init(0);
|
||||
int ret = soft_iic_init(0);
|
||||
int num_chars_written = snprintf(log_buffer_1, sizeof(log_buffer_1),"init iic: %d\n", ret);
|
||||
|
||||
#endif
|
||||
|
||||
gpio_set_direction(IO_PORTE_05,0); //设置PE5 输出模式
|
||||
@ -436,9 +488,11 @@ void xtell_task_create(void){
|
||||
|
||||
create_process(&sensor_read_data_id, "read",NULL, sensor_read_data, 10);
|
||||
|
||||
create_process(&calculate_data_id, "calculate",NULL, calculate_data, 1);
|
||||
create_process(&calculate_data_id, "calculate",NULL, calculate_data, 5);
|
||||
|
||||
create_process(&ble_send_data_id, "send",NULL, BLE_send_data, 1);
|
||||
|
||||
// create_process(&xt_iic_test_id,"iic_test",NULL,xt_iic_test,1000);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -63,20 +63,21 @@ static void sl_delay(unsigned char sl_i)
|
||||
os_time_dly(sl_i);
|
||||
}
|
||||
|
||||
|
||||
char iic_read_len;
|
||||
char iic_write_result;
|
||||
unsigned char SL_SC7U22_Check(void)
|
||||
{
|
||||
unsigned char reg_value=0;
|
||||
xlog("SL_SC7U22_Check\n");
|
||||
SL_SC7U22_I2c_Spi_Write(SL_SPI_IIC_INTERFACE, 0x7F, 0x00);//goto 0x00
|
||||
SL_SC7U22_I2c_Spi_Read(SL_SPI_IIC_INTERFACE, SC7U22_WHO_AM_I, 1, ®_value);
|
||||
iic_write_result = SL_SC7U22_I2c_Spi_Write(SL_SPI_IIC_INTERFACE, 0x7F, 0x00);//goto 0x00
|
||||
iic_read_len = SL_SC7U22_I2c_Spi_Read(SL_SPI_IIC_INTERFACE, SC7U22_WHO_AM_I, 1, ®_value);
|
||||
xlog("0x%x=0x%x\r\n",SC7U22_WHO_AM_I,reg_value);
|
||||
if(reg_value==0x6A) //设备的id
|
||||
return 0x01;//SC7U22
|
||||
else
|
||||
return 0x00;//通信异常
|
||||
}
|
||||
|
||||
char xt_Check_Flag;
|
||||
unsigned char SL_SC7U22_Config(void)
|
||||
{
|
||||
xlog("SL_SC7U22_Config\n");
|
||||
@ -102,6 +103,10 @@ unsigned char SL_SC7U22_Config(void)
|
||||
// Check_Flag=1;//强制初始化
|
||||
|
||||
xlog("SL_SC7U22_Check=0x%x\r\n",Check_Flag);
|
||||
|
||||
|
||||
xt_Check_Flag = Check_Flag;
|
||||
|
||||
if(Check_Flag==1)
|
||||
{
|
||||
Check_Flag= SL_SC7U22_POWER_DOWN();
|
||||
|
||||
@ -100,6 +100,10 @@ void close_BL(){
|
||||
close_process(&close_BL_number,__func__);
|
||||
}
|
||||
|
||||
void xtell_set_ble_name(char* name){
|
||||
|
||||
}
|
||||
|
||||
|
||||
extern u32 timer_get_ms(void);
|
||||
void xtell_app_main()
|
||||
|
||||
@ -78,7 +78,7 @@ extern u8 init_ok;
|
||||
extern u8 sniff_out;
|
||||
unsigned char xtell_bl_state=0; //存放经典蓝牙的连接状态,0断开,1是连接
|
||||
u8 bt_newname =0;
|
||||
unsigned char xt_ble_new_name[9] = "CM-11111";
|
||||
unsigned char xt_ble_new_name[9] = "CM-22222";
|
||||
static u16 play_poweron_ok_timer_id = 0;
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -313,7 +313,7 @@ static int bt_connction_status_event_handler(struct bt_event *bt)
|
||||
case BT_STATUS_FIRST_CONNECTED:
|
||||
xlog("BT_STATUS_CONNECTED\n");
|
||||
xtell_bl_state = 1; //蓝牙连接成功 置1
|
||||
if(strcmp(xt_ble_new_name,"CM-1111") != 0){
|
||||
if(strcmp(xt_ble_new_name,"CM-11111") != 0){
|
||||
//蓝牙连接成功
|
||||
bt_newname =1;
|
||||
u8 temp[5]={0xBB,0xBE,0x02,0x04,0x00};
|
||||
|
||||
Reference in New Issue
Block a user