Added new functions (#2202)

This commit is contained in:
jLynx 2024-07-18 21:50:53 +12:00 committed by GitHub
parent b93fbad207
commit e11c28cf30
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 62 additions and 5 deletions

View File

@ -82,7 +82,7 @@ bool MAX17055::detect() {
// Get Data from IC // Get Data from IC
if (readMultipleRegister(0x00, _MAX17055_Data, 2, false)) { if (readMultipleRegister(0x00, _MAX17055_Data, 2, false)) {
if (((_MAX17055_Data[0] != 0x00) && (_MAX17055_Data[0] != 0x02)) || (_MAX17055_Data[1] != 0x00)) { if (_MAX17055_Data[0] != 0x02) {
// validate result, since i2c gives a bit of power to the ic, and sometimes it sets the init value. // validate result, since i2c gives a bit of power to the ic, and sometimes it sets the init value.
// this will return false when the ic is in init state (0x0002), but on the next iteration it'll give the good value // this will return false when the ic is in init state (0x0002), but on the next iteration it'll give the good value
if (detected_ == false) { if (detected_ == false) {
@ -343,6 +343,60 @@ bool MAX17055::setDesignCapacity(const uint16_t _Capacity) {
return _Result; return _Result;
} }
bool MAX17055::setFullCapRep(const uint16_t _Capacity) {
// Set Raw
uint16_t _Raw_Cap = (uint16_t)_Capacity * 2;
// Declare Default Data Array
uint8_t _Data[2];
// Set Data Low/High Byte
_Data[0] = ((_Raw_Cap & (uint16_t)0x00FF));
_Data[1] = ((_Raw_Cap & (uint16_t)0xFF00) >> 8);
// Set Register
bool _Result = writeMultipleRegister(0x10, _Data, 2);
// End Function
return _Result;
}
bool MAX17055::setFullCapNom(const uint16_t _Capacity) {
// Set Raw
uint16_t _Raw_Cap = (uint16_t)_Capacity * 2;
// Declare Default Data Array
uint8_t _Data[2];
// Set Data Low/High Byte
_Data[0] = ((_Raw_Cap & (uint16_t)0x00FF));
_Data[1] = ((_Raw_Cap & (uint16_t)0xFF00) >> 8);
// Set Register
bool _Result = writeMultipleRegister(0x23, _Data, 2);
// End Function
return _Result;
}
bool MAX17055::setRepCap(const uint16_t _Capacity) {
// Set Raw
uint16_t _Raw_Cap = (uint16_t)_Capacity * 2;
// Declare Default Data Array
uint8_t _Data[2];
// Set Data Low/High Byte
_Data[0] = ((_Raw_Cap & (uint16_t)0x00FF));
_Data[1] = ((_Raw_Cap & (uint16_t)0xFF00) >> 8);
// Set Register
bool _Result = writeMultipleRegister(0x05, _Data, 2);
// End Function
return _Result;
}
bool MAX17055::setMinSOC(uint8_t _Minimum_SOC) { bool MAX17055::setMinSOC(uint8_t _Minimum_SOC) {
// Define Data Variable // Define Data Variable
uint8_t MAX17055_Current_Data[2]; uint8_t MAX17055_Current_Data[2];

View File

@ -62,7 +62,7 @@
// Define Maximum Voltage // Define Maximum Voltage
#ifndef __MAX17055_Max_Voltage__ #ifndef __MAX17055_Max_Voltage__
#define __MAX17055_Max_Voltage__ 4.175 // Maximum Voltage #define __MAX17055_Max_Voltage__ 4.17 // Maximum Voltage
#endif #endif
// Define Empty Voltage // Define Empty Voltage
@ -72,7 +72,7 @@
// Define Recovery Voltage // Define Recovery Voltage
#ifndef __MAX17055_Recovery_Voltage__ #ifndef __MAX17055_Recovery_Voltage__
#define __MAX17055_Recovery_Voltage__ 3.7 // Recovery Voltage #define __MAX17055_Recovery_Voltage__ 3.1 // Recovery Voltage
#endif #endif
// Define Maximum Current // Define Maximum Current
@ -105,12 +105,12 @@
// Define Minimum SOC // Define Minimum SOC
#ifndef __MAX17055_Min_SOC__ #ifndef __MAX17055_Min_SOC__
#define __MAX17055_Min_SOC__ 20 // Minimum SOC #define __MAX17055_Min_SOC__ 0 // Minimum SOC
#endif #endif
// Define Maximum SOC // Define Maximum SOC
#ifndef __MAX17055_Max_SOC__ #ifndef __MAX17055_Max_SOC__
#define __MAX17055_Max_SOC__ 90 // Maximum SOC #define __MAX17055_Max_SOC__ 100 // Maximum SOC
#endif #endif
// Config1 (0x1D) Configuration // Config1 (0x1D) Configuration
@ -303,6 +303,9 @@ class MAX17055 {
bool setMaxCurrent(uint16_t _Maximum_Current); bool setMaxCurrent(uint16_t _Maximum_Current);
bool setChargeTerminationCurrent(uint16_t _Charge_Termination_Current); bool setChargeTerminationCurrent(uint16_t _Charge_Termination_Current);
bool setDesignCapacity(const uint16_t _Capacity); bool setDesignCapacity(const uint16_t _Capacity);
bool setFullCapRep(const uint16_t _Capacity);
bool setFullCapNom(const uint16_t _Capacity);
bool setRepCap(const uint16_t _Capacity);
bool setMinSOC(uint8_t _Minimum_SOC); bool setMinSOC(uint8_t _Minimum_SOC);
bool setMaxSOC(uint8_t _Maximum_SOC); bool setMaxSOC(uint8_t _Maximum_SOC);
bool setMinTemperature(uint8_t _Minimum_Temperature); bool setMinTemperature(uint8_t _Minimum_Temperature);