1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-20 06:45:16 +03:00

fixup Mikeller and levinap

This commit is contained in:
timman2er 2018-08-29 02:38:41 +02:00
parent 7b196b2ed7
commit bc596e1f8b
5 changed files with 10 additions and 12 deletions

View file

@ -654,7 +654,6 @@ static bool mspCommonProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProce
sbufWriteU16(dst, batteryConfig()->batteryCapacity); sbufWriteU16(dst, batteryConfig()->batteryCapacity);
sbufWriteU8(dst, batteryConfig()->voltageMeterSource); sbufWriteU8(dst, batteryConfig()->voltageMeterSource);
sbufWriteU8(dst, batteryConfig()->currentMeterSource); sbufWriteU8(dst, batteryConfig()->currentMeterSource);
sbufWriteU8(dst, batteryConfig()->forceBatteryCellCount);
break; break;
case MSP_TRANSPONDER_CONFIG: { case MSP_TRANSPONDER_CONFIG: {
@ -2419,7 +2418,6 @@ static mspResult_e mspCommonProcessInCommand(uint8_t cmdMSP, sbuf_t *src, mspPos
batteryConfigMutable()->batteryCapacity = sbufReadU16(src); batteryConfigMutable()->batteryCapacity = sbufReadU16(src);
batteryConfigMutable()->voltageMeterSource = sbufReadU8(src); batteryConfigMutable()->voltageMeterSource = sbufReadU8(src);
batteryConfigMutable()->currentMeterSource = sbufReadU8(src); batteryConfigMutable()->currentMeterSource = sbufReadU8(src);
batteryConfigMutable()->forceBatteryCellCount = sbufReadU8(src);
break; break;
#if defined(USE_OSD) #if defined(USE_OSD)

View file

@ -682,7 +682,7 @@ const clivalue_t valueTable[] = {
{ "use_cbat_alerts", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_BATTERY_CONFIG, offsetof(batteryConfig_t, useConsumptionAlerts) }, { "use_cbat_alerts", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_BATTERY_CONFIG, offsetof(batteryConfig_t, useConsumptionAlerts) },
{ "cbat_alert_percent", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 100 }, PG_BATTERY_CONFIG, offsetof(batteryConfig_t, consumptionWarningPercentage) }, { "cbat_alert_percent", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 100 }, PG_BATTERY_CONFIG, offsetof(batteryConfig_t, consumptionWarningPercentage) },
{ "vbat_cutoff_percent", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 100 }, PG_BATTERY_CONFIG, offsetof(batteryConfig_t, lvcPercentage) }, { "vbat_cutoff_percent", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 100 }, PG_BATTERY_CONFIG, offsetof(batteryConfig_t, lvcPercentage) },
{ "force_battery_cell_count", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 80 }, PG_BATTERY_CONFIG, offsetof(batteryConfig_t, forceBatteryCellCount) }, { "force_battery_cell_count", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 24 }, PG_BATTERY_CONFIG, offsetof(batteryConfig_t, forceBatteryCellCount) },
// PG_VOLTAGE_SENSOR_ADC_CONFIG // PG_VOLTAGE_SENSOR_ADC_CONFIG
{ "vbat_scale", VAR_UINT8 | MASTER_VALUE, .config.minmax = { VBAT_SCALE_MIN, VBAT_SCALE_MAX }, PG_VOLTAGE_SENSOR_ADC_CONFIG, offsetof(voltageSensorADCConfig_t, vbatscale) }, { "vbat_scale", VAR_UINT8 | MASTER_VALUE, .config.minmax = { VBAT_SCALE_MIN, VBAT_SCALE_MAX }, PG_VOLTAGE_SENSOR_ADC_CONFIG, offsetof(voltageSensorADCConfig_t, vbatscale) },

View file

@ -183,18 +183,21 @@ void batteryUpdatePresence(void)
/* battery has just been connected - calculate cells, warning voltages and reset state */ /* battery has just been connected - calculate cells, warning voltages and reset state */
unsigned cells = (voltageMeter.filtered / batteryConfig()->vbatmaxcellvoltage) + 1;
if (cells > 8) {
// something is wrong, we expect 8 cells maximum (and autodetection will be problematic at 6+ cells)
cells = 8;
}
consumptionState = voltageState = BATTERY_OK; consumptionState = voltageState = BATTERY_OK;
if (batteryConfig()->forceBatteryCellCount != 0) { if (batteryConfig()->forceBatteryCellCount != 0) {
batteryCellCount = batteryConfig()->forceBatteryCellCount; batteryCellCount = batteryConfig()->forceBatteryCellCount;
} else { } else {
unsigned cells = (voltageMeter.filtered / batteryConfig()->vbatmaxcellvoltage) + 1;
if (cells > 8) {
// something is wrong, we expect 8 cells maximum (and autodetection will be problematic at 6+ cells)
cells = 8;
}
else
{
batteryCellCount = cells; batteryCellCount = cells;
} }
}
batteryWarningVoltage = batteryCellCount * batteryConfig()->vbatwarningcellvoltage; batteryWarningVoltage = batteryCellCount * batteryConfig()->vbatwarningcellvoltage;
batteryCriticalVoltage = batteryCellCount * batteryConfig()->vbatmincellvoltage; batteryCriticalVoltage = batteryCellCount * batteryConfig()->vbatmincellvoltage;
lowVoltageCutoff.percentage = 100; lowVoltageCutoff.percentage = 100;

View file

@ -48,7 +48,6 @@ typedef struct batteryConfig_s {
uint8_t vbatfullcellvoltage; // Cell voltage at which the battery is deemed to be "full" 0.1V units, default is 41 (4.1V) uint8_t vbatfullcellvoltage; // Cell voltage at which the battery is deemed to be "full" 0.1V units, default is 41 (4.1V)
// cells
uint8_t forceBatteryCellCount; // number of cells in battery, used for overwriting auto-detected cell count if someone has issues with it. uint8_t forceBatteryCellCount; // number of cells in battery, used for overwriting auto-detected cell count if someone has issues with it.
} batteryConfig_t; } batteryConfig_t;

View file

@ -381,7 +381,6 @@ static bool bstSlaveProcessFeedbackCommand(uint8_t bstRequest)
bstWrite8(batteryConfig()->vbatmincellvoltage); bstWrite8(batteryConfig()->vbatmincellvoltage);
bstWrite8(batteryConfig()->vbatmaxcellvoltage); bstWrite8(batteryConfig()->vbatmaxcellvoltage);
bstWrite8(batteryConfig()->vbatwarningcellvoltage); bstWrite8(batteryConfig()->vbatwarningcellvoltage);
bstWrite8(batteryConfig()->forceBatteryCellCount);
break; break;
case BST_FEATURE: case BST_FEATURE:
@ -539,7 +538,6 @@ static bool bstSlaveProcessWriteCommand(uint8_t bstWriteCommand)
batteryConfigMutable()->vbatmincellvoltage = bstRead8(); // vbatlevel_warn1 in MWC2.3 GUI batteryConfigMutable()->vbatmincellvoltage = bstRead8(); // vbatlevel_warn1 in MWC2.3 GUI
batteryConfigMutable()->vbatmaxcellvoltage = bstRead8(); // vbatlevel_warn2 in MWC2.3 GUI batteryConfigMutable()->vbatmaxcellvoltage = bstRead8(); // vbatlevel_warn2 in MWC2.3 GUI
batteryConfigMutable()->vbatwarningcellvoltage = bstRead8(); // vbatlevel when buzzer starts to alert batteryConfigMutable()->vbatwarningcellvoltage = bstRead8(); // vbatlevel when buzzer starts to alert
batteryConfigMutable()->forceBatteryCellCount = bstRead8();
break; break;
case BST_ACC_CALIBRATION: case BST_ACC_CALIBRATION: