This commit is contained in:
lmx
2025-11-11 09:38:51 +08:00
parent d12252dfda
commit 23a71377a2
4 changed files with 179 additions and 94 deletions

View File

@ -49,7 +49,9 @@ extern void create_process(u16* pid, const char* name, void *priv, void (*func)(
// --- 任务ID ---
static u16 xtell_i2c_test_id;
static u16 collect_data_id;
static u16 send_data_id;
static u16 ble_send_data_id;
static u16 sensor_read_data_id;
static u16 calculate_data_id;
// --- 环形缓冲区 ---
#define SENSOR_DATA_BUFFER_SIZE 512
@ -240,41 +242,25 @@ void test(){
}
#else
void BLE_send_data(){
signed short acc_data_buf[3] = {0};
signed short gyr_data_buf[3] = {0};
signed short acc_gyro_input[6] = {0};
float Angle_output[3] = {0};
SL_SC7U22_RawData_Read(acc_data_buf,gyr_data_buf);
BLE_send_data = sensor_processing_task(acc_data_buf, gyr_data_buf);
u8 data[50];
data[0] = 0xBB;
data[1] = 0xBE;
data[2] = 0x01;
data[3] = sizeof(BLE_send_data_t); //后续包的数据长度
// send_data_to_ble_client(&data,sizeof(BLE_send_data_t)+4);
memcpy(&data[4], &BLE_send_data, sizeof(BLE_send_data_t));
static int count = 0;
if(count >=10){
count = 0;
send_data_to_ble_client(&data,sizeof(BLE_send_data_t)+4);
}
count++;
memset(&BLE_send_data, 0, sizeof(BLE_send_data_t));
memset(&data, 0, 50);
}
#endif
void gsensor_test(){
sys_timer_del(gsensor_id);
void sensor_read_data(){
//读取传感器的原始六轴数据放进缓冲区
}
void calculate_data(){
//从缓冲区取出原始六轴数据,进行计算得到速度和距离
//计算方面已经实现,直接调用函数就行了
}
void BLE_send_data(){
//蓝牙发送数据:计算得到的速度、距离以及读到的原始六轴数据
}
void xtell_task_create(void){
@ -301,11 +287,10 @@ void xtell_task_create(void){
// SkiingTracker_Init(&skiing_data);
xlog("SkiingTracker_Init\n");
// create_process(&gsensor_id, "gsensor",NULL, gsensor_test, 1000);
create_process(&test_id, "test",NULL, test, (int)(DELTA_TIME*1000));
// while(1){
// test();
// os_time_dly((int)(DELTA_TIME*1000));
// }
// create_process(&test_id, "test",NULL, test, (int)(DELTA_TIME*1000));
create_process(&ble_send_data_id, "send",NULL, ble_send_data, (int)(DELTA_TIME*1000));
create_process(&sensor_read_data_id, "read",NULL, sensor_read_data, (int)(DELTA_TIME*1000));
create_process(&calculate_data_id, "calculate",NULL, calculate_data, (int)(DELTA_TIME*1000));
}