Removed doubles

This commit is contained in:
CommanderRedYT
2022-06-12 17:51:31 +02:00
parent c42e44c40b
commit 460f40ce47
15 changed files with 130 additions and 130 deletions

View File

@ -18,40 +18,40 @@ float getBatteryPercentage(float batVoltage, BatteryCellType cellType)
case BatteryCellType::_22P: case BatteryCellType::_22P:
{ {
const float expected_ah = BAT_MIN_AH_22P; const float expected_ah = BAT_MIN_AH_22P;
if (cellVoltage > 4.15) if (cellVoltage > 4.15f)
return 100; return 100.f;
BAT_CURVE_22P(PERCENTAGE); BAT_CURVE_22P(PERCENTAGE);
break; break;
} }
case BatteryCellType::MH1: case BatteryCellType::MH1:
{ {
const float expected_ah = BAT_MIN_AH_MH1; const float expected_ah = BAT_MIN_AH_MH1;
if (cellVoltage > 4.15) if (cellVoltage > 4.15f)
return 100; return 100.f;
BAT_CURVE_MH1(PERCENTAGE); BAT_CURVE_MH1(PERCENTAGE);
break; break;
} }
case BatteryCellType::HG2: case BatteryCellType::HG2:
{ {
const float expected_ah = BAT_MIN_AH_HG2; const float expected_ah = BAT_MIN_AH_HG2;
if (cellVoltage > 4.15) if (cellVoltage > 4.15f)
return 100; return 100.f;
BAT_CURVE_HG2(PERCENTAGE); BAT_CURVE_HG2(PERCENTAGE);
break; break;
} }
case BatteryCellType::VTC5: case BatteryCellType::VTC5:
{ {
const float expected_ah = BAT_MIN_AH_VTC5; const float expected_ah = BAT_MIN_AH_VTC5;
if (cellVoltage > 4.15) if (cellVoltage > 4.15f)
return 100; return 100.f;
BAT_CURVE_VTC5(PERCENTAGE); BAT_CURVE_VTC5(PERCENTAGE);
break; break;
} }
case BatteryCellType::BAK_25R: case BatteryCellType::BAK_25R:
{ {
const float expected_ah = BAT_MIN_AH_BAK_25R; const float expected_ah = BAT_MIN_AH_BAK_25R;
if(cellVoltage > 4.15){ if(cellVoltage > 4.15f){
return 100; return 100.f;
} }
BAT_CURVE_25R(PERCENTAGE); BAT_CURVE_25R(PERCENTAGE);
break; break;
@ -59,8 +59,8 @@ float getBatteryPercentage(float batVoltage, BatteryCellType cellType)
case BatteryCellType::HE4: case BatteryCellType::HE4:
{ {
const float expected_ah = BAT_MIN_AH_HE4; const float expected_ah = BAT_MIN_AH_HE4;
if(cellVoltage > 4.15){ if(cellVoltage > 4.15f){
return 100; return 100.f;
} }
BAT_CURVE_HE4(PERCENTAGE); BAT_CURVE_HE4(PERCENTAGE);
break; break;
@ -75,21 +75,21 @@ float getRemainingWattHours()
if (const auto avgVoltage = controllers.getAvgVoltage(); avgVoltage) if (const auto avgVoltage = controllers.getAvgVoltage(); avgVoltage)
{ {
return (target_mah / 1000.f) * 3.7 * configs.battery.cellsParallel.value() * configs.battery.cellsSeries.value() * (getBatteryPercentage(*avgVoltage, BatteryCellType(configs.battery.cellType.value())) / 100); return (target_mah / 1000.f) * 3.7f * configs.battery.cellsParallel.value() * configs.battery.cellsSeries.value() * (getBatteryPercentage(*avgVoltage, BatteryCellType(configs.battery.cellType.value())) / 100);
} }
else else
return 0.; return 0.f;
} }
float getPercentageByWh(float wh) float getPercentageByWh(float wh)
{ {
const float maxWh = (getTarget_mAh() / 1000.f) * 3.7 * configs.battery.cellsParallel.value() * configs.battery.cellsSeries.value(); const float maxWh = (getTarget_mAh() / 1000.f) * 3.7f * configs.battery.cellsParallel.value() * configs.battery.cellsSeries.value();
return maxWh / wh; return maxWh / wh;
} }
float getBatteryWattHours() float getBatteryWattHours()
{ {
return (getTarget_mAh() / 1000.f) * 3.7 * configs.battery.cellsParallel.value() * configs.battery.cellsSeries.value(); return (getTarget_mAh() / 1000.f) * 3.7f * configs.battery.cellsParallel.value() * configs.battery.cellsSeries.value();
} }
float getTarget_mAh() float getTarget_mAh()

View File

@ -37,94 +37,94 @@ if (cellVoltage >= lowerVoltage && cellVoltage <= higherVoltage) \
// as some functions require this to display data in correct order // as some functions require this to display data in correct order
// 22P // 22P
#define BAT_MIN_AH_22P 2.2 #define BAT_MIN_AH_22P 2.2f
#define BAT_CURVE_22P(func) \ #define BAT_CURVE_22P(func) \
func(4.15, 4.04, 0, 0.25) \ func(4.15f, 4.04f, 0.00f, 0.25f) \
func(4.04, 3.95, 0.25, 0.5) \ func(4.04f, 3.95f, 0.25f, 0.50f) \
func(3.95, 3.86, 0.5, 0.75) \ func(3.95f, 3.86f, 0.50f, 0.75f) \
func(3.86, 3.74, 0.75, 1.0) \ func(3.86f, 3.74f, 0.75f, 1.00f) \
func(3.74, 3.64, 1.0, 1.25) \ func(3.74f, 3.64f, 1.00f, 1.25f) \
func(3.64, 3.59, 1.25, 1.5) \ func(3.64f, 3.59f, 1.25f, 1.50f) \
func(3.59, 3.54, 1.5, 1.75) \ func(3.59f, 3.54f, 1.50f, 1.75f) \
func(3.54, 3.43, 1.75, 2.0) \ func(3.54f, 3.43f, 1.75f, 2.00f) \
func(3.43, 3.35, 2.0, 2.1) \ func(3.43f, 3.35f, 2.00f, 2.10f) \
func(3.35, 2.50, 2.1, 2.2) func(3.35f, 2.50f, 2.10f, 2.20f)
// MH1 // MH1
#define BAT_MIN_AH_MH1 3.2 #define BAT_MIN_AH_MH1 3.2f
#define BAT_CURVE_MH1(func) \ #define BAT_CURVE_MH1(func) \
func(4.15, 4.09, 0, 0.25) \ func(4.15f, 4.09f, 0.00f, 0.25f) \
func(4.09, 4.04, 0.25, 0.5) \ func(4.09f, 4.04f, 0.25f, 0.50f) \
func(4.04, 3.95, 0.5, 0.75) \ func(4.04f, 3.95f, 0.50f, 0.75f) \
func(3.95, 3.88, 0.75, 1.0) \ func(3.95f, 3.88f, 0.75f, 1.00f) \
func(3.88, 3.79, 1.0, 1.25) \ func(3.88f, 3.79f, 1.00f, 1.25f) \
func(3.79, 3.70, 1.25, 1.5) \ func(3.79f, 3.70f, 1.25f, 1.50f) \
func(3.70, 3.65, 1.5, 1.75) \ func(3.70f, 3.65f, 1.50f, 1.75f) \
func(3.65, 3.60, 1.75, 2.0) \ func(3.65f, 3.60f, 1.75f, 2.00f) \
func(3.60, 3.56, 2.0, 2.25) \ func(3.60f, 3.56f, 2.00f, 2.25f) \
func(3.56, 3.50, 2.25, 2.5) \ func(3.56f, 3.50f, 2.25f, 2.50f) \
func(3.50, 3.40, 2.5, 2.75) \ func(3.50f, 3.40f, 2.50f, 2.75f) \
func(3.40, 3.30, 2.75, 3.0) \ func(3.40f, 3.30f, 2.75f, 3.00f) \
func(3.30, 2.5, 3.0, 3.2) func(3.30f, 2.50f, 3.00f, 3.20f)
// HG2 // HG2
#define BAT_MIN_AH_HG2 3.0 #define BAT_MIN_AH_HG2 3.0f
#define BAT_CURVE_HG2(func) \ #define BAT_CURVE_HG2(func) \
func(4.15, 4.08, 0, 0.25) \ func(4.15f, 4.08f, 0.00f, 0.25f) \
func(4.08, 4.01, 0.25, 0.5) \ func(4.08f, 4.01f, 0.25f, 0.50f) \
func(4.01, 3.92, 0.5, 0.75) \ func(4.01f, 3.92f, 0.50f, 0.75f) \
func(3.92, 3.84, 0.75, 1.0) \ func(3.92f, 3.84f, 0.75f, 1.00f) \
func(3.84, 3.75, 1.0, 1.25) \ func(3.84f, 3.75f, 1.00f, 1.25f) \
func(3.75, 3.67, 1.25, 1.5) \ func(3.75f, 3.67f, 1.25f, 1.50f) \
func(3.67, 3.62, 1.5, 1.75) \ func(3.67f, 3.62f, 1.50f, 1.75f) \
func(3.62, 3.55, 1.75, 2.0) \ func(3.62f, 3.55f, 1.75f, 2.00f) \
func(3.55, 3.44, 2.0, 2.25) \ func(3.55f, 3.44f, 2.00f, 2.25f) \
func(3.44, 3.30, 2.25, 2.5) \ func(3.44f, 3.30f, 2.25f, 2.50f) \
func(3.30, 3.05, 2.5, 2.75) \ func(3.30f, 3.05f, 2.50f, 2.75f) \
func(3.05, 2.50, 2.75, 3.0) func(3.05f, 2.50f, 2.75f, 3.00f)
// VTC5 // VTC5
#define BAT_MIN_AH_VTC5 2.6 #define BAT_MIN_AH_VTC5 2.6f
#define BAT_CURVE_VTC5(func) \ #define BAT_CURVE_VTC5(func) \
func(4.15, 4.08, 0, 0.25) \ func(4.15f, 4.08f, 0.00f, 0.25f) \
func(4.08, 3.98, 0.25, 0.5) \ func(4.08f, 3.98f, 0.25f, 0.50f) \
func(3.98, 3.89, 0.5, 0.75) \ func(3.98f, 3.89f, 0.50f, 0.75f) \
func(3.89, 3.79, 0.75, 1.0) \ func(3.89f, 3.79f, 0.75f, 1.00f) \
func(3.79, 3.71, 1.0, 1.25) \ func(3.79f, 3.71f, 1.00f, 1.25f) \
func(3.71, 3.64, 1.25, 1.5) \ func(3.71f, 3.64f, 1.25f, 1.50f) \
func(3.64, 3.53, 1.5, 1.75) \ func(3.64f, 3.53f, 1.50f, 1.75f) \
func(3.53, 3.44, 1.75, 2.0) \ func(3.53f, 3.44f, 1.75f, 2.00f) \
func(3.44, 3.20, 2.0, 2.25) \ func(3.44f, 3.20f, 2.00f, 2.25f) \
func(3.20, 2.80, 2.25, 2.5) \ func(3.20f, 2.80f, 2.25f, 2.50f) \
func(2.80, 2.50, 2.5, 2.60) func(2.80f, 2.50f, 2.50f, 2.60f)
// BAK_25R // BAK_25R
#define BAT_MIN_AH_BAK_25R 2.5 #define BAT_MIN_AH_BAK_25R 2.5f
#define BAT_CURVE_25R(func) \ #define BAT_CURVE_25R(func) \
func(4.15, 4.06, 0, 0.25) \ func(4.15f, 4.06f, 0.00f, 0.25f) \
func(4.06, 3.96, 0.25, 0.5) \ func(4.06f, 3.96f, 0.25f, 0.50f) \
func(3.96, 3.88, 0.5, 0.75) \ func(3.96f, 3.88f, 0.50f, 0.75f) \
func(3.88, 3.77, 0.75, 1) \ func(3.88f, 3.77f, 0.75f, 1.00f) \
func(3.77, 3.68, 1, 1.25) \ func(3.77f, 3.68f, 1.00f, 1.25f) \
func(3.68, 3.62, 1.25, 1.5) \ func(3.68f, 3.62f, 1.25f, 1.50f) \
func(3.62, 3.56, 1.5, 1.75) \ func(3.62f, 3.56f, 1.50f, 1.75f) \
func(3.56, 3.47, 1.75, 2) \ func(3.56f, 3.47f, 1.75f, 2.00f) \
func(3.47, 3.31, 2, 2.25) \ func(3.47f, 3.31f, 2.00f, 2.25f) \
func(3.31, 2.50, 2.25, 2.5) func(3.31f, 2.50f, 2.25f, 2.50f)
// HE4 // HE4
#define BAT_MIN_AH_HE4 2.3 #define BAT_MIN_AH_HE4 2.3f
#define BAT_CURVE_HE4(func) \ #define BAT_CURVE_HE4(func) \
func(4.15, 4.02, 0, 0.25) \ func(4.15f, 4.02f, 0.00f, 0.25f) \
func(4.02, 3.91, 0.25, 0.5) \ func(4.02f, 3.91f, 0.25f, 0.50f) \
func(3.91, 3.81, 0.5, 0.75) \ func(3.91f, 3.81f, 0.50f, 0.75f) \
func(3.81, 3.72, 0.75, 1) \ func(3.81f, 3.72f, 0.75f, 1.00f) \
func(3.72, 3.61, 1, 1.25) \ func(3.72f, 3.61f, 1.00f, 1.25f) \
func(3.61, 3.62, 1.25, 1.5) \ func(3.61f, 3.62f, 1.25f, 1.50f) \
func(3.62, 3.53, 1.5, 1.75) \ func(3.62f, 3.53f, 1.50f, 1.75f) \
func(3.53, 3.45, 1.75, 2) \ func(3.53f, 3.45f, 1.75f, 2.00f) \
func(3.45, 3.21, 2, 2.25) \ func(3.45f, 3.21f, 2.00f, 2.25f) \
func(3.21, 2.80, 2.25, 2.3) func(3.21f, 2.80f, 2.25f, 2.30f)
#define BatteryCellTypeValues(x) \ #define BatteryCellTypeValues(x) \
x(_22P) \ x(_22P) \

View File

@ -27,7 +27,7 @@ float Controller::getCalibratedVoltage() const
} }
else else
{ {
voltage = voltage / 100.; voltage = voltage / 100.f;
} }
return voltage; return voltage;
} }

View File

@ -64,7 +64,7 @@ public:
float convertToFloat(int16_t value) float convertToFloat(int16_t value)
{ {
return value/100.; return value / 100.f;
} }
class BatteryVoltageCalibrationFront30VText : public virtual espgui::TextInterface class BatteryVoltageCalibrationFront30VText : public virtual espgui::TextInterface

View File

@ -14,7 +14,7 @@ using namespace std::chrono_literals;
float calculateMegaJoules() float calculateMegaJoules()
{ {
return getBatteryWattHours() * 0.0036; return getBatteryWattHours() * 0.0036f;
} }
void ConfiscationDisplay::start() void ConfiscationDisplay::start()

View File

@ -160,10 +160,10 @@ class ClearCurrentStatsAction : public virtual espgui::ActionInterface
public: public:
void triggered() override void triggered() override
{ {
drivingStatistics.meters_driven = 0.; drivingStatistics.meters_driven = 0.f;
drivingStatistics.currentDrivingTime = {}; drivingStatistics.currentDrivingTime = {};
drivingStatistics.wh_used = 0; drivingStatistics.wh_used = 0.f;
drivingStatistics.batteryWhEstimate = 0; drivingStatistics.batteryWhEstimate = 0.f;
} }
}; };
} // namespace } // namespace

View File

@ -58,12 +58,12 @@ void PotisCalibrateDisplay::update()
Base::update(); Base::update();
if (raw_gas) if (raw_gas)
m_gas = cpputils::mapValueClamped<float>(*raw_gas, m_gasMin, m_gasMax, 0., 1000.); m_gas = cpputils::mapValueClamped<float>(*raw_gas, m_gasMin, m_gasMax, 0.f, 1000.f);
else else
m_gas = std::nullopt; m_gas = std::nullopt;
if (raw_brems) if (raw_brems)
m_brems = cpputils::mapValueClamped<float>(*raw_brems, m_bremsMin, m_bremsMax, 0., 1000.); m_brems = cpputils::mapValueClamped<float>(*raw_brems, m_bremsMin, m_bremsMax, 0.f, 1000.f);
else else
m_brems = std::nullopt; m_brems = std::nullopt;
} }

View File

@ -84,9 +84,9 @@ void calculateStatistics()
const auto duration = espchrono::ago(last_km_calculation); const auto duration = espchrono::ago(last_km_calculation);
last_km_calculation = espchrono::millis_clock::now(); last_km_calculation = espchrono::millis_clock::now();
const float meters_driven_now = (abs(avgSpeedKmh) / 3.6) * ((duration / 1ms) / 1000.); const float meters_driven_now = (abs(avgSpeedKmh) / 3.6f) * ((duration / 1ms) / 1000.f);
drivingStatistics.meters_driven += meters_driven_now; drivingStatistics.meters_driven += meters_driven_now;
drivingStatistics.totalMeters += meters_driven_now; // Udate meters driven drivingStatistics.totalMeters += meters_driven_now; // Update meters driven
if (abs(avgSpeedKmh) > 1) if (abs(avgSpeedKmh) > 1)
{ {
@ -98,19 +98,19 @@ void calculateStatistics()
if (const auto avgVoltage = controllers.getAvgVoltage(); avgVoltage) if (const auto avgVoltage = controllers.getAvgVoltage(); avgVoltage)
{ {
auto watt = sumCurrent * *avgVoltage; const float watt = sumCurrent * *avgVoltage;
const float ws_driven_now = watt * ((duration / 1ms) / 1000.); const float ws_driven_now = watt * ((duration / 1ms) / 1000.f);
drivingStatistics.wh_used += ws_driven_now / 3600; // Wh drivingStatistics.wh_used += ws_driven_now / 3600.f; // Wh
drivingStatistics.batteryWhEstimate -= ws_driven_now / 3600; drivingStatistics.batteryWhEstimate -= ws_driven_now / 3600.f;
} }
} }
else else
{ {
drivingStatistics.wh_used += (13 * ((duration / 1ms) / 1000.)) / 3600; // Wh drivingStatistics.wh_used += (13 * ((duration / 1ms) / 1000.f)) / 3600.f; // Wh
drivingStatistics.batteryWhEstimate = getRemainingWattHours(); drivingStatistics.batteryWhEstimate = getRemainingWattHours();
} }
if ((drivingStatistics.totalMeters > ((drivingStatistics.last_cm_written / 100.f) + 100)) || (saveTotal && abs(avgSpeedKmh) < 0.5)) if ((drivingStatistics.totalMeters > ((drivingStatistics.last_cm_written / 100.f) + 100)) || (saveTotal && abs(avgSpeedKmh) < 0.5f))
{ {
if (saveTotal) if (saveTotal)
{ {

View File

@ -97,7 +97,7 @@ public:
std::optional<float> getAvgVoltage() const std::optional<float> getAvgVoltage() const
{ {
uint8_t voltages{0}; uint8_t voltages{0};
float avgVoltage{0.}; float avgVoltage{0.f};
for (auto &controller : *this) for (auto &controller : *this)
{ {
if (const auto result = controller.getCalibratedVoltage(); !std::isnan(result) && controller.feedbackValid) if (const auto result = controller.getCalibratedVoltage(); !std::isnan(result) && controller.feedbackValid)

View File

@ -265,8 +265,8 @@ void showOtaAnimation()
} }
else if (configs.ledstrip.otaMode.value() == OtaAnimationModes::ColorChangeAll) else if (configs.ledstrip.otaMode.value() == OtaAnimationModes::ColorChangeAll)
{ {
const uint8_t redChannel = 255 - (2.55 * percentage); const uint8_t redChannel = 255 - (2.55f * percentage);
const uint8_t greenChannel = 2.55 * percentage; const uint8_t greenChannel = 2.55f * percentage;
std::fill(std::begin(leds), std::end(leds), CRGB{redChannel, greenChannel, 0}); std::fill(std::begin(leds), std::end(leds), CRGB{redChannel, greenChannel, 0});
} }
@ -308,8 +308,8 @@ void showSpeedSyncAnimation()
static float hue_result = 0; static float hue_result = 0;
const float hue_per_led = 1. / std::max(uint8_t(1), uint8_t(configs.ledstrip.animationMultiplier.value())); const float hue_per_led = 1.f / std::max(uint8_t(1), uint8_t(configs.ledstrip.animationMultiplier.value()));
const float meter_per_second = avgSpeedKmh / 3.6; const float meter_per_second = avgSpeedKmh / 3.6f;
const float leds_per_second = meter_per_second * configs.ledstrip.leds_per_meter.value(); const float leds_per_second = meter_per_second * configs.ledstrip.leds_per_meter.value();
const float hue_per_second = leds_per_second * hue_per_led; const float hue_per_second = leds_per_second * hue_per_led;
@ -334,7 +334,7 @@ void showDefaultLedstrip()
void showSnakeAnimation() void showSnakeAnimation()
{ {
const float leds_per_cycle = (1. / std::max<int16_t>(1, configs.ledstrip.animationMultiplier.value())) * (avgSpeedKmh + 1); // yes, this is intendet as a float value! Do NOT change! const float leds_per_cycle = (1.f / std::max<int16_t>(1, configs.ledstrip.animationMultiplier.value())) * (avgSpeedKmh + 1); // yes, this is intended as a float value! Do NOT change!
fadeToBlackBy(&*std::begin(leds), leds.size(), floor(20*leds_per_cycle)); fadeToBlackBy(&*std::begin(leds), leds.size(), floor(20*leds_per_cycle));
if (gLedPosition >= leds.size()) if (gLedPosition >= leds.size())
{ {
@ -348,7 +348,7 @@ void showSnakeAnimation()
for(int16_t i = floor(gLedPosition); i < floor(gLedPosition + leds_per_cycle); i++) for(int16_t i = floor(gLedPosition); i < floor(gLedPosition + leds_per_cycle); i++)
{ {
leds[i] |= CHSV(gHue, 255, 255); leds[i] |= CHSV(gHue, 255, 255);
uint8_t snake_2_pos = floor(leds.size() / 2) + i; uint8_t snake_2_pos = floorf(leds.size() / 2.f) + i;
if (snake_2_pos > leds.size()) if (snake_2_pos > leds.size())
{ {
@ -378,19 +378,19 @@ void showGasOMeterAnimation()
} }
else if (w_per_kmh < -20) else if (w_per_kmh < -20)
{ {
color = CRGB(255, 0, cpputils::mapValueClamped<float>(w_per_kmh, -40, -20, 255., 0.)); color = CRGB(255, 0, cpputils::mapValueClamped<float>(w_per_kmh, -40, -20, 255.f, 0.f));
} }
else if (w_per_kmh < 0) else if (w_per_kmh < 0)
{ {
color = CRGB(255, cpputils::mapValueClamped<float>(w_per_kmh, -20, 0, 0., 255.), 0); color = CRGB(255, cpputils::mapValueClamped<float>(w_per_kmh, -20, 0, 0.f, 255.f), 0);
} }
else if (w_per_kmh < 20) else if (w_per_kmh < 20)
{ {
color = CRGB(cpputils::mapValueClamped<float>(w_per_kmh, 0, 20, 255., 0.), 255, 0); color = CRGB(cpputils::mapValueClamped<float>(w_per_kmh, 0, 20, 255.f, 0.f), 255, 0);
} }
else if (w_per_kmh < 40) else if (w_per_kmh < 40)
{ {
color = CRGB(0, cpputils::mapValueClamped<float>(w_per_kmh, 20, 40, 255., 0.), cpputils::mapValueClamped<float>(w_per_kmh, 20, 40, 0., 255.)); color = CRGB(0, cpputils::mapValueClamped<float>(w_per_kmh, 20, 40, 255.f, 0.f), cpputils::mapValueClamped<float>(w_per_kmh, 20, 40, 0.f, 255.f));
} }
else else
{ {

View File

@ -175,15 +175,15 @@ void DefaultMode::update()
{ {
if (gas_processed >= profileSettings.defaultMode.add_schwelle) if (gas_processed >= profileSettings.defaultMode.add_schwelle)
{ {
pwm = (gas_processed/1000.*profileSettings.defaultMode.gas1_wert) + (brems_processed/1000.*profileSettings.defaultMode.brems1_wert); pwm = (gas_processed/1000.f*profileSettings.defaultMode.gas1_wert) + (brems_processed/1000.f*profileSettings.defaultMode.brems1_wert);
if ((profileSettings.defaultMode.enableSmoothingUp || profileSettings.defaultMode.enableSmoothingDown) && (pwm > 1000. || m_lastPwm > 1000.)) if ((profileSettings.defaultMode.enableSmoothingUp || profileSettings.defaultMode.enableSmoothingDown) && (pwm > 1000.f || m_lastPwm > 1000.f))
{ {
if (m_lastPwm < pwm && profileSettings.defaultMode.enableSmoothingUp) if (m_lastPwm < pwm && profileSettings.defaultMode.enableSmoothingUp)
{ {
pwm = std::min(pwm, m_lastPwm + (profileSettings.defaultMode.smoothing * std::chrono::floor<std::chrono::milliseconds>(now - m_lastTime).count() / 100.f)); pwm = std::min(pwm, m_lastPwm + (profileSettings.defaultMode.smoothing * std::chrono::floor<std::chrono::milliseconds>(now - m_lastTime).count() / 100.f));
if (pwm < 1000.) if (pwm < 1000.f)
pwm = 1000.; pwm = 1000.f;
} }
else if (m_lastPwm > pwm && profileSettings.defaultMode.enableSmoothingDown) else if (m_lastPwm > pwm && profileSettings.defaultMode.enableSmoothingDown)
{ {
@ -193,7 +193,7 @@ void DefaultMode::update()
} }
else else
{ {
pwm = (gas_processed/1000.*profileSettings.defaultMode.gas2_wert) - (brems_processed/1000.*profileSettings.defaultMode.brems2_wert); pwm = (gas_processed/1000.f*profileSettings.defaultMode.gas2_wert) - (brems_processed/1000.f*profileSettings.defaultMode.brems2_wert);
if ( if (
(profileSettings.defaultMode.enableFieldWeakSmoothingUp || profileSettings.defaultMode.enableFieldWeakSmoothingDown) && (profileSettings.defaultMode.enableFieldWeakSmoothingUp || profileSettings.defaultMode.enableFieldWeakSmoothingDown) &&
(m_lastPwm > profileSettings.defaultMode.fwSmoothLowerLimit) && (m_lastPwm > profileSettings.defaultMode.fwSmoothLowerLimit) &&
@ -246,7 +246,7 @@ void DefaultMode::update()
{ {
motor.ctrlTyp = pair.first; motor.ctrlTyp = pair.first;
motor.ctrlMod = pair.second; motor.ctrlMod = pair.second;
motor.pwm = pwm / 100. * profileSettings.defaultMode.frontPercentage; motor.pwm = pwm / 100.f * profileSettings.defaultMode.frontPercentage;
motor.cruiseCtrlEna = false; motor.cruiseCtrlEna = false;
motor.nCruiseMotTgt = 0; motor.nCruiseMotTgt = 0;
} }
@ -254,7 +254,7 @@ void DefaultMode::update()
{ {
motor.ctrlTyp = pair.first; motor.ctrlTyp = pair.first;
motor.ctrlMod = pair.second; motor.ctrlMod = pair.second;
motor.pwm = pwm / 100. * profileSettings.defaultMode.backPercentage; motor.pwm = pwm / 100.f * profileSettings.defaultMode.backPercentage;
motor.cruiseCtrlEna = false; motor.cruiseCtrlEna = false;
motor.nCruiseMotTgt = 0; motor.nCruiseMotTgt = 0;
} }

View File

@ -42,7 +42,7 @@ void GametrakMode::update()
} }
else else
{ {
if (*gas > 500. || *brems > 500.) if (*gas > 500.f || *brems > 500.f)
{ {
modes::defaultMode.waitForGasLoslass = true; modes::defaultMode.waitForGasLoslass = true;
modes::defaultMode.waitForBremsLoslass = true; modes::defaultMode.waitForBremsLoslass = true;

View File

@ -183,7 +183,7 @@ void WheelchairMode::update()
} }
else else
{ {
pwm = (gas_processed/1000.*profileSettings.defaultMode.gas1_wert) - (brems_processed/1000.*profileSettings.defaultMode.brems1_wert); pwm = (gas_processed/1000.f*profileSettings.defaultMode.gas1_wert) - (brems_processed/1000.*profileSettings.defaultMode.brems1_wert);
if (profileSettings.defaultMode.enableSmoothingUp || profileSettings.defaultMode.enableSmoothingDown) if (profileSettings.defaultMode.enableSmoothingUp || profileSettings.defaultMode.enableSmoothingDown)
{ {
@ -200,12 +200,12 @@ void WheelchairMode::update()
m_lastPwm = pwm; m_lastPwm = pwm;
m_lastTime = now; m_lastTime = now;
float steer = cpputils::mapValueClamped<float>(abs(avgSpeedKmh), 0, 50, profileSettings.wheelchairMode.sensitivity0Kmh, profileSettings.wheelchairMode.sensitivity50Kmh) / 1000. * left_right; float steer = cpputils::mapValueClamped<float>(abs(avgSpeedKmh), 0, 50, profileSettings.wheelchairMode.sensitivity0Kmh, profileSettings.wheelchairMode.sensitivity50Kmh) / 1000.f * left_right;
for (Controller &controller : controllers) for (Controller &controller : controllers)
{ {
// motor.pwm = pwm / 100. * profileSettings.defaultMode.frontPercentage; // motor.pwm = pwm / 100.f * profileSettings.defaultMode.frontPercentage;
controller.command.left.ctrlTyp = pair.first; controller.command.left.ctrlTyp = pair.first;
controller.command.left.ctrlMod = pair.second; controller.command.left.ctrlMod = pair.second;

View File

@ -68,11 +68,11 @@ void readPotis()
#ifndef FEATURE_JOYSTICK #ifndef FEATURE_JOYSTICK
if (raw_gas) if (raw_gas)
gas = cpputils::mapValueClamped<float>(*raw_gas, configs.gasMin.value(), configs.gasMax.value(), 0., 1000.); gas = cpputils::mapValueClamped<float>(*raw_gas, configs.gasMin.value(), configs.gasMax.value(), 0.f, 1000.f);
else else
gas = std::nullopt; gas = std::nullopt;
if (raw_brems) if (raw_brems)
brems = cpputils::mapValueClamped<float>(*raw_brems, configs.bremsMin.value(), configs.bremsMax.value(), 0., 1000.); brems = cpputils::mapValueClamped<float>(*raw_brems, configs.bremsMin.value(), configs.bremsMax.value(), 0.f, 1000.f);
else else
brems = std::nullopt; brems = std::nullopt;
#else #else

View File

@ -32,12 +32,12 @@ float convertFromInch(float val)
float fixCurrent(int16_t value) float fixCurrent(int16_t value)
{ {
return -value/50.; return -value/50.f;
} }
float fixBoardTemp(int16_t value) float fixBoardTemp(int16_t value)
{ {
return value/10.; return value/10.f;
} }
std::string hallString(const bobbycar::protocol::serial::MotorFeedback &motor) std::string hallString(const bobbycar::protocol::serial::MotorFeedback &motor)