Skip to content

Commit

Permalink
Send host actions on filament runout
Browse files Browse the repository at this point in the history
  • Loading branch information
sarusani committed Aug 16, 2024
1 parent 21fc1dd commit 0670621
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions Firmware/Filament_sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ void Filament_sensor::triggerFilamentRemoved() {

void Filament_sensor::filRunout() {
// SERIAL_ECHOLNPGM("filRunout");
sendHostNotification_P(MSG_FILAMEN_RUNOUT_DETECTED);
runoutEnabled = false;
autoLoadEnabled = false;
stop_and_save_print_to_ram(0, 0);
Expand Down
10 changes: 8 additions & 2 deletions Firmware/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3402,6 +3402,7 @@ static void gcode_M600(const bool automatic, const float x_position, const float
// Retract E
if (!printingIsPaused())
{
SERIAL_ECHOLNRPGM(MSG_HOST_ACTION_PAUSED);
current_position[E_AXIS] += e_shift;
plan_buffer_line_curposXYZE(FILAMENTCHANGE_RFEED);
st_synchronize();
Expand Down Expand Up @@ -3504,8 +3505,13 @@ static void gcode_M600(const bool automatic, const float x_position, const float
feedmultiply = saved_feedmultiply2;
enquecommandf_P(MSG_M220, saved_feedmultiply2);

if (printingIsPaused()) lcd_setstatuspgm(_T(MSG_PRINT_PAUSED));
else lcd_setstatuspgm(MSG_WELCOME);
if (printingIsPaused()) {
lcd_setstatuspgm(_T(MSG_PRINT_PAUSED));
}
else {
SERIAL_ECHOLNRPGM(MSG_HOST_ACTION_RESUMED);
lcd_setstatuspgm(MSG_WELCOME);
}
custom_message_type = CustomMsg::Status;
}

Expand Down
2 changes: 2 additions & 0 deletions Firmware/messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ const char MSG_HOST_ACTION_NOT_READY[] PROGMEM_N1 = "//action:not_ready"; ////
const char MSG_HOST_ACTION_START[] PROGMEM_N1 = "//action:start"; ////
const char MSG_HOST_ACTION_UVLO_RECOVERY_READY[] PROGMEM_N1 = "//action:uvlo_recovery_ready"; ////
const char MSG_HOST_ACTION_UVLO_AUTO_RECOVERY_READY[] PROGMEM_N1 = "//action:uvlo_auto_recovery_ready"; ////
const char MSG_HOST_ACTION_NOTIFICATION[] PROGMEM_N1 = "//action:notification %S"; ////
#ifdef HOST_SHUTDOWN
const char MSG_HOST_ACTION_SHUTDOWN[] PROGMEM_N1 = "//action:shutdown"; ////
#endif //HOST_SHUTOWN
Expand All @@ -420,6 +421,7 @@ const char MSG_ADVANCE_K[] PROGMEM_N1 = "Advance K:"; ////c=13
const char MSG_POWERPANIC_DETECTED[] PROGMEM_N1 = "POWER PANIC DETECTED"; ////c=20
const char MSG_LCD_STATUS_CHANGED[] PROGMEM_N1 = "LCD status changed";
const char MSG_UNKNOWN_CODE[] PROGMEM_N1 = "Unknown %c code: %s\n";
const char MSG_FILAMEN_RUNOUT_DETECTED[] PROGMEM_N1 = "Filament runout detected!"; ////c=20 r=2

// Common G-gcodes
const char G1_E_F2700[] PROGMEM_N1 = "G1 E%-.3f F2700";
Expand Down
2 changes: 2 additions & 0 deletions Firmware/messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ extern const char MSG_HOST_ACTION_NOT_READY[];
extern const char MSG_HOST_ACTION_START[];
extern const char MSG_HOST_ACTION_UVLO_RECOVERY_READY[];
extern const char MSG_HOST_ACTION_UVLO_AUTO_RECOVERY_READY[];
extern const char MSG_HOST_ACTION_NOTIFICATION[];
#ifdef HOST_SHUTDOWN
extern const char MSG_HOST_ACTION_SHUTDOWN[];
#endif //HOST_SHUTOWN
Expand All @@ -422,6 +423,7 @@ extern const char MSG_ADVANCE_K[];
extern const char MSG_POWERPANIC_DETECTED[];
extern const char MSG_LCD_STATUS_CHANGED[];
extern const char MSG_UNKNOWN_CODE[];
extern const char MSG_FILAMEN_RUNOUT_DETECTED[];

// Common G-gcodes
extern const char G1_E_F2700[];
Expand Down
6 changes: 5 additions & 1 deletion Firmware/ultralcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5059,7 +5059,11 @@ static void change_sheet()
menu_back(3);
}


//! @brief Send a notification to the host. Param 'message' must reside in program memory!
void sendHostNotification_P(const char* message)
{
SERIAL_ECHOLN(printf_P(MSG_HOST_ACTION_NOTIFICATION, message));
}

static void lcd_rename_sheet_menu()
{
Expand Down
2 changes: 2 additions & 0 deletions Firmware/ultralcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,4 +260,6 @@ extern void lcd_heat_bed_on_load_toggle();
extern void retract_for_ooze_prevention();
#endif //COMMUNITY_PREVENT_OOZE

extern void sendHostNotification_P(const char* message);

#endif //ULTRALCD_H

0 comments on commit 0670621

Please sign in to comment.