Skip to content

Commit

Permalink
Fixes for MMU12x
Browse files Browse the repository at this point in the history
  • Loading branch information
3d-gussner committed Nov 6, 2024
1 parent ef3527e commit 1432f73
Show file tree
Hide file tree
Showing 23 changed files with 770 additions and 57 deletions.
10 changes: 5 additions & 5 deletions Firmware/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7871,7 +7871,7 @@ void process_commands()
M701 [ P | T | L | Z ]
#### Parameters
- `P` - n index of MMU slot (zero based, so 0-4 like T0 and T4)
- `P` - n index of MMU slot (zero based, so 0-4 like T0 and T12)
- `T` - Alias of `P`. Used for compatibility with Marlin
- `L` - Extrude distance for insertion (positive value)(manual reload)
- `Z` - Move the Z axis by this distance. Default value is 0 to maintain backwards compatibility with older gcodes.
Expand Down Expand Up @@ -7943,7 +7943,7 @@ void process_commands()
M704 [ P ]
#### Parameters
- `P` - n index of slot (zero based, so 0-4 like T0 and T4)
- `P` - n index of slot (zero based, so 0-4 like T0 and T12)
*/
case 704:
{
Expand All @@ -7958,7 +7958,7 @@ void process_commands()
M705 [ P ]
#### Parameters
- `P` - n index of slot (zero based, so 0-4 like T0 and T4)
- `P` - n index of slot (zero based, so 0-4 like T0 and T12)
*/
case 705:
{
Expand All @@ -7974,7 +7974,7 @@ void process_commands()
M706 [ P ]
#### Parameters
- `P` - n index of slot (zero based, so 0-4 like T0 and T4)
- `P` - n index of slot (zero based, so 0-4 like T0 and T12)
*/
case 706:
{
Expand Down Expand Up @@ -8115,7 +8115,7 @@ void process_commands()
// end if(code_seen('M')) (end of M codes)
/*!
-----------------------------------------------------------------------------------------
T<extruder nr.> - select extruder in case of multi extruder printer. Selects filament position 1-5 (T0-T4) in case of MMU.
T<extruder nr.> - select extruder in case of multi extruder printer. Selects filament position 1-5 (T0-T12) in case of MMU.
For MMU2/S / MMU3:
T<extruder nr.> - Selects the filament position. A Gcode to load a filament to the nozzle must follow.
Expand Down
2 changes: 1 addition & 1 deletion Firmware/SpoolJoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ uint8_t SpoolJoin::nextSlot()
SERIAL_ECHOPGM("SpoolJoin: ");
SERIAL_ECHO((int)currentMMUSlot);

if (currentMMUSlot >= 4) currentMMUSlot = 0;
if (currentMMUSlot >= MMU_FILAMENT_COUNT-1 ) currentMMUSlot = 0;
else currentMMUSlot++;

SERIAL_ECHOPGM(" -> ");
Expand Down
4 changes: 2 additions & 2 deletions Firmware/Tcodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
static const char duplicate_Tcode_ignored[] PROGMEM = "Duplicate T-code ignored.";

inline bool IsInvalidTCode(char *const s, uint8_t i) {
return ((s[i] < '0' || s[i] > '4') && s[i] != '?' && s[i] != 'x' && s[i] != 'c');
return ((s[i] < '0' || s[i] > '9') && s[i] != '?' && s[i] != 'x' && s[i] != 'c');
}

inline void TCodeInvalid() {
Expand All @@ -38,7 +38,7 @@ void TCodes(char *const strchr_pointer, const uint8_t codeValue) {
if (MMU2::mmu2.Enabled()) {
MMU2::mmu2.tool_change(strchr_pointer[index], MMU2::mmu2.get_current_tool());
}
} else { // Process T0 ... T4
} else { // Process T0 ... T12
if (MMU2::mmu2.Enabled()) {
if (codeValue == MMU2::mmu2.get_current_tool()){
// don't execute the same T-code twice in a row
Expand Down
8 changes: 5 additions & 3 deletions Firmware/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,14 @@ static void menu_draw_item_puts_E(char type_char, const Sheet &sheet)
lcd_putc(type_char);
}

static void menu_draw_item_puts_P(char type_char, const char* str, char num)
static void menu_draw_item_puts_P(char type_char, const char* str, int8_t num)
{
const uint8_t max_strlen = LCD_WIDTH - 3;
lcd_putc_at(0, menu_row, menu_selection_mark());
uint8_t len = lcd_print_pad_P(str, max_strlen);
lcd_putc_at((max_strlen - len) + 2, menu_row, num);
//lcd_putc_at((max_strlen - len) + 2, menu_row, num);
lcd_set_cursor((max_strlen - len) + 2,menu_row);
lcd_print(num);
lcd_putc_at(LCD_WIDTH - 1, menu_row, type_char);
}

Expand Down Expand Up @@ -354,7 +356,7 @@ void menu_item_function_P(const char* str, menu_func_t func)
//! @param fn_par value to be passed to function
//! @retval 0
//! @retval 1 Item was clicked
void menu_item_function_P(const char* str, char number, void (*func)(uint8_t), uint8_t fn_par)
void menu_item_function_P(const char* str, int8_t number, void (*func)(uint8_t), uint8_t fn_par)
{
if (menu_item == menu_line)
{
Expand Down
2 changes: 1 addition & 1 deletion Firmware/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ extern bool menu_item_leave();
extern void menu_item_function_P(const char* str, menu_func_t func);

#define MENU_ITEM_FUNCTION_NR_P(str, number, func, fn_par) do { menu_item_function_P(str, number, func, fn_par); } while (0)
extern void menu_item_function_P(const char* str, char number, void (*func)(uint8_t), uint8_t fn_par);
extern void menu_item_function_P(const char* str, const int8_t number, void (*func)(uint8_t), uint8_t fn_par);

#define MENU_ITEM_TOGGLE_P(str, toggle, func) do { menu_item_toggle_P(str, toggle, func, 0x02); } while (0)
#define MENU_ITEM_TOGGLE(str, toggle, func) do { menu_item_toggle_P(str, toggle, func, 0x00); } while (0)
Expand Down
9 changes: 5 additions & 4 deletions Firmware/mmu2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ bool MMU2::tool_change(uint8_t slot) {
!marlin_printingIsActive()) {
// If Tcodes are used manually through the serial
// we need to unload manually as well -- but only if FINDA detects filament
unload();
UnloadInner();
}

ReportingRAII rep(CommandInProgress::ToolChange);
Expand Down Expand Up @@ -483,9 +483,6 @@ void MMU2::UnloadInner() {
}
MakeSound(Confirm);

// no active tool
SetCurrentTool(MMU2_NO_TOOL);
tool_change_extruder = MMU2_NO_TOOL;
}

bool MMU2::unload() {
Expand All @@ -500,6 +497,10 @@ bool MMU2::unload() {
UnloadInner();
}

// no active tool
SetCurrentTool(MMU2_NO_TOOL);
tool_change_extruder = MMU2_NO_TOOL;

ScreenUpdateEnable();
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion Firmware/mmu2/errors_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ static const char MSG_DESC_TMC[] PROGMEM_I1 = ISTR("More details online."); ////
static const char MSG_DESC_MMU_NOT_RESPONDING[] PROGMEM_I1 = ISTR("MMU not responding. Check the wiring and connectors."); ////MSG_DESC_MMU_NOT_RESPONDING c=20 r=4
static const char MSG_DESC_COMMUNICATION_ERROR[] PROGMEM_I1 = ISTR("MMU not responding correctly. Check the wiring and connectors."); ////MSG_DESC_COMMUNICATION_ERROR c=20 r=4
static const char MSG_DESC_FILAMENT_ALREADY_LOADED[] PROGMEM_I1 = ISTR("Cannot perform the action, filament is already loaded. Unload it first."); ////MSG_DESC_FILAMENT_ALREADY_LOADED c=20 r=8
static const char MSG_DESC_INVALID_TOOL[] PROGMEM_I1 = ISTR("Requested filament tool is not available on this hardware. Check the G-code for tool index out of range (T0-T4)."); ////MSG_DESC_INVALID_TOOL c=20 r=8
static const char MSG_DESC_INVALID_TOOL[] PROGMEM_I1 = ISTR("Requested filament tool is not available on this hardware. Check the G-code for tool index out of range (T0-T12)."); ////MSG_DESC_INVALID_TOOL c=20 r=8
static const char MSG_DESC_QUEUE_FULL[] PROGMEM_I1 = ISTR("MMU Firmware internal error, please reset the MMU."); ////MSG_DESC_QUEUE_FULL c=20 r=8
static const char MSG_DESC_FW_RUNTIME_ERROR[] PROGMEM_I1 = ISTR("Internal runtime error. Try resetting the MMU or updating the firmware."); ////MSG_DESC_FW_RUNTIME_ERROR c=20 r=8
static const char MSG_DESC_UNLOAD_MANUALLY[] PROGMEM_I1 = ISTR("Filament detected unexpectedly. Ensure no filament is loaded. Check the sensors and wiring."); ////MSG_DESC_UNLOAD_MANUALLY c=20 r=8
Expand Down
32 changes: 19 additions & 13 deletions Firmware/ultralcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ void lcdui_print_feedrate(void)
lcd_space(8 - chars);
}

// Print percent done in form "USB---%", " SD---%", " ---%" (7 chars total)
// Print percent done in form " HO---%", " SD---%", " ---%" (7 chars total)
void lcdui_print_percent_done(void)
{
const char* src = usb_timer.running()?_N(" HO"):(IS_SD_PRINTING?_N(" SD"):_N(" "));
Expand Down Expand Up @@ -406,15 +406,20 @@ void lcdui_print_percent_done(void)
// This scenario should not be possible and indicates a bug in the firmware
uint8_t lcdui_print_extruder(void) {
uint8_t chars = 1;
lcd_space(1);
// printf_P(PSTR("DBG:MMU2::mmu2.get_current_tool() = %d\n"), MMU2::mmu2.get_current_tool());
// printf_P(PSTR("DBG:MMU2::mmu2.get_tool_change_tool() = %d\n"), MMU2::mmu2.get_tool_change_tool());
if (MMU2::mmu2.get_current_tool() == MMU2::mmu2.get_tool_change_tool()) {
lcd_space(1);
lcd_putc('F');
lcd_putc(MMU2::mmu2.get_current_tool() == (uint8_t)MMU2::FILAMENT_UNKNOWN ? '?' : MMU2::mmu2.get_current_tool() + '1');
lcd_print(MMU2::mmu2.get_current_tool() == (uint8_t)MMU2::FILAMENT_UNKNOWN ? -1 : MMU2::mmu2.get_current_tool() + 1);
chars += 2;
} else {
lcd_putc(MMU2::mmu2.get_current_tool() == (uint8_t)MMU2::FILAMENT_UNKNOWN ? '?' : MMU2::mmu2.get_current_tool() + '1');
if(MMU2::mmu2.get_current_tool() < 9 || MMU2::mmu2.get_tool_change_tool() <9 ) {
lcd_space(1);
}
lcd_print(MMU2::mmu2.get_current_tool() == (uint8_t)MMU2::FILAMENT_UNKNOWN ? -1 : MMU2::mmu2.get_current_tool() + 1);
lcd_putc('>');
lcd_putc(MMU2::mmu2.get_tool_change_tool() == (uint8_t)MMU2::FILAMENT_UNKNOWN ? '?' : MMU2::mmu2.get_tool_change_tool() + '1');
lcd_print(MMU2::mmu2.get_tool_change_tool() == (uint8_t)MMU2::FILAMENT_UNKNOWN ? -1 : MMU2::mmu2.get_tool_change_tool() + 1);
chars += 3;
}
return chars;
Expand Down Expand Up @@ -681,15 +686,16 @@ void lcdui_print_status_screen(void)
lcdui_print_percent_done();

if (MMU2::mmu2.Enabled()) {
// Print extruder status (5 chars)
// Print extruder status (6 chars)
lcd_space(5 - lcdui_print_extruder());
} else if (farm_mode) {
// Print farm number (5 chars)
// Print farm number (6 chars)
lcdui_print_farm();
} else {
lcd_space(5); // 5 spaces
lcd_space(6); // 5 spaces
}

lcd_set_cursor(12, 2); //line 2
#ifdef CMD_DIAGNOSTICS
//Print cmd queue diagnostics (8chars)
lcdui_print_cmd_diag();
Expand Down Expand Up @@ -4735,7 +4741,7 @@ static void lcd_disable_farm_mode()
}

static inline void load_all_wrapper(){
for(uint8_t i = 0; i < 5; ++i){
for(uint8_t i = 0; i < MMU_FILAMENT_COUNT; ++i){
MMU2::mmu2.load_filament(i);
}
}
Expand All @@ -4749,7 +4755,7 @@ static void mmu_preload_filament_menu() {
MENU_ITEM_BACK_P(_T(MSG_MAIN));
MENU_ITEM_FUNCTION_P(_T(MSG_LOAD_ALL), load_all_wrapper);
for (uint8_t i = 0; i < MMU_FILAMENT_COUNT; i++)
MENU_ITEM_FUNCTION_NR_P(_T(MSG_LOAD_FILAMENT), i + '1', load_filament_wrapper, i);
MENU_ITEM_FUNCTION_NR_P(_T(MSG_LOAD_FILAMENT), i + 1, load_filament_wrapper, i);
MENU_END();
}

Expand Down Expand Up @@ -4781,7 +4787,7 @@ static void mmu_common_choose_filament_menu(const char * label, void (*menuActio
);
MENU_ITEM_BACK_P(_T(MSG_MAIN));
for (uint8_t i = 0; i < MMU_FILAMENT_COUNT; i++)
MENU_ITEM_FUNCTION_NR_P(label, i + '1', menuAction, i);
MENU_ITEM_FUNCTION_NR_P(label, i + 1, menuAction, i);
MENU_END();
}

Expand Down Expand Up @@ -4812,7 +4818,7 @@ static void mmu_cut_filament_menu() {
#endif //MMU_HAS_CUTTER

static inline void loading_test_all_wrapper(){
for(uint8_t i = 0; i < 5; ++i){
for(uint8_t i = 0; i < MMU_FILAMENT_COUNT; ++i){
MMU2::mmu2.loading_test(i);
}

Expand All @@ -4835,7 +4841,7 @@ static void mmu_loading_test_menu() {
MENU_ITEM_BACK_P(_T(MSG_MAIN));
MENU_ITEM_FUNCTION_P(_T(MSG_LOAD_ALL), loading_test_all_wrapper);
for (uint8_t i = 0; i < MMU_FILAMENT_COUNT; i++)
MENU_ITEM_FUNCTION_NR_P(_T(MSG_LOAD_FILAMENT), i + '1', loading_test_wrapper, i);
MENU_ITEM_FUNCTION_NR_P(_T(MSG_LOAD_FILAMENT), i + 1, loading_test_wrapper, i);
MENU_END();
}

Expand Down
Loading

0 comments on commit 1432f73

Please sign in to comment.