PFW-1343 initial commit

This commit is contained in:
Guðni Már Gilbert 2022-06-18 13:03:10 +00:00 committed by D.R.racer
parent ed04c24ba0
commit 8fd1653b84
3 changed files with 29 additions and 13 deletions

View File

@ -86,6 +86,7 @@ MMU2::MMU2()
, logic(&mmu2Serial)
, extruder(MMU2_NO_TOOL)
, previous_extruder(MMU2_NO_TOOL)
, tool_change_extruder(MMU2_NO_TOOL)
, resume_position()
, resume_hotend_temp(0)
, logicStepLastStatus(StepStatus::Finished)
@ -214,6 +215,7 @@ bool MMU2::tool_change(uint8_t index) {
st_synchronize();
tool_change_extruder = index;
logic.ToolChange(index); // let the MMU pull the filament out and push a new one in
manage_response(true, true);
@ -259,6 +261,7 @@ bool MMU2::tool_change(char code, uint8_t slot) {
case 'x': {
set_extrude_min_temp(0); // Allow cold extrusion since Tx only loads to the gears not nozzle
st_synchronize();
tool_change_extruder = slot;
logic.ToolChange(slot);
manage_response(false, false);
extruder = slot;
@ -277,7 +280,11 @@ bool MMU2::tool_change(char code, uint8_t slot) {
}
uint8_t MMU2::get_current_tool() const {
return extruder == MMU2_NO_TOOL ? -1 : extruder;
return extruder == MMU2_NO_TOOL ? (uint8_t)FILAMENT_UNKNOWN : extruder;
}
uint8_t MMU2::get_tool_change_tool() const {
return tool_change_extruder == MMU2_NO_TOOL ? (uint8_t)FILAMENT_UNKNOWN : tool_change_extruder;
}
bool MMU2::set_filament_type(uint8_t index, uint8_t type) {
@ -310,6 +317,7 @@ bool MMU2::unload() {
// no active tool
extruder = MMU2_NO_TOOL;
tool_change_extruder = MMU2_NO_TOOL;
}
return true;
}
@ -364,6 +372,7 @@ bool MMU2::load_filament_to_nozzle(uint8_t index) {
filament_ramming();
}
tool_change_extruder = index;
logic.ToolChange(index);
manage_response(true, true);
@ -426,6 +435,7 @@ bool MMU2::eject_filament(uint8_t index, bool recover) {
// no active tool
extruder = MMU2_NO_TOOL;
tool_change_extruder = MMU2_NO_TOOL;
Sound_MakeSound(e_SOUND_TYPE_StandardConfirm);
// disable_E0();

View File

@ -104,13 +104,16 @@ public:
/// Requires unloaded filament from the printer (obviously)
/// @returns false if the operation cannot be performed (Stopped)
bool cut_filament(uint8_t index);
/// @returns the active filament slot index (0-4) or 0xff in case of no active tool
uint8_t get_current_tool() const;
/// @returns the previous active filament slot index (0-4) or 0xff in case of no active tool at boot-up
inline uint8_t get_previous_tool() const { return previous_extruder; };
/// @returns The filament slot index (0 to 4) that will be loaded next, 0xff in case of no active tool change
uint8_t get_tool_change_tool() const;
bool set_filament_type(uint8_t index, uint8_t type);
/// Issue a "button" click into the MMU - to be used from Error screens of the MMU
@ -205,6 +208,7 @@ private:
ProtocolLogic logic; ///< implementation of the protocol logic layer
int extruder; ///< currently active slot in the MMU ... somewhat... not sure where to get it from yet
uint8_t previous_extruder; ///< last active slot in the MMU, useful for M600
uint8_t tool_change_extruder; ///< only used for UI purposes
xyz_pos_t resume_position;
int16_t resume_hotend_temp;

View File

@ -452,17 +452,19 @@ void lcdui_print_percent_done(void)
// Print extruder status (5 chars total)
void lcdui_print_extruder(void) {
uint8_t chars = 0;
// @@TODO if (MMU2::mmu2.get_current_tool() == tmp_extruder) {
// if (MMU2::mmu2.get_current_tool() == MMU2::FILAMENT_UNKNOWN)
// chars = lcd_printf_P(_N(" F?"));
// else
// chars = lcd_printf_P(_N(" F%u"), MMU2::mmu2.get_current_tool() + 1);
// } else {
// if (MMU2::mmu2.get_current_tool() == MMU2::FILAMENT_UNKNOWN)
// chars = lcd_printf_P(_N(" ?>%u"), tmp_extruder + 1);
// else
// chars = lcd_printf_P(_N(" %u>%u"), MMU2::mmu2.get_current_tool() + 1, tmp_extruder + 1);
// }
if (MMU2::mmu2.get_current_tool() == MMU2::mmu2.get_tool_change_tool()) {
if (MMU2::mmu2.get_current_tool() == (uint8_t)MMU2::FILAMENT_UNKNOWN) {
chars = lcd_printf_P(_N(" F?"));
} else {
chars = lcd_printf_P(_N(" F%u"), MMU2::mmu2.get_current_tool() + 1);
}
} else {
if (MMU2::mmu2.get_current_tool() == (uint8_t)MMU2::FILAMENT_UNKNOWN) {
chars = lcd_printf_P(_N(" ?>%u"), MMU2::mmu2.get_tool_change_tool() + 1);
} else {
chars = lcd_printf_P(_N(" %u>%u"), MMU2::mmu2.get_current_tool() + 1, MMU2::mmu2.get_tool_change_tool() + 1);
}
}
lcd_space(5 - chars);
}