Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: MAX1704X_example_app
MAX1704X Class Reference
#include <MAX1704X.h>
Public Types | |
| enum | Address |
Represents the different I2C address possibilities for the MAX1704X. More... | |
Public Member Functions | |
| MAX1704X (PinName sda, PinName scl, Address addr=ADDRESS_0, int hz=400000) | |
| Create an MAX1704X object connected to the specified I2C pins with the specified I2C slave address. | |
| bool | open () |
| Probe for the MAX1704X and indicate if it's present on the bus. | |
| void | power_on_reset (void) |
| assert power on reset on MAX1704X | |
| uint32_t | read_ad () |
| Get the current ad of the MAX1704X. | |
| uint16_t | read_config () |
| Get the current config of the MAX1704X. | |
| uint32_t | read_percent () |
| Get the current battery charge percent from MAX1704X. | |
Detailed Description
MAX1704X class.
Used for reading MAX1704X lipo fuel guage connected via I2C.
Example:
#include "mbed.h" #include "MAX1704X.h" //Create an MAX1704X object at the default address (ADDRESS_0) MAX1704X battery_level(p28, p27); int main() { //Try to open the MAX1704X if (battery_level.open()) { printf("Device detected!\n"); while (1) { //Print the current battery level printf("battery = %d\n", battery_level); //Sleep for 1 seconds wait(1); } } else { error("Device not detected!\n"); } }
Definition at line 52 of file MAX1704X.h.
Member Enumeration Documentation
| enum Address |
Represents the different I2C address possibilities for the MAX1704X.
Definition at line 58 of file MAX1704X.h.
Constructor & Destructor Documentation
Create an MAX1704X object connected to the specified I2C pins with the specified I2C slave address.
- Parameters:
-
sda The I2C data pin. scl The I2C clock pin. addr The I2C slave address (defaults to ADDRESS_0). hz The I2C bus frequency (defaults to 400kHz).
Definition at line 21 of file MAX1704X.cpp.
Member Function Documentation
| bool open | ( | ) |
Probe for the MAX1704X and indicate if it's present on the bus.
- Returns:
- 'true' if the device exists on the bus, 'false' if the device doesn't exist on the bus.
Definition at line 30 of file MAX1704X.cpp.
| void power_on_reset | ( | void | ) |
| uint32_t read_ad | ( | ) |
Get the current ad of the MAX1704X.
- Returns:
- The current ad.
Definition at line 42 of file MAX1704X.cpp.
| uint16_t read_config | ( | ) |
Get the current config of the MAX1704X.
- Returns:
- The current config of the MAX170X.
Definition at line 61 of file MAX1704X.cpp.
| uint32_t read_percent | ( | ) |
Get the current battery charge percent from MAX1704X.
- Returns:
- The current battery charge percent from MAX1704X.
Definition at line 77 of file MAX1704X.cpp.
Generated on Sun Jul 17 2022 14:24:55 by
1.7.2