Parametrize Idler and Selector in common config.h

pull/46/head
D.R.racer 2021-07-01 12:50:41 +02:00 committed by DRracer
parent ccda84df80
commit 552fec9abf
5 changed files with 9 additions and 22 deletions

View File

@ -7,7 +7,10 @@ namespace config {
static constexpr const uint8_t toolCount = 5U; ///< Max number of extruders/tools/slots static constexpr const uint8_t toolCount = 5U; ///< Max number of extruders/tools/slots
// Idler's setup // Idler's setup
//static constexpr uint16_t idlerSlotPositions[toolCount+1] = { 1, 2, 3, 4, 5, 0 }; static constexpr uint16_t idlerSlotPositions[toolCount + 1] = { 1, 2, 3, 4, 5, 0 }; ///< slots 0-4 are the real ones, the 5th is the idle position
// Selector's setup
static constexpr uint16_t selectorSlotPositions[toolCount + 1] = { 1, 2, 3, 4, 5, 6 }; ///< slots 0-4 are the real ones, the 5th is the farthest parking positions
// Printer's filament sensor setup // Printer's filament sensor setup
static constexpr const uint16_t fsensorDebounceMs = 10; static constexpr const uint16_t fsensorDebounceMs = 10;

View File

@ -7,9 +7,6 @@
namespace modules { namespace modules {
namespace idler { namespace idler {
// @@TODO PROGMEM
uint16_t const Idler::slotPositions[slotPositionSize] = { 1, 2, 3, 4, 5, 0 };
Idler idler; Idler idler;
namespace mm = modules::motion; namespace mm = modules::motion;
@ -25,7 +22,7 @@ bool Idler::Disengage() {
mm::motion.InitAxis(mm::Idler); mm::motion.InitAxis(mm::Idler);
// plan move to idle position // plan move to idle position
mm::motion.PlanMove(mm::Idler, slotPositions[IdleSlotIndex()] - mm::motion.CurrentPos(mm::Idler), 1000); // @@TODO mm::motion.PlanMove(mm::Idler, config::idlerSlotPositions[IdleSlotIndex()] - mm::motion.CurrentPos(mm::Idler), 1000); // @@TODO
state = Moving; state = Moving;
return true; return true;
} }
@ -41,7 +38,7 @@ bool Idler::Engage(uint8_t slot) {
return true; return true;
mm::motion.InitAxis(mm::Idler); mm::motion.InitAxis(mm::Idler);
mm::motion.PlanMove(mm::Idler, slotPositions[slot] - mm::motion.CurrentPos(mm::Idler), 1000); // @@TODO mm::motion.PlanMove(mm::Idler, config::idlerSlotPositions[slot] - mm::motion.CurrentPos(mm::Idler), 1000); // @@TODO
state = Moving; state = Moving;
return true; return true;
} }

View File

@ -50,17 +50,12 @@ public:
inline uint8_t Slot() const { return currentSlot; } inline uint8_t Slot() const { return currentSlot; }
/// @returns predefined positions of individual slots /// @returns predefined positions of individual slots
inline static uint16_t SlotPosition(uint8_t slot) { return slotPositions[slot]; } inline static uint16_t SlotPosition(uint8_t slot) { return config::idlerSlotPositions[slot]; }
/// @returns the index of idle position of the idler, usually 5 in case of 0-4 valid indices of filament slots /// @returns the index of idle position of the idler, usually 5 in case of 0-4 valid indices of filament slots
inline static constexpr uint8_t IdleSlotIndex() { return config::toolCount; } inline static constexpr uint8_t IdleSlotIndex() { return config::toolCount; }
private: private:
constexpr static const uint8_t slotPositionSize = config::toolCount + 1;
/// slots 0-4 are the real ones, the 5th is the idle position
static const uint16_t slotPositions[slotPositionSize];
/// internal state of the automaton /// internal state of the automaton
uint8_t state; uint8_t state;

View File

@ -7,9 +7,6 @@
namespace modules { namespace modules {
namespace selector { namespace selector {
// @@TODO PROGMEM
const uint16_t Selector::slotPositions[slotPositionSize] = { 1, 2, 3, 4, 5, 6 }; // @@TODO
Selector selector; Selector selector;
namespace mm = modules::motion; namespace mm = modules::motion;
@ -24,7 +21,7 @@ bool Selector::MoveToSlot(uint8_t slot) {
return true; return true;
mm::motion.InitAxis(mm::Selector); mm::motion.InitAxis(mm::Selector);
mm::motion.PlanMove(mm::Selector, slotPositions[slot] - mm::motion.CurrentPos(mm::Selector), 1000); // @@TODO mm::motion.PlanMove(mm::Selector, config::selectorSlotPositions[slot] - mm::motion.CurrentPos(mm::Selector), 1000); // @@TODO
state = Moving; state = Moving;
return true; return true;
} }

View File

@ -41,17 +41,12 @@ public:
inline uint8_t Slot() const { return currentSlot; } inline uint8_t Slot() const { return currentSlot; }
/// @returns predefined positions of individual slots /// @returns predefined positions of individual slots
inline static uint16_t SlotPosition(uint8_t slot) { return slotPositions[slot]; } inline static uint16_t SlotPosition(uint8_t slot) { return config::selectorSlotPositions[slot]; }
/// @returns the index of idle position of the selector, usually 5 in case of 0-4 valid indices of filament slots /// @returns the index of idle position of the selector, usually 5 in case of 0-4 valid indices of filament slots
inline static constexpr uint8_t IdleSlotIndex() { return config::toolCount; } inline static constexpr uint8_t IdleSlotIndex() { return config::toolCount; }
private: private:
constexpr static const uint8_t slotPositionSize = config::toolCount + 1;
/// slots 0-4 are the real ones, the 5th is the farthest parking positions
static const uint16_t slotPositions[slotPositionSize];
/// internal state of the automaton /// internal state of the automaton
uint8_t state; uint8_t state;
uint8_t plannedSlot; uint8_t plannedSlot;