Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed QEI-1 nRF24L01P xiugai
Diff: JY901.h
- Revision:
- 14:5bc7349d0e3b
diff -r 99e774135a00 -r 5bc7349d0e3b JY901.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/JY901.h Fri Dec 13 01:32:26 2019 +0000
@@ -0,0 +1,37 @@
+#include "mbed.h"
+#include "BufferedSerial.h"
+class JY901
+{
+ int state, token, payloadLen, recvLen;
+ unsigned char payloadBuf[16];
+protected:
+ BufferedSerial mod;
+ float acc[3], gyo[3], mag[3], att[3];
+ void parseCmpt(int token, unsigned char* payloadBuf, int payloadLen);
+ void parseInput(const char* data, int len);
+public:
+ JY901(PinName TX, PinName RX) : mod(TX, RX, 32){}
+ ~JY901() {}
+ void baud (int baudrate) {mod.baud(baudrate);}
+ void receiveData();
+ void getAcc(float &x, float &y, float &z){
+ x = acc[0];
+ y = acc[1];
+ z = acc[2];
+ }
+ void getGyo(float &x, float &y, float &z){
+ x = gyo[0];
+ y = gyo[1];
+ z = gyo[2];
+ }
+ void getMag(float &x, float &y, float &z){
+ x = mag[0];
+ y = mag[1];
+ z = mag[2];
+ }
+ void getAttitude(float &roll, float &pitch, float &yaw){
+ roll = att[0];
+ pitch = att[1];
+ yaw = att[2];
+ }
+};
\ No newline at end of file