Adafruit LC709203F Library
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Adafruit_LC709203F Class Reference

Class that stores state and functions for interacting with the LC709203F I2C battery monitor. More...

#include <Adafruit_LC709203F.h>

Public Member Functions

 Adafruit_LC709203F ()
 Instantiates a new LC709203F class.
 
bool begin (TwoWire *wire=&Wire)
 Sets up the hardware and initializes I2C. More...
 
bool initRSOC (void)
 Initialize the RSOC algorithm. More...
 
bool setPowerMode (lc709203_powermode_t t)
 Set the power mode, LC709203F_POWER_OPERATE or LC709203F_POWER_SLEEP. More...
 
bool setPackSize (lc709203_adjustment_t apa)
 Set the approximate pack size, helps RSOC calculation. More...
 
bool setPackAPA (uint8_t apa_value)
 Set battery APA value, per LC709203F datasheet. More...
 
uint16_t getICversion (void)
 Get IC LSI version. More...
 
float cellVoltage (void)
 Get battery voltage. More...
 
float cellPercent (void)
 Get battery state in percent (0-100%) More...
 
uint16_t getThermistorB (void)
 Get the thermistor B value (e.g. 3950) More...
 
bool setThermistorB (uint16_t b)
 Set the thermistor B value (e.g. 3950) More...
 
uint16_t getBattProfile (void)
 Get the battery profile parameter. More...
 
bool setBattProfile (uint16_t b)
 Set the battery profile parameter. More...
 
bool setTemperatureMode (lc709203_tempmode_t t)
 Set the temperature mode (external or internal) More...
 
float getCellTemperature (void)
 Get battery thermistor temperature. More...
 
bool setAlarmRSOC (uint8_t percent)
 Set the alarm pin to respond to an RSOC percentage level. More...
 
bool setAlarmVoltage (float voltage)
 Set the alarm pin to respond to a battery voltage level. More...
 

Protected Member Functions

bool readWord (uint8_t address, uint16_t *data)
 Helper that reads 16 bits of CRC data from the chip. Note this function performs a CRC on data that includes the I2C write address, command, read address and 2 bytes of response. More...
 
bool writeWord (uint8_t command, uint16_t data)
 Helper that writes 16 bits of CRC data to the chip. Note this function performs a CRC on data that includes the I2C write address, command, and 2 bytes of response. More...
 

Protected Attributes

Adafruit_I2CDevice * i2c_dev = NULL
 Pointer to I2C bus interface.
 

Detailed Description

Class that stores state and functions for interacting with the LC709203F I2C battery monitor.

Member Function Documentation

◆ begin()

bool Adafruit_LC709203F::begin ( TwoWire *  wire = &Wire)

Sets up the hardware and initializes I2C.

Parameters
wireThe Wire object to be used for I2C connections.
Returns
True if initialization was successful, otherwise false.

◆ initRSOC()

bool Adafruit_LC709203F::initRSOC ( void  )

Initialize the RSOC algorithm.

Returns
True on I2C command success

◆ setPowerMode()

bool Adafruit_LC709203F::setPowerMode ( lc709203_powermode_t  t)

Set the power mode, LC709203F_POWER_OPERATE or LC709203F_POWER_SLEEP.

Parameters
tThe power mode desired
Returns
True on successful I2C write

◆ setPackSize()

bool Adafruit_LC709203F::setPackSize ( lc709203_adjustment_t  apa)

Set the approximate pack size, helps RSOC calculation.

Parameters
apaThe lc709203_adjustment_t enumerated approximate cell size
Returns
True on successful I2C write

◆ setPackAPA()

bool Adafruit_LC709203F::setPackAPA ( uint8_t  apa_value)

Set battery APA value, per LC709203F datasheet.

Parameters
apa_value8-bit APA value to use for the attached battery
Returns
True on successful I2C write

◆ getICversion()

uint16_t Adafruit_LC709203F::getICversion ( void  )

Get IC LSI version.

Returns
16-bit value read from LC709203F_CMD_ICVERSION register

◆ cellVoltage()

float Adafruit_LC709203F::cellVoltage ( void  )

Get battery voltage.

Returns
Floating point value read in Volts

◆ cellPercent()

float Adafruit_LC709203F::cellPercent ( void  )

Get battery state in percent (0-100%)

Returns
Floating point value from 0 to 100.0

◆ getThermistorB()

uint16_t Adafruit_LC709203F::getThermistorB ( void  )

Get the thermistor B value (e.g. 3950)

Returns
The uint16_t B value

◆ setThermistorB()

bool Adafruit_LC709203F::setThermistorB ( uint16_t  b)

Set the thermistor B value (e.g. 3950)

Parameters
bThe value to set it to
Returns
True on successful I2C write

◆ getBattProfile()

uint16_t Adafruit_LC709203F::getBattProfile ( void  )

Get the battery profile parameter.

Returns
The uint16_t profile value (0 or 1)

◆ setBattProfile()

bool Adafruit_LC709203F::setBattProfile ( uint16_t  b)

Set the battery profile parameter.

Parameters
bThe value to set it to (0 or 1)
Returns
True on successful I2C write

◆ setTemperatureMode()

bool Adafruit_LC709203F::setTemperatureMode ( lc709203_tempmode_t  t)

Set the temperature mode (external or internal)

Parameters
tThe desired mode: LC709203F_TEMPERATURE_I2C or LC709203F_TEMPERATURE_THERMISTOR
Returns
True on successful I2C write

◆ getCellTemperature()

float Adafruit_LC709203F::getCellTemperature ( void  )

Get battery thermistor temperature.

Returns
Floating point value from -20 to 60 *C

◆ setAlarmRSOC()

bool Adafruit_LC709203F::setAlarmRSOC ( uint8_t  percent)

Set the alarm pin to respond to an RSOC percentage level.

Parameters
percentThe threshold value, set to 0 to disable alarm
Returns
True on successful I2C write

◆ setAlarmVoltage()

bool Adafruit_LC709203F::setAlarmVoltage ( float  voltage)

Set the alarm pin to respond to a battery voltage level.

Parameters
voltageThe threshold value, set to 0 to disable alarm
Returns
True on successful I2C write

◆ readWord()

bool Adafruit_LC709203F::readWord ( uint8_t  command,
uint16_t *  data 
)
protected

Helper that reads 16 bits of CRC data from the chip. Note this function performs a CRC on data that includes the I2C write address, command, read address and 2 bytes of response.

Parameters
commandThe I2C register/command
dataPointer to uint16_t value we will store response
Returns
True on successful I2C read

◆ writeWord()

bool Adafruit_LC709203F::writeWord ( uint8_t  command,
uint16_t  data 
)
protected

Helper that writes 16 bits of CRC data to the chip. Note this function performs a CRC on data that includes the I2C write address, command, and 2 bytes of response.

Parameters
commandThe I2C register/command
dataPointer to uint16_t value we will write to register
Returns
True on successful I2C write

The documentation for this class was generated from the following files: