Skip to content

Commit

Permalink
Merge pull request #4759 from Panayiotis-git/MK3_M600_Filament_name
Browse files Browse the repository at this point in the history
PFW-1204: M600 - Show filament name at the Insert filament prompt
  • Loading branch information
3d-gussner committed Aug 22, 2024
2 parents f64f2bb + 815b686 commit 2f7715a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 21 deletions.
6 changes: 3 additions & 3 deletions Firmware/Marlin.h
Original file line number Diff line number Diff line change
Expand Up @@ -451,10 +451,10 @@ void gcode_M701(float fastLoadLength, uint8_t mmuSlotIndex);
#define UVLO !(PINE & (1<<4))


void M600_load_filament();
void M600_load_filament_movements();
void M600_load_filament(const char* filament_name);
void M600_load_filament_movements(const char* filament_name);
void M600_wait_for_user();
bool M600_check_state_and_repeat();
bool M600_check_state_and_repeat(const char* filament_name);
void load_filament_final_feed();
void marlin_wait_for_click();
float raise_z(float delta);
Expand Down
35 changes: 23 additions & 12 deletions Firmware/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3387,7 +3387,7 @@ static void mmu_M600_load_filament(bool automatic) {
st_synchronize();
}

static void gcode_M600(const bool automatic, const float x_position, const float y_position, const float z_shift, const float e_shift, const float e_shift_late) {
static void gcode_M600(const bool automatic, const float x_position, const float y_position, const float z_shift, const float e_shift, const float e_shift_late, const char* filament_name) {
st_synchronize();

// When using an MMU, save the currently use slot number
Expand Down Expand Up @@ -3450,15 +3450,15 @@ static void gcode_M600(const bool automatic, const float x_position, const float
st_synchronize();
lcd_show_fullscreen_message_and_wait_P(_T(MSG_CHECK_IDLER));
}
M600_load_filament();
M600_load_filament(filament_name);
}
else // MMU is enabled
{
if (!automatic) mmu_M600_filament_change_screen(eject_slot);
mmu_M600_load_filament(automatic);
}
if (!automatic)
repeat = M600_check_state_and_repeat();
repeat = M600_check_state_and_repeat(filament_name);
}
while (repeat);

Expand Down Expand Up @@ -7641,9 +7641,10 @@ SERIAL_PROTOCOLPGM("\n\n");
- `Z` - relative lift Z, default MIN_Z_FOR_SWAP.
- `E` - initial retract, default FILAMENTCHANGE_FIRSTRETRACT
- `L` - later retract distance for removal, default FILAMENTCHANGE_FINALRETRACT
- `C` - filament name to show during loading
- `AUTO` - Automatically (only with MMU)
*/
case 600: //Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
case 600: //Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal] C"[filament name to show during loading]"
{
st_synchronize();

Expand All @@ -7669,10 +7670,20 @@ SERIAL_PROTOCOLPGM("\n\n");
if (code_seen('X')) x_position = code_value();
if (code_seen('Y')) y_position = code_value();

// Filament name to show during the loading
char filament_name[LCD_WIDTH + 1] = "";
if (code_seen('C')) {
unquoted_string str = unquoted_string(strchr_pointer);
if (str.WasFound()) {
const uint8_t len = min(str.GetLength(), LCD_WIDTH);
memcpy(filament_name, str.GetUnquotedString(), len);
}
}

if (MMU2::mmu2.Enabled() && code_seen_P(PSTR("AUTO")))
automatic = true;

gcode_M600(automatic, x_position, y_position, z_shift, e_shift_init, e_shift_late);
gcode_M600(automatic, x_position, y_position, z_shift, e_shift_init, e_shift_late, filament_name);

// From this point forward, power panic should not use
// the partial backup in RAM since the extruder is no
Expand Down Expand Up @@ -10899,7 +10910,7 @@ void load_filament_final_feed()
}

//! @brief Wait for user to check the state
bool M600_check_state_and_repeat()
bool M600_check_state_and_repeat(const char* filament_name)
{
uint8_t lcd_change_filament_state = 10;
while (lcd_change_filament_state != 0 && lcd_change_filament_state != 3)
Expand All @@ -10923,7 +10934,7 @@ bool M600_check_state_and_repeat()
// After user clicks knob, MMU will load the filament
mmu_M600_load_filament(false);
} else {
M600_load_filament_movements();
M600_load_filament_movements(filament_name);
}
break;

Expand Down Expand Up @@ -11001,18 +11012,18 @@ void M600_wait_for_user() {
sound_wait_for_user_reset();
}

void M600_load_filament_movements()
void M600_load_filament_movements(const char* filament_name)
{
current_position[E_AXIS]+= FILAMENTCHANGE_FIRSTFEED;
plan_buffer_line_curposXYZE(FILAMENTCHANGE_EFEED_FIRST);
load_filament_final_feed();
lcd_loading_filament();
lcd_loading_filament(filament_name);
st_synchronize();
}

void M600_load_filament() {
void M600_load_filament(const char* filament_name) {
//load filament for single material and MMU
lcd_wait_interact();
lcd_wait_interact(filament_name);

KEEPALIVE_STATE(PAUSED_FOR_USER);

Expand All @@ -11029,7 +11040,7 @@ void M600_load_filament() {
}
KEEPALIVE_STATE(IN_HANDLER);

M600_load_filament_movements();
M600_load_filament_movements(filament_name);

Sound_MakeCustom(50,1000,false);
}
Expand Down
16 changes: 12 additions & 4 deletions Firmware/ultralcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2141,16 +2141,21 @@ static void lcd_unLoadFilament()
preheat_or_continue(FilamentAction::UnLoad);
}

void lcd_wait_interact() {
void lcd_wait_interact(const char* filament_name) {

lcd_clear();

lcd_puts_at_P(0, 0, _T(MSG_INSERT_FILAMENT));
lcd_set_cursor(0, 1);
if (filament_name[0]) {
lcd_print(filament_name);
lcd_set_cursor(0, 2);
}
#ifdef FILAMENT_SENSOR
if (!fsensor.getAutoLoadEnabled())
#endif //FILAMENT_SENSOR
{
lcd_puts_at_P(0, 1, _T(MSG_PRESS));
lcd_puts_P(_T(MSG_PRESS));
}
}

Expand Down Expand Up @@ -2187,12 +2192,15 @@ void lcd_loading_color() {
}


void lcd_loading_filament() {

void lcd_loading_filament(const char* filament_name) {

lcd_clear();

lcd_puts_at_P(0, 0, _T(MSG_LOADING_FILAMENT));
if (filament_name[0]) {
lcd_set_cursor(0, 1);
lcd_print(filament_name);
}
lcd_puts_at_P(0, 2, _T(MSG_PLEASE_WAIT));
uint16_t slow_seq_time = (FILAMENTCHANGE_FINALFEED * 1000ul) / FILAMENTCHANGE_EFEED_FINAL;
uint16_t fast_seq_time = (FILAMENTCHANGE_FIRSTFEED * 1000ul) / FILAMENTCHANGE_EFEED_FIRST;
Expand Down
4 changes: 2 additions & 2 deletions Firmware/ultralcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ void lcd_reset_alert_level();

uint8_t lcd_alright();
void show_preheat_nozzle_warning();
void lcd_wait_interact();
void lcd_loading_filament();
void lcd_wait_interact(const char* filament_name);
void lcd_loading_filament(const char* filament_name);
void lcd_change_success();
void lcd_loading_color();
void lcd_sdcard_stop();
Expand Down

0 comments on commit 2f7715a

Please sign in to comment.