第6版
This commit is contained in:
@ -20,6 +20,7 @@
|
||||
#include "circle_buffer.h"
|
||||
#include "btstack/avctp_user.h"
|
||||
#include "calculate/skiing_tracker.h"
|
||||
#include "xtell.h"
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//宏定义
|
||||
#define ENABLE_XLOG 1
|
||||
@ -55,7 +56,7 @@ static u16 send_data_id;
|
||||
static u8 sensor_data_buffer[SENSOR_DATA_BUFFER_SIZE];
|
||||
static circle_buffer_t sensor_cb;
|
||||
|
||||
|
||||
BLE_send_data_t BLE_send_data;
|
||||
//--- test ---
|
||||
// 全局变量
|
||||
u16 gsensor_id=0;
|
||||
@ -142,36 +143,59 @@ void send_sensor_data_task(void) {
|
||||
}
|
||||
|
||||
void test(){
|
||||
|
||||
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};
|
||||
extern void SL_SC7U22_RawData_Read(signed short * acc_data_buf,signed short * gyr_data_buf);
|
||||
|
||||
SL_SC7U22_RawData_Read(acc_data_buf,gyr_data_buf);
|
||||
acc_gyro_input[0] = acc_data_buf[0];
|
||||
acc_gyro_input[1] = acc_data_buf[1];
|
||||
acc_gyro_input[2] = acc_data_buf[2];
|
||||
acc_gyro_input[3] = gyr_data_buf[0];
|
||||
acc_gyro_input[4] = gyr_data_buf[1];
|
||||
acc_gyro_input[5] = gyr_data_buf[2];
|
||||
// extern unsigned char SL_SC7U22_Angle_Output(unsigned char calibration_en, signed short *acc_gyro_input, float *Angle_output, unsigned char yaw_rst);
|
||||
// SL_SC7U22_Angle_Output(0,acc_gyro_input,Angle_output,1);
|
||||
|
||||
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 >=100){ //1s打印1次
|
||||
if(count >=10){
|
||||
count = 0;
|
||||
#ifdef XTELL_TEST
|
||||
xlog("BLE_send_data_t:%d\n",sizeof(BLE_send_data_t));
|
||||
xlog("ACC_X:%d, ACC_Y:%d, ACC_Z:%d, GYR_X:%.d, GYR_Y:%d, GYR_Z:%d",
|
||||
acc_gyro_input[0],acc_gyro_input[1],acc_gyro_input[2],acc_gyro_input[3],acc_gyro_input[4],acc_gyro_input[5]
|
||||
acc_data_buf[0],acc_data_buf[1],acc_data_buf[2],gyr_data_buf[0],gyr_data_buf[1],gyr_data_buf[2]
|
||||
);
|
||||
printf("State: %d, Speed: %d cm/s, Distance: %d cm\n",
|
||||
BLE_send_data.skiing_state,
|
||||
BLE_send_data.speed_cms,
|
||||
BLE_send_data.distance_cm);
|
||||
|
||||
char log_buffer[100]; // 100个字符应该足够了
|
||||
|
||||
// 使用 snprintf 进行格式化
|
||||
int num_chars_written = snprintf(
|
||||
log_buffer, // 目标缓冲区
|
||||
sizeof(log_buffer), // 目标缓冲区的最大容量
|
||||
"State: %d, Speed: %d cm/s, Distance: %d cm\n", // 格式化字符串
|
||||
BLE_send_data.skiing_state, // 第一个 %d 的参数
|
||||
BLE_send_data.speed_cms, // 第二个 %d 的参数
|
||||
BLE_send_data.distance_cm // 第三个 %d 的参数
|
||||
);
|
||||
send_data_to_ble_client(&log_buffer,strlen(log_buffer));
|
||||
// xlog("Pitch:%.2f, Roll:%.2f, Yaw:%.2f\n",
|
||||
// Angle_output[0],Angle_output[1],Angle_output[2]
|
||||
// );
|
||||
// Angle_output[0],Angle_output[1],Angle_output[2]
|
||||
// );
|
||||
#else
|
||||
send_data_to_ble_client(&data,sizeof(BLE_send_data_t)+4);
|
||||
#endif
|
||||
}
|
||||
count++;
|
||||
|
||||
void sensor_processing_task(signed short * acc_data_buf,signed short * gyr_data_buf);
|
||||
sensor_processing_task(acc_data_buf, gyr_data_buf);
|
||||
memset(&BLE_send_data, 0, sizeof(BLE_send_data_t));
|
||||
memset(&data, 0, 50);
|
||||
|
||||
}
|
||||
void gsensor_test(){
|
||||
|
||||
@ -206,6 +230,6 @@ void xtell_task_create(void){
|
||||
xlog("SkiingTracker_Init\n");
|
||||
|
||||
// create_process(&gsensor_id, "gsensor",NULL, gsensor_test, 1000);
|
||||
create_process(&test_id, "test",NULL, test, 10);
|
||||
create_process(&test_id, "test",NULL, test, (int)(DELTA_TIME*1000));
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user