Add registers for measured bowden lengths (individual slots)
parent
352d39fdfb
commit
e8805b543e
|
|
@ -35,7 +35,7 @@ void FeedToBondtech::UpdateBowdenLength(int32_t feedEnd_mm) {
|
||||||
static_assert(config::maximumBowdenLength.v <= 65535, "Max bowden length too long");
|
static_assert(config::maximumBowdenLength.v <= 65535, "Max bowden length too long");
|
||||||
int16_t mbl = (int16_t)measuredBowdenLength;
|
int16_t mbl = (int16_t)measuredBowdenLength;
|
||||||
int16_t difference = abs(mbl - mps::BowdenLength::Get(mg::globals.ActiveSlot()));
|
int16_t difference = abs(mbl - mps::BowdenLength::Get(mg::globals.ActiveSlot()));
|
||||||
if (difference > 5) { // @@TODO 5_mm is it good enough?
|
if (difference > 10) { // @@TODO 10_mm is it good enough?
|
||||||
mps::BowdenLength::Set(mg::globals.ActiveSlot(), mbl);
|
mps::BowdenLength::Set(mg::globals.ActiveSlot(), mbl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -63,10 +63,10 @@ bool FeedToBondtech::Step() {
|
||||||
state = PushingFilamentFast;
|
state = PushingFilamentFast;
|
||||||
mpu::pulley.InitAxis();
|
mpu::pulley.InitAxis();
|
||||||
// plan a fast move while in the safe minimal length
|
// plan a fast move while in the safe minimal length
|
||||||
feedStart_mm = mm::motion.CurPosition(mm::Pulley);
|
feedStart_mm = mpu::pulley.CurrentPosition_mm();
|
||||||
// fast feed in millimeters - if the EEPROM value is incorrect, we'll get the default length
|
// fast feed in millimeters - if the EEPROM value is incorrect, we'll get the default length
|
||||||
unit::U_mm fastFeedDistance = { (long double)mps::BowdenLength::Get(mg::globals.ActiveSlot()) };
|
unit::U_mm fastFeedDistance = { (long double)mps::BowdenLength::Get(mg::globals.ActiveSlot()) };
|
||||||
mpu::pulley.PlanMove(fastFeedDistance,
|
mpu::pulley.PlanMove(fastFeedDistance,
|
||||||
mg::globals.PulleyLoadFeedrate_mm_s(),
|
mg::globals.PulleyLoadFeedrate_mm_s(),
|
||||||
mg::globals.PulleySlowFeedrate_mm_s());
|
mg::globals.PulleySlowFeedrate_mm_s());
|
||||||
// plan additional slow move while waiting for fsensor to trigger
|
// plan additional slow move while waiting for fsensor to trigger
|
||||||
|
|
@ -121,9 +121,7 @@ bool FeedToBondtech::Step() {
|
||||||
dbg_logic_P(PSTR("Feed to Bondtech --> Idler disengaged"));
|
dbg_logic_P(PSTR("Feed to Bondtech --> Idler disengaged"));
|
||||||
dbg_logic_fP(PSTR("Pulley end steps %u"), mpu::pulley.CurrentPosition_mm());
|
dbg_logic_fP(PSTR("Pulley end steps %u"), mpu::pulley.CurrentPosition_mm());
|
||||||
state = OK;
|
state = OK;
|
||||||
mpu::pulley.Disable();
|
UpdateBowdenLength(mpu::pulley.CurrentPosition_mm());
|
||||||
UpdateBowdenLength(mm::motion.CurPosition(mm::Pulley));
|
|
||||||
mm::motion.Disable(mm::Pulley);
|
|
||||||
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::on);
|
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::on);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ private:
|
||||||
|
|
||||||
uint8_t state;
|
uint8_t state;
|
||||||
uint8_t maxRetries;
|
uint8_t maxRetries;
|
||||||
int32_t feedStart_mm; // intentionally trying to avoid using U_mm because it is a float (reps. long double)
|
int32_t feedStart_mm; // intentionally trying to avoid using U_mm because it is a float (resp. long double)
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace logic
|
} // namespace logic
|
||||||
|
|
|
||||||
|
|
@ -51,8 +51,6 @@ constexpr const uint16_t eepromBowdenLenDefault = config::defaultBowdenLength.v;
|
||||||
constexpr const uint16_t eepromBowdenLenMinimum = config::minimumBowdenLength.v; ///< Minimum bowden length (~341 mm)
|
constexpr const uint16_t eepromBowdenLenMinimum = config::minimumBowdenLength.v; ///< Minimum bowden length (~341 mm)
|
||||||
constexpr const uint16_t eepromBowdenLenMaximum = config::maximumBowdenLength.v; ///< Maximum bowden length (~792 mm)
|
constexpr const uint16_t eepromBowdenLenMaximum = config::maximumBowdenLength.v; ///< Maximum bowden length (~792 mm)
|
||||||
|
|
||||||
// static_assert (mm::unitToSteps<mm::P_pos_t>(config::maximumBowdenLength) < 65535U, "");
|
|
||||||
|
|
||||||
namespace ee = hal::eeprom;
|
namespace ee = hal::eeprom;
|
||||||
|
|
||||||
#define EEOFFSET(x) reinterpret_cast<size_t>(&(x))
|
#define EEOFFSET(x) reinterpret_cast<size_t>(&(x))
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
#include "modules/globals.h"
|
#include "modules/globals.h"
|
||||||
#include "modules/idler.h"
|
#include "modules/idler.h"
|
||||||
#include "modules/pulley.h"
|
#include "modules/pulley.h"
|
||||||
|
#include "modules/permanent_storage.h"
|
||||||
#include "modules/selector.h"
|
#include "modules/selector.h"
|
||||||
|
|
||||||
/** @defgroup register_table Register Table
|
/** @defgroup register_table Register Table
|
||||||
|
|
@ -362,6 +363,31 @@ static const RegisterRec registers[] /*PROGMEM*/ = {
|
||||||
[](uint16_t d) { d >= config::toolCount ? mi::idler.Disengage() : mi::idler.Engage(d); },
|
[](uint16_t d) { d >= config::toolCount ? mi::idler.Disengage() : mi::idler.Engage(d); },
|
||||||
1),
|
1),
|
||||||
|
|
||||||
|
// 0x1d Detected bowden length slot 0 RW
|
||||||
|
RegisterRec(
|
||||||
|
[]() -> uint16_t { return mps::BowdenLength::Get(0); },
|
||||||
|
[](uint16_t d) { mps::BowdenLength::Set(0, d); },
|
||||||
|
2),
|
||||||
|
// 0x1e Detected bowden length slot 1 RW
|
||||||
|
RegisterRec(
|
||||||
|
[]() -> uint16_t { return mps::BowdenLength::Get(1); },
|
||||||
|
[](uint16_t d) { mps::BowdenLength::Set(1, d); },
|
||||||
|
2),
|
||||||
|
// 0x1f Detected bowden length slot 2 RW
|
||||||
|
RegisterRec(
|
||||||
|
[]() -> uint16_t { return mps::BowdenLength::Get(2); },
|
||||||
|
[](uint16_t d) { mps::BowdenLength::Set(2, d); },
|
||||||
|
2),
|
||||||
|
// 0x20 Detected bowden length slot 3 RW
|
||||||
|
RegisterRec(
|
||||||
|
[]() -> uint16_t { return mps::BowdenLength::Get(3); },
|
||||||
|
[](uint16_t d) { mps::BowdenLength::Set(3, d); },
|
||||||
|
2),
|
||||||
|
// 0x21 Detected bowden length slot 4 RW
|
||||||
|
RegisterRec(
|
||||||
|
[]() -> uint16_t { return mps::BowdenLength::Get(4); },
|
||||||
|
[](uint16_t d) { mps::BowdenLength::Set(4, d); },
|
||||||
|
2),
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr uint8_t registersSize = sizeof(registers) / sizeof(RegisterRec);
|
static constexpr uint8_t registersSize = sizeof(registers) / sizeof(RegisterRec);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue