mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-22 07:45:29 +03:00
CF/BF - fix naming of currentMeterVirtualState_t
This commit is contained in:
parent
abb6eb5b54
commit
4554019c52
4 changed files with 15 additions and 15 deletions
|
@ -640,8 +640,8 @@ static const clivalue_t valueTable[] = {
|
|||
{ "ibata_scale", VAR_INT16 | MASTER_VALUE, .config.minmax = { -16000, 16000 }, PG_CURRENT_SENSOR_ADC_CONFIG, offsetof(currentSensorADCConfig_t, scale) },
|
||||
{ "ibata_offset", VAR_INT16 | MASTER_VALUE, .config.minmax = { -16000, 16000 }, PG_CURRENT_SENSOR_ADC_CONFIG, offsetof(currentSensorADCConfig_t, offset) },
|
||||
// PG_CURRENT_SENSOR_ADC_CONFIG
|
||||
{ "ibatv_scale", VAR_INT16 | MASTER_VALUE, .config.minmax = { -16000, 16000 }, PG_CURRENT_SENSOR_VIRTUAL_CONFIG, offsetof(currentMeterVirtualConfig_t, scale) },
|
||||
{ "ibatv_offset", VAR_INT16 | MASTER_VALUE, .config.minmax = { -16000, 16000 }, PG_CURRENT_SENSOR_VIRTUAL_CONFIG, offsetof(currentMeterVirtualConfig_t, offset) },
|
||||
{ "ibatv_scale", VAR_INT16 | MASTER_VALUE, .config.minmax = { -16000, 16000 }, PG_CURRENT_SENSOR_VIRTUAL_CONFIG, offsetof(currentSensorVirtualConfig_t, scale) },
|
||||
{ "ibatv_offset", VAR_INT16 | MASTER_VALUE, .config.minmax = { -16000, 16000 }, PG_CURRENT_SENSOR_VIRTUAL_CONFIG, offsetof(currentSensorVirtualConfig_t, offset) },
|
||||
|
||||
// PG_BEEPER_DEV_CONFIG
|
||||
#ifdef BEEPER
|
||||
|
|
|
@ -986,8 +986,8 @@ static bool mspFcProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProcessFn
|
|||
sbufWriteU8(dst, virtualSensorSubframeLength);
|
||||
sbufWriteU8(dst, CURRENT_METER_ID_VIRTUAL_1); // the id of the sensor
|
||||
sbufWriteU8(dst, CURRENT_SENSOR_VIRTUAL); // indicate the type of sensor that the next part of the payload is for
|
||||
sbufWriteU16(dst, currentMeterVirtualConfig()->scale);
|
||||
sbufWriteU16(dst, currentMeterVirtualConfig()->offset);
|
||||
sbufWriteU16(dst, currentSensorVirtualConfig()->scale);
|
||||
sbufWriteU16(dst, currentSensorVirtualConfig()->offset);
|
||||
|
||||
// if we had any other current sensors, this is where we would output any needed configuration
|
||||
break;
|
||||
|
@ -1864,8 +1864,8 @@ static mspResult_e mspFcProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
|
|||
currentSensorADCConfigMutable()->offset = sbufReadU16(src);
|
||||
break;
|
||||
case CURRENT_METER_ID_VIRTUAL_1:
|
||||
currentMeterVirtualConfigMutable()->scale = sbufReadU16(src);
|
||||
currentMeterVirtualConfigMutable()->offset = sbufReadU16(src);
|
||||
currentSensorVirtualConfigMutable()->scale = sbufReadU16(src);
|
||||
currentSensorVirtualConfigMutable()->offset = sbufReadU16(src);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -93,7 +93,7 @@ PG_RESET_TEMPLATE(currentSensorADCConfig_t, currentSensorADCConfig,
|
|||
.offset = CURRENT_METER_OFFSET_DEFAULT,
|
||||
);
|
||||
|
||||
PG_REGISTER(currentMeterVirtualConfig_t, currentMeterVirtualConfig, PG_CURRENT_SENSOR_VIRTUAL_CONFIG, 0);
|
||||
PG_REGISTER(currentSensorVirtualConfig_t, currentSensorVirtualConfig, PG_CURRENT_SENSOR_VIRTUAL_CONFIG, 0);
|
||||
|
||||
static int32_t currentMeterADCToCentiamps(const uint16_t src)
|
||||
{
|
||||
|
@ -144,23 +144,23 @@ void currentMeterADCRead(currentMeter_t *meter)
|
|||
// VIRTUAL
|
||||
//
|
||||
|
||||
currentMeterVirtualState_t currentMeterVirtualState;
|
||||
currentSensorVirtualState_t currentMeterVirtualState;
|
||||
|
||||
void currentMeterVirtualInit(void)
|
||||
{
|
||||
memset(¤tMeterVirtualState, 0, sizeof(currentMeterVirtualState_t));
|
||||
memset(¤tMeterVirtualState, 0, sizeof(currentSensorVirtualState_t));
|
||||
}
|
||||
|
||||
void currentMeterVirtualRefresh(int32_t lastUpdateAt, bool armed, bool throttleLowAndMotorStop, int32_t throttleOffset)
|
||||
{
|
||||
currentMeterVirtualState.amperage = (int32_t)currentMeterVirtualConfig()->offset;
|
||||
currentMeterVirtualState.amperage = (int32_t)currentSensorVirtualConfig()->offset;
|
||||
if (armed) {
|
||||
if (throttleLowAndMotorStop) {
|
||||
throttleOffset = 0;
|
||||
}
|
||||
|
||||
int throttleFactor = throttleOffset + (throttleOffset * throttleOffset / 50); // FIXME magic number 50, 50hz?
|
||||
currentMeterVirtualState.amperage += throttleFactor * (int32_t)currentMeterVirtualConfig()->scale / 1000;
|
||||
currentMeterVirtualState.amperage += throttleFactor * (int32_t)currentSensorVirtualConfig()->scale / 1000;
|
||||
}
|
||||
updateCurrentmAhDrawnState(¤tMeterVirtualState.mahDrawnState, currentMeterVirtualState.amperage, lastUpdateAt);
|
||||
}
|
||||
|
|
|
@ -75,14 +75,14 @@ PG_DECLARE(currentSensorADCConfig_t, currentSensorADCConfig);
|
|||
typedef struct currentMeterVirtualState_s {
|
||||
currentMeterMAhDrawnState_t mahDrawnState;
|
||||
int32_t amperage; // current read by current sensor in centiampere (1/100th A)
|
||||
} currentMeterVirtualState_t;
|
||||
} currentSensorVirtualState_t;
|
||||
|
||||
typedef struct currentMeterVirtualConfig_s {
|
||||
typedef struct currentSensorVirtualConfig_s {
|
||||
int16_t scale; // scale the current sensor output voltage to milliamps. Value in 1/10th mV/A
|
||||
uint16_t offset; // offset of the current sensor in millivolt steps
|
||||
} currentMeterVirtualConfig_t;
|
||||
} currentSensorVirtualConfig_t;
|
||||
|
||||
PG_DECLARE(currentMeterVirtualConfig_t, currentMeterVirtualConfig);
|
||||
PG_DECLARE(currentSensorVirtualConfig_t, currentSensorVirtualConfig);
|
||||
|
||||
//
|
||||
// ESC
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue