PFW-1362 SpoolJoin needs to known what the previous slot was

This commit is contained in:
Guðni Már Gilbert 2022-09-10 18:13:58 +00:00 committed by D.R.racer
parent 1010f23959
commit 63b4abb66d
3 changed files with 13 additions and 1 deletions

View File

@ -58,12 +58,17 @@ uint8_t SpoolJoin::isSpoolJoinEnabled()
}
}
void SpoolJoin::setSlot(uint8_t slot)
{
currentMMUSlot = slot;
}
uint8_t SpoolJoin::nextSlot()
{
SERIAL_ECHOPGM("SpoolJoin: Changing slot from ");
SERIAL_ECHO((int)currentMMUSlot);
if (currentMMUSlot == 4) currentMMUSlot = 0;
if (currentMMUSlot >= 4) currentMMUSlot = 0;
else currentMMUSlot++;
SERIAL_ECHOPGM(" to ");

View File

@ -33,6 +33,10 @@ public:
/// @brief Check if SpoolJoin is enabled
uint8_t isSpoolJoinEnabled();
/// @brief Update the saved MMU slot number so SpoolJoin can determine the next slot to use
/// @param slot number of the slot to set
void setSlot(uint8_t slot);
/// @brief Fetch the next slot number should count from 0 to 4.
/// When filament slot 4 is depleted, the next slot should be 0.
/// @returns the next slot, ranges from 0 to 4

View File

@ -307,6 +307,7 @@ bool MMU2::tool_change(uint8_t index) {
plan_set_e_position(current_position[E_AXIS]);
extruder = index; //filament change is finished
SpoolJoin::spooljoin.setSlot(index);
// @@TODO really report onto the serial? May be for the Octoprint? Not important now
// SERIAL_ECHO_START();
@ -339,6 +340,7 @@ bool MMU2::tool_change(char code, uint8_t slot) {
logic.ToolChange(slot);
manage_response(false, false);
extruder = slot;
SpoolJoin::spooljoin.setSlot(slot);
set_extrude_min_temp(EXTRUDE_MINTEMP);
} break;
@ -485,6 +487,7 @@ bool MMU2::load_filament_to_nozzle(uint8_t index) {
execute_extruder_sequence((const E_Step *)load_to_nozzle_sequence, sizeof(load_to_nozzle_sequence) / sizeof (load_to_nozzle_sequence[0]));
extruder = index;
SpoolJoin::spooljoin.setSlot(index);
Sound_MakeSound(e_SOUND_TYPE_StandardConfirm);
}