From 1f2085e8c6bdfea11a4f97d47a19e87da65a8690 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Wed, 14 Sep 2022 01:15:07 +0200 Subject: [PATCH] Remove some runtime float conversions with explicit casts --- src/logic/feed_to_bondtech.cpp | 2 +- src/modules/idler.cpp | 2 +- src/modules/selector.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/logic/feed_to_bondtech.cpp b/src/logic/feed_to_bondtech.cpp index f004271..8877701 100644 --- a/src/logic/feed_to_bondtech.cpp +++ b/src/logic/feed_to_bondtech.cpp @@ -30,7 +30,7 @@ void logic::FeedToBondtech::GoToPushToNozzle() { } void FeedToBondtech::UpdateBowdenLength(int32_t measuredBowdenLength) { - if (measuredBowdenLength < config::maximumBowdenLength.v) { // is the measured length any valid/acceptable? + if (measuredBowdenLength < (int32_t)config::maximumBowdenLength.v) { // is the measured length any valid/acceptable? static_assert(config::maximumBowdenLength.v <= 65535, "Max bowden length too long"); int16_t mbl = (int16_t)measuredBowdenLength; int16_t difference = abs(mbl - mps::BowdenLength::Get(mg::globals.ActiveSlot())); diff --git a/src/modules/idler.cpp b/src/modules/idler.cpp index dab4cb3..aea43d7 100644 --- a/src/modules/idler.cpp +++ b/src/modules/idler.cpp @@ -37,7 +37,7 @@ void Idler::PlanHomingMoveBack() { bool Idler::FinishHomingAndPlanMoveToParkPos() { // check the axis' length int32_t axisEnd = mm::axisUnitToTruncatedUnit(mm::motion.CurPosition()); - if (abs(axisEnd - axisStart) < (config::idlerLimits.lenght.v - 10)) { //@@TODO is 10 degrees ok? + if (abs(axisEnd - axisStart) < (int32_t)(config::idlerLimits.lenght.v - 10)) { //@@TODO is 10 degrees ok? return false; // we couldn't home correctly, we cannot set the Idler's position } diff --git a/src/modules/selector.cpp b/src/modules/selector.cpp index 0b7fbdc..8cff82b 100644 --- a/src/modules/selector.cpp +++ b/src/modules/selector.cpp @@ -36,7 +36,7 @@ void Selector::PlanHomingMoveBack() { bool Selector::FinishHomingAndPlanMoveToParkPos() { // check the axis' length int32_t axisEnd = mm::axisUnitToTruncatedUnit(mm::motion.CurPosition()); - if (abs(axisEnd - axisStart) < (config::selectorLimits.lenght.v - 3)) { //@@TODO is 3mm ok? + if (abs(axisEnd - axisStart) < (int32_t)(config::selectorLimits.lenght.v - 3)) { //@@TODO is 3mm ok? return false; // we couldn't home correctly, we cannot set the Selector's position }