Prusa MINI Firmware overview
wizard_load_unload.c File Reference
#include "wizard_load_unload.h"
#include "wizard_ui.h"
#include "window_dlg_load.h"
#include "window_dlg_unload.h"
#include "window_dlg_preheat.h"
#include "filament.h"
#include "filament_sensor.h"

Macros

#define FKNOWN   0x01
 
#define F_NOTSENSED   0x02
 

Functions

LD_UNLD_STATE_t _decide_continue_load_unload ()
 
LD_UNLD_STATE_t wizard_load_unload (LD_UNLD_STATE_t state)
 

Macro Definition Documentation

◆ FKNOWN

#define FKNOWN   0x01

◆ F_NOTSENSED

#define F_NOTSENSED   0x02

Function Documentation

◆ _decide_continue_load_unload()

LD_UNLD_STATE_t _decide_continue_load_unload ( )
16  {
17  uint8_t filament = 0;
18  filament |= get_filament() != FILAMENT_NONE ? FKNOWN : 0;
19  filament |= fs_get_state() == FS_NO_FILAMENT ? F_NOTSENSED : 0;
20  uint16_t def_bt = filament == (FKNOWN | F_NOTSENSED) ? MSGBOX_DEF_BUTTON2 : MSGBOX_DEF_BUTTON1;
21  switch (filament){
22  case FKNOWN:{//known and not "unsensed" - do not allow load
23  const char *btns[2] = { "NEXT", "UNLOAD" };
24  switch (wizard_msgbox_btns(
25  "To calibrate with \n"
26  "currently loaded \n"
27  "filament, \n"
28  "press NEXT. \n"
29  "To change filament,\n"
30  "press UNLOAD.",
31  MSGBOX_BTN_CUSTOM2, 0, btns)) {
32  case MSGBOX_RES_CUSTOM0:
33  return LD_UNLD_DONE;
34  case MSGBOX_RES_CUSTOM1:
35  return LD_UNLD_DIALOG_UNLOAD;
36  default:
37  //should not happen
39  }
40  }
41  case FKNOWN | F_NOTSENSED://allow load, prepick UNLOAD, force ask preheat
42  case F_NOTSENSED://allow load, prepick LOAD, force ask preheat
43  case 0://filament is not known but is sensed == most likely same as F_NOTSENSED, but user inserted filament into sensor
44  default:{
45  //cannot use CONTINUE button, string is too long
46  const char *btns[3] = { "NEXT", "LOAD", "UNLOAD" };
47  switch (wizard_msgbox_btns(
48  "To calibrate with \n"
49  "currently loaded \n"
50  "filament, \n"
51  "press NEXT. \n"
52  "To load filament, \n"
53  "press LOAD. \n"
54  "To change filament,\n"
55  "press UNLOAD.",
56  MSGBOX_BTN_CUSTOM3 | def_bt, 0, btns)) {
57  case MSGBOX_RES_CUSTOM0:
59  case MSGBOX_RES_CUSTOM1:
60  return LD_UNLD_DIALOG_LOAD;
61  case MSGBOX_RES_CUSTOM2:
62  return LD_UNLD_DIALOG_UNLOAD;
63  default:
64  //should not happen
66  }
67  }
68  }
69 
70 
71  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wizard_load_unload()

LD_UNLD_STATE_t wizard_load_unload ( LD_UNLD_STATE_t  state)
74  {
75  switch (state) {
76  case LD_UNLD_INIT:
78 
82  gui_dlg_preheat_forced("Select filament type");
83  return LD_UNLD_DONE;
84 
86  switch (gui_dlg_load_forced()) {
87  case DLG_OK:
88  return LD_UNLD_DONE;
89  case DLG_ABORTED:
91  }
92 
94  switch (gui_dlg_unload_forced()) {
95  case DLG_OK:
96  return LD_UNLD_DIALOG_LOAD;
97  case DLG_ABORTED:
99  }
100 
101  case LD_UNLD_DONE:
102  default:
103  return state;
104  }
105 
106  //dlg_load
107 }
Here is the call graph for this function:
Here is the caller graph for this function:
LD_UNLD_MSG_DECIDE_CONTINUE_LOAD_UNLOAD
Definition: wizard_load_unload.h:11
_decide_continue_load_unload
LD_UNLD_STATE_t _decide_continue_load_unload()
Definition: wizard_load_unload.c:16
LD_UNLD_DIALOG_PREHEAT
Definition: wizard_load_unload.h:12
FILAMENT_NONE
Definition: filament.h:26
MSGBOX_RES_CUSTOM1
#define MSGBOX_RES_CUSTOM1
Definition: window_msgbox.h:50
MSGBOX_DEF_BUTTON2
#define MSGBOX_DEF_BUTTON2
Definition: window_msgbox.h:56
state
static volatile fsensor_t state
Definition: filament_sensor.c:23
wizard_msgbox_btns
int wizard_msgbox_btns(const char *text, uint16_t flags, uint16_t id_icon, const char **buttons)
Definition: wizard_ui.c:52
MSGBOX_DEF_BUTTON1
#define MSGBOX_DEF_BUTTON1
Definition: window_msgbox.h:55
MSGBOX_RES_CUSTOM2
#define MSGBOX_RES_CUSTOM2
Definition: window_msgbox.h:51
DLG_ABORTED
Definition: dlg_result.h:11
get_filament
FILAMENT_t get_filament()
Definition: filament.cpp:41
F_NOTSENSED
#define F_NOTSENSED
Definition: wizard_load_unload.c:13
gui_dlg_preheat_forced
int gui_dlg_preheat_forced(const char *caption)
Definition: window_dlg_preheat.c:152
FS_NO_FILAMENT
Definition: filament_sensor.h:20
fs_get_state
fsensor_t fs_get_state()
Definition: filament_sensor.c:67
MSGBOX_RES_CUSTOM0
#define MSGBOX_RES_CUSTOM0
Definition: window_msgbox.h:49
gui_dlg_load_forced
dlg_result_t gui_dlg_load_forced(void)
Definition: window_dlg_load.c:124
gui_dlg_unload_forced
dlg_result_t gui_dlg_unload_forced(void)
Definition: window_dlg_unload.c:31
LD_UNLD_DONE
Definition: wizard_load_unload.h:15
uint8_t
const uint8_t[]
Definition: 404_html.c:3
DLG_OK
Definition: dlg_result.h:10
MSGBOX_BTN_CUSTOM3
#define MSGBOX_BTN_CUSTOM3
Definition: window_msgbox.h:28
FKNOWN
#define FKNOWN
Definition: wizard_load_unload.c:12
LD_UNLD_INIT
Definition: wizard_load_unload.h:10
MSGBOX_BTN_CUSTOM2
#define MSGBOX_BTN_CUSTOM2
Definition: window_msgbox.h:27
LD_UNLD_DIALOG_LOAD
Definition: wizard_load_unload.h:13
LD_UNLD_DIALOG_UNLOAD
Definition: wizard_load_unload.h:14