A feature complete driver for the MAX17048 lithium fuel gauge from Maxim.
Dependents: MAX17048_HelloWorld ECGAFE_copy MAX17048_HelloWorld Orion_newPCB_test_LV ... more
Now fully tested!
Diff: MAX17048.h
- Revision:
- 4:e61b2723d2cf
- Parent:
- 3:32087cca331f
- Child:
- 5:ffce4fe12ed1
--- a/MAX17048.h Wed Aug 28 17:53:53 2013 +0000 +++ b/MAX17048.h Mon Sep 16 22:02:40 2013 +0000 @@ -36,17 +36,14 @@ * printf("Device detected!\n"); * * while (1) { - * //Read the cell voltage - * float vcell = gauge.vcell(); - * - * //Print the cell voltage - * printf("Vcell = %f\n", vcell); + * //Print the current state of charge + * printf("SOC = %f%%\n", (float)gauge); * * //Sleep for 0.5 seconds * wait(0.5); * } * } else { - * printf("Device not detected!\n"); + * error("Device not detected!\n"); * } * } * @endcode @@ -286,18 +283,42 @@ */ float vcell(void); - /** Get the current state of charge measurement of the MAX17048 + /** Get the current state of charge measurement of the MAX17048 as a float * * @returns The state of charge measurement as a float. */ float soc(void); + /** Get the current state of charge measurement of the MAX17048 as an int + * + * @returns The state of charge measurement as an int. + */ + int socInt(void); + /** Get the current C rate measurement of the MAX17048 * * @returns The C rate measurement as a float. */ float crate(void); +#ifdef MBED_OPERATORS + /** A shorthand for soc() + * + * @returns The state of charge measurement as a float. + */ + operator float() { + return soc(); + } + + /** A shorthand for socInt() + * + * @returns The state of charge measurement as an int. + */ + operator int() { + return socInt(); + } +#endif + private: //I2C register addresses enum Register {