四轴
Dependencies: BufferedSerial SoftPWM mbed send
Fork of send_copy by
JY901.h
00001 #include "mbed.h" 00002 #include "BufferedSerial.h"//波特率在这个头文件中改 00003 class JY901 00004 { 00005 int state, token, payloadLen, recvLen; 00006 unsigned char payloadBuf[16]; 00007 protected: 00008 BufferedSerial mod; 00009 float acc[3], gyo[3], mag[3], att[3]; 00010 void parseCmpt(int token, unsigned char* payloadBuf, int payloadLen); 00011 void parseInput(const char* data, int len); 00012 public: 00013 JY901(PinName TX, PinName RX) : mod(TX, RX){} 00014 ~JY901() {} 00015 void receiveData(); 00016 void getAcc(float &x, float &y, float &z){ 00017 x = acc[0]; 00018 y = acc[1]; 00019 z = acc[2]; 00020 } 00021 void getGyo(float &x, float &y, float &z){ 00022 x = gyo[0]; 00023 y = gyo[1]; 00024 z = gyo[2]; 00025 } 00026 void getMag(float &x, float &y, float &z){ 00027 x = mag[0]; 00028 y = mag[1]; 00029 z = mag[2]; 00030 } 00031 void getAttitude(float &roll, float &pitch, float &yaw){ 00032 roll = att[0]; 00033 pitch = att[1]; 00034 yaw = att[2]; 00035 } 00036 };
Generated on Tue Jul 12 2022 17:59:49 by 1.7.2