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
Fork of Laurus_acc_gyro by
toString.cpp@0:5e220b09d315, 2015-04-13 (annotated)
- Committer:
- ojan
- Date:
- Mon Apr 13 08:10:05 2015 +0000
- Revision:
- 0:5e220b09d315
read acceleration and angler ratio from mpu6050 and estimate pitch and roll angle
Who changed what in which revision?
| User | Revision | Line number | New 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 | } |
