1233
Dependencies: cJSON_lib mcp2515- mbed-dev-f303 esp8266 yezhong_main_controller_copy_3
Diff: DATA_xiedian/data_xiedian.cpp
- Revision:
- 0:e923de71caa5
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DATA_xiedian/data_xiedian.cpp Fri Jun 24 07:58:26 2022 +0000 @@ -0,0 +1,150 @@ +#include "data_xiedian.h" +#include "data_pc.h" +#include "CAN.h" + +Serial xiedian(PC_10, PC_11); + + + + + +unsigned int flag_foot_A = 0, flag_foot_B = 0; +unsigned int Sfootnum = 0; + +uint8_t Sfootget[45] = {0}; +uint8_t Sfootuse[45] = {0}; + +uint16_t shou[28]={0}; +float shou1[28]={0}; +Timer vv; + + + + + +void xiedian_decode() +{ + vv.start(); + vv.read(); + float b=vv.read(); +/* + for(int i = 0; i < 6; i++) + { + shou[i]=(Sfootuse[2*i]<<8)|Sfootuse[2*i+1]; + } + for(int i = 0; i < 11; i++) + { + shou[2*i+6]=(Sfootuse[3*i+12]<<4)|(Sfootuse[3*i+13]>>4); + shou[2*i+7]=((Sfootuse[3*i+13]<<8)&0xFFF)|Sfootuse[3*i+14]; + } + + for(int i = 0; i < 28; i++) + { + //shou1[i]=(float)shou[i]/4096*3.3; + shou1[i]=4096-shou[i]; + } + pc.printf("%2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %.3f\r\n",shou1[6],shou1[7],shou1[8],shou1[9],shou1[10],shou1[11],shou1[12],shou1[13],shou1[14],shou1[15],shou1[16],shou1[17],shou1[18],shou1[19],shou1[20],shou1[21],shou1[22],shou1[23],shou1[24],shou1[25],shou1[26],b); +*/ + for(int i = 0; i < 2; i++) + { + shou[2*i]=(Sfootuse[3*i]<<4)|(Sfootuse[3*i+1]>>4); + shou[2*i+1]=((Sfootuse[3*i+1]<<8)&0xFFF)|Sfootuse[3*i+2]; + } + for(int i = 0; i < 4; i++) + { + shou1[i]=4096-shou[i]; + } + // pc.printf("%2.2f %2.2f %2.2f %2.2f %0.3f\r\n",shou1[0],shou1[1],shou1[2],shou1[3],b); + pc.printf("xiedian:%2.2f %2.2f %2.2f %2.2f\r\n",shou1[0],shou1[1],shou1[2],shou1[3]); +} + + +void xiedian_clear() +{ + //for(int i = 0; i < 45; i++) + for(int i = 0; i < 6; i++) + { + Sfootuse[i] = 0; + } +} + + +void serial_xiedian_isr(void) +{ + // pc.printf("begin\n"); + + while(xiedian.readable()) + { + uint8_t c = xiedian.getc(); + if(c ==0x0A) + { + flag_foot_A = 1; + flag_foot_B = 0; + Sfootnum = 0; + //for(unsigned int i = 0; i < 45; i++) + for(unsigned int i = 0; i < 6; i++) + { + Sfootget[i] = 0; + } + + break; //直接结束;回到起始位置; + } + if(c ==0x0B) + { + flag_foot_B = 1; + } + + if(flag_foot_A == 1) + { + //if((flag_foot_B != 1) && (Sfootnum < 45)) + if((flag_foot_B != 1) && (Sfootnum < 6)) + { + Sfootget[Sfootnum] = c; + } + + Sfootnum++; + + //if((flag_foot_B == 1) && (Sfootnum != 46)) + if((flag_foot_B == 1) && (Sfootnum != 7)) + { + flag_foot_A = 0; + flag_foot_B = 0; + Sfootnum = 0; + } + + //if((flag_foot_B == 1) && (Sfootnum == 46)) + if((flag_foot_B == 1) && (Sfootnum == 7)) + { + flag_foot_A = 0; + flag_foot_B = 0; + Sfootnum = 0; + + // for(unsigned int i = 0; i < 45; i++) + for(unsigned int i = 0; i < 6; i++) + { + // Sfootuse[i] = Sfootget[i] - '0'; + Sfootuse[i] = Sfootget[i] ; + } + + xiedian_decode(); + xiedian_clear(); + } + } + } + +} + + + + + + + + + + + + + + +