Prusa MINI Firmware overview
fwretract.h
Go to the documentation of this file.
1 /**
2  * Marlin 3D Printer Firmware
3  * Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4  *
5  * Based on Sprinter and grbl.
6  * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 #pragma once
23 
24 /**
25  * fwretract.h - Define firmware-based retraction interface
26  */
27 
28 #include "../inc/MarlinConfigPre.h"
29 
30 typedef struct {
31  float retract_length; // M207 S - G10 Retract length
32  feedRate_t retract_feedrate_mm_s; // M207 F - G10 Retract feedrate
33  float retract_zraise, // M207 Z - G10 Retract hop size
34  retract_recover_extra; // M208 S - G11 Recover length
35  feedRate_t retract_recover_feedrate_mm_s; // M208 F - G11 Recover feedrate
36  float swap_retract_length, // M207 W - G10 Swap Retract length
37  swap_retract_recover_extra; // M208 W - G11 Swap Recover length
38  feedRate_t swap_retract_recover_feedrate_mm_s; // M208 R - G11 Swap Recover feedrate
40 
41 #if ENABLED(FWRETRACT)
42 
43 class FWRetract {
44 private:
45  #if EXTRUDERS > 1
46  static bool retracted_swap[EXTRUDERS]; // Which extruders are swap-retracted
47  #endif
48 
49 public:
51 
52  #if ENABLED(FWRETRACT_AUTORETRACT)
53  static bool autoretract_enabled; // M209 S - Autoretract switch
54  #else
55  static constexpr bool autoretract_enabled = false;
56  #endif
57 
58  static bool retracted[EXTRUDERS]; // Which extruders are currently retracted
59  static float current_retract[EXTRUDERS], // Retract value used by planner
60  current_hop; // Hop value used by planner
61 
62  FWRetract() { reset(); }
63 
64  static void reset();
65 
66  static void refresh_autoretract() {
67  LOOP_L_N(i, EXTRUDERS) retracted[i] = false;
68  }
69 
70  static void enable_autoretract(const bool enable) {
71  #if ENABLED(FWRETRACT_AUTORETRACT)
72  autoretract_enabled = enable;
73  refresh_autoretract();
74  #endif
75  }
76 
77  static void retract(const bool retracting
78  #if EXTRUDERS > 1
79  , bool swapping = false
80  #endif
81  );
82 };
83 
84 extern FWRetract fwretract;
85 
86 #endif // FWRETRACT
mixer
Mixer mixer
planner_settings_t::max_feedrate_mm_s
feedRate_t max_feedrate_mm_s[XYZE_N]
Definition: planner.h:182
settings
MarlinSettings settings
Definition: configuration_store.cpp:344
fwretract_settings_t::retract_feedrate_mm_s
feedRate_t retract_feedrate_mm_s
Definition: fwretract.h:32
XYZEval::e
T e
Definition: types.h:383
fwretract_settings_t::retract_zraise
float retract_zraise
Definition: fwretract.h:33
i
uint8_t i
Definition: screen_test_graph.c:72
fwretract_settings_t::swap_retract_recover_feedrate_mm_s
feedRate_t swap_retract_recover_feedrate_mm_s
Definition: fwretract.h:38
destination
xyze_pos_t destination
Definition: motion.cpp:110
fwretract_settings_t::retract_length
float retract_length
Definition: fwretract.h:31
feedRate_t
float feedRate_t
Definition: types.h:80
prepare_internal_move_to_destination
void prepare_internal_move_to_destination(const feedRate_t &fr_mm_s=0.0f)
Definition: motion.h:186
current_position
xyze_pos_t current_position
Definition: motion.cpp:102
LOOP_L_N
#define LOOP_L_N(VAR, N)
Definition: types.h:58
mixing.h
sync_plan_position_e
void sync_plan_position_e()
Definition: motion.cpp:221
uint8_t
const uint8_t[]
Definition: 404_html.c:3
fwretract_settings_t
Definition: fwretract.h:30
Mixer::T
static FORCE_INLINE void T(const uint_fast8_t c)
Definition: mixing.h:113
Z_AXIS
Definition: types.h:39
EXTRUDERS
#define EXTRUDERS
Definition: Configuration_A3ides_2209_MINI.h:148
fwretract_settings_t::retract_recover_feedrate_mm_s
feedRate_t retract_recover_feedrate_mm_s
Definition: fwretract.h:35
Planner::settings
static planner_settings_t settings
Definition: planner.h:251
Mixer::get_current_vtool
static FORCE_INLINE uint8_t get_current_vtool()
Definition: mixing.h:111
active_extruder
constexpr uint8_t active_extruder
Definition: motion.h:107
fwretract_settings_t::swap_retract_recover_extra
float swap_retract_recover_extra
Definition: fwretract.h:36
ENABLED
#define ENABLED(V...)
Definition: macros.h:177
planner
Planner planner
Definition: planner.cpp:111
fwretract.h