Skip to content

Commit

Permalink
cleanup after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Aug 20, 2024
1 parent 9a4443e commit 9ffa167
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 95 deletions.
12 changes: 6 additions & 6 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -4398,13 +4398,13 @@
// Use hardware reset for MMU if a pin is defined for it
//#define MMU2_RST_PIN 23

// Enable if the MMU2 has 12V stepper motors (MMU2 Firmware 1.0.2 and up)
// (MMU2/MMU2S only)
//#define MMU2_MODE_12V
#if HAS_PRUSA_MMU2
// Enable if the MMU2 has 12V stepper motors (MMU2 Firmware 1.0.2 and up)
//#define MMU2_MODE_12V

// G-code to execute when MMU2 F.I.N.D.A. probe detects filament runout
//(MMU2/MMU2S only)
#define MMU2_FILAMENT_RUNOUT_SCRIPT "M600"
// G-code to execute when MMU2 F.I.N.D.A. probe detects filament runout
#define MMU2_FILAMENT_RUNOUT_SCRIPT "M600"
#endif

// Add an LCD menu for MMU2/MMU2S/MMU3
//#define MMU_MENUS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* Copyright (c) 2024 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
Expand Down Expand Up @@ -47,7 +47,7 @@ static void gcodes_M704_M705_M706(uint16_t gcode) {
}

/**
* ### M704 - Preload to MMU <a href="https://reprap.org/wiki/G-code#M704:_Preload_to_MMU">M704: Preload to MMU</a>
* ### M704 - Preload to MMU
* #### Usage
*
* M704 [ P ]
Expand All @@ -60,7 +60,7 @@ void GcodeSuite::M704() {
}

/**
* ### M705 - Eject filament <a href="https://reprap.org/wiki/G-code#M705:_Eject_filament">M705: Eject filament</a>
* ### M705 - Eject filament
* #### Usage
*
* M705 [ P ]
Expand All @@ -73,7 +73,7 @@ void GcodeSuite::M705() {
}

/*!
* ### M706 - Cut filament <a href="https://reprap.org/wiki/G-code#M706:_Cut_filament">M706: Cut filament</a>
* ### M706 - Cut filament
* #### Usage
*
* M706 [ P ]
Expand All @@ -86,7 +86,7 @@ void GcodeSuite::M706() {
}

/**
* ### M707 - Read from MMU register <a href="https://reprap.org/wiki/G-code#M707:_Read_from_MMU_register">M707: Read from MMU register</a>
* ### M707 - Read from MMU register
* #### Usage
*
* M707 [ A ]
Expand All @@ -102,16 +102,14 @@ void GcodeSuite::M706() {
*
*/
void GcodeSuite::M707() {
if (mmu3.enabled() ) {
if (parser.seenval('A') ) {
char *address = parser.stringval('A');
mmu3.readRegister(uint8_t(strtol(address, NULL, 16)));
}
if (mmu3.enabled() && parser.seenval('A')) {
char *address = parser.value_string();
mmu3.readRegister(uint8_t(strtol(address, NULL, 16)));
}
}

/**
* ### M708 - Write to MMU register <a href="https://reprap.org/wiki/G-code#M708:_Write_to_MMU_register">M707: Write to MMU register</a>
* ### M708 - Write to MMU register
* #### Usage
*
* M708 [ A | X ]
Expand All @@ -126,24 +124,18 @@ void GcodeSuite::M707() {
* Does nothing if A parameter is missing or if MMU is not enabled.
*/
void GcodeSuite::M708() {
if (mmu3.enabled() ) {
uint8_t addr = 0;
if (parser.seenval('A') ) {
char *address = parser.stringval('A');
addr = uint8_t(strtol(address, NULL, 16));
}
uint16_t data = 0;
if (parser.seenval('X') ) {
data = parser.ushortval('X', 0);
}
if (mmu3.enabled() && parser.seenval('A')) {
char *address = parser.value_string();
const uint8_t addr = uint8_t(strtol(address, NULL, 16));
if (addr) {
const uint16_t data = parser.ushortval('X', 0);
mmu3.writeRegister(addr, data);
}
}
}

/**
* ### M709 - MMU power & reset <a href="https://reprap.org/wiki/G-code#M709:_MMU_power_&_reset">M709: MMU power & reset</a>
* ### M709 - MMU power & reset
* The MK3S cannot not power off the MMU, but we can en- and disable the MMU.
*
* The new state of the MMU is stored in printer's EEPROM.
Expand All @@ -167,14 +159,14 @@ void GcodeSuite::M708() {
*/
void GcodeSuite::M709() {
if (parser.seenval('S')) {
switch (parser.byteval('S', -1)) {
case 0: mmu3.stop(); break;
case 1: mmu3.start(); break;
default: break;
}
if (parser.value_bool())
mmu3.start();
else
mmu3.stop();
}

if (mmu3.enabled() && parser.seenval('X')) {
switch (parser.byteval('X', -1)) {
switch (parser.value_byte()) {
case 0: mmu3.reset(MMU3::MMU3::Software); break;
case 1: mmu3.reset(MMU3::MMU3::ResetPin); break;
case 42: mmu3.reset(MMU3::MMU3::EraseEEPROM); break;
Expand All @@ -184,4 +176,26 @@ void GcodeSuite::M709() {
mmu3.status();
}

/**
* Report for M503.
* TODO: Report MMU3 G-code settings here, status via a different G-code.
*/
void GcodeSuite::MMU3_report() {
report_heading(forReplay, F("MMU3 Operational Stats"));
SERIAL_ECHOPGM(" MMU "); serialprintln_onoff(mmu3.mmu_hw_enabled);
SERIAL_ECHOPGM(" Stealth Mode "); serialprintln_onoff(mmu3.stealth_mode);
#if ENABLED(MMU_HAS_CUTTER)
SERIAL_ECHOPGM(" Cutter ");
serialprintln_onoff(mmu3.cutter_mode != 0);
#endif
SERIAL_ECHOPGM(" SpoolJoin "); serialprintln_onoff(spooljoin.enabled);
SERIAL_ECHOLNPGM(" Tool Changes ", MMU3::operation_statistics.tool_change_counter);
SERIAL_ECHOLNPGM(" Total Tool Changes ", MMU3::operation_statistics.tool_change_total_counter);
SERIAL_ECHOLNPGM(" Fails ", MMU3::operation_statistics.fail_num);
SERIAL_ECHOLNPGM(" Total Fails ", MMU3::operation_statistics.fail_total_num);
SERIAL_ECHOLNPGM(" Load Fails ", MMU3::operation_statistics.load_fail_num);
SERIAL_ECHOLNPGM(" Total Load Fails ", MMU3::operation_statistics.load_fail_total_num);
SERIAL_ECHOLNPGM(" Power Fails ", mmu3.tmcFailures());
}

#endif // HAS_PRUSA_MMU3
1 change: 1 addition & 0 deletions Marlin/src/gcode/gcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,7 @@ class GcodeSuite {
static void M707();
static void M708();
static void M709();
static void MMU3_report();
#endif

#if ENABLED(GCODE_REPEAT_MARKERS)
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/gcode/gcode_d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void GcodeSuite::D(const int16_t dcode) {
}
else {
//while (len--) {
// // TODO: Read bytes from EEPROM
//// TODO: Read bytes from EEPROM
// print_hex_byte(eeprom_read_byte(adr++));
//}
SERIAL_EOL();
Expand All @@ -162,7 +162,7 @@ void GcodeSuite::D(const int16_t dcode) {
}
else {
//while (len--) {
// // TODO: Read bytes from FLASH
//// TODO: Read bytes from FLASH
// print_hex_byte(flash_read_byte(adr++));
//}
SERIAL_EOL();
Expand Down
65 changes: 7 additions & 58 deletions Marlin/src/module/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3822,11 +3822,11 @@ void MarlinSettings::reset() {
// MMU Settings
//
#if HAS_PRUSA_MMU3
spooljoin.enabled = false;
MMU3::operation_statistics.reset_stats();
mmu3.cutter_mode = 0;
mmu3.stealth_mode = 0;
mmu3.mmu_hw_enabled = true;
spooljoin.enabled = false;
MMU3::operation_statistics.reset_stats();
mmu3.cutter_mode = 0;
mmu3.stealth_mode = 0;
mmu3.mmu_hw_enabled = true;
#endif

//
Expand Down Expand Up @@ -4150,60 +4150,9 @@ void MarlinSettings::reset() {
TERN_(MPCTEMP, gcode.M306_report(forReplay));

//
// MMU
// MMU3
//
#if HAS_PRUSA_MMU3
CONFIG_ECHO_HEADING("MMU3 Operational Stats");

CONFIG_ECHO_START(); SERIAL_ECHO_SP(2);
SERIAL_ECHOPGM("MMU ");
serialprintln_onoff(mmu3.mmu_hw_enabled);

CONFIG_ECHO_START(); SERIAL_ECHO_SP(2);
SERIAL_ECHOPGM("Stealth Mode ");
serialprintln_onoff(mmu3.stealth_mode);

CONFIG_ECHO_START(); SERIAL_ECHO_SP(2);
SERIAL_ECHOPGM("Cutter ");
#if ENABLED(MMU_HAS_CUTTER)
serialprintln_onoff(mmu3.cutter_mode != 0);
#else
SERIAL_ECHOLNPGM("Disabled");
#endif

CONFIG_ECHO_START(); SERIAL_ECHO_SP(2);
SERIAL_ECHOPGM("SpoolJoin ");
serialprintln_onoff(spooljoin.enabled);

CONFIG_ECHO_START(); SERIAL_ECHO_SP(2);
SERIAL_ECHOPGM("Tool Changes ");
SERIAL_ECHOLN(MMU3::operation_statistics.tool_change_counter);

CONFIG_ECHO_START(); SERIAL_ECHO_SP(2);
SERIAL_ECHOPGM("Total Tool Changes ");
SERIAL_ECHOLN(MMU3::operation_statistics.tool_change_total_counter);

CONFIG_ECHO_START(); SERIAL_ECHO_SP(2);
SERIAL_ECHOPGM("Fails ");
SERIAL_ECHOLN(MMU3::operation_statistics.fail_num);

CONFIG_ECHO_START(); SERIAL_ECHO_SP(2);
SERIAL_ECHOPGM("Total Fails ");
SERIAL_ECHOLN(MMU3::operation_statistics.fail_total_num);

CONFIG_ECHO_START(); SERIAL_ECHO_SP(2);
SERIAL_ECHOPGM("Load Fails ");
SERIAL_ECHOLN(MMU3::operation_statistics.load_fail_num);

CONFIG_ECHO_START(); SERIAL_ECHO_SP(2);
SERIAL_ECHOPGM("Total Load Fails ");
SERIAL_ECHOLN(MMU3::operation_statistics.load_fail_total_num);

CONFIG_ECHO_START(); SERIAL_ECHO_SP(2);
SERIAL_ECHOPGM("Power Fails ");
SERIAL_ECHOLN(mmu3.tmcFailures());

#endif
TERN_(HAS_PRUSA_MMU3, gcode.MMU3_report(forReplay));
}

#endif // !DISABLE_M503
Expand Down
1 change: 0 additions & 1 deletion Marlin/src/sd/usb_flashdrive/lib-uhs2/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* Web : https://www.circuitsathome.com
* e-mail : [email protected]
*/

#pragma once

#include "../../../inc/MarlinConfig.h"
Expand Down

0 comments on commit 9ffa167

Please sign in to comment.