Public Member Functions | |
STC3115 (uint8_t address=0x70) | |
Initialize STC3115 I2C driver with given address. More... | |
bool | begin (int batteryCapacity=BATT_CAPACITY, int rSense=RSENSE) |
Initialize the STC3115 Gas Gauge chip. More... | |
int | getTemperature () |
Get temperature of the battery. Temperature unit is celcius. More... | |
int | getVoltage () |
Get battery voltage. More... | |
int | getCurrent () |
Get battery current. More... | |
int | getChargeValue () |
Get the remaining capacity in mAh unit. More... | |
int | getSOC () |
Get SOC of the battery. More... | |
int | getOCV () |
Get OCV of the battery. More... | |
int | getRemainingTime () |
int | getChipID () |
Get the chip ID from STC3115. More... | |
int | getStatus () |
Get STC3115 status. More... | |
void | enableDebugging (Stream *stream=NULL) |
void | disableDebugging () |
int | getRunningCounter () |
Get the STC3115 conversion counter value. More... | |
bool | readBatteryData () |
Read battery measurement data in one go. More... | |
bool | reset () |
Reset gauge. More... | |
bool | stop () |
Store last reading data to RAM and then stop the gauge. More... | |
bool | powerDown () |
Power down the gauge. More... | |
void | run () |
Gradually update battery status on the internal structure & RAM. This function should be called inside loop. | |
bool | startPowerSavingMode () |
Start power saving mode. More... | |
bool | stopPowerSavingMode () |
Stop power saving mode. More... | |
bool | isBatteryDetected () |
Check whether the battery is detected or not. More... | |
![]() | |
STC3115I2CCore (uint8_t address=0x70) | |
Initialize STC3115 I2C driver and assign the address. More... | |
bool | beginI2C () |
Initialize I2C and check whether the address is available or not. More... | |
bool | readRegister (uint8_t *output, uint8_t reg) |
Read an unsigned byte from a register and return the read status. More... | |
bool | readRegisterRegion (uint8_t *output, uint8_t reg, uint8_t length) |
Read unsigned bytes from register range. More... | |
bool | readRegisterInt16 (int16_t *output, uint8_t reg) |
Read 2 bytes of data and convert it to a signed integer. More... | |
bool | readRegisterInt (int *output, uint8_t reg) |
Read signed integer value from a register. More... | |
bool | writeRegister (uint8_t reg, uint8_t data) |
Write unsigned byte data to a register. More... | |
bool | writeRegisterInt (uint8_t reg, int data) |
Write signed integer data to a register. More... | |
bool | writeRegister (uint8_t reg, uint8_t *data, size_t length) |
Write array of unsigned bytes to a register. More... | |
Static Public Member Functions | |
static int | convert (short value, unsigned short factor) |
Convert measurement data with given factor. More... | |
Public Attributes | |
STC3115ConfigData | config |
Protected Member Functions | |
void | initConfig (int battCapacity, int rSense) |
Initialize STC3115 config default values. | |
int | calculateCRC8RAM (uint8_t *data, size_t length) |
Calculate the CRC8 of a buffer. More... | |
void | initRAM () |
Initialize STC3115 RAM data. | |
bool | readRAMData () |
Read STC3115 RAM data and store it to an internal structure. More... | |
int | updateRAMCRC8 () |
Update STC3115 RAM CRC8 value. More... | |
bool | writeRAMData () |
Write data from internal structure to STC3115 RAM. More... | |
bool | startup () |
Write SOC data to STC3115 and run. More... | |
bool | restore () |
Restore SOC value from RAM and run. More... | |
void | setParamAndRun () |
Write configuration to STC3115 registers. | |
Protected Attributes | |
STC3115BatteryData | batteryData |
STC3115RAMData | ramData |
bool | debugEnabled |
Stream * | debugStream |
![]() | |
uint8_t | address |
STC3115::STC3115 | ( | uint8_t | address = 0x70 | ) |
Initialize STC3115 I2C driver with given address.
address |
bool STC3115::begin | ( | int | battCapacity = BATT_CAPACITY , |
int | rSense = RSENSE |
||
) |
Initialize the STC3115 Gas Gauge chip.
battCapacity | maximum battery capacity |
rSense | RSENSE value |
|
protected |
Calculate the CRC8 of a buffer.
data | pointer to array of uint8_t |
length | length of the array |
|
static |
Convert measurement data with given factor.
value | value to be converted |
factor | conversion factor |
int STC3115::getChargeValue | ( | ) |
Get the remaining capacity in mAh unit.
int STC3115::getCurrent | ( | ) |
Get battery current.
int STC3115::getOCV | ( | ) |
Get OCV of the battery.
int STC3115::getRunningCounter | ( | ) |
Get the STC3115 conversion counter value.
int STC3115::getSOC | ( | ) |
Get SOC of the battery.
int STC3115::getStatus | ( | ) |
Get STC3115 status.
int STC3115::getTemperature | ( | ) |
Get temperature of the battery. Temperature unit is celcius.
int STC3115::getVoltage | ( | ) |
Get battery voltage.
bool STC3115::isBatteryDetected | ( | ) |
Check whether the battery is detected or not.
bool STC3115::powerDown | ( | ) |
Power down the gauge.
bool STC3115::readBatteryData | ( | ) |
Read battery measurement data in one go.
|
protected |
Read STC3115 RAM data and store it to an internal structure.
bool STC3115::reset | ( | ) |
Reset gauge.
|
protected |
Restore SOC value from RAM and run.
bool STC3115::startPowerSavingMode | ( | ) |
Start power saving mode.
|
protected |
Write SOC data to STC3115 and run.
bool STC3115::stop | ( | ) |
Store last reading data to RAM and then stop the gauge.
bool STC3115::stopPowerSavingMode | ( | ) |
Stop power saving mode.
|
protected |
Update STC3115 RAM CRC8 value.
|
protected |
Write data from internal structure to STC3115 RAM.