Neil Thiessen
/
MAX17048_HelloWorld
A simple serial test program for the MAX17048 library.
Diff: main.cpp
- Revision:
- 1:d098c4448f6d
- Parent:
- 0:54ca3b1d1f75
- Child:
- 3:2152dd143ba3
--- a/main.cpp Wed Aug 14 05:03:09 2013 +0000 +++ b/main.cpp Wed Aug 28 17:54:24 2013 +0000 @@ -3,15 +3,23 @@ MAX17048 gauge(p28, p27); -int main() { - while (1) { - //Read the cell voltage - float vcell = gauge.vcell(); +int main() +{ + //Try to open the MAX17048 + if (gauge.open()) { + printf("Device detected!\n"); - //Print the cell voltage - printf("Vcell = %f\n", vcell); + while (1) { + //Read the cell voltage + float vcell = gauge.vcell(); - //Sleep for 0.5 seconds - wait(0.5); + //Print the cell voltage + printf("Vcell = %f\n", vcell); + + //Sleep for 0.5 seconds + wait(0.5); + } + } else { + printf("Device not detected!\n"); } }