mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-05 13:14:45 +00:00
design capacity
This commit is contained in:
parent
7a1295e976
commit
c65feb65d5
@ -126,7 +126,7 @@ RAK9154Sensor rak9154Sensor;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAS_BQ27220
|
#ifdef HAS_BQ27220
|
||||||
#include "BQ27220.h"
|
#include "bq27220.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAS_PMU
|
#ifdef HAS_PMU
|
||||||
@ -1306,8 +1306,13 @@ class LipoCharger : public HasBatteryLevel
|
|||||||
}
|
}
|
||||||
if (bq == nullptr) {
|
if (bq == nullptr) {
|
||||||
bq = new BQ27220;
|
bq = new BQ27220;
|
||||||
bool result = bq->init(&Wire, BQ27220_I2C_SDA, BQ27220_I2C_SCL);
|
bq->setDefaultCapacity(BQ27220_DESIGN_CAPACITY);
|
||||||
|
|
||||||
|
bool result = bq->init();
|
||||||
if (result) {
|
if (result) {
|
||||||
|
LOG_DEBUG("BQ27220 design capacity: %d", bq->getDesignCapacity());
|
||||||
|
LOG_DEBUG("BQ27220 fullCharge capacity: %d", bq->getFullChargeCapacity());
|
||||||
|
LOG_DEBUG("BQ27220 remaining capacity: %d", bq->getRemainingCapacity());
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
LOG_WARN("BQ27220 init failed");
|
LOG_WARN("BQ27220 init failed");
|
||||||
@ -1322,12 +1327,12 @@ class LipoCharger : public HasBatteryLevel
|
|||||||
/**
|
/**
|
||||||
* Battery state of charge, from 0 to 100 or -1 for unknown
|
* Battery state of charge, from 0 to 100 or -1 for unknown
|
||||||
*/
|
*/
|
||||||
virtual int getBatteryPercent() override { return bq->getChargePcnt(); }
|
virtual int getBatteryPercent() override { return bq->getChargePercent(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The raw voltage of the battery in millivolts, or NAN if unknown
|
* The raw voltage of the battery in millivolts, or NAN if unknown
|
||||||
*/
|
*/
|
||||||
virtual uint16_t getBattVoltage() override { return bq->getVolt(BQ27220::VOLT); }
|
virtual uint16_t getBattVoltage() override { return bq->getVoltage(); } // BQ27220::VOLT
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return true if there is a battery installed in this unit
|
* return true if there is a battery installed in this unit
|
||||||
@ -1342,7 +1347,18 @@ class LipoCharger : public HasBatteryLevel
|
|||||||
/**
|
/**
|
||||||
* return true if the battery is currently charging
|
* return true if the battery is currently charging
|
||||||
*/
|
*/
|
||||||
virtual bool isCharging() override { return ppm->isCharging(); }
|
virtual bool isCharging() override
|
||||||
|
{
|
||||||
|
bool isCharging = ppm->isCharging();
|
||||||
|
if (isCharging) {
|
||||||
|
LOG_DEBUG("BQ27220 time to full charge: %d min", bq->getTimeToFull());
|
||||||
|
} else {
|
||||||
|
if (!ppm->isVbusIn()) {
|
||||||
|
LOG_DEBUG("BQ27220 time to empty: %d min (%d mAh)", bq->getTimeToEmpty(), bq->getRemainingCapacity());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return isCharging;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
LipoCharger lipoCharger;
|
LipoCharger lipoCharger;
|
||||||
|
@ -21,4 +21,4 @@ lib_deps =
|
|||||||
https://github.com/ZinggJM/GxEPD2/archive/refs/tags/1.6.4.zip
|
https://github.com/ZinggJM/GxEPD2/archive/refs/tags/1.6.4.zip
|
||||||
https://github.com/CIRCUITSTATE/CSE_Touch/archive/b44f23b6f870b848f1fbe453c190879bc6cfaafa.zip
|
https://github.com/CIRCUITSTATE/CSE_Touch/archive/b44f23b6f870b848f1fbe453c190879bc6cfaafa.zip
|
||||||
https://github.com/CIRCUITSTATE/CSE_CST328/archive/refs/tags/v0.0.4.zip
|
https://github.com/CIRCUITSTATE/CSE_CST328/archive/refs/tags/v0.0.4.zip
|
||||||
https://github.com/mverch67/BQ27220/archive/9249016527c19bea5ab38351c7d0f1ffe4c19dd9.zip
|
https://github.com/mverch67/BQ27220/archive/07d92be846abd8a0258a50c23198dac0858b22ed.zip
|
||||||
|
@ -65,6 +65,7 @@
|
|||||||
#define HAS_BQ27220 1
|
#define HAS_BQ27220 1
|
||||||
#define BQ27220_I2C_SDA SDA
|
#define BQ27220_I2C_SDA SDA
|
||||||
#define BQ27220_I2C_SCL SCL
|
#define BQ27220_I2C_SCL SCL
|
||||||
|
#define BQ27220_DESIGN_CAPACITY 1400
|
||||||
|
|
||||||
// LoRa
|
// LoRa
|
||||||
#define USE_SX1262
|
#define USE_SX1262
|
||||||
|
Loading…
Reference in New Issue
Block a user