![](/media/cache/profiles/8474b8609e772af467ac0fc4acad4dd4.jpg.50x50_q85.jpg)
A compilation of code from different sources to provide support for a Playstation 3 controller via bluetooth on the m3pi.
Fork of mbed_TANK_PS3 by
Utils.cpp
- Committer:
- srsmitherman
- Date:
- 2013-01-01
- Revision:
- 2:895f70862eb9
- Parent:
- 0:44619612f575
File content as of revision 2:895f70862eb9:
#include "mbed.h" #include "Utils.h" void printfBytes(const char* s, const u8* data, int len) { printf("%s %d:",s,len); if (len > 256) len = 256; while (len-- > 0) printf(" %02X",*data++); printf("\r\n"); } void printHexLine(const u8* d, int addr, int len) { printf("%04X ",addr); int i; for (i = 0; i < len; i++) printf("%02X ",d[i]); for (;i < 16; i++) printf(" "); char s[16+1]; memset(s,0,sizeof(s)); for (i = 0; i < len; i++) { int c = d[i]; if (c < 0x20 || c > 0x7E) c = '.'; s[i] = c; } printf("%s\r\n",s); } void printHex(const u8* d, int len) { int addr = 0; while (len) { int count = len; if (count > 16) count = 16; printHexLine(d+addr,addr,count); addr += 16; len -= count; } }