mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 16:25:31 +03:00
Change virtual current meter to use setpoint rather than rcCommand throttle
Use the final calculated throttle value that may be affected by throttle limiting, throttle boost, etc. instead of the rcCommand input when calculating the virtual current meter.
This commit is contained in:
parent
c77c593a14
commit
be79913726
4 changed files with 14 additions and 10 deletions
|
@ -1035,7 +1035,7 @@ static void loadMainState(timeUs_t currentTimeUs)
|
||||||
blackboxCurrent->setpoint[i] = lrintf(pidGetPreviousSetpoint(i));
|
blackboxCurrent->setpoint[i] = lrintf(pidGetPreviousSetpoint(i));
|
||||||
}
|
}
|
||||||
// log the final throttle value used in the mixer
|
// log the final throttle value used in the mixer
|
||||||
blackboxCurrent->setpoint[3] = lrintf(mixerGetLoggingThrottle() * 1000);
|
blackboxCurrent->setpoint[3] = lrintf(mixerGetThrottle() * 1000);
|
||||||
|
|
||||||
for (int i = 0; i < DEBUG16_VALUE_COUNT; i++) {
|
for (int i = 0; i < DEBUG16_VALUE_COUNT; i++) {
|
||||||
blackboxCurrent->debug[i] = debug[i];
|
blackboxCurrent->debug[i] = debug[i];
|
||||||
|
|
|
@ -472,7 +472,7 @@ void stopMotors(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static FAST_RAM_ZERO_INIT float throttle = 0;
|
static FAST_RAM_ZERO_INIT float throttle = 0;
|
||||||
static FAST_RAM_ZERO_INIT float loggingThrottle = 0;
|
static FAST_RAM_ZERO_INIT float mixerThrottle = 0;
|
||||||
static FAST_RAM_ZERO_INIT float motorOutputMin;
|
static FAST_RAM_ZERO_INIT float motorOutputMin;
|
||||||
static FAST_RAM_ZERO_INIT float motorRangeMin;
|
static FAST_RAM_ZERO_INIT float motorRangeMin;
|
||||||
static FAST_RAM_ZERO_INIT float motorRangeMax;
|
static FAST_RAM_ZERO_INIT float motorRangeMax;
|
||||||
|
@ -891,7 +891,7 @@ FAST_CODE_NOINLINE void mixTable(timeUs_t currentTimeUs, uint8_t vbatPidCompensa
|
||||||
throttle += pidGetAirmodeThrottleOffset();
|
throttle += pidGetAirmodeThrottleOffset();
|
||||||
float airmodeThrottleChange = 0;
|
float airmodeThrottleChange = 0;
|
||||||
#endif
|
#endif
|
||||||
loggingThrottle = throttle;
|
mixerThrottle = throttle;
|
||||||
|
|
||||||
motorMixRange = motorMixMax - motorMixMin;
|
motorMixRange = motorMixMax - motorMixMin;
|
||||||
if (motorMixRange > 1.0f) {
|
if (motorMixRange > 1.0f) {
|
||||||
|
@ -934,7 +934,7 @@ void mixerSetThrottleAngleCorrection(int correctionValue)
|
||||||
throttleAngleCorrection = correctionValue;
|
throttleAngleCorrection = correctionValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
float mixerGetLoggingThrottle(void)
|
float mixerGetThrottle(void)
|
||||||
{
|
{
|
||||||
return loggingThrottle;
|
return mixerThrottle;
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,4 +111,4 @@ void writeMotors(void);
|
||||||
bool mixerIsTricopter(void);
|
bool mixerIsTricopter(void);
|
||||||
|
|
||||||
void mixerSetThrottleAngleCorrection(int correctionValue);
|
void mixerSetThrottleAngleCorrection(int correctionValue);
|
||||||
float mixerGetLoggingThrottle(void);
|
float mixerGetThrottle(void);
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include "stdbool.h"
|
#include "stdbool.h"
|
||||||
#include "stdint.h"
|
#include "stdint.h"
|
||||||
|
#include "math.h"
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
|
||||||
|
@ -29,18 +30,21 @@
|
||||||
#include "common/maths.h"
|
#include "common/maths.h"
|
||||||
#include "common/utils.h"
|
#include "common/utils.h"
|
||||||
|
|
||||||
|
#include "config/config.h"
|
||||||
#include "config/feature.h"
|
#include "config/feature.h"
|
||||||
#include "pg/pg.h"
|
|
||||||
#include "pg/pg_ids.h"
|
|
||||||
|
|
||||||
#include "drivers/adc.h"
|
#include "drivers/adc.h"
|
||||||
|
|
||||||
#include "fc/runtime_config.h"
|
#include "fc/runtime_config.h"
|
||||||
#include "config/config.h"
|
|
||||||
#include "fc/rc_controls.h"
|
#include "fc/rc_controls.h"
|
||||||
|
|
||||||
|
#include "flight/mixer.h"
|
||||||
|
|
||||||
#include "io/beeper.h"
|
#include "io/beeper.h"
|
||||||
|
|
||||||
|
#include "pg/pg.h"
|
||||||
|
#include "pg/pg_ids.h"
|
||||||
|
|
||||||
#include "sensors/battery.h"
|
#include "sensors/battery.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -427,7 +431,7 @@ void batteryUpdateCurrentMeter(timeUs_t currentTimeUs)
|
||||||
#ifdef USE_VIRTUAL_CURRENT_METER
|
#ifdef USE_VIRTUAL_CURRENT_METER
|
||||||
throttleStatus_e throttleStatus = calculateThrottleStatus();
|
throttleStatus_e throttleStatus = calculateThrottleStatus();
|
||||||
bool throttleLowAndMotorStop = (throttleStatus == THROTTLE_LOW && featureIsEnabled(FEATURE_MOTOR_STOP));
|
bool throttleLowAndMotorStop = (throttleStatus == THROTTLE_LOW && featureIsEnabled(FEATURE_MOTOR_STOP));
|
||||||
int32_t throttleOffset = (int32_t)rcCommand[THROTTLE] - 1000;
|
const int32_t throttleOffset = lrintf(mixerGetThrottle() * 1000);
|
||||||
|
|
||||||
currentMeterVirtualRefresh(lastUpdateAt, ARMING_FLAG(ARMED), throttleLowAndMotorStop, throttleOffset);
|
currentMeterVirtualRefresh(lastUpdateAt, ARMING_FLAG(ARMED), throttleLowAndMotorStop, throttleOffset);
|
||||||
currentMeterVirtualRead(¤tMeter);
|
currentMeterVirtualRead(¤tMeter);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue