How to print the MAC address of an mbed to the dispBoB
Dependencies: dispBoB mbed PCA9635
main.cpp@0:483d5a8daac0, 2011-07-11 (annotated)
- Committer:
- d_worrall
- Date:
- Mon Jul 11 15:04:02 2011 +0000
- Revision:
- 0:483d5a8daac0
version1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
d_worrall | 0:483d5a8daac0 | 1 | #include "mbed.h" |
d_worrall | 0:483d5a8daac0 | 2 | #include "dispBoB.h" |
d_worrall | 0:483d5a8daac0 | 3 | #include "stdio.h" |
d_worrall | 0:483d5a8daac0 | 4 | |
d_worrall | 0:483d5a8daac0 | 5 | dispBoB db(p28, p27, p26); //object instantiation |
d_worrall | 0:483d5a8daac0 | 6 | extern "C" int mbed_mac_address(char *); |
d_worrall | 0:483d5a8daac0 | 7 | |
d_worrall | 0:483d5a8daac0 | 8 | int main() { |
d_worrall | 0:483d5a8daac0 | 9 | uint64_t uid = 0; |
d_worrall | 0:483d5a8daac0 | 10 | char mac[6]; |
d_worrall | 0:483d5a8daac0 | 11 | mbed_mac_address(mac); //this copies the MAC address into the |
d_worrall | 0:483d5a8daac0 | 12 | uid = mac[0] << 40 | mac[1] << 32 | //variable 'uid' |
d_worrall | 0:483d5a8daac0 | 13 | mac[2] << 24 | mac[3] << 16 | |
d_worrall | 0:483d5a8daac0 | 14 | mac[4] << 8 | mac[5] << 0; |
d_worrall | 0:483d5a8daac0 | 15 | char MACAddressBuffer[9]; |
d_worrall | 0:483d5a8daac0 | 16 | sprintf(MACAddressBuffer, "%x", uid); //convert type uint64_t --> char* (format hex) |
d_worrall | 0:483d5a8daac0 | 17 | db.scroll(MACAddressBuffer, 0.2); //scroll foramtted MAC address across dispBoB |
d_worrall | 0:483d5a8daac0 | 18 | } |