1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-13 19:40:31 +03:00

Change virtual current meter to use setpoint rather than rcComm… (#9153)

Change virtual current meter to use setpoint rather than rcCommand throttle
This commit is contained in:
Michael Keller 2019-11-10 10:42:43 +13:00 committed by GitHub
commit 9f6ff8d3fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 10 deletions

View file

@ -1035,7 +1035,7 @@ static void loadMainState(timeUs_t currentTimeUs)
blackboxCurrent->setpoint[i] = lrintf(pidGetPreviousSetpoint(i));
}
// 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++) {
blackboxCurrent->debug[i] = debug[i];

View file

@ -472,7 +472,7 @@ void stopMotors(void)
}
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 motorRangeMin;
static FAST_RAM_ZERO_INIT float motorRangeMax;
@ -891,7 +891,7 @@ FAST_CODE_NOINLINE void mixTable(timeUs_t currentTimeUs, uint8_t vbatPidCompensa
throttle += pidGetAirmodeThrottleOffset();
float airmodeThrottleChange = 0;
#endif
loggingThrottle = throttle;
mixerThrottle = throttle;
motorMixRange = motorMixMax - motorMixMin;
if (motorMixRange > 1.0f) {
@ -934,7 +934,7 @@ void mixerSetThrottleAngleCorrection(int correctionValue)
throttleAngleCorrection = correctionValue;
}
float mixerGetLoggingThrottle(void)
float mixerGetThrottle(void)
{
return loggingThrottle;
return mixerThrottle;
}

View file

@ -111,4 +111,4 @@ void writeMotors(void);
bool mixerIsTricopter(void);
void mixerSetThrottleAngleCorrection(int correctionValue);
float mixerGetLoggingThrottle(void);
float mixerGetThrottle(void);

View file

@ -20,6 +20,7 @@
#include "stdbool.h"
#include "stdint.h"
#include "math.h"
#include "platform.h"
@ -29,18 +30,21 @@
#include "common/maths.h"
#include "common/utils.h"
#include "config/config.h"
#include "config/feature.h"
#include "pg/pg.h"
#include "pg/pg_ids.h"
#include "drivers/adc.h"
#include "fc/runtime_config.h"
#include "config/config.h"
#include "fc/rc_controls.h"
#include "flight/mixer.h"
#include "io/beeper.h"
#include "pg/pg.h"
#include "pg/pg_ids.h"
#include "sensors/battery.h"
/**
@ -427,7 +431,7 @@ void batteryUpdateCurrentMeter(timeUs_t currentTimeUs)
#ifdef USE_VIRTUAL_CURRENT_METER
throttleStatus_e throttleStatus = calculateThrottleStatus();
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);
currentMeterVirtualRead(&currentMeter);