diff --git a/Firmware/mmu2.cpp b/Firmware/mmu2.cpp index 7b6304d03..b46b51c3a 100644 --- a/Firmware/mmu2.cpp +++ b/Firmware/mmu2.cpp @@ -204,7 +204,7 @@ void MMU2::CheckFINDARunout() { // Check for FINDA filament runout if (!FindaDetectsFilament() && check_fsensor()) { SERIAL_ECHOLNPGM("FINDA filament runout!"); - stop_and_save_print_to_ram(0, 0); + marlin_stop_and_save_print_to_ram(); restore_print_from_ram_and_continue(0); if (SpoolJoin::spooljoin.isSpoolJoinEnabled() && get_current_tool() != (uint8_t)FILAMENT_UNKNOWN){ // Can't auto if F=? enquecommand_front_P(PSTR("M600 AUTO")); // save print and run M600 command @@ -261,7 +261,6 @@ bool MMU2::VerifyFilamentEnteredPTFE() { // MMU has finished its load, push the filament further by some defined constant length // If the filament sensor reads 0 at any moment, then report FAILURE - const float tryload_length = MMU2_CHECK_FILAMENT_PRESENCE_EXTRUSION_LENGTH - logic.ExtraLoadDistance(); TryLoadUnloadReporter tlur(tryload_length); @@ -617,7 +616,7 @@ void MMU2::SaveAndPark(bool move_axes) { // In case a power panic happens while waiting for the user // take a partial back up of print state into RAM (current position, etc.) - refresh_print_state_in_ram(); + marlin_refresh_print_state_in_ram(); if (move_axes) { mmu_print_saved |= SavedState::ParkExtruder; @@ -676,7 +675,7 @@ void MMU2::ResumeUnpark() { // From this point forward, power panic should not use // the partial backup in RAM since the extruder is no // longer in parking position - clear_print_state_in_ram(); + marlin_clear_print_state_in_ram(); mmu_print_saved &= ~(SavedState::ParkExtruder); } @@ -707,12 +706,12 @@ void MMU2::CheckUserInput() { case Buttons::Middle: case Buttons::Right: SERIAL_ECHOPGM("CheckUserInput-btnLMR "); - SERIAL_ECHOLN(btn); + SERIAL_ECHOLN(buttons_to_uint8t(btn)); ResumeHotendTemp(); // Recover the hotend temp before we attempt to do anything else... if (mmu2.MMULastErrorSource() == MMU2::ErrorSourceMMU) { // Do not send a button to the MMU unless the MMU is in error state - Button(btn); + Button(buttons_to_uint8t(btn)); } // A quick hack: for specific error codes move the E-motor every time. diff --git a/Firmware/mmu2/buttons.h b/Firmware/mmu2/buttons.h index 4941513a0..2d7b3128f 100644 --- a/Firmware/mmu2/buttons.h +++ b/Firmware/mmu2/buttons.h @@ -2,8 +2,8 @@ #include // Helper macros to parse the operations from Btns() -#define BUTTON_OP_RIGHT(X) ( ( X & 0xF0 ) >> 4 ) -#define BUTTON_OP_MIDDLE(X) ( X & 0x0F ) +#define BUTTON_OP_RIGHT(X) ((X & 0xF0) >> 4) +#define BUTTON_OP_MIDDLE(X) (X & 0x0F) namespace MMU2 { @@ -23,11 +23,11 @@ enum class ButtonOperations : uint8_t { }; /// Button codes + extended actions performed on the printer's side -enum Buttons : uint8_t { +enum class Buttons : uint_least8_t { Right = 0, Middle, Left, - + // performed on the printer's side ResetMMU, Load, @@ -35,9 +35,12 @@ enum Buttons : uint8_t { StopPrint, DisableMMU, TuneMMU, // Printer changes MMU register value - + NoButton = 0xff // shall be kept last }; +constexpr uint_least8_t buttons_to_uint8t(Buttons b) { + return static_cast(b); +} } // namespace MMU2 diff --git a/Firmware/mmu2_marlin.h b/Firmware/mmu2_marlin.h index 0990fdbc2..40aeee0f2 100644 --- a/Firmware/mmu2_marlin.h +++ b/Firmware/mmu2_marlin.h @@ -44,6 +44,9 @@ bool marlin_printingIsActive(); void marlin_manage_heater(); void marlin_manage_inactivity(bool b); void marlin_idle(bool b); +void marlin_refresh_print_state_in_ram(); +void marlin_clear_print_state_in_ram(); +void marlin_stop_and_save_print_to_ram(); int16_t thermal_degTargetHotend(); int16_t thermal_degHotend(); diff --git a/Firmware/mmu2_marlin1.cpp b/Firmware/mmu2_marlin1.cpp index 05a9bf05e..3a7dfa837 100644 --- a/Firmware/mmu2_marlin1.cpp +++ b/Firmware/mmu2_marlin1.cpp @@ -101,6 +101,18 @@ void marlin_idle(bool b){ manage_inactivity(b); } +void marlin_refresh_print_state_in_ram(){ + refresh_print_state_in_ram(); +} + +void marlin_clear_print_state_in_ram(){ + clear_print_state_in_ram(); +} + +void marlin_stop_and_save_print_to_ram(){ + stop_and_save_print_to_ram(0,0); +} + int16_t thermal_degTargetHotend() { return degTargetHotend(0); }