Skip to content

Commit 4ab07d6

Browse files
committed
optimisation: compare uint16_t against uint16_t
AxisDistance returns uint16_t type and is currently compared with long double axis length. The axis lengths fit easily into uint16_t: selectorLimits.lenght = 75 idlerLimits.lenght = 225 Change in memory: Flash: -122 bytes SRAM: 0 bytes
1 parent 0a205e4 commit 4ab07d6

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/modules/idler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void Idler::PlanHomingMoveBack() {
3939
bool Idler::FinishHomingAndPlanMoveToParkPos() {
4040
// check the axis' length
4141
if (AxisDistance(mm::axisUnitToTruncatedUnit<config::U_deg>(mm::motion.CurPosition<mm::Idler>()))
42-
< (config::idlerLimits.lenght.v - 10)) { //@@TODO is 10 degrees ok?
42+
< uint16_t(config::idlerLimits.lenght.v - 10)) { //@@TODO is 10 degrees ok?
4343
return false; // we couldn't home correctly, we cannot set the Idler's position
4444
}
4545

src/modules/selector.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void Selector::PlanHomingMoveBack() {
3535

3636
bool Selector::FinishHomingAndPlanMoveToParkPos() {
3737
// check the axis' length
38-
if (AxisDistance(mm::axisUnitToTruncatedUnit<config::U_mm>(mm::motion.CurPosition<mm::Selector>())) < (config::selectorLimits.lenght.v - 3)) { //@@TODO is 3mm ok?
38+
if (AxisDistance(mm::axisUnitToTruncatedUnit<config::U_mm>(mm::motion.CurPosition<mm::Selector>())) < uint16_t(config::selectorLimits.lenght.v - 3)) { //@@TODO is 3mm ok?
3939
return false; // we couldn't home correctly, we cannot set the Selector's position
4040
}
4141

0 commit comments

Comments
 (0)