Code size optimization
parent
09c5f7df56
commit
678fc096f0
|
|
@ -37,15 +37,20 @@ bool UnloadToFinda::Step() {
|
||||||
unloadStart_mm = mpu::pulley.CurrentPosition_mm();
|
unloadStart_mm = mpu::pulley.CurrentPosition_mm();
|
||||||
// plan both moves to keep the unload smooth
|
// plan both moves to keep the unload smooth
|
||||||
mpu::pulley.InitAxis();
|
mpu::pulley.InitAxis();
|
||||||
mpu::pulley.PlanMove(-mg::globals.FSensorUnloadCheck_mm(), mg::globals.PulleySlowFeedrate_mm_s());
|
mm::P_pos_t unloadCheck = mm::unitToAxisUnit<mm::P_pos_t>(-mg::globals.FSensorUnloadCheck_mm());
|
||||||
mpu::pulley.PlanMove(-config::defaultBowdenLength - config::feedToFinda - config::filamentMinLoadedToMMU // standard lenght where FINDA is expected to trigger
|
mm::P_speed_t pulleyUnloadFR = mm::unitToAxisUnit<mm::P_speed_t>(mg::globals.PulleyUnloadFeedrate_mm_s());
|
||||||
+ mg::globals.FSensorUnloadCheck_mm(), // but subtract the slow unload phase distance
|
mm::P_speed_t pulleyUnloadSlowFR = mm::unitToAxisUnit<mm::P_speed_t>(mg::globals.PulleySlowFeedrate_mm_s());
|
||||||
mg::globals.PulleyUnloadFeedrate_mm_s());
|
mpu::pulley.PlanMove(unloadCheck, pulleyUnloadSlowFR, pulleyUnloadFR);
|
||||||
|
constexpr mm::P_pos_t distance = mm::unitToAxisUnit<mm::P_pos_t>(-config::defaultBowdenLength - config::feedToFinda - config::filamentMinLoadedToMMU); // standard lenght where FINDA is expected to trigger
|
||||||
|
//+ mg::globals.FSensorUnloadCheck_mm(); // but subtract the slow unload phase distance
|
||||||
|
// damn, this addition is heavy :(
|
||||||
|
// mpu::pulley.PlanMove(distance + mg::globals.FSensorUnloadCheck_mm(),
|
||||||
|
// mg::globals.PulleyUnloadFeedrate_mm_s());
|
||||||
|
mpu::pulley.PlanMove(distance - unloadCheck, pulleyUnloadFR);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
case UnloadingFromFSensor: {
|
case UnloadingFromFSensor: {
|
||||||
int32_t mpucp = mpu::pulley.CurrentPosition_mm();
|
if ((abs(unloadStart_mm - mpu::pulley.CurrentPosition_mm()) > mm::truncatedUnit(mg::globals.FSensorUnloadCheck_mm()))) {
|
||||||
if ((abs(unloadStart_mm - mpucp) > mm::truncatedUnit(mg::globals.FSensorUnloadCheck_mm()))) {
|
|
||||||
// passed the slow unload distance, check fsensor
|
// passed the slow unload distance, check fsensor
|
||||||
if (mfs::fsensor.Pressed()) {
|
if (mfs::fsensor.Pressed()) {
|
||||||
// fsensor didn't trigger within the first fsensorUnloadCheckDistance mm -> stop pulling, something failed, report an error
|
// fsensor didn't trigger within the first fsensorUnloadCheckDistance mm -> stop pulling, something failed, report an error
|
||||||
|
|
|
||||||
|
|
@ -210,7 +210,7 @@ TEST_CASE("unload_to_finda::unload_repeated", "[unload_to_finda]") {
|
||||||
// but set FSensor correctly
|
// but set FSensor correctly
|
||||||
// In this case it is vital to correctly compute the amount of steps
|
// In this case it is vital to correctly compute the amount of steps
|
||||||
// to make the unload state machine restart after the 1st attempt
|
// to make the unload state machine restart after the 1st attempt
|
||||||
uint32_t unlSteps = 2 + mm::unitToSteps<mm::P_pos_t>(config::defaultBowdenLength + config::feedToFinda + config::filamentMinLoadedToMMU - mg::globals.FSensorUnloadCheck_mm());
|
uint32_t unlSteps = 3 + mm::unitToSteps<mm::P_pos_t>(config::defaultBowdenLength + config::feedToFinda + config::filamentMinLoadedToMMU - mg::globals.FSensorUnloadCheck_mm());
|
||||||
REQUIRE_FALSE(WhileCondition(
|
REQUIRE_FALSE(WhileCondition(
|
||||||
ff,
|
ff,
|
||||||
std::bind(SimulateUnloadToFINDA, _1,
|
std::bind(SimulateUnloadToFINDA, _1,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue