mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-14 15:37:43 +00:00
Learn ic fix (#2253)
* WIP * Fixed merge * Added test code * WIP * Clean up * add reset learned params * ui fix * ui fix2 * Updated func * Fixed english * WIP * WIP testing * Added new debug app * Got new app for debug * Got new app for debug * Got one full page showing * Got app working with all reg * Got app working with all reg * Got full hex showing * Fixed dp * Fixed dp * Moved entities * Enabled apps again * SHow battery debug if ic * WIP * Refactored further * WIP * Refactor and clean up * Refactor and clean up * fix warning, add tte/ttf, add cycles counter. * wip * morse tx to ext app * fix morse crash * fix ui * Updated wording * WIP * WIP * Updated to display hours and minutes --------- Co-authored-by: HTotoo <ttotoo@gmail.com>
This commit is contained in:
@@ -23,16 +23,16 @@ bool BatteryManagement::calcOverride = false;
|
||||
void BatteryManagement::detect() {
|
||||
// try to detect supported modules
|
||||
detected_ = BATT_NONE;
|
||||
if (battery_max17055.detect()) {
|
||||
battery_max17055.init();
|
||||
detected_ = BATT_MAX17055;
|
||||
return;
|
||||
}
|
||||
if (battery_ads1110.detect()) {
|
||||
battery_ads1110.init();
|
||||
detected_ = BATT_ADS1110;
|
||||
return;
|
||||
}
|
||||
if (battery_max17055.detect()) {
|
||||
// battery_max17055.init(); //detect will call this on each "re detect"
|
||||
detected_ = BATT_MAX17055;
|
||||
return;
|
||||
}
|
||||
|
||||
// add new supported module detect + init here
|
||||
|
||||
@@ -51,6 +51,13 @@ void BatteryManagement::init(bool override) {
|
||||
create_thread();
|
||||
}
|
||||
|
||||
bool BatteryManagement::reset_learned() {
|
||||
if (detected_ == BATT_MAX17055) {
|
||||
return battery_max17055.reset_learned();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// set if the default percentage calculation should be overrided by voltage based one
|
||||
void BatteryManagement::set_calc_override(bool override) {
|
||||
calcOverride = override;
|
||||
@@ -90,6 +97,26 @@ void BatteryManagement::getBatteryInfo(uint8_t& valid_mask, uint8_t& batteryPerc
|
||||
(void)current;
|
||||
}
|
||||
|
||||
uint16_t BatteryManagement::get_cycles() {
|
||||
if (detected_ == BATT_MAX17055) {
|
||||
return (uint16_t)battery_max17055.getValue("Cycles");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
float BatteryManagement::get_tte() {
|
||||
if (detected_ == BATT_MAX17055) {
|
||||
return battery_max17055.getValue("TTE");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
float BatteryManagement::get_ttf() {
|
||||
if (detected_ == BATT_MAX17055) {
|
||||
return battery_max17055.getValue("TTF");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16_t BatteryManagement::read_register(const uint8_t reg) {
|
||||
if (detected_ == BATT_MAX17055) {
|
||||
return battery_max17055.read_register(reg);
|
||||
|
Reference in New Issue
Block a user