Browse Source

Update MMU2 code style

pull/1/head
Scott Lahteine 6 years ago
parent
commit
fae2b7edc3
  1. 2
      Marlin/src/Marlin.cpp
  2. 80
      Marlin/src/feature/prusa_MMU2/mmu2.cpp
  3. 36
      Marlin/src/feature/prusa_MMU2/mmu2.h
  4. 2
      Marlin/src/gcode/control/T.cpp
  5. 2
      Marlin/src/gcode/feature/pause/M701_M702.cpp
  6. 2
      Marlin/src/gcode/feature/prusa_MMU2/M403.cpp
  7. 118
      Marlin/src/lcd/menu/menu_mmu2.cpp
  8. 2
      Marlin/src/lcd/menu/menu_mmu2.h
  9. 4
      Marlin/src/module/tool_change.cpp

2
Marlin/src/Marlin.cpp

@ -723,7 +723,7 @@ void idle(
#endif #endif
#if ENABLED(PRUSA_MMU2) #if ENABLED(PRUSA_MMU2)
mmu2.mmuLoop(); mmu2.mmu_loop();
#endif #endif
} }

80
Marlin/src/feature/prusa_MMU2/mmu2.cpp

@ -90,7 +90,7 @@ bool MMU2::enabled, MMU2::ready, MMU2::mmu_print_saved;
uint8_t MMU2::cmd, MMU2::cmd_arg, MMU2::last_cmd, MMU2::extruder; uint8_t MMU2::cmd, MMU2::cmd_arg, MMU2::last_cmd, MMU2::extruder;
int8_t MMU2::state = 0; int8_t MMU2::state = 0;
volatile int8_t MMU2::finda = 1; volatile int8_t MMU2::finda = 1;
volatile bool MMU2::findaRunoutValid; volatile bool MMU2::finda_runout_valid;
int16_t MMU2::version = -1, MMU2::buildnr = -1; int16_t MMU2::version = -1, MMU2::buildnr = -1;
millis_t MMU2::last_request, MMU2::next_P0_request; millis_t MMU2::last_request, MMU2::next_P0_request;
char MMU2::rx_buffer[16], MMU2::tx_buffer[16]; char MMU2::rx_buffer[16], MMU2::tx_buffer[16];
@ -103,7 +103,7 @@ char MMU2::rx_buffer[16], MMU2::tx_buffer[16];
}; };
static constexpr E_Step ramming_sequence[] PROGMEM = { MMU2_RAMMING_SEQUENCE }; static constexpr E_Step ramming_sequence[] PROGMEM = { MMU2_RAMMING_SEQUENCE };
static constexpr E_Step loadToNozzle_sequence[] PROGMEM = { MMU2_LOAD_TO_NOZZLE_SEQUENCE }; static constexpr E_Step load_to_nozzle_sequence[] PROGMEM = { MMU2_LOAD_TO_NOZZLE_SEQUENCE };
#endif // MMU2_MENUS #endif // MMU2_MENUS
@ -142,11 +142,11 @@ void MMU2::reset() {
#endif #endif
} }
uint8_t MMU2::getCurrentTool() { uint8_t MMU2::get_current_tool() {
return extruder == MMU2_NO_TOOL ? -1 : extruder; return extruder == MMU2_NO_TOOL ? -1 : extruder;
} }
void MMU2::mmuLoop() { void MMU2::mmu_loop() {
switch (state) { switch (state) {
@ -185,7 +185,7 @@ void MMU2::mmuLoop() {
DEBUG_ECHOLNPAIR("MMU => ", buildnr); DEBUG_ECHOLNPAIR("MMU => ", buildnr);
checkVersion(); check_version();
#if ENABLED(MMU2_MODE_12V) #if ENABLED(MMU2_MODE_12V)
DEBUG_ECHOLNPGM("MMU <= 'M1'"); DEBUG_ECHOLNPGM("MMU <= 'M1'");
@ -207,7 +207,7 @@ void MMU2::mmuLoop() {
if (rx_ok()) { if (rx_ok()) {
DEBUG_ECHOLNPGM("MMU => ok"); DEBUG_ECHOLNPGM("MMU => ok");
checkVersion(); check_version();
DEBUG_ECHOLNPGM("MMU <= 'P0'"); DEBUG_ECHOLNPGM("MMU <= 'P0'");
@ -294,13 +294,13 @@ void MMU2::mmuLoop() {
sscanf(rx_buffer, "%hhuok\n", &finda); sscanf(rx_buffer, "%hhuok\n", &finda);
// This is super annoying. Only activate if necessary // This is super annoying. Only activate if necessary
// if (findaRunoutValid) DEBUG_ECHOLNPAIR_F("MMU <= 'P0'\nMMU => ", finda, 6); // if (finda_runout_valid) DEBUG_ECHOLNPAIR_F("MMU <= 'P0'\nMMU => ", finda, 6);
state = 1; state = 1;
if (cmd == 0) ready = true; if (cmd == 0) ready = true;
if (!finda && findaRunoutValid) filamentRunout(); if (!finda && finda_runout_valid) filament_runout();
} }
else if (ELAPSED(millis(), last_request + MMU_P0_TIMEOUT)) // Resend request after timeout (30s) else if (ELAPSED(millis(), last_request + MMU_P0_TIMEOUT)) // Resend request after timeout (30s)
state = 1; state = 1;
@ -434,7 +434,7 @@ bool MMU2::rx_ok() {
/** /**
* Check if MMU has compatible firmware * Check if MMU has compatible firmware
*/ */
void MMU2::checkVersion() { void MMU2::check_version() {
if (buildnr < MMU_REQUIRED_FW_BUILDNR) { if (buildnr < MMU_REQUIRED_FW_BUILDNR) {
SERIAL_ERROR_START(); SERIAL_ERROR_START();
SERIAL_ECHOPGM("MMU2 firmware version invalid. Required version >= "); SERIAL_ECHOPGM("MMU2 firmware version invalid. Required version >= ");
@ -447,7 +447,7 @@ void MMU2::checkVersion() {
/** /**
* Handle tool change * Handle tool change
*/ */
void MMU2::toolChange(uint8_t index) { void MMU2::tool_change(uint8_t index) {
if (!enabled) return; if (!enabled) return;
@ -461,7 +461,7 @@ void MMU2::toolChange(uint8_t index) {
command(MMU_CMD_T0 + index); command(MMU_CMD_T0 + index);
manageResponse(true, true); manage_response(true, true);
KEEPALIVE_STATE(IN_HANDLER); KEEPALIVE_STATE(IN_HANDLER);
command(MMU_CMD_C0); command(MMU_CMD_C0);
@ -490,7 +490,7 @@ void MMU2::toolChange(uint8_t index) {
* Tc Load to nozzle after filament was prepared by Tx and extruder nozzle is already heated. * Tc Load to nozzle after filament was prepared by Tx and extruder nozzle is already heated.
* *
*/ */
void MMU2::toolChange(const char* special) { void MMU2::tool_change(const char* special) {
if (!enabled) return; if (!enabled) return;
@ -501,19 +501,19 @@ void MMU2::toolChange(const char* special) {
switch (*special) { switch (*special) {
case '?': { case '?': {
uint8_t index = mmu2_chooseFilament(); uint8_t index = mmu2_choose_filament();
while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100); while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100);
loadFilamentToNozzle(index); load_filament_to_nozzle(index);
} break; } break;
case 'x': { case 'x': {
planner.synchronize(); planner.synchronize();
uint8_t index = mmu2_chooseFilament(); uint8_t index = mmu2_choose_filament();
disable_E0(); disable_E0();
command(MMU_CMD_T0 + index); command(MMU_CMD_T0 + index);
manageResponse(true, true); manage_response(true, true);
command(MMU_CMD_C0); command(MMU_CMD_C0);
mmuLoop(); mmu_loop();
enable_E0(); enable_E0();
extruder = index; extruder = index;
@ -522,7 +522,7 @@ void MMU2::toolChange(const char* special) {
case 'c': { case 'c': {
while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100); while (!thermalManager.wait_for_hotend(active_extruder, false)) safe_delay(100);
executeExtruderSequence((const E_Step *)loadToNozzle_sequence, COUNT(loadToNozzle_sequence)); execute_extruder_sequence((const E_Step *)load_to_nozzle_sequence, COUNT(load_to_nozzle_sequence));
} break; } break;
} }
@ -547,7 +547,7 @@ void MMU2::command(const uint8_t mmu_cmd) {
/** /**
* Wait for response from MMU * Wait for response from MMU
*/ */
bool MMU2::getResponse(void) { bool MMU2::get_response(void) {
while (cmd != MMU_CMD_NONE) idle(); while (cmd != MMU_CMD_NONE) idle();
while (!ready) { while (!ready) {
@ -565,7 +565,7 @@ bool MMU2::getResponse(void) {
/** /**
* Wait for response and deal with timeout if nexcessary * Wait for response and deal with timeout if nexcessary
*/ */
void MMU2::manageResponse(bool move_axes, bool turn_off_nozzle) { void MMU2::manage_response(bool move_axes, bool turn_off_nozzle) {
bool response = false; bool response = false;
mmu_print_saved = false; mmu_print_saved = false;
@ -575,7 +575,7 @@ void MMU2::manageResponse(bool move_axes, bool turn_off_nozzle) {
while (!response) { while (!response) {
response = getResponse(); //wait for "ok" from mmu response = get_response(); //wait for "ok" from mmu
if (!response) { //no "ok" was received in reserved time frame, user will fix the issue on mmu unit if (!response) { //no "ok" was received in reserved time frame, user will fix the issue on mmu unit
if (!mmu_print_saved) { //first occurence, we are saving current position, park print head in certain position and disable nozzle heater if (!mmu_print_saved) { //first occurence, we are saving current position, park print head in certain position and disable nozzle heater
@ -636,7 +636,7 @@ void MMU2::manageResponse(bool move_axes, bool turn_off_nozzle) {
} }
} }
void MMU2::setFilamentType(uint8_t index, uint8_t filamentType) { void MMU2::set_filament_type(uint8_t index, uint8_t filamentType) {
if (!enabled) return; if (!enabled) return;
KEEPALIVE_STATE(IN_HANDLER); KEEPALIVE_STATE(IN_HANDLER);
@ -644,12 +644,12 @@ void MMU2::setFilamentType(uint8_t index, uint8_t filamentType) {
cmd_arg = filamentType; cmd_arg = filamentType;
command(MMU_CMD_F0 + index); command(MMU_CMD_F0 + index);
manageResponse(true, true); manage_response(true, true);
KEEPALIVE_STATE(NOT_BUSY); KEEPALIVE_STATE(NOT_BUSY);
} }
void MMU2::filamentRunout() { void MMU2::filament_runout() {
enqueue_and_echo_commands_P(PSTR(MMU2_FILAMENT_RUNOUT_SCRIPT)); enqueue_and_echo_commands_P(PSTR(MMU2_FILAMENT_RUNOUT_SCRIPT));
planner.synchronize(); planner.synchronize();
} }
@ -657,10 +657,10 @@ void MMU2::filamentRunout() {
#if HAS_LCD_MENU && ENABLED(MMU2_MENUS) #if HAS_LCD_MENU && ENABLED(MMU2_MENUS)
// Load filament into MMU2 // Load filament into MMU2
void MMU2::loadFilament(uint8_t index) { void MMU2::load_filament(uint8_t index) {
if (!enabled) return; if (!enabled) return;
command(MMU_CMD_L0 + index); command(MMU_CMD_L0 + index);
manageResponse(false, false); manage_response(false, false);
BUZZ(200, 404); BUZZ(200, 404);
} }
@ -669,7 +669,7 @@ void MMU2::filamentRunout() {
* Switch material and load to nozzle * Switch material and load to nozzle
* *
*/ */
bool MMU2::loadFilamentToNozzle(uint8_t index) { bool MMU2::load_filament_to_nozzle(uint8_t index) {
if (!enabled) return false; if (!enabled) return false;
@ -682,14 +682,14 @@ void MMU2::filamentRunout() {
KEEPALIVE_STATE(IN_HANDLER); KEEPALIVE_STATE(IN_HANDLER);
command(MMU_CMD_T0 + index); command(MMU_CMD_T0 + index);
manageResponse(true, true); manage_response(true, true);
command(MMU_CMD_C0); command(MMU_CMD_C0);
mmuLoop(); mmu_loop();
extruder = index; extruder = index;
active_extruder = 0; active_extruder = 0;
loadToNozzle(); load_to_nozzle();
BUZZ(200, 404); BUZZ(200, 404);
@ -706,12 +706,12 @@ void MMU2::filamentRunout() {
* It is not used after T0 .. T4 command (select filament), in such case, gcode is responsible for loading * It is not used after T0 .. T4 command (select filament), in such case, gcode is responsible for loading
* filament to nozzle. * filament to nozzle.
*/ */
void MMU2::loadToNozzle() { void MMU2::load_to_nozzle() {
if (!enabled) return; if (!enabled) return;
executeExtruderSequence((const E_Step *)loadToNozzle_sequence, COUNT(loadToNozzle_sequence)); execute_extruder_sequence((const E_Step *)load_to_nozzle_sequence, COUNT(load_to_nozzle_sequence));
} }
bool MMU2::ejectFilament(uint8_t index, bool recover) { bool MMU2::eject_filament(uint8_t index, bool recover) {
if (!enabled) return false; if (!enabled) return false;
@ -731,7 +731,7 @@ void MMU2::filamentRunout() {
planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2500 / 60, active_extruder); planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2500 / 60, active_extruder);
planner.synchronize(); planner.synchronize();
command(MMU_CMD_E0 + index); command(MMU_CMD_E0 + index);
manageResponse(false, false); manage_response(false, false);
if (recover) { if (recover) {
LCD_MESSAGEPGM(MSG_MMU2_EJECT_RECOVER); LCD_MESSAGEPGM(MSG_MMU2_EJECT_RECOVER);
@ -745,7 +745,7 @@ void MMU2::filamentRunout() {
BUZZ(200, 404); BUZZ(200, 404);
command(MMU_CMD_R0); command(MMU_CMD_R0);
manageResponse(false, false); manage_response(false, false);
} }
ui.reset_status(); ui.reset_status();
@ -783,10 +783,10 @@ void MMU2::filamentRunout() {
KEEPALIVE_STATE(IN_HANDLER); KEEPALIVE_STATE(IN_HANDLER);
filamentRamming(); filament_ramming();
command(MMU_CMD_U0); command(MMU_CMD_U0);
manageResponse(false, true); manage_response(false, true);
BUZZ(200, 404); BUZZ(200, 404);
@ -803,11 +803,11 @@ void MMU2::filamentRunout() {
/** /**
* Unload sequence to optimize shape of the tip of the unloaded filament * Unload sequence to optimize shape of the tip of the unloaded filament
*/ */
void MMU2::filamentRamming() { void MMU2::filament_ramming() {
executeExtruderSequence((const E_Step *)ramming_sequence, sizeof(ramming_sequence) / sizeof(E_Step)); execute_extruder_sequence((const E_Step *)ramming_sequence, sizeof(ramming_sequence) / sizeof(E_Step));
} }
void MMU2::executeExtruderSequence(const E_Step * sequence, int steps) { void MMU2::execute_extruder_sequence(const E_Step * sequence, int steps) {
planner.synchronize(); planner.synchronize();
enable_E0(); enable_E0();

36
Marlin/src/feature/prusa_MMU2/mmu2.h

@ -36,18 +36,18 @@ public:
static void init(); static void init();
static void reset(); static void reset();
static void mmuLoop(); static void mmu_loop();
static void toolChange(uint8_t index); static void tool_change(uint8_t index);
static void toolChange(const char* special); static void tool_change(const char* special);
static uint8_t getCurrentTool(); static uint8_t get_current_tool();
static void setFilamentType(uint8_t index, uint8_t type); static void set_filament_type(uint8_t index, uint8_t type);
#if HAS_LCD_MENU && ENABLED(MMU2_MENUS) #if HAS_LCD_MENU && ENABLED(MMU2_MENUS)
static bool unload(); static bool unload();
static void loadFilament(uint8_t); static void load_filament(uint8_t);
static void loadAll(); static void load_all();
static bool loadFilamentToNozzle(uint8_t index); static bool load_filament_to_nozzle(uint8_t index);
static bool ejectFilament(uint8_t index, bool recover); static bool eject_filament(uint8_t index, bool recover);
#endif #endif
private: private:
@ -59,31 +59,31 @@ private:
static bool rx_ok(); static bool rx_ok();
static bool rx_start(); static bool rx_start();
static void checkVersion(); static void check_version();
static void command(const uint8_t cmd); static void command(const uint8_t cmd);
static bool getResponse(void); static bool get_response(void);
static void manageResponse(bool move_axes, bool turn_off_nozzle); static void manage_response(bool move_axes, bool turn_off_nozzle);
#if HAS_LCD_MENU && ENABLED(MMU2_MENUS) #if HAS_LCD_MENU && ENABLED(MMU2_MENUS)
static void loadToNozzle(); static void load_to_nozzle();
static void filamentRamming(); static void filament_ramming();
static void executeExtruderSequence(const E_Step * sequence, int steps); static void execute_extruder_sequence(const E_Step * sequence, int steps);
#endif #endif
static void filamentRunout(); static void filament_runout();
static bool enabled, ready, mmu_print_saved; static bool enabled, ready, mmu_print_saved;
static uint8_t cmd, cmd_arg, last_cmd, extruder; static uint8_t cmd, cmd_arg, last_cmd, extruder;
static int8_t state; static int8_t state;
static volatile int8_t finda; static volatile int8_t finda;
static volatile bool findaRunoutValid; static volatile bool finda_runout_valid;
static int16_t version, buildnr; static int16_t version, buildnr;
static millis_t last_request, next_P0_request; static millis_t last_request, next_P0_request;
static char rx_buffer[16], tx_buffer[16]; static char rx_buffer[16], tx_buffer[16];
static inline void set_runout_valid(const bool valid) { static inline void set_runout_valid(const bool valid) {
findaRunoutValid = valid; finda_runout_valid = valid;
#if HAS_FILAMENT_SENSOR #if HAS_FILAMENT_SENSOR
if (valid) runout.reset(); if (valid) runout.reset();
#endif #endif

2
Marlin/src/gcode/control/T.cpp

@ -55,7 +55,7 @@ void GcodeSuite::T(const uint8_t tool_index) {
#if ENABLED(PRUSA_MMU2) #if ENABLED(PRUSA_MMU2)
if (parser.string_arg) { if (parser.string_arg) {
mmu2.toolChange(parser.string_arg); // Special commands T?/Tx/Tc mmu2.tool_change(parser.string_arg); // Special commands T?/Tx/Tc
return; return;
} }
#endif #endif

2
Marlin/src/gcode/feature/pause/M701_M702.cpp

@ -84,7 +84,7 @@ void GcodeSuite::M701() {
// Load filament // Load filament
#if ENABLED(PRUSA_MMU2) #if ENABLED(PRUSA_MMU2)
mmu2.loadFilamentToNozzle(target_extruder); mmu2.load_filament_to_nozzle(target_extruder);
#else #else
constexpr float slow_load_length = FILAMENT_CHANGE_SLOW_LOAD_LENGTH; constexpr float slow_load_length = FILAMENT_CHANGE_SLOW_LOAD_LENGTH;
const float fast_load_length = ABS(parser.seen('L') ? parser.value_axis_units(E_AXIS) const float fast_load_length = ABS(parser.seen('L') ? parser.value_axis_units(E_AXIS)

2
Marlin/src/gcode/feature/prusa_MMU2/M403.cpp

@ -41,7 +41,7 @@ void GcodeSuite::M403() {
type = parser.intval('F', -1); type = parser.intval('F', -1);
if (WITHIN(index, 0, 4) && WITHIN(type, 0, 2)) if (WITHIN(index, 0, 4) && WITHIN(type, 0, 2))
mmu2.setFilamentType(index, type); mmu2.set_filament_type(index, type);
else else
SERIAL_ECHO_MSG("M403 - bad arguments."); SERIAL_ECHO_MSG("M403 - bad arguments.");
} }

118
Marlin/src/lcd/menu/menu_mmu2.cpp

@ -35,60 +35,60 @@ bool mmuMenuWait;
// Load Filament // Load Filament
// //
void _mmu2_loadFilamentToNozzle(uint8_t index) { void _mmu2_load_filamentToNozzle(uint8_t index) {
ui.reset_status(); ui.reset_status();
ui.return_to_status(); ui.return_to_status();
ui.status_printf_P(0, PSTR(MSG_MMU2_LOADING_FILAMENT), int(index + 1)); ui.status_printf_P(0, PSTR(MSG_MMU2_LOADING_FILAMENT), int(index + 1));
if (mmu2.loadFilamentToNozzle(index)) ui.reset_status(); if (mmu2.load_filament_to_nozzle(index)) ui.reset_status();
} }
inline void action_mmu2_loadFilamentToNozzle(const uint8_t tool) { inline void action_mmu2_load_filament_to_nozzl_e(const uint8_t tool) {
_mmu2_loadFilamentToNozzle(tool); _mmu2_load_filamentToNozzle(tool);
ui.return_to_status(); ui.return_to_status();
} }
inline void action_mmu2_loadFilamentToNozzle0() { action_mmu2_loadFilamentToNozzle(0); } inline void action_mmu2_load_filament_to_nozzle_0() { action_mmu2_load_filament_to_nozzl_e(0); }
inline void action_mmu2_loadFilamentToNozzle1() { action_mmu2_loadFilamentToNozzle(1); } inline void action_mmu2_load_filament_to_nozzle_1() { action_mmu2_load_filament_to_nozzl_e(1); }
inline void action_mmu2_loadFilamentToNozzle2() { action_mmu2_loadFilamentToNozzle(2); } inline void action_mmu2_load_filament_to_nozzle_2() { action_mmu2_load_filament_to_nozzl_e(2); }
inline void action_mmu2_loadFilamentToNozzle3() { action_mmu2_loadFilamentToNozzle(3); } inline void action_mmu2_load_filament_to_nozzle_3() { action_mmu2_load_filament_to_nozzl_e(3); }
inline void action_mmu2_loadFilamentToNozzle4() { action_mmu2_loadFilamentToNozzle(4); } inline void action_mmu2_load_filament_to_nozzle_4() { action_mmu2_load_filament_to_nozzl_e(4); }
void _mmu2_loadFilament(uint8_t index) { void _mmu2_load_filament(uint8_t index) {
ui.return_to_status(); ui.return_to_status();
ui.status_printf_P(0, PSTR(MSG_MMU2_LOADING_FILAMENT), int(index + 1)); ui.status_printf_P(0, PSTR(MSG_MMU2_LOADING_FILAMENT), int(index + 1));
mmu2.loadFilament(index); mmu2.load_filament(index);
ui.reset_status(); ui.reset_status();
} }
void action_mmu2_loadAll() { void action_mmu2_load_all() {
for (uint8_t i = 0; i < EXTRUDERS; i++) for (uint8_t i = 0; i < EXTRUDERS; i++)
_mmu2_loadFilament(i); _mmu2_load_filament(i);
ui.return_to_status(); ui.return_to_status();
} }
inline void action_mmu2_loadFilament0() { _mmu2_loadFilament(0); } inline void action_mmu2_load_filament_0() { _mmu2_load_filament(0); }
inline void action_mmu2_loadFilament1() { _mmu2_loadFilament(1); } inline void action_mmu2_load_filament_1() { _mmu2_load_filament(1); }
inline void action_mmu2_loadFilament2() { _mmu2_loadFilament(2); } inline void action_mmu2_load_filament_2() { _mmu2_load_filament(2); }
inline void action_mmu2_loadFilament3() { _mmu2_loadFilament(3); } inline void action_mmu2_load_filament_3() { _mmu2_load_filament(3); }
inline void action_mmu2_loadFilament4() { _mmu2_loadFilament(4); } inline void action_mmu2_load_filament_4() { _mmu2_load_filament(4); }
void menu_mmu2_loadFilament() { void menu_mmu2_load_filament() {
START_MENU(); START_MENU();
MENU_BACK(MSG_MMU2_MENU); MENU_BACK(MSG_MMU2_MENU);
MENU_ITEM(function, MSG_MMU2_ALL, action_mmu2_loadAll); MENU_ITEM(function, MSG_MMU2_ALL, action_mmu2_load_all);
MENU_ITEM(function, MSG_MMU2_FILAMENT0, action_mmu2_loadFilament0); MENU_ITEM(function, MSG_MMU2_FILAMENT0, action_mmu2_load_filament_0);
MENU_ITEM(function, MSG_MMU2_FILAMENT1, action_mmu2_loadFilament1); MENU_ITEM(function, MSG_MMU2_FILAMENT1, action_mmu2_load_filament_1);
MENU_ITEM(function, MSG_MMU2_FILAMENT2, action_mmu2_loadFilament2); MENU_ITEM(function, MSG_MMU2_FILAMENT2, action_mmu2_load_filament_2);
MENU_ITEM(function, MSG_MMU2_FILAMENT3, action_mmu2_loadFilament3); MENU_ITEM(function, MSG_MMU2_FILAMENT3, action_mmu2_load_filament_3);
MENU_ITEM(function, MSG_MMU2_FILAMENT4, action_mmu2_loadFilament4); MENU_ITEM(function, MSG_MMU2_FILAMENT4, action_mmu2_load_filament_4);
END_MENU(); END_MENU();
} }
void menu_mmu2_loadToNozzle() { void menu_mmu2_load_to_nozzle() {
START_MENU(); START_MENU();
MENU_BACK(MSG_MMU2_MENU); MENU_BACK(MSG_MMU2_MENU);
MENU_ITEM(function, MSG_MMU2_FILAMENT0, action_mmu2_loadFilamentToNozzle0); MENU_ITEM(function, MSG_MMU2_FILAMENT0, action_mmu2_load_filament_to_nozzle_0);
MENU_ITEM(function, MSG_MMU2_FILAMENT1, action_mmu2_loadFilamentToNozzle1); MENU_ITEM(function, MSG_MMU2_FILAMENT1, action_mmu2_load_filament_to_nozzle_1);
MENU_ITEM(function, MSG_MMU2_FILAMENT2, action_mmu2_loadFilamentToNozzle2); MENU_ITEM(function, MSG_MMU2_FILAMENT2, action_mmu2_load_filament_to_nozzle_2);
MENU_ITEM(function, MSG_MMU2_FILAMENT3, action_mmu2_loadFilamentToNozzle3); MENU_ITEM(function, MSG_MMU2_FILAMENT3, action_mmu2_load_filament_to_nozzle_3);
MENU_ITEM(function, MSG_MMU2_FILAMENT4, action_mmu2_loadFilamentToNozzle4); MENU_ITEM(function, MSG_MMU2_FILAMENT4, action_mmu2_load_filament_to_nozzle_4);
END_MENU(); END_MENU();
} }
@ -96,19 +96,19 @@ void menu_mmu2_loadToNozzle() {
// Eject Filament // Eject Filament
// //
void _mmu2_ejectFilament(uint8_t index) { void _mmu2_eject_filament(uint8_t index) {
ui.reset_status(); ui.reset_status();
ui.return_to_status(); ui.return_to_status();
ui.status_printf_P(0, PSTR(MSG_MMU2_EJECTING_FILAMENT), int(index + 1)); ui.status_printf_P(0, PSTR(MSG_MMU2_EJECTING_FILAMENT), int(index + 1));
if (mmu2.ejectFilament(index, true)) ui.reset_status(); if (mmu2.eject_filament(index, true)) ui.reset_status();
} }
inline void action_mmu2_ejectFilament0() { _mmu2_ejectFilament(0); } inline void action_mmu2_eject_filament_0() { _mmu2_eject_filament(0); }
inline void action_mmu2_ejectFilament1() { _mmu2_ejectFilament(1); } inline void action_mmu2_eject_filament_1() { _mmu2_eject_filament(1); }
inline void action_mmu2_ejectFilament2() { _mmu2_ejectFilament(2); } inline void action_mmu2_eject_filament_2() { _mmu2_eject_filament(2); }
inline void action_mmu2_ejectFilament3() { _mmu2_ejectFilament(3); } inline void action_mmu2_eject_filament_3() { _mmu2_eject_filament(3); }
inline void action_mmu2_ejectFilament4() { _mmu2_ejectFilament(4); } inline void action_mmu2_eject_filament_4() { _mmu2_eject_filament(4); }
void action_mmu2_unloadFilament() { void action_mmu2_unload_filament() {
ui.reset_status(); ui.reset_status();
ui.return_to_status(); ui.return_to_status();
LCD_MESSAGEPGM(MSG_MMU2_UNLOADING_FILAMENT); LCD_MESSAGEPGM(MSG_MMU2_UNLOADING_FILAMENT);
@ -116,14 +116,14 @@ void action_mmu2_unloadFilament() {
if (mmu2.unload()) ui.reset_status(); if (mmu2.unload()) ui.reset_status();
} }
void menu_mmu2_ejectFilament() { void menu_mmu2_eject_filament() {
START_MENU(); START_MENU();
MENU_BACK(MSG_MMU2_MENU); MENU_BACK(MSG_MMU2_MENU);
MENU_ITEM(function, MSG_MMU2_FILAMENT0, action_mmu2_ejectFilament0); MENU_ITEM(function, MSG_MMU2_FILAMENT0, action_mmu2_eject_filament_0);
MENU_ITEM(function, MSG_MMU2_FILAMENT1, action_mmu2_ejectFilament1); MENU_ITEM(function, MSG_MMU2_FILAMENT1, action_mmu2_eject_filament_1);
MENU_ITEM(function, MSG_MMU2_FILAMENT2, action_mmu2_ejectFilament2); MENU_ITEM(function, MSG_MMU2_FILAMENT2, action_mmu2_eject_filament_2);
MENU_ITEM(function, MSG_MMU2_FILAMENT3, action_mmu2_ejectFilament3); MENU_ITEM(function, MSG_MMU2_FILAMENT3, action_mmu2_eject_filament_3);
MENU_ITEM(function, MSG_MMU2_FILAMENT4, action_mmu2_ejectFilament4); MENU_ITEM(function, MSG_MMU2_FILAMENT4, action_mmu2_eject_filament_4);
END_MENU(); END_MENU();
} }
@ -139,10 +139,10 @@ void action_mmu2_reset() {
void menu_mmu2() { void menu_mmu2() {
START_MENU(); START_MENU();
MENU_BACK(MSG_MAIN); MENU_BACK(MSG_MAIN);
MENU_ITEM(submenu, MSG_MMU2_LOAD_FILAMENT, menu_mmu2_loadFilament); MENU_ITEM(submenu, MSG_MMU2_LOAD_FILAMENT, menu_mmu2_load_filament);
MENU_ITEM(submenu, MSG_MMU2_LOAD_TO_NOZZLE, menu_mmu2_loadToNozzle); MENU_ITEM(submenu, MSG_MMU2_LOAD_TO_NOZZLE, menu_mmu2_load_to_nozzle);
MENU_ITEM(submenu, MSG_MMU2_EJECT_FILAMENT, menu_mmu2_ejectFilament); MENU_ITEM(submenu, MSG_MMU2_EJECT_FILAMENT, menu_mmu2_eject_filament);
MENU_ITEM(function, MSG_MMU2_UNLOAD_FILAMENT, action_mmu2_unloadFilament); MENU_ITEM(function, MSG_MMU2_UNLOAD_FILAMENT, action_mmu2_unload_filament);
MENU_ITEM(function, MSG_MMU2_RESET, action_mmu2_reset); MENU_ITEM(function, MSG_MMU2_RESET, action_mmu2_reset);
END_MENU(); END_MENU();
} }
@ -161,7 +161,7 @@ inline void action_mmu2_choose2() { action_mmu2_choose(2); }
inline void action_mmu2_choose3() { action_mmu2_choose(3); } inline void action_mmu2_choose3() { action_mmu2_choose(3); }
inline void action_mmu2_choose4() { action_mmu2_choose(4); } inline void action_mmu2_choose4() { action_mmu2_choose(4); }
void menu_mmu2_chooseFilament() { void menu_mmu2_choose_filament() {
START_MENU(); START_MENU();
#if LCD_HEIGHT > 2 #if LCD_HEIGHT > 2
STATIC_ITEM(MSG_MMU2_CHOOSE_FILAMENT_HEADER, true, true); STATIC_ITEM(MSG_MMU2_CHOOSE_FILAMENT_HEADER, true, true);
@ -178,21 +178,21 @@ void menu_mmu2_chooseFilament() {
// MMU2 Filament Runout // MMU2 Filament Runout
// //
inline void action_mmu2_M600_loadCurrentFilament() { mmu2.loadFilament(currentTool); } inline void action_mmu2_M600_load_current_filament() { mmu2.load_filament(currentTool); }
inline void action_mmu2_M600_loadCurrentFilamentToNozzle() { mmu2.loadFilamentToNozzle(currentTool); } inline void action_mmu2_M600_load_current_filament_to_nozzle() { mmu2.load_filament_to_nozzle(currentTool); }
inline void action_mmu2_M600_unloadFilament() { mmu2.unload(); } inline void action_mmu2_M600_unload_filament() { mmu2.unload(); }
inline void action_mmu2_M600_resume() { mmuMenuWait = false; } inline void action_mmu2_M600_resume() { mmuMenuWait = false; }
void menu_mmu2_pause() { void menu_mmu2_pause() {
currentTool = mmu2.getCurrentTool(); currentTool = mmu2.get_current_tool();
START_MENU(); START_MENU();
#if LCD_HEIGHT > 2 #if LCD_HEIGHT > 2
STATIC_ITEM(MSG_MMU2_FILAMENT_CHANGE_HEADER, true, true); STATIC_ITEM(MSG_MMU2_FILAMENT_CHANGE_HEADER, true, true);
#endif #endif
MENU_ITEM(function, MSG_MMU2_RESUME, action_mmu2_M600_resume); MENU_ITEM(function, MSG_MMU2_RESUME, action_mmu2_M600_resume);
MENU_ITEM(function, MSG_MMU2_UNLOAD_FILAMENT, action_mmu2_M600_unloadFilament); MENU_ITEM(function, MSG_MMU2_UNLOAD_FILAMENT, action_mmu2_M600_unload_filament);
MENU_ITEM(function, MSG_MMU2_LOAD_FILAMENT, action_mmu2_M600_loadCurrentFilament); MENU_ITEM(function, MSG_MMU2_LOAD_FILAMENT, action_mmu2_M600_load_current_filament);
MENU_ITEM(function, MSG_MMU2_LOAD_TO_NOZZLE, action_mmu2_M600_loadCurrentFilamentToNozzle); MENU_ITEM(function, MSG_MMU2_LOAD_TO_NOZZLE, action_mmu2_M600_load_current_filament_to_nozzle);
END_MENU(); END_MENU();
} }
@ -203,9 +203,9 @@ void mmu2_M600() {
while (mmuMenuWait) idle(); while (mmuMenuWait) idle();
} }
uint8_t mmu2_chooseFilament() { uint8_t mmu2_choose_filament() {
ui.defer_status_screen(); ui.defer_status_screen();
ui.goto_screen(menu_mmu2_chooseFilament); ui.goto_screen(menu_mmu2_choose_filament);
mmuMenuWait = true; mmuMenuWait = true;
while (mmuMenuWait) idle(); while (mmuMenuWait) idle();
ui.return_to_status(); ui.return_to_status();

2
Marlin/src/lcd/menu/menu_mmu2.h

@ -25,4 +25,4 @@
void menu_mmu2(); void menu_mmu2();
void mmu2_M600(); void mmu2_M600();
uint8_t mmu2_chooseFilament(); uint8_t mmu2_choose_filament();

4
Marlin/src/module/tool_change.cpp

@ -577,7 +577,7 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
UNUSED(fr_mm_s); UNUSED(no_move); UNUSED(fr_mm_s); UNUSED(no_move);
mmu2.toolChange(tmp_extruder); mmu2.tool_change(tmp_extruder);
#elif EXTRUDERS < 2 #elif EXTRUDERS < 2
@ -777,7 +777,7 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
#endif #endif
#if ENABLED(PRUSA_MMU2) #if ENABLED(PRUSA_MMU2)
mmu2.toolChange(tmp_extruder); mmu2.tool_change(tmp_extruder);
#endif #endif
#if SWITCHING_NOZZLE_TWO_SERVOS #if SWITCHING_NOZZLE_TWO_SERVOS

Loading…
Cancel
Save