Prusa MINI Firmware overview
window_dlg_loadunload_shared.h File Reference

Go to the source code of this file.

Classes

struct  _dlg_ld_vars
 

Macros

#define LD_BT_DONE   DLG_DI_US0
 
#define LD_BT_PURG   DLG_DI_US1
 
#define LD_BT_PURG_SEL   DLG_DI_US2
 

Functions

void f_SH_on_load (void)
 
loop_result_t f_SH_on_loop (_dlg_vars *p_vars, _dlg_ld_vars *p_additional_vars)
 
void f_SH_on_timeout ()
 
int f_SH_INIT (_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
 
int f_SH_MOVE_INITIAL_Z (_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
 
int f_SH_WAIT_INITIAL_Z_MOTION (_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
 
int f_SH_WAIT_INITIAL_Z_STOPPED (_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
 
int f_SH_WAIT_E_MOTION (_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
 
int f_SH_WAIT_E_STOPPED (_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
 
int f_SH_WAIT_TEMP (_dlg_vars *p_vars, _dlg_ld_vars *additional_vars)
 
void window_dlg_load_draw_buttons (window_dlg_statemachine_t *window, int is_donelhs_purgerhs)
 
void window_dlg_load_event_cb (window_dlg_statemachine_t *window, uint8_t event, void *param)
 
void window_dlg_load_event_inverted_cb (window_dlg_statemachine_t *window, uint8_t event, void *param)
 

Variables

const float ld_purge_amount
 
const _dlg_button_t bt_stop_ena
 
const _dlg_button_t bt_stop_dis
 
const _dlg_button_t bt_cont_ena
 
const _dlg_button_t bt_cont_dis
 
const _dlg_button_t bt_none
 

Macro Definition Documentation

◆ LD_BT_DONE

#define LD_BT_DONE   DLG_DI_US0

◆ LD_BT_PURG

#define LD_BT_PURG   DLG_DI_US1

◆ LD_BT_PURG_SEL

#define LD_BT_PURG_SEL   DLG_DI_US2

Function Documentation

◆ f_SH_on_load()

void f_SH_on_load ( void  )
Here is the call graph for this function:

◆ f_SH_on_loop()

loop_result_t f_SH_on_loop ( _dlg_vars p_vars,
_dlg_ld_vars p_additional_vars 
)
47  {
48  //after M70X is sent i must check marlin_command()
49  //0 == M70X ended - dialog has no reason to exist anymore
51  return LOOP_RESULT_BREAK;
52  }
53 
54  additional_vars->p_marlin_vars = marlin_update_vars(
56  return LOOP_RESULT_CONTINUE;
57 }
Here is the call graph for this function:

◆ f_SH_on_timeout()

void f_SH_on_timeout ( )
Here is the call graph for this function:

◆ f_SH_INIT()

int f_SH_INIT ( _dlg_vars p_vars,
_dlg_ld_vars additional_vars 
)
67  {
68  marlin_gcode("G92 E0"); //saves calculation
70  p_vars->phase++;
71  return 0;
72 }
Here is the call graph for this function:

◆ f_SH_MOVE_INITIAL_Z()

int f_SH_MOVE_INITIAL_Z ( _dlg_vars p_vars,
_dlg_ld_vars additional_vars 
)
74  {
75  additional_vars->initial_move = additional_vars->z_min_extr_pos - additional_vars->z_start;
76 
77  if (_was_move(additional_vars)) {
78  marlin_gcode_printf("G0 Z%f", (double)additional_vars->z_min_extr_pos); //move to start pos
79  additional_vars->z_start = additional_vars->z_min_extr_pos; //set new start pos
80  }
81  p_vars->phase++;
82  return 0;
83 }
Here is the call graph for this function:

◆ f_SH_WAIT_INITIAL_Z_MOTION()

int f_SH_WAIT_INITIAL_Z_MOTION ( _dlg_vars p_vars,
_dlg_ld_vars additional_vars 
)
85  {
86  if (_was_move(additional_vars)) {
87  //did move
88  //wait Z motion
89  if (additional_vars->p_marlin_vars->motion & MARLIN_VAR_MOTION_MSK_Z)
90  p_vars->phase++;
91  } else {
92  //no move, skip this part
93  p_vars->phase++;
94  }
95  return 0;
96 }
Here is the call graph for this function:

◆ f_SH_WAIT_INITIAL_Z_STOPPED()

int f_SH_WAIT_INITIAL_Z_STOPPED ( _dlg_vars p_vars,
_dlg_ld_vars additional_vars 
)
98  {
99  if (_was_move(additional_vars)) {
100  //did move, wait Z stopped
101  if ((additional_vars->p_marlin_vars->motion & MARLIN_VAR_MOTION_MSK_Z) == 0)
102  p_vars->phase++;
103 
104  return 100.F * (additional_vars->p_marlin_vars->pos[MARLIN_VAR_INDEX_Z] - additional_vars->z_start) / additional_vars->initial_move;
105  } else {
106  //no move, skip this part
107  p_vars->phase++;
108  }
109  return 0;
110 }
Here is the call graph for this function:

◆ f_SH_WAIT_E_MOTION()

int f_SH_WAIT_E_MOTION ( _dlg_vars p_vars,
_dlg_ld_vars additional_vars 
)
112  {
113  //wait E motion
114  if (additional_vars->p_marlin_vars->motion & MARLIN_VAR_MOTION_MSK_E)
115  p_vars->phase++;
116  return 0;
117 }

◆ f_SH_WAIT_E_STOPPED()

int f_SH_WAIT_E_STOPPED ( _dlg_vars p_vars,
_dlg_ld_vars additional_vars 
)
119  {
120  //wait Z stopped
121  if ((additional_vars->p_marlin_vars->motion & MARLIN_VAR_MOTION_MSK_E) == 0)
122  p_vars->phase++;
123  return 0;
124 }

◆ f_SH_WAIT_TEMP()

int f_SH_WAIT_TEMP ( _dlg_vars p_vars,
_dlg_ld_vars additional_vars 
)
126  {
127  //wait E temp
128  float min_temp = additional_vars->p_marlin_vars->target_nozzle - 10.0F;
129  float diff_temp = additional_vars->p_marlin_vars->temp_nozzle - min_temp;
130  if (diff_temp > 0) {
131  p_vars->phase++;
132  return 100;
133  } else {
134  //200 degrrees diff == 0%
135  diff_temp = 100.0F + diff_temp / 2;
136  if (diff_temp > 99.0F)
137  return 99;
138  if (diff_temp < 0.0F)
139  return 0;
140  return (int)diff_temp;
141  }
142 }

◆ window_dlg_load_draw_buttons()

void window_dlg_load_draw_buttons ( window_dlg_statemachine_t window,
int  is_donelhs_purgerhs 
)
23  {
25  int is_enabled = window->_ths->p_states[window->vars.phase].p_button->flags & BT_ENABLED;
26 
27  const char *bt_caption = window->_ths->p_states[window->vars.phase].p_button->labels[0];
28  int is_active = ((window->vars.flags & LD_BT_PURG_SEL) != 0) != (is_donelhs_purgerhs != 0);
29  int16_t btn_width = rc_btn.w / 2 - gui_defaults.btn_spacing;
30 
31  rc_btn.w = btn_width;
32  //lhs button
33  button_draw(rc_btn, bt_caption, window->font_title, is_active && is_enabled);
34 
35  //more difficult calculations of coords to avoid round errors
36 
37  //space between buttons
38  rc_btn.x += btn_width;
39  rc_btn.w = _get_dlg_statemachine_button_size(window).w - rc_btn.w * 2;
40  display->fill_rect(rc_btn, window->color_back);
41 
42  //distance of both buttons from screen sides is same
43  rc_btn.x += rc_btn.w;
44  rc_btn.w = btn_width;
45  is_active = !is_active;
46  bt_caption = window->_ths->p_states[window->vars.phase].p_button->labels[1];
47  //rhs button
48  button_draw(rc_btn, bt_caption, window->font_title, is_active && is_enabled);
49 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ window_dlg_load_event_cb()

void window_dlg_load_event_cb ( window_dlg_statemachine_t window,
uint8_t  event,
void param 
)
56  {
57  uint8_t *p_flags = &window->vars.flags;
58  switch (event) {
60  case WINDOW_EVENT_CLICK:
61  if ((*p_flags) & LD_BT_PURG_SEL)
62  window->vars.flags |= LD_BT_PURG; //set purge button
63  else
64  window->vars.flags |= LD_BT_DONE; //set done button
65  return;
67  if ((*p_flags) & LD_BT_PURG_SEL) {
68  (*p_flags) &= ~LD_BT_PURG_SEL;
69  set_repaint_btn_flg(window); //set window flag - wil repaint buttons
70  }
71  return;
73  if (!((*p_flags) & LD_BT_PURG_SEL)) {
74  (*p_flags) |= LD_BT_PURG_SEL;
75  set_repaint_btn_flg(window); //set window flag - wil repaint buttons
76  }
77  return;
78  }
79 }
Here is the call graph for this function:

◆ window_dlg_load_event_inverted_cb()

void window_dlg_load_event_inverted_cb ( window_dlg_statemachine_t window,
uint8_t  event,
void param 
)
83  {
84  uint8_t *p_flags = &window->vars.flags;
85  switch (event) {
87  case WINDOW_EVENT_CLICK:
88  if ((*p_flags) & LD_BT_PURG_SEL)
89  window->vars.flags |= LD_BT_PURG; //set purge button
90  else
91  window->vars.flags |= LD_BT_DONE; //set done button
92  return;
94  if ((*p_flags) & LD_BT_PURG_SEL) {
95  (*p_flags) &= ~LD_BT_PURG_SEL;
96  set_repaint_btn_flg(window); //set window flag - wil repaint buttons
97  }
98  return;
100  if (!((*p_flags) & LD_BT_PURG_SEL)) {
101  (*p_flags) |= LD_BT_PURG_SEL;
102  set_repaint_btn_flg(window); //set window flag - wil repaint buttons
103  }
104  return;
105  }
106 }
Here is the call graph for this function:

Variable Documentation

◆ ld_purge_amount

const float ld_purge_amount

◆ bt_stop_ena

const _dlg_button_t bt_stop_ena

◆ bt_stop_dis

const _dlg_button_t bt_stop_dis

◆ bt_cont_ena

const _dlg_button_t bt_cont_ena

◆ bt_cont_dis

const _dlg_button_t bt_cont_dis

◆ bt_none

_window_dlg_statemachine_t::_ths
const _cl_dlg * _ths
Definition: window_dlg_statemachine.h:97
_cl_dlg::p_states
const _dlg_state * p_states
Definition: window_dlg_statemachine.h:79
BT_ENABLED
#define BT_ENABLED
Definition: window_dlg_statemachine.h:15
_window_dlg_statemachine_t::color_back
color_t color_back
Definition: window_dlg_statemachine.h:89
_rect_ui16_t::w
uint16_t w
Definition: guitypes.h:72
_dlg_vars::flags
uint8_t flags
Definition: window_dlg_statemachine.h:38
set_repaint_btn_flg
void set_repaint_btn_flg(window_dlg_statemachine_t *window)
Definition: window_dlg_statemachine.c:49
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
WINDOW_EVENT_ENC_UP
#define WINDOW_EVENT_ENC_UP
Definition: window.h:41
_dlg_ld_vars::z_start
float z_start
Definition: window_dlg_loadunload_shared.h:18
_dlg_vars::phase
int8_t phase
Definition: window_dlg_statemachine.h:39
F
#define F(str)
Definition: UHS_macros.h:164
LD_BT_PURG
#define LD_BT_PURG
Definition: window_dlg_loadunload_shared.h:29
_display_t::fill_rect
display_fill_rect_t * fill_rect
Definition: display.h:33
_window_dlg_statemachine_t::vars
_dlg_vars vars
Definition: window_dlg_statemachine.h:98
_marlin_vars_t::temp_nozzle
float temp_nozzle
Definition: marlin_vars.h:83
_dlg_ld_vars::z_min_extr_pos
float z_min_extr_pos
Definition: window_dlg_loadunload_shared.h:16
button_draw
void button_draw(rect_ui16_t rc_btn, const char *text, font_t *pf, int is_selected)
Definition: button_draw.c:5
LOOP_RESULT_BREAK
Definition: window_dlg_statemachine.h:52
_was_move
int _was_move(_dlg_ld_vars *additional_vars)
Definition: window_dlg_loadunload_shared.c:63
_window_dlg_statemachine_t::font_title
font_t * font_title
Definition: window_dlg_statemachine.h:92
MARLIN_VAR_TEMP_NOZ
#define MARLIN_VAR_TEMP_NOZ
Definition: marlin_vars.h:19
MARLIN_EVT_CommandEnd
#define MARLIN_EVT_CommandEnd
Definition: marlin_events.h:34
LOOP_RESULT_CONTINUE
Definition: window_dlg_statemachine.h:51
_marlin_vars_t::target_nozzle
float target_nozzle
Definition: marlin_vars.h:85
_dlg_button_t::flags
uint8_t flags
Definition: window_dlg_statemachine.h:62
_gui_defaults_t::btn_spacing
uint8_t btn_spacing
Definition: guitypes.h:115
marlin_gcode
void marlin_gcode(const char *gcode)
Definition: marlin_client.c:195
MARLIN_VAR_POS_Z
#define MARLIN_VAR_POS_Z
Definition: marlin_vars.h:17
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
_rect_ui16_t
Definition: guitypes.h:69
uint8_t
const uint8_t[]
Definition: 404_html.c:3
MARLIN_VAR_MSK
#define MARLIN_VAR_MSK(v_id)
Definition: marlin_vars.h:35
display
display_t * display
Definition: display.c:6
_dlg_state::p_button
const _dlg_button_t * p_button
Definition: window_dlg_statemachine.h:72
WINDOW_EVENT_CLICK
#define WINDOW_EVENT_CLICK
Definition: window.h:46
DLG_CH_CMD
#define DLG_CH_CMD
Definition: window_dlg_statemachine.h:20
_rect_ui16_t::x
uint16_t x
Definition: guitypes.h:70
MARLIN_VAR_INDEX_Z
#define MARLIN_VAR_INDEX_Z
Definition: marlin_vars.h:66
_marlin_vars_t::pos
float pos[4]
Definition: marlin_vars.h:82
gui_defaults
gui_defaults_t gui_defaults
Definition: gui.c:20
MARLIN_VAR_TTEM_NOZ
#define MARLIN_VAR_TTEM_NOZ
Definition: marlin_vars.h:21
WINDOW_EVENT_BTN_DN
#define WINDOW_EVENT_BTN_DN
Definition: window.h:38
_get_dlg_statemachine_button_size
rect_ui16_t _get_dlg_statemachine_button_size(window_dlg_statemachine_t *window)
Definition: window_dlg_statemachine.c:78
MARLIN_VAR_MOTION_MSK_E
#define MARLIN_VAR_MOTION_MSK_E
Definition: marlin_vars.h:71
_dlg_button_t::labels
const char ** labels
Definition: window_dlg_statemachine.h:61
_dlg_ld_vars::p_marlin_vars
marlin_vars_t * p_marlin_vars
Definition: window_dlg_loadunload_shared.h:15
marlin_gcode_printf
int marlin_gcode_printf(const char *format,...)
Definition: marlin_client.c:206
WINDOW_EVENT_ENC_DN
#define WINDOW_EVENT_ENC_DN
Definition: window.h:40
_dlg_ld_vars::initial_move
float initial_move
Definition: window_dlg_loadunload_shared.h:17
LD_BT_DONE
#define LD_BT_DONE
Definition: window_dlg_loadunload_shared.h:28
_marlin_vars_t::motion
uint8_t motion
Definition: marlin_vars.h:78
marlin_event_clr
int marlin_event_clr(uint8_t evt_id)
Definition: marlin_client.c:252
MARLIN_VAR_MOTION_MSK_Z
#define MARLIN_VAR_MOTION_MSK_Z
Definition: marlin_vars.h:70