Prusa MINI Firmware overview
window_dlg_unload.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"
#include "filament.h"

Functions

static dlg_result_t _gui_dlg_unload (void)
 
dlg_result_t gui_dlg_unload (void)
 
dlg_result_t gui_dlg_unload_forced (void)
 
static int f_UL_GCODE (_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
 
static int f_UL_WAIT_E_POS__RAM_RETRACTING (_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
 
static int f_UL_WAIT_E_POS__RAMMING (_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
 
static int f_UL_WAIT_E_POS__UNLOADING (_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
 

Variables

static const _cl_dlg cl_unload
 
static const _dlg_state unload_states []
 

Function Documentation

◆ _gui_dlg_unload()

static dlg_result_t _gui_dlg_unload ( void  )
static
14  {
15  _dlg_ld_vars ld_vars;
16  memset(&ld_vars, '\0', sizeof(ld_vars));
17  ld_vars.z_min_extr_pos = 10;
18  dlg_result_t ret = _gui_dlg(&cl_unload, &ld_vars, 300000); //5min
20  return ret;
21 
22 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ gui_dlg_unload()

dlg_result_t gui_dlg_unload ( void  )
24  {
25  //todo must be called inside _gui_dlg, but nested dialogs are not supported now
27  return DLG_ABORTED; //user can choose "RETURN"
28  return _gui_dlg_unload();
29 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ gui_dlg_unload_forced()

dlg_result_t gui_dlg_unload_forced ( void  )
31  {
32  //todo must be called inside _gui_dlg, but nested dialogs are not supported now
33  if (gui_dlg_preheat_autoselect_if_able_forced("PREHEAT for UNLOAD") < 0)
34  return DLG_ABORTED; //LD_ABORTED should not happen
35  return _gui_dlg_unload();
36 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f_UL_GCODE()

static int f_UL_GCODE ( _dlg_vars p_vars,
_dlg_ld_vars additional_vars 
)
static
41  {
42  marlin_gcode("M702 Z0");
43  p_vars->phase++;
44  p_vars->flags |= DLG_CH_CMD; //kill screen after M702 ends
45  return 0;
46 }
Here is the call graph for this function:

◆ f_UL_WAIT_E_POS__RAM_RETRACTING()

static int f_UL_WAIT_E_POS__RAM_RETRACTING ( _dlg_vars p_vars,
_dlg_ld_vars additional_vars 
)
static
50  {
51  // 0 ... -8
52  if ( //todo unprecise
53  (additional_vars->p_marlin_vars->pos[MARLIN_VAR_INDEX_E] < -7.9F) || (additional_vars->p_marlin_vars->pos[MARLIN_VAR_INDEX_E] > 0.0F) //this part should not happen, just to be safe
54  )
55  p_vars->phase++;
56 
57  float ret = 100.0F * (-additional_vars->p_marlin_vars->pos[MARLIN_VAR_INDEX_E]) / 8;
58  if (ret >= 100)
59  return 100;
60  if (ret <= 0)
61  return 0;
62  return ret;
63 }

◆ f_UL_WAIT_E_POS__RAMMING()

static int f_UL_WAIT_E_POS__RAMMING ( _dlg_vars p_vars,
_dlg_ld_vars additional_vars 
)
static
65  {
66  // -8 ... 8
67  if ( //todo unprecise
68  additional_vars->p_marlin_vars->pos[MARLIN_VAR_INDEX_E] > 4.0F
69  //(p_vars->p_marlin_vars->pos[MARLIN_VAR_INDEX_E] > 7.9F) ||
70  //(p_vars->p_marlin_vars->pos[MARLIN_VAR_INDEX_E] < -8.1F) //this part should not happen, just to be safe
71  )
72  p_vars->phase++;
73 
74  float ret = 100.0F * (8.0F + additional_vars->p_marlin_vars->pos[MARLIN_VAR_INDEX_E]) / (8 + 8);
75 
76  if (ret >= 100)
77  return 100;
78  if (ret <= 0)
79  return 0;
80  return ret;
81 }

◆ f_UL_WAIT_E_POS__UNLOADING()

static int f_UL_WAIT_E_POS__UNLOADING ( _dlg_vars p_vars,
_dlg_ld_vars additional_vars 
)
static
83  {
84  // 8 ... -392
85  if (additional_vars->p_marlin_vars->pos[MARLIN_VAR_INDEX_E] < -391.9F)
86  p_vars->phase++;
87  return 100 * (8.0F - additional_vars->p_marlin_vars->pos[MARLIN_VAR_INDEX_E]) / (392 + 8);
88 }

Variable Documentation

◆ cl_unload

static const _cl_dlg cl_unload
static
Initial value:
= {
"Unloading filament",
sizeof(unload_states) / sizeof(unload_states[0]),
NULL,
}

◆ unload_states

f_UL_WAIT_E_POS__RAM_RETRACTING
static int f_UL_WAIT_E_POS__RAM_RETRACTING(_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
Definition: window_dlg_unload.c:50
f_SH_on_loop
loop_result_t f_SH_on_loop(_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
Definition: window_dlg_loadunload_shared.c:47
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_UL_GCODE
static int f_UL_GCODE(_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
Definition: window_dlg_unload.c:41
_gui_dlg
dlg_result_t _gui_dlg(const _cl_dlg *_ths, void *p_additional_vars, int32_t ttl)
Definition: window_dlg_statemachine.c:257
set_filament
void set_filament(FILAMENT_t filament)
Definition: filament.cpp:32
f_UL_WAIT_E_POS__RAMMING
static int f_UL_WAIT_E_POS__RAMMING(_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
Definition: window_dlg_unload.c:65
FILAMENT_NONE
Definition: filament.h:26
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
cl_unload
static const _cl_dlg cl_unload
Definition: window_dlg_unload.c:12
f_SH_INIT
int f_SH_INIT(_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
Definition: window_dlg_loadunload_shared.c:67
_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
NULL
#define NULL
Definition: usbd_def.h:53
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
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
f_UL_WAIT_E_POS__UNLOADING
static int f_UL_WAIT_E_POS__UNLOADING(_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
Definition: window_dlg_unload.c:83
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
f_SH_WAIT_E_STOPPED
int f_SH_WAIT_E_STOPPED(_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
Definition: window_dlg_loadunload_shared.c:119
DLG_ABORTED
Definition: dlg_result.h:11
bt_stop_dis
const _dlg_button_t bt_stop_dis
Definition: window_dlg_loadunload_shared.c:25
_dlg_ld_vars
Definition: window_dlg_loadunload_shared.h:13
marlin_gcode
void marlin_gcode(const char *gcode)
Definition: marlin_client.c:195
dlg_result_t
dlg_result_t
Definition: dlg_result.h:9
f_SH_on_load
void f_SH_on_load(void)
Definition: window_dlg_loadunload_shared.c:42
DLG_CH_CMD
#define DLG_CH_CMD
Definition: window_dlg_statemachine.h:20
bt_stop_ena
const _dlg_button_t bt_stop_ena
Definition: window_dlg_loadunload_shared.c:20
_marlin_vars_t::pos
float pos[4]
Definition: marlin_vars.h:82
gui_dlg_preheat_autoselect_if_able_forced
int gui_dlg_preheat_autoselect_if_able_forced(const char *caption)
Definition: window_dlg_preheat.c:163
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
f_SH_on_timeout
void f_SH_on_timeout(void)
Definition: window_dlg_loadunload_shared.c:59
_gui_dlg_unload
static dlg_result_t _gui_dlg_unload(void)
Definition: window_dlg_unload.c:14
unload_states
static const _dlg_state unload_states[]
Definition: window_dlg_unload.c:93