mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 08:15:30 +03:00
Update to Virtual Current Meter fix
now using rc_controls/calculateThrottleStatus() unneeded dependencies removed.
This commit is contained in:
parent
7c2a2a1732
commit
40cc7697fe
3 changed files with 8 additions and 38 deletions
|
@ -246,7 +246,7 @@ void annexCode(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (feature(FEATURE_CURRENT_METER)) {
|
if (feature(FEATURE_CURRENT_METER)) {
|
||||||
updateCurrentMeter(vbatCycleTime);
|
updateCurrentMeter(vbatCycleTime, &masterConfig.rxConfig, masterConfig.flight3DConfig.deadband3d_throttle);
|
||||||
}
|
}
|
||||||
vbatCycleTime = 0;
|
vbatCycleTime = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,53 +17,20 @@
|
||||||
|
|
||||||
#include "stdbool.h"
|
#include "stdbool.h"
|
||||||
#include "stdint.h"
|
#include "stdint.h"
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "platform.h"
|
|
||||||
|
|
||||||
#include "common/maths.h"
|
#include "common/maths.h"
|
||||||
#include "common/axis.h"
|
|
||||||
#include "common/color.h"
|
|
||||||
|
|
||||||
#include "drivers/adc.h"
|
#include "drivers/adc.h"
|
||||||
#include "drivers/system.h"
|
#include "drivers/system.h"
|
||||||
#include "drivers/sensor.h"
|
|
||||||
#include "drivers/accgyro.h"
|
|
||||||
#include "drivers/gpio.h"
|
|
||||||
#include "drivers/timer.h"
|
|
||||||
#include "drivers/serial.h"
|
|
||||||
#include "drivers/pwm_rx.h"
|
|
||||||
|
|
||||||
#include "config/runtime_config.h"
|
#include "config/runtime_config.h"
|
||||||
|
#include "config/config.h"
|
||||||
|
|
||||||
#include "sensors/sensors.h"
|
|
||||||
#include "sensors/acceleration.h"
|
|
||||||
#include "sensors/battery.h"
|
#include "sensors/battery.h"
|
||||||
#include "sensors/boardalignment.h"
|
|
||||||
#include "sensors/gyro.h"
|
|
||||||
#include "sensors/barometer.h"
|
|
||||||
|
|
||||||
#include "flight/mixer.h"
|
|
||||||
#include "flight/failsafe.h"
|
|
||||||
#include "flight/pid.h"
|
|
||||||
#include "flight/imu.h"
|
|
||||||
#include "flight/navigation.h"
|
|
||||||
|
|
||||||
#include "rx/rx.h"
|
#include "rx/rx.h"
|
||||||
|
|
||||||
#include "io/rc_controls.h"
|
#include "io/rc_controls.h"
|
||||||
#include "io/escservo.h"
|
|
||||||
#include "io/serial.h"
|
|
||||||
#include "io/gps.h"
|
|
||||||
#include "io/gimbal.h"
|
|
||||||
#include "io/ledstrip.h"
|
|
||||||
|
|
||||||
#include "telemetry/telemetry.h"
|
|
||||||
|
|
||||||
#include "config/runtime_config.h"
|
|
||||||
#include "config/config.h"
|
|
||||||
#include "config/config_profile.h"
|
|
||||||
#include "config/config_master.h"
|
|
||||||
|
|
||||||
// Battery monitoring stuff
|
// Battery monitoring stuff
|
||||||
uint8_t batteryCellCount = 3; // cell count
|
uint8_t batteryCellCount = 3; // cell count
|
||||||
|
@ -146,7 +113,7 @@ int32_t currentSensorToCentiamps(uint16_t src)
|
||||||
return (millivolts * 1000) / (int32_t)batteryConfig->currentMeterScale; // current in 0.01A steps
|
return (millivolts * 1000) / (int32_t)batteryConfig->currentMeterScale; // current in 0.01A steps
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateCurrentMeter(int32_t lastUpdateAt)
|
void updateCurrentMeter(int32_t lastUpdateAt, rxConfig_t *rxConfig, uint16_t deadband3d_throttle)
|
||||||
{
|
{
|
||||||
static int32_t amperageRaw = 0;
|
static int32_t amperageRaw = 0;
|
||||||
static int64_t mAhdrawnRaw = 0;
|
static int64_t mAhdrawnRaw = 0;
|
||||||
|
@ -162,7 +129,8 @@ void updateCurrentMeter(int32_t lastUpdateAt)
|
||||||
case CURRENT_SENSOR_VIRTUAL:
|
case CURRENT_SENSOR_VIRTUAL:
|
||||||
amperage = (int32_t)batteryConfig->currentMeterOffset;
|
amperage = (int32_t)batteryConfig->currentMeterOffset;
|
||||||
if(ARMING_FLAG(ARMED)) {
|
if(ARMING_FLAG(ARMED)) {
|
||||||
if((rcData[THROTTLE]) < masterConfig.rxConfig.mincheck && feature(FEATURE_MOTOR_STOP))
|
throttleStatus_e throttleStatus = calculateThrottleStatus(rxConfig, deadband3d_throttle);
|
||||||
|
if (throttleStatus == THROTTLE_LOW && feature(FEATURE_MOTOR_STOP))
|
||||||
throttleOffset = 0;
|
throttleOffset = 0;
|
||||||
throttleFactor = throttleOffset + (throttleOffset * throttleOffset / 50);
|
throttleFactor = throttleOffset + (throttleOffset * throttleOffset / 50);
|
||||||
amperage += throttleFactor * (int32_t)batteryConfig->currentMeterScale / 1000;
|
amperage += throttleFactor * (int32_t)batteryConfig->currentMeterScale / 1000;
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "rx/rx.h"
|
||||||
|
|
||||||
#define VBAT_SCALE_DEFAULT 110
|
#define VBAT_SCALE_DEFAULT 110
|
||||||
#define VBAT_SCALE_MIN 0
|
#define VBAT_SCALE_MIN 0
|
||||||
#define VBAT_SCALE_MAX 255
|
#define VBAT_SCALE_MAX 255
|
||||||
|
@ -62,7 +64,7 @@ batteryState_e calculateBatteryState(void);
|
||||||
void updateBatteryVoltage(void);
|
void updateBatteryVoltage(void);
|
||||||
void batteryInit(batteryConfig_t *initialBatteryConfig);
|
void batteryInit(batteryConfig_t *initialBatteryConfig);
|
||||||
|
|
||||||
void updateCurrentMeter(int32_t lastUpdateAt);
|
void updateCurrentMeter(int32_t lastUpdateAt, rxConfig_t *rxConfig, uint16_t deadband3d_throttle);
|
||||||
int32_t currentMeterToCentiamps(uint16_t src);
|
int32_t currentMeterToCentiamps(uint16_t src);
|
||||||
|
|
||||||
uint8_t calculateBatteryPercentage(void);
|
uint8_t calculateBatteryPercentage(void);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue