Prusa MINI Firmware overview
|
Go to the documentation of this file.
28 #include "../sd/cardreader.h"
29 #include "../module/printcounter.h"
30 #include "../module/planner.h"
31 #include "../module/stepper.h"
32 #include "../gcode/queue.h"
34 #include "../inc/MarlinConfig.h"
36 #if ENABLED(EXTENSIBLE_UI)
37 #include "../lcd/extensible_ui/ui_api.h"
40 #if ENABLED(ADVANCED_PAUSE_FEATURE)
45 #ifndef FILAMENT_RUNOUT_THRESHOLD
46 #define FILAMENT_RUNOUT_THRESHOLD 5
55 #if ENABLED(HOST_ACTION_COMMANDS)
62 template<
class RESPONSE_T,
class SENSOR_T>
65 typedef RESPONSE_T response_t;
66 typedef SENSOR_T sensor_t;
67 static response_t response;
68 static sensor_t sensor;
84 response.filament_present(extruder);
87 #ifdef FILAMENT_RUNOUT_DISTANCE_MM
88 static inline float& runout_distance() {
return response.runout_distance_mm; }
89 static inline void set_runout_distance(
const float &mm) { response.runout_distance_mm = mm; }
96 response.block_completed(
b);
97 sensor.block_completed(
b);
102 static inline void run() {
108 #ifdef FILAMENT_RUNOUT_DISTANCE_MM
113 const bool ran_out = response.has_run_out();
114 #ifdef FILAMENT_RUNOUT_DISTANCE_MM
134 #if ENABLED(FIL_RUNOUT_PULLUP)
135 #define INIT_RUNOUT_PIN(P) SET_INPUT_PULLUP(P)
136 #elif ENABLED(FIL_RUNOUT_PULLDOWN)
137 #define INIT_RUNOUT_PIN(P) SET_INPUT_PULLDOWN(P)
139 #define INIT_RUNOUT_PIN(P) SET_INPUT(P)
143 #if NUM_RUNOUT_SENSORS > 1
145 #if NUM_RUNOUT_SENSORS > 2
147 #if NUM_RUNOUT_SENSORS > 3
149 #if NUM_RUNOUT_SENSORS > 4
151 #if NUM_RUNOUT_SENSORS > 5
167 | (
READ(FIL_RUNOUT3_PIN) ?
_BV(2) : 0)
169 | (
READ(FIL_RUNOUT4_PIN) ?
_BV(3) : 0)
171 | (
READ(FIL_RUNOUT5_PIN) ?
_BV(4) : 0)
173 | (
READ(FIL_RUNOUT6_PIN) ?
_BV(5) : 0)
194 #if ENABLED(FILAMENT_MOTION_SENSOR)
204 static uint8_t motion_detected;
206 static inline void poll_motion_sensor() {
209 change = old_state ^ new_state;
210 old_state = new_state;
212 #ifdef FILAMENT_RUNOUT_SENSOR_DEBUG
221 motion_detected |= change;
225 static inline void block_completed(
const block_t*
const b) {
228 if (
TEST(motion_detected,
b->extruder))
235 static inline void run() { poll_motion_sensor(); }
246 static inline bool poll_runout_state(
const uint8_t extruder) {
249 #if NUM_RUNOUT_SENSORS == 1
256 && (dual_x_carriage_mode == DXC_DUPLICATION_MODE || dual_x_carriage_mode == DXC_MIRRORED_MODE)
257 #elif
ENABLED(MULTI_NOZZLE_DUPLICATION)
263 )
return runout_states;
265 #if NUM_RUNOUT_SENSORS > 1
266 return TEST(runout_states, extruder);
273 static inline void run() {
276 #ifdef FILAMENT_RUNOUT_SENSOR_DEBUG
277 static bool was_out =
false;
278 if (out != was_out) {
288 #endif // !FILAMENT_MOTION_SENSOR
292 #ifdef FILAMENT_RUNOUT_DISTANCE_MM
297 class RunoutResponseDelayed {
299 static volatile float runout_mm_countdown[
EXTRUDERS];
302 static float runout_distance_mm;
304 static inline void reset() {
308 static inline void run() {
309 #ifdef FILAMENT_RUNOUT_SENSOR_DEBUG
323 static inline bool has_run_out() {
327 static inline void filament_present(
const uint8_t extruder) {
328 runout_mm_countdown[extruder] = runout_distance_mm;
331 static inline void block_completed(
const block_t*
const b) {
332 if (
b->steps.x ||
b->steps.y ||
b->steps.z
339 const int32_t steps =
b->steps.e;
345 #else // !FILAMENT_RUNOUT_DISTANCE_MM
353 static int8_t runout_count;
355 static inline void reset() { runout_count = runout_threshold; }
356 static inline void run() {
if (runout_count >= 0) runout_count--; }
362 #endif // !FILAMENT_RUNOUT_DISTANCE_MM
367 #ifdef FILAMENT_RUNOUT_DISTANCE_MM
368 RunoutResponseDelayed,
369 #if ENABLED(FILAMENT_MOTION_SENSOR)
370 FilamentSensorEncoder
#define SERIAL_CHAR(x)
Definition: serial.h:69
static uint8_t poll_runout_pins()
Definition: runout.h:161
static void synchronize()
Definition: planner.cpp:1556
void host_action_prompt_end()
Definition: marlin_server.cpp:1047
#define SERIAL_ECHO(x)
Definition: serial.h:70
static void filament_present(const uint8_t)
Definition: runout.h:359
GCodeQueue queue
Definition: queue.cpp:28
void host_action(const char *const pstr, const bool eol=true)
Definition: marlin_server.cpp:959
static void block_completed(const block_t *const)
Definition: runout.h:358
static void block_completed(const block_t *const)
Definition: runout.h:271
static bool filament_ran_out
Definition: runout.h:53
uint8_t i
Definition: screen_test_graph.c:72
#define FIL_RUNOUT2_PIN
Definition: pins_GT2560_V3.h:83
uint32_t millis(void)
Definition: wiring_time.c:29
#define INIT_RUNOUT_PIN(P)
bool extruder_duplication_enabled
Definition: motion.cpp:876
#define FILAMENT_RUNOUT_THRESHOLD
Definition: runout.h:46
#define E_AXIS_N(E)
Definition: Conditionals_LCD.h:454
static void block_completed(const block_t *const b)
Definition: runout.h:94
static void reset()
Definition: runout.h:355
#define PSTR(str)
Definition: pgmspace.h:31
TFilamentMonitor< RunoutResponseDebounced, FilamentSensorSwitch > FilamentMonitor
Definition: runout.h:377
#define LOOP_L_N(VAR, N)
Definition: types.h:58
#define DISABLED(V...)
Definition: macros.h:178
static void reset()
Definition: runout.h:76
static void run()
Definition: runout.h:273
#define SERIAL_ECHOPGM(S)
Definition: serial.h:173
void event_filament_runout()
#define NUM_RUNOUT_SENSORS
Definition: pins_FORMBOT_TREX3.h:132
#define ELAPSED(NOW, SOON)
Definition: millis_t.h:29
const uint8_t[]
Definition: 404_html.c:3
#define _BV(bit)
Definition: wiring_constants.h:99
static float steps_to_mm[XYZE_N]
Definition: planner.h:254
#define FIL_RUNOUT_PIN
Definition: pins_RAMPS_LINUX.h:216
static uint8_t poll_runout_states()
Definition: runout.h:183
#define EXTRUDERS
Definition: Configuration_A3ides_2209_MINI.h:148
static void filament_present(const uint8_t extruder)
#define ADVANCED_PAUSE_FEATURE
Definition: Configuration_A3ides_2209_MINI_adv.h:1311
#define SERIAL_EOL()
Definition: serial.h:181
void host_action_paused(const bool eol)
Definition: marlin_server.cpp:1021
static bool enabled
Definition: runout.h:53
#define TEST(n, b)
Definition: macros.h:81
static void setup()
Definition: runout.h:133
void onFilamentRunout(const extruder_t extruder)
Definition: marlin_server.cpp:894
void host_action_pause(const bool eol)
Definition: marlin_server.cpp:1009
bool printingIsActive()
Definition: Marlin.cpp:349
static void inject_P(PGM_P const pgcode)
Definition: queue.cpp:206
static constexpr bool host_handling
Definition: runout.h:58
static bool has_run_out()
Definition: runout.h:357
void serialprintPGM(PGM_P str)
Definition: serial.cpp:35
static void run()
Definition: runout.h:356
void host_action_prompt_show()
Definition: marlin_server.cpp:1053
static void filament_present(const uint8_t extruder)
Definition: runout.h:83
static void setup()
Definition: runout.h:71
list b
Definition: createSpeedLookupTable.py:30
#define READ(IO)
Definition: fastio.h:95
#define UNUSED(X)
Definition: stm32f4xx_hal_def.h:74
uint32_t millis_t
Definition: millis_t.h:26
static void run()
Definition: runout.h:102
constexpr uint8_t active_extruder
Definition: motion.h:107
#define ENABLED(V...)
Definition: macros.h:177
void host_action_prompt_begin(const char *const pstr, const bool eol)
Definition: marlin_server.cpp:1033
Planner planner
Definition: planner.cpp:111
PromptReason host_prompt_reason
Definition: marlin_server.cpp:77