mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 16:25:31 +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_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) },
|
{ "ibata_offset", VAR_INT16 | MASTER_VALUE, .config.minmax = { -16000, 16000 }, PG_CURRENT_SENSOR_ADC_CONFIG, offsetof(currentSensorADCConfig_t, offset) },
|
||||||
// PG_CURRENT_SENSOR_ADC_CONFIG
|
// 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_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(currentMeterVirtualConfig_t, offset) },
|
{ "ibatv_offset", VAR_INT16 | MASTER_VALUE, .config.minmax = { -16000, 16000 }, PG_CURRENT_SENSOR_VIRTUAL_CONFIG, offsetof(currentSensorVirtualConfig_t, offset) },
|
||||||
|
|
||||||
// PG_BEEPER_DEV_CONFIG
|
// PG_BEEPER_DEV_CONFIG
|
||||||
#ifdef BEEPER
|
#ifdef BEEPER
|
||||||
|
|
|
@ -986,8 +986,8 @@ static bool mspFcProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProcessFn
|
||||||
sbufWriteU8(dst, virtualSensorSubframeLength);
|
sbufWriteU8(dst, virtualSensorSubframeLength);
|
||||||
sbufWriteU8(dst, CURRENT_METER_ID_VIRTUAL_1); // the id of the sensor
|
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
|
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, currentSensorVirtualConfig()->scale);
|
||||||
sbufWriteU16(dst, currentMeterVirtualConfig()->offset);
|
sbufWriteU16(dst, currentSensorVirtualConfig()->offset);
|
||||||
|
|
||||||
// if we had any other current sensors, this is where we would output any needed configuration
|
// if we had any other current sensors, this is where we would output any needed configuration
|
||||||
break;
|
break;
|
||||||
|
@ -1864,8 +1864,8 @@ static mspResult_e mspFcProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
|
||||||
currentSensorADCConfigMutable()->offset = sbufReadU16(src);
|
currentSensorADCConfigMutable()->offset = sbufReadU16(src);
|
||||||
break;
|
break;
|
||||||
case CURRENT_METER_ID_VIRTUAL_1:
|
case CURRENT_METER_ID_VIRTUAL_1:
|
||||||
currentMeterVirtualConfigMutable()->scale = sbufReadU16(src);
|
currentSensorVirtualConfigMutable()->scale = sbufReadU16(src);
|
||||||
currentMeterVirtualConfigMutable()->offset = sbufReadU16(src);
|
currentSensorVirtualConfigMutable()->offset = sbufReadU16(src);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -93,7 +93,7 @@ PG_RESET_TEMPLATE(currentSensorADCConfig_t, currentSensorADCConfig,
|
||||||
.offset = CURRENT_METER_OFFSET_DEFAULT,
|
.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)
|
static int32_t currentMeterADCToCentiamps(const uint16_t src)
|
||||||
{
|
{
|
||||||
|
@ -144,23 +144,23 @@ void currentMeterADCRead(currentMeter_t *meter)
|
||||||
// VIRTUAL
|
// VIRTUAL
|
||||||
//
|
//
|
||||||
|
|
||||||
currentMeterVirtualState_t currentMeterVirtualState;
|
currentSensorVirtualState_t currentMeterVirtualState;
|
||||||
|
|
||||||
void currentMeterVirtualInit(void)
|
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)
|
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 (armed) {
|
||||||
if (throttleLowAndMotorStop) {
|
if (throttleLowAndMotorStop) {
|
||||||
throttleOffset = 0;
|
throttleOffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int throttleFactor = throttleOffset + (throttleOffset * throttleOffset / 50); // FIXME magic number 50, 50hz?
|
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);
|
updateCurrentmAhDrawnState(¤tMeterVirtualState.mahDrawnState, currentMeterVirtualState.amperage, lastUpdateAt);
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,14 +75,14 @@ PG_DECLARE(currentSensorADCConfig_t, currentSensorADCConfig);
|
||||||
typedef struct currentMeterVirtualState_s {
|
typedef struct currentMeterVirtualState_s {
|
||||||
currentMeterMAhDrawnState_t mahDrawnState;
|
currentMeterMAhDrawnState_t mahDrawnState;
|
||||||
int32_t amperage; // current read by current sensor in centiampere (1/100th A)
|
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
|
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
|
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
|
// ESC
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue