Prusa MINI Firmware overview
window_dlg_purge.c File Reference
#include "window_dlg_statemachine.h"
#include "marlin_client.h"
#include "menu_vars.h"
#include "stm32f4xx_hal.h"
#include <limits.h>
#include "window_dlg_preheat.h"
#include "window_dlg_loadunload_shared.h"

Functions

void window_dlg_purge_draw_buttons_cb (window_dlg_statemachine_t *window)
 
static dlg_result_t _gui_dlg_purge (void)
 
dlg_result_t gui_dlg_purge (void)
 
static int f_PU_GCODE (_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
 
static int f_PU_PURGE_USER_INTERACTION (_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
 
static int f_PU_PURGE_SHOW_PROGRESS (_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
 
static int f_PU_WAIT_READY (_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
 
static int f_PU_PREPICK_PURGE_BTN (_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
 
static void purge_done (void)
 
static loop_result_t purge_loop (_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
 

Variables

const float ld_purge_amount
 
static const _cl_dlg cl_purge
 
static const char * txt_prgdn [] = { "PURGE", "DONE" }
 
const _dlg_button_t bt_prgdn_ena
 
const _dlg_button_t bt_prgdn_dis
 
static const _dlg_state purge_states []
 

Function Documentation

◆ window_dlg_purge_draw_buttons_cb()

void window_dlg_purge_draw_buttons_cb ( window_dlg_statemachine_t window)
15  {
17 }
Here is the call graph for this function:

◆ _gui_dlg_purge()

static dlg_result_t _gui_dlg_purge ( void  )
static
19  {
20  _dlg_ld_vars ld_vars;
21  memset(&ld_vars, '\0', sizeof(ld_vars));
22  ld_vars.z_min_extr_pos = 30;
23  return _gui_dlg(&cl_purge, &ld_vars, 600000); //10min
24 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ gui_dlg_purge()

dlg_result_t gui_dlg_purge ( void  )
26  {
27  //todo must be called inside
29  return DLG_ABORTED; //user can choose "RETURN"
30  return _gui_dlg_purge();
31 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f_PU_GCODE()

static int f_PU_GCODE ( _dlg_vars p_vars,
_dlg_ld_vars additional_vars 
)
static
36  {
37  marlin_gcode("M83"); //extruder relative mode
38  marlin_gcode("G21"); //set units to millimeters
39  p_vars->phase++;
40  return 0;
41 }
Here is the call graph for this function:

◆ f_PU_PURGE_USER_INTERACTION()

static int f_PU_PURGE_USER_INTERACTION ( _dlg_vars p_vars,
_dlg_ld_vars additional_vars 
)
static
43  {
44  switch (p_vars->flags & (LD_BT_PURG | LD_BT_DONE)) {
45  case LD_BT_PURG:
46  additional_vars->e_last = additional_vars->p_marlin_vars->pos[MARLIN_VAR_INDEX_E]; //needed in next phase
47  marlin_gcode("G1 E40 F200");
48  p_vars->phase++; //f_LD_PURGE_SHOW_PROGRESS
49  break;
50  case LD_BT_DONE:
51  case (LD_BT_DONE | LD_BT_PURG): //if both buttons are clicked DONE has priority, but should not happen
52  p_vars->phase += 2; //DONE
53  break;
54  }
55  return 100; //progressbar MUST be 100
56 }
Here is the call graph for this function:

◆ f_PU_PURGE_SHOW_PROGRESS()

static int f_PU_PURGE_SHOW_PROGRESS ( _dlg_vars p_vars,
_dlg_ld_vars additional_vars 
)
static
58  {
59  float ret = 100.0F * (additional_vars->p_marlin_vars->pos[MARLIN_VAR_INDEX_E] - additional_vars->e_last)
61  if (ret > 99.5F) {
62  p_vars->phase--; //jump back to f_LD_PURGE_USER_INTERACTION
63  p_vars->flags &= (~(LD_BT_PURG | LD_BT_DONE | LD_BT_PURG_SEL)); //clr buttons, select done
64  return 100;
65  }
66  return (int)ret;
67 }

◆ f_PU_WAIT_READY()

static int f_PU_WAIT_READY ( _dlg_vars p_vars,
_dlg_ld_vars additional_vars 
)
static
69  {
70  //wait ready
71  if (!marlin_busy())
72  p_vars->phase = -1;
73  return 0;
74 }
Here is the call graph for this function:

◆ f_PU_PREPICK_PURGE_BTN()

static int f_PU_PREPICK_PURGE_BTN ( _dlg_vars p_vars,
_dlg_ld_vars additional_vars 
)
static
76  {
77  p_vars->flags |= LD_BT_PURG_SEL; // default button is purge
78  p_vars->phase++;
79  return 0;
80 }

◆ purge_done()

static void purge_done ( void  )
static
106  {
107  marlin_gcode("M84"); // disable motors
108 }
Here is the call graph for this function:

◆ purge_loop()

static loop_result_t purge_loop ( _dlg_vars p_vars,
_dlg_ld_vars additional_vars 
)
static
111  {
112  //todo do I need all those variables?
113  additional_vars->p_marlin_vars = marlin_update_vars(
115  return LOOP_RESULT_CONTINUE;
116 }
Here is the call graph for this function:

Variable Documentation

◆ ld_purge_amount

const float ld_purge_amount

◆ cl_purge

static const _cl_dlg cl_purge
static
Initial value:
= {
"Purge nozzle",
sizeof(purge_states) / sizeof(purge_states[0]),
NULL,
NULL,
}

◆ txt_prgdn

const char* txt_prgdn[] = { "PURGE", "DONE" }
static

◆ bt_prgdn_ena

◆ bt_prgdn_dis

const _dlg_button_t bt_prgdn_dis

◆ purge_states

BT_ENABLED
#define BT_ENABLED
Definition: window_dlg_statemachine.h:15
f_SH_WAIT_INITIAL_Z_STOPPED
int f_SH_WAIT_INITIAL_Z_STOPPED(_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
Definition: window_dlg_loadunload_shared.c:98
_dlg_vars::flags
uint8_t flags
Definition: window_dlg_statemachine.h:38
MARLIN_VAR_INDEX_E
#define MARLIN_VAR_INDEX_E
Definition: marlin_vars.h:67
f_PU_PURGE_USER_INTERACTION
static int f_PU_PURGE_USER_INTERACTION(_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
Definition: window_dlg_purge.c:43
bt_none
const _dlg_button_t bt_none
Definition: window_dlg_loadunload_shared.c:38
_gui_dlg
dlg_result_t _gui_dlg(const _cl_dlg *_ths, void *p_additional_vars, int32_t ttl)
Definition: window_dlg_statemachine.c:257
f_SH_WAIT_TEMP
int f_SH_WAIT_TEMP(_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
Definition: window_dlg_loadunload_shared.c:126
MARLIN_VAR_MOTION
#define MARLIN_VAR_MOTION
Definition: marlin_vars.h:8
LD_BT_PURG_SEL
#define LD_BT_PURG_SEL
Definition: window_dlg_loadunload_shared.h:30
cl_purge
static const _cl_dlg cl_purge
Definition: window_dlg_purge.c:13
window_dlg_load_event_inverted_cb
void window_dlg_load_event_inverted_cb(window_dlg_statemachine_t *window, uint8_t event, void *param)
Definition: window_dlg_load.c:83
f_SH_INIT
int f_SH_INIT(_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
Definition: window_dlg_loadunload_shared.c:67
window_dlg_load_draw_buttons
void window_dlg_load_draw_buttons(window_dlg_statemachine_t *window, int is_donelhs_purgerhs)
Definition: window_dlg_load.c:22
f_PU_PURGE_SHOW_PROGRESS
static int f_PU_PURGE_SHOW_PROGRESS(_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
Definition: window_dlg_purge.c:58
_dlg_ld_vars::e_last
float e_last
Definition: window_dlg_loadunload_shared.h:20
f_PU_PREPICK_PURGE_BTN
static int f_PU_PREPICK_PURGE_BTN(_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
Definition: window_dlg_purge.c:76
_dlg_vars::phase
int8_t phase
Definition: window_dlg_statemachine.h:39
window_dlg_statemachine_draw_progress_tot
void window_dlg_statemachine_draw_progress_tot(window_dlg_statemachine_t *window)
Definition: window_dlg_statemachine.c:144
window_dlg_statemachine_draw_progress_part
void window_dlg_statemachine_draw_progress_part(window_dlg_statemachine_t *window)
Definition: window_dlg_statemachine.c:150
NULL
#define NULL
Definition: usbd_def.h:53
F
#define F(str)
Definition: UHS_macros.h:164
f_SH_MOVE_INITIAL_Z
int f_SH_MOVE_INITIAL_Z(_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
Definition: window_dlg_loadunload_shared.c:74
purge_states
static const _dlg_state purge_states[]
Definition: window_dlg_purge.c:93
dlg_loop_cb_t
loop_result_t(* dlg_loop_cb_t)(_dlg_vars *p_vars, void *p_additional_vars)
Definition: window_dlg_statemachine.h:57
LD_BT_PURG
#define LD_BT_PURG
Definition: window_dlg_loadunload_shared.h:29
window_dlg_purge_draw_buttons_cb
void window_dlg_purge_draw_buttons_cb(window_dlg_statemachine_t *window)
Definition: window_dlg_purge.c:15
dlg_state_func
int(* dlg_state_func)(_dlg_vars *p_vars, void *p_additional_vars)
Definition: window_dlg_statemachine.h:55
gui_dlg_preheat_autoselect_if_able
int gui_dlg_preheat_autoselect_if_able(const char *caption)
Definition: window_dlg_preheat.c:135
_dlg_ld_vars::z_min_extr_pos
float z_min_extr_pos
Definition: window_dlg_loadunload_shared.h:16
purge_loop
static loop_result_t purge_loop(_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
Definition: window_dlg_purge.c:111
f_PU_WAIT_READY
static int f_PU_WAIT_READY(_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
Definition: window_dlg_purge.c:69
MARLIN_VAR_TEMP_NOZ
#define MARLIN_VAR_TEMP_NOZ
Definition: marlin_vars.h:19
LOOP_RESULT_CONTINUE
Definition: window_dlg_statemachine.h:51
DLG_ABORTED
Definition: dlg_result.h:11
ld_purge_amount
const float ld_purge_amount
Definition: window_dlg_loadunload_shared.c:14
marlin_busy
int marlin_busy(void)
Definition: marlin_client.c:152
f_PU_GCODE
static int f_PU_GCODE(_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
Definition: window_dlg_purge.c:36
purge_done
static void purge_done(void)
Definition: window_dlg_purge.c:106
_dlg_ld_vars
Definition: window_dlg_loadunload_shared.h:13
marlin_gcode
void marlin_gcode(const char *gcode)
Definition: marlin_client.c:195
MARLIN_VAR_POS_E
#define MARLIN_VAR_POS_E
Definition: marlin_vars.h:18
marlin_update_vars
marlin_vars_t * marlin_update_vars(uint64_t msk)
Definition: marlin_client.c:368
MARLIN_VAR_MSK
#define MARLIN_VAR_MSK(v_id)
Definition: marlin_vars.h:35
window_dlg_statemachine_draw_progress_none
void window_dlg_statemachine_draw_progress_none(window_dlg_statemachine_t *window)
Definition: window_dlg_statemachine.c:156
txt_prgdn
static const char * txt_prgdn[]
Definition: window_dlg_purge.c:84
bt_stop_ena
const _dlg_button_t bt_stop_ena
Definition: window_dlg_loadunload_shared.c:20
_gui_dlg_purge
static dlg_result_t _gui_dlg_purge(void)
Definition: window_dlg_purge.c:19
_marlin_vars_t::pos
float pos[4]
Definition: marlin_vars.h:82
MARLIN_VAR_TTEM_NOZ
#define MARLIN_VAR_TTEM_NOZ
Definition: marlin_vars.h:21
f_SH_WAIT_INITIAL_Z_MOTION
int f_SH_WAIT_INITIAL_Z_MOTION(_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
Definition: window_dlg_loadunload_shared.c:85
_dlg_ld_vars::p_marlin_vars
marlin_vars_t * p_marlin_vars
Definition: window_dlg_loadunload_shared.h:15
bt_prgdn_ena
const _dlg_button_t bt_prgdn_ena
Definition: window_dlg_purge.c:85
LD_BT_DONE
#define LD_BT_DONE
Definition: window_dlg_loadunload_shared.h:28