dont return 0 in calibrated voltage

This commit is contained in:
2021-10-13 13:46:19 +02:00
parent 2cc1ca6ab7
commit 8414769397
2 changed files with 13 additions and 21 deletions

View File

@ -29,11 +29,13 @@ struct Controller {
#ifdef FEATURE_SERIAL
HardwareSerial &serial,
#endif
bool &enableLeft, bool &enableRight, bool &invertLeft, bool &invertRight) :
bool &enableLeft, bool &enableRight, bool &invertLeft, bool &invertRight,
int16_t &voltageCalib30V, int16_t &voltageCalib50V) :
#ifdef FEATURE_SERIAL
serial{serial},
#endif
enableLeft{enableLeft}, enableRight{enableRight}, invertLeft{invertLeft}, invertRight{invertRight}
enableLeft{enableLeft}, enableRight{enableRight}, invertLeft{invertLeft}, invertRight{invertRight},
voltageCalib30V{voltageCalib30V}, voltageCalib50V{voltageCalib50V}
{
}
// Controller(const Controller &) = delete;
@ -43,6 +45,7 @@ struct Controller {
std::reference_wrapper<HardwareSerial> serial;
#endif
bool &enableLeft, &enableRight, &invertLeft, &invertRight;
int16_t &voltageCalib30V, &voltageCalib50V;
bobbycar::protocol::serial::Command command{};
@ -59,23 +62,10 @@ struct Controller {
float getCalibratedVoltage() const
{
return 0.f;
float voltage = feedback.batVoltage;
//if (settings.battery.applyCalibration)
voltage = ((voltage - float(voltageCalib30V)) * (20.f / (float(voltageCalib50V) - float(voltageCalib30V))) + 30.f);
return voltage;
}
// float fixFrontBatVoltage(int16_t value)
// {
// float frontVoltage = value;
// if (settings.battery.applyCalibration)
// frontVoltage = ((frontVoltage - float(settings.battery.front30VoltCalibration)) * (20.f / (float(settings.battery.front50VoltCalibration) - float(settings.battery.front30VoltCalibration))) + 30.f);
// return frontVoltage;
// }
// float fixBackBatVoltage(int16_t value)
// {
// float backVoltage = value;
// if (settings.battery.applyCalibration)
// backVoltage = ((backVoltage - float(settings.battery.back30VoltCalibration)) * (20.f / (float(settings.battery.back50VoltCalibration) - float(settings.battery.back30VoltCalibration))) + 30.f);
// return backVoltage;
// }
};
}

View File

@ -60,13 +60,15 @@ public:
#ifdef FEATURE_SERIAL
Serial1,
#endif
settings.controllerHardware.enableFrontLeft, settings.controllerHardware.enableFrontRight, settings.controllerHardware.invertFrontLeft, settings.controllerHardware.invertFrontRight
settings.controllerHardware.enableFrontLeft, settings.controllerHardware.enableFrontRight, settings.controllerHardware.invertFrontLeft, settings.controllerHardware.invertFrontRight,
settings.battery.front30VoltCalibration, settings.battery.front50VoltCalibration
},
Controller {
#ifdef FEATURE_SERIAL
Serial2,
#endif
settings.controllerHardware.enableBackLeft, settings.controllerHardware.enableBackRight, settings.controllerHardware.invertBackLeft, settings.controllerHardware.invertBackRight
settings.controllerHardware.enableBackLeft, settings.controllerHardware.enableBackRight, settings.controllerHardware.invertBackLeft, settings.controllerHardware.invertBackRight,
settings.battery.back30VoltCalibration, settings.battery.back50VoltCalibration
}
}}
{}