123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290 |
- #include "send_data.h"
- void send_package_data(uint16_t package_num, int32_t right_pos_data[3], int32_t left_pos_data[3], int16_t right_att_data[3], int16_t left_att_data[3],
- int16_t s_zupt, int16_t h_zupt,int16_t is_down, int16_t is_jump, int8_t s_rssi, uint8_t time_stamp)
- {
-
- uint8_t buf[256];
- uint8_t L=0;
-
-
- buf[L++] = (uint8_t)(right_pos_data[0]>>24);
- buf[L++] = (uint8_t)(right_pos_data[0]>>16);
- buf[L++] = (uint8_t)(right_pos_data[0]>>8);
- buf[L++] = (uint8_t)(right_pos_data[0]>>0);
-
- buf[L++] = (uint8_t)(right_pos_data[1]>>24);
- buf[L++] = (uint8_t)(right_pos_data[1]>>16);
- buf[L++] = (uint8_t)(right_pos_data[1]>>8);
- buf[L++] = (uint8_t)(right_pos_data[1]>>0);
-
- buf[L++] = (uint8_t)(right_pos_data[2]>>24);
- buf[L++] = (uint8_t)(right_pos_data[2]>>16);
- buf[L++] = (uint8_t)(right_pos_data[2]>>8);
- buf[L++] = (uint8_t)(right_pos_data[2]>>0);
-
-
- buf[L++] = (uint8_t)(left_pos_data[0]>>24);
- buf[L++] = (uint8_t)(left_pos_data[0]>>16);
- buf[L++] = (uint8_t)(left_pos_data[0]>>8);
- buf[L++] = (uint8_t)(left_pos_data[0]>>0);
-
- buf[L++] = (uint8_t)(left_pos_data[1]>>24);
- buf[L++] = (uint8_t)(left_pos_data[1]>>16);
- buf[L++] = (uint8_t)(left_pos_data[1]>>8);
- buf[L++] = (uint8_t)(left_pos_data[1]>>0);
-
- buf[L++] = (uint8_t)(left_pos_data[2]>>24);
- buf[L++] = (uint8_t)(left_pos_data[2]>>16);
- buf[L++] = (uint8_t)(left_pos_data[2]>>8);
- buf[L++] = (uint8_t)(left_pos_data[2]>>0);
-
- buf[L++] = (uint8_t)(right_att_data[0]>>8);
- buf[L++] = (uint8_t)(right_att_data[0]>>0);
-
- buf[L++] = (uint8_t)(right_att_data[1]>>8);
- buf[L++] = (uint8_t)(right_att_data[1]>>0);
-
- buf[L++] = (uint8_t)(right_att_data[2]>>8);
- buf[L++] = (uint8_t)(right_att_data[2]>>0);
-
- buf[L++] = (uint8_t)(left_att_data[0]>>8);
- buf[L++] = (uint8_t)(left_att_data[0]>>0);
-
- buf[L++] = (uint8_t)(left_att_data[1]>>8);
- buf[L++] = (uint8_t)(left_att_data[1]>>0);
-
- buf[L++] = (uint8_t)(left_att_data[2]>>8);
- buf[L++] = (uint8_t)(left_att_data[2]>>0);
-
- int is_girl = 0;
-
- if(GIRL_SHOES)
- is_girl = 1;
-
-
- buf[L++] = (uint8_t)(is_girl * 16 + s_zupt * 8 + h_zupt * 4 + is_down * 2 + is_jump * 1);
-
- buf[L++] = (uint8_t)(s_rssi >> 0);
-
- buf[L++] = (uint8_t)(time_stamp);
-
- send_protocol(DEX_NUM,package_num,buf,L);
-
- }
- void send_data_to_com(int32_t s_pos[3], int32_t h_pos[3], int16_t s_att[3], int16_t h_att[3] , int16_t s_zupt, int16_t h_zupt, int16_t is_down, int16_t is_jump, int8_t s_rssi)
- {
- static uint8_t time_stamp = 0;
-
- if(LEFT_IS_HOST)
- send_package_data( 0x04, s_pos, h_pos, s_att, h_att ,s_zupt, h_zupt, is_down, is_jump, s_rssi, time_stamp);
-
- else
- send_package_data( 0x04, h_pos, s_pos, h_att, s_att ,h_zupt, s_zupt, is_down, is_jump, s_rssi, time_stamp);
-
- time_stamp ++;
- }
- void send_data_to_host(uint16_t press, int32_t pos_n_offset[3], int16_t att[3], int16_t zupt)
- {
- static uint16_t ts = 0;
- uint8_t buf[256];
- uint8_t L=0;
-
- buf[L++] = (uint8_t)(press>>8);
- buf[L++] = (uint8_t)(press>>0);
-
- buf[L++] = (uint8_t)(pos_n_offset[0]>>24);
- buf[L++] = (uint8_t)(pos_n_offset[0]>>16);
- buf[L++] = (uint8_t)(pos_n_offset[0]>>8);
- buf[L++] = (uint8_t)(pos_n_offset[0]>>0);
-
- buf[L++] = (uint8_t)(pos_n_offset[1]>>24);
- buf[L++] = (uint8_t)(pos_n_offset[1]>>16);
- buf[L++] = (uint8_t)(pos_n_offset[1]>>8);
- buf[L++] = (uint8_t)(pos_n_offset[1]>>0);
-
- buf[L++] = (uint8_t)(pos_n_offset[2]>>24);
- buf[L++] = (uint8_t)(pos_n_offset[2]>>16);
- buf[L++] = (uint8_t)(pos_n_offset[2]>>8);
- buf[L++] = (uint8_t)(pos_n_offset[2]>>0);
-
- buf[L++] = (uint8_t)(att[0]>>8);
- buf[L++] = (uint8_t)(att[0]>>0);
-
- buf[L++] = (uint8_t)(att[1]>>8);
- buf[L++] = (uint8_t)(att[1]>>0);
-
- buf[L++] = (uint8_t)(att[2]>>8);
- buf[L++] = (uint8_t)(att[2]>>0);
-
- buf[L++] = (uint8_t)(zupt>>0);
-
- buf[L++] = (uint8_t)(ts>>8);
- buf[L++] = (uint8_t)(ts>>0);
-
- ts++;
- send_protocol(DEX_NUM,CMD_HEART,buf,L);
- }
- void send_acc_mag_to_host(uint16_t press, int16_t accl[3], int16_t magn[3], int16_t zupt)
- {
- static uint16_t ts = 0;
- uint8_t buf[256];
- uint8_t L=0;
-
- buf[L++] = 0;
- buf[L++] = 0;
- buf[L++] = (uint8_t)(press>>8);
- buf[L++] = (uint8_t)(press>>0);
-
- buf[L++] = (uint8_t)(accl[0]>>8);
- buf[L++] = (uint8_t)(accl[0]>>0);
-
- buf[L++] = (uint8_t)(accl[1]>>8);
- buf[L++] = (uint8_t)(accl[1]>>0);
-
- buf[L++] = (uint8_t)(accl[2]>>8);
- buf[L++] = (uint8_t)(accl[2]>>0);
-
- buf[L++] = (uint8_t)(magn[0]>>8);
- buf[L++] = (uint8_t)(magn[0]>>0);
-
- buf[L++] = (uint8_t)(magn[1]>>8);
- buf[L++] = (uint8_t)(magn[1]>>0);
-
- buf[L++] = (uint8_t)(magn[2]>>8);
- buf[L++] = (uint8_t)(magn[2]>>0);
-
- buf[L++] = (uint8_t)(zupt>>0);
-
- ts++;
- send_protocol(DEX_NUM,CMD_HEART,buf,L);
- }
- void send_imu_data_to_host(uint16_t press, int16_t gyro[3], int16_t accl[3], int16_t magn[3], int16_t zupt)
- {
-
- static uint16_t ts = 0;
- uint8_t buf[256];
- uint8_t L=0;
-
- buf[L++] = (uint8_t)(press>>8);
- buf[L++] = (uint8_t)(press>>0);
-
- buf[L++] = (uint8_t)(gyro[0]>>8);
- buf[L++] = (uint8_t)(gyro[0]>>0);
-
- buf[L++] = (uint8_t)(gyro[1]>>8);
- buf[L++] = (uint8_t)(gyro[1]>>0);
-
- buf[L++] = (uint8_t)(gyro[2]>>8);
- buf[L++] = (uint8_t)(gyro[2]>>0);
-
- buf[L++] = (uint8_t)(accl[0]>>8);
- buf[L++] = (uint8_t)(accl[0]>>0);
-
- buf[L++] = (uint8_t)(accl[1]>>8);
- buf[L++] = (uint8_t)(accl[1]>>0);
-
- buf[L++] = (uint8_t)(accl[2]>>8);
- buf[L++] = (uint8_t)(accl[2]>>0);
-
- buf[L++] = (uint8_t)(magn[0]>>8);
- buf[L++] = (uint8_t)(magn[0]>>0);
-
- buf[L++] = (uint8_t)(magn[1]>>8);
- buf[L++] = (uint8_t)(magn[1]>>0);
-
- buf[L++] = (uint8_t)(magn[2]>>8);
- buf[L++] = (uint8_t)(magn[2]>>0);
-
- buf[L++] = (uint8_t)(zupt>>0);
-
- buf[L++] = (uint8_t)(ts>>8);
- buf[L++] = (uint8_t)(ts>>0);
-
- ts++;
- send_protocol(DEX_NUM,CMD_HEART,buf,L);
- }
- void send_imu_data_to_ble(uint16_t press, int16_t gyro[3], int16_t accl[3], int16_t magn[3],
- uint16_t s_press, int16_t s_gyro[3], int16_t s_accl[3], int16_t s_magn[3], int8_t rssi )
- {
- static uint16_t ts = 0;
- uint8_t buf[256];
- uint8_t L=0;
-
- buf[L++] = (uint8_t)(press>>8);
- buf[L++] = (uint8_t)(press>>0);
-
- buf[L++] = (uint8_t)(gyro[0]>>8);
- buf[L++] = (uint8_t)(gyro[0]>>0);
-
- buf[L++] = (uint8_t)(gyro[1]>>8);
- buf[L++] = (uint8_t)(gyro[1]>>0);
-
- buf[L++] = (uint8_t)(gyro[2]>>8);
- buf[L++] = (uint8_t)(gyro[2]>>0);
-
- buf[L++] = (uint8_t)(accl[0]>>8);
- buf[L++] = (uint8_t)(accl[0]>>0);
-
- buf[L++] = (uint8_t)(accl[1]>>8);
- buf[L++] = (uint8_t)(accl[1]>>0);
-
- buf[L++] = (uint8_t)(accl[2]>>8);
- buf[L++] = (uint8_t)(accl[2]>>0);
-
- buf[L++] = (uint8_t)(magn[0]>>8);
- buf[L++] = (uint8_t)(magn[0]>>0);
-
- buf[L++] = (uint8_t)(magn[1]>>8);
- buf[L++] = (uint8_t)(magn[1]>>0);
-
- buf[L++] = (uint8_t)(magn[2]>>8);
- buf[L++] = (uint8_t)(magn[2]>>0);
-
- buf[L++] = (uint8_t)(s_press>>8);
- buf[L++] = (uint8_t)(s_press>>0);
-
- buf[L++] = (uint8_t)(s_gyro[0]>>8);
- buf[L++] = (uint8_t)(s_gyro[0]>>0);
-
- buf[L++] = (uint8_t)(s_gyro[1]>>8);
- buf[L++] = (uint8_t)(s_gyro[1]>>0);
-
- buf[L++] = (uint8_t)(s_gyro[2]>>8);
- buf[L++] = (uint8_t)(s_gyro[2]>>0);
-
- buf[L++] = (uint8_t)(s_accl[0]>>8);
- buf[L++] = (uint8_t)(s_accl[0]>>0);
-
- buf[L++] = (uint8_t)(s_accl[1]>>8);
- buf[L++] = (uint8_t)(s_accl[1]>>0);
-
- buf[L++] = (uint8_t)(s_accl[2]>>8);
- buf[L++] = (uint8_t)(s_accl[2]>>0);
-
- buf[L++] = (uint8_t)(s_magn[0]>>8);
- buf[L++] = (uint8_t)(s_magn[0]>>0);
-
- buf[L++] = (uint8_t)(s_magn[1]>>8);
- buf[L++] = (uint8_t)(s_magn[1]>>0);
-
- buf[L++] = (uint8_t)(s_magn[2]>>8);
- buf[L++] = (uint8_t)(s_magn[2]>>0);
-
- buf[L++] = (uint8_t)(rssi);
-
- send_protocol(DEX_NUM,CMD_HEART,buf,L);
- }
|