read acceleration and angler ratio from mpu6050 and estimate pitch and roll angle

Dependencies:   mbed

Committer:
ojan
Date:
Wed May 13 04:02:27 2015 +0000
Revision:
3:40559ebef0f1
Parent:
0:5e220b09d315
estimate gravity vector & geomagnetic vector

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ojan 0:5e220b09d315 1 #include "toString.h"
ojan 0:5e220b09d315 2
ojan 0:5e220b09d315 3 void ToBinaryString(char* dest, int destSize, const int integer, int byteNum) {
ojan 0:5e220b09d315 4 memset(dest, 0, destSize*sizeof(char));
ojan 0:5e220b09d315 5 strcat(dest, "0b");
ojan 0:5e220b09d315 6 if(byteNum > 4) {
ojan 0:5e220b09d315 7 strcat(dest, "########");
ojan 0:5e220b09d315 8 return;
ojan 0:5e220b09d315 9 }
ojan 0:5e220b09d315 10 for(int i=1; i<=8*byteNum; i++) {
ojan 0:5e220b09d315 11 if(integer & (1<<(8*byteNum-i))) {
ojan 0:5e220b09d315 12 strcat(dest, "1");
ojan 0:5e220b09d315 13 } else {
ojan 0:5e220b09d315 14 strcat(dest, "0");
ojan 0:5e220b09d315 15 }
ojan 0:5e220b09d315 16 }
ojan 0:5e220b09d315 17 }