A simple serial test program for the MAX17048 library.

Dependencies:   MAX17048 mbed

main.cpp

Committer:
neilt6
Date:
2013-09-16
Revision:
3:2152dd143ba3
Parent:
1:d098c4448f6d
Child:
6:20e76649ba57

File content as of revision 3:2152dd143ba3:

#include "mbed.h"
#include "MAX17048.h"

MAX17048 gauge(p28, p27);

int main()
{
    //Try to open the MAX17048
    if (gauge.open()) {
        printf("Device detected!\n");

        while (1) {
            //Print the current state of charge
            printf("SOC = %f%%\n", (float)gauge);

            //Sleep for 0.5 seconds
            wait(0.5);
        }
    } else {
        error("Device not detected!\n");
    }
}