mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 21:05:35 +03:00
CF/BF - First cut of Current/Voltage/Battery cleanup.
many refactorings, bugs squished, concerns separated, single-responsibility violations fixed and performance optimizations.
This commit is contained in:
parent
b46e0fe46d
commit
067d3c0ac2
69 changed files with 1178 additions and 514 deletions
|
@ -452,24 +452,26 @@ void showBatteryPage(void)
|
|||
{
|
||||
uint8_t rowIndex = PAGE_TITLE_LINE_COUNT;
|
||||
|
||||
if (feature(FEATURE_VBAT)) {
|
||||
tfp_sprintf(lineBuffer, "Volts: %d.%1d Cells: %d", getVbat() / 10, getVbat() % 10, batteryCellCount);
|
||||
if (batteryConfig()->voltageMeterSource != VOLTAGE_METER_NONE) {
|
||||
tfp_sprintf(lineBuffer, "Volts: %d.%1d Cells: %d", getBatteryVoltage() / 10, getBatteryVoltage() % 10, getBatteryCellCount());
|
||||
padLineBuffer();
|
||||
i2c_OLED_set_line(rowIndex++);
|
||||
i2c_OLED_send_string(lineBuffer);
|
||||
|
||||
uint8_t batteryPercentage = calculateBatteryPercentage();
|
||||
uint8_t batteryPercentage = calculateBatteryPercentageRemaining();
|
||||
i2c_OLED_set_line(rowIndex++);
|
||||
drawHorizonalPercentageBar(SCREEN_CHARACTER_COLUMN_COUNT, batteryPercentage);
|
||||
}
|
||||
|
||||
if (feature(FEATURE_CURRENT_METER)) {
|
||||
tfp_sprintf(lineBuffer, "Amps: %d.%2d mAh: %d", amperage / 100, amperage % 100, mAhDrawn);
|
||||
if (batteryConfig()->currentMeterSource != CURRENT_METER_NONE) {
|
||||
|
||||
int32_t amperage = getAmperage();
|
||||
tfp_sprintf(lineBuffer, "Amps: %d.%2d mAh: %d", amperage / 100, amperage % 100, getMAhDrawn());
|
||||
padLineBuffer();
|
||||
i2c_OLED_set_line(rowIndex++);
|
||||
i2c_OLED_send_string(lineBuffer);
|
||||
|
||||
uint8_t capacityPercentage = calculateBatteryPercentage();
|
||||
uint8_t capacityPercentage = calculateBatteryPercentageRemaining();
|
||||
i2c_OLED_set_line(rowIndex++);
|
||||
drawHorizonalPercentageBar(SCREEN_CHARACTER_COLUMN_COUNT, capacityPercentage);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue