mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-06-21 20:42:15 -07:00
Power: Fake battery status on Kiisu
This commit is contained in:
@@ -105,6 +105,7 @@ void furi_hal_power_init(void) {
|
||||
|
||||
bool furi_hal_power_gauge_is_ok(void) {
|
||||
bool ret = true;
|
||||
return ret;
|
||||
|
||||
Bq27220BatteryStatus battery_status;
|
||||
Bq27220OperationStatus operation_status;
|
||||
@@ -127,6 +128,7 @@ bool furi_hal_power_gauge_is_ok(void) {
|
||||
|
||||
bool furi_hal_power_is_shutdown_requested(void) {
|
||||
bool ret = false;
|
||||
return ret;
|
||||
|
||||
Bq27220BatteryStatus battery_status;
|
||||
|
||||
@@ -265,6 +267,7 @@ void furi_hal_power_sleep(void) {
|
||||
}
|
||||
|
||||
uint8_t furi_hal_power_get_pct(void) {
|
||||
return 100;
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
uint8_t ret = bq27220_get_state_of_charge(&furi_hal_i2c_handle_power);
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
@@ -272,6 +275,7 @@ uint8_t furi_hal_power_get_pct(void) {
|
||||
}
|
||||
|
||||
uint8_t furi_hal_power_get_bat_health_pct(void) {
|
||||
return 100;
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
uint8_t ret = bq27220_get_state_of_health(&furi_hal_i2c_handle_power);
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
@@ -279,6 +283,7 @@ uint8_t furi_hal_power_get_bat_health_pct(void) {
|
||||
}
|
||||
|
||||
bool furi_hal_power_is_charging(void) {
|
||||
return false;
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
bool ret = bq25896_is_charging(&furi_hal_i2c_handle_power);
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
@@ -286,6 +291,7 @@ bool furi_hal_power_is_charging(void) {
|
||||
}
|
||||
|
||||
bool furi_hal_power_is_charging_done(void) {
|
||||
return false;
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
bool ret = bq25896_is_charging_done(&furi_hal_i2c_handle_power);
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
@@ -366,6 +372,7 @@ bool furi_hal_power_is_otg_enabled(void) {
|
||||
}
|
||||
|
||||
float furi_hal_power_get_battery_charge_voltage_limit(void) {
|
||||
return 4.208;
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
float ret = (float)bq25896_get_vreg_voltage(&furi_hal_i2c_handle_power) / 1000.0f;
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
@@ -373,6 +380,7 @@ float furi_hal_power_get_battery_charge_voltage_limit(void) {
|
||||
}
|
||||
|
||||
void furi_hal_power_set_battery_charge_voltage_limit(float voltage) {
|
||||
return;
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
// Adding 0.0005 is necessary because 4.016f is 4.015999794000, which gets truncated
|
||||
bq25896_set_vreg_voltage(&furi_hal_i2c_handle_power, (uint16_t)(voltage * 1000.0f + 0.0005f));
|
||||
@@ -380,6 +388,7 @@ void furi_hal_power_set_battery_charge_voltage_limit(float voltage) {
|
||||
}
|
||||
|
||||
bool furi_hal_power_check_otg_fault(void) {
|
||||
return false;
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
bool ret = bq25896_check_otg_fault(&furi_hal_i2c_handle_power);
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
@@ -387,6 +396,7 @@ bool furi_hal_power_check_otg_fault(void) {
|
||||
}
|
||||
|
||||
void furi_hal_power_check_otg_status(void) {
|
||||
return;
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
if(bq25896_check_otg_fault(&furi_hal_i2c_handle_power))
|
||||
bq25896_disable_otg(&furi_hal_i2c_handle_power);
|
||||
@@ -394,6 +404,7 @@ void furi_hal_power_check_otg_status(void) {
|
||||
}
|
||||
|
||||
uint32_t furi_hal_power_get_battery_remaining_capacity(void) {
|
||||
return 2100;
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
uint32_t ret = bq27220_get_remaining_capacity(&furi_hal_i2c_handle_power);
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
@@ -401,6 +412,7 @@ uint32_t furi_hal_power_get_battery_remaining_capacity(void) {
|
||||
}
|
||||
|
||||
uint32_t furi_hal_power_get_battery_full_capacity(void) {
|
||||
return 2100;
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
uint32_t ret = bq27220_get_full_charge_capacity(&furi_hal_i2c_handle_power);
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
@@ -408,6 +420,7 @@ uint32_t furi_hal_power_get_battery_full_capacity(void) {
|
||||
}
|
||||
|
||||
uint32_t furi_hal_power_get_battery_design_capacity(void) {
|
||||
return 2100;
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
uint32_t ret = bq27220_get_design_capacity(&furi_hal_i2c_handle_power);
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
@@ -415,6 +428,7 @@ uint32_t furi_hal_power_get_battery_design_capacity(void) {
|
||||
}
|
||||
|
||||
float furi_hal_power_get_battery_voltage(FuriHalPowerIC ic) {
|
||||
return 4.169;
|
||||
float ret = 0.0f;
|
||||
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
@@ -431,6 +445,7 @@ float furi_hal_power_get_battery_voltage(FuriHalPowerIC ic) {
|
||||
}
|
||||
|
||||
float furi_hal_power_get_battery_current(FuriHalPowerIC ic) {
|
||||
return -0.0015;
|
||||
float ret = 0.0f;
|
||||
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
@@ -460,6 +475,7 @@ static float furi_hal_power_get_battery_temperature_internal(FuriHalPowerIC ic)
|
||||
}
|
||||
|
||||
float furi_hal_power_get_battery_temperature(FuriHalPowerIC ic) {
|
||||
return 30;
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
float ret = furi_hal_power_get_battery_temperature_internal(ic);
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
@@ -468,6 +484,7 @@ float furi_hal_power_get_battery_temperature(FuriHalPowerIC ic) {
|
||||
}
|
||||
|
||||
float furi_hal_power_get_usb_voltage(void) {
|
||||
return 0;
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
float ret = (float)bq25896_get_vbus_voltage(&furi_hal_i2c_handle_power) / 1000.0f;
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
@@ -487,6 +504,7 @@ void furi_hal_power_suppress_charge_enter(void) {
|
||||
bool disable_charging = furi_hal_power.suppress_charge == 0;
|
||||
furi_hal_power.suppress_charge++;
|
||||
FURI_CRITICAL_EXIT();
|
||||
return;
|
||||
|
||||
if(disable_charging) {
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
@@ -500,6 +518,7 @@ void furi_hal_power_suppress_charge_exit(void) {
|
||||
furi_hal_power.suppress_charge--;
|
||||
bool enable_charging = furi_hal_power.suppress_charge == 0;
|
||||
FURI_CRITICAL_EXIT();
|
||||
return;
|
||||
|
||||
if(enable_charging) {
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
|
||||
Reference in New Issue
Block a user