Prusa MINI Firmware overview
screen_menu_filament.c File Reference
#include "gui.h"
#include "screen_menu.h"
#include "filament.h"
#include "filament_sensor.h"
#include "marlin_client.h"
#include "menu_vars.h"
#include "window_dlg_load.h"
#include "window_dlg_unload.h"
#include "window_dlg_purge.h"
#include "dbg.h"

Macros

#define FKNOWN   0x01
 
#define F_NOTSENSED   0x02
 

Enumerations

enum  MI_t {
  MI_RETURN, MI_RETURN, MI_WIZARD, MI_Z_OFFSET,
  MI_AUTO_HOME, MI_MESH_BED, MI_SELFTEST, MI_CALIB_FIRST,
  MI_RETURN, MI_LOAD, MI_UNLOAD, MI_CHANGE,
  MI_PURGE, MI_RETURN, MI_ALWAYS, MI_ON_RESTART,
  MI_COUNT, MI_RETURN, MI_SYS_INFO, MI_VERSIONS,
  MI_RETURN, MI_MOVE_X, MI_MOVE_Y, MI_MOVE_Z,
  MI_MOVE_E, MI_RETURN, MI_SYS_RESET, MI_CLR_EEPROM,
  MI_WDG_TEST, MI_PLL, MI_SSCG, MI_SSCG_FREQ,
  MI_SSCG_DEPTH, MI_SPI_PRESC, MI_MESH, MI_BSOD,
  MI_BSOD_HARD_FAULT, MI_COUNT, MI_RETURN, MI_TEMPERATURE,
  MI_MOVE_AXIS, MI_DISABLE_STEP, MI_FACTORY_DEFAULTS, MI_FW_UPDATE,
  MI_FILAMENT_SENSOR, MI_TIMEOUT, MI_LAN_SETTINGS, MI_RETURN,
  MI_NOZZLE, MI_HEATBED, MI_PRINTFAN, MI_COOLDOWN,
  MI_RETURN, MI_NOZZLE, MI_HEAT_PWM_PERIOD, MI_HEATBED,
  MI_FAN_PWM_PERIOD, MI_PRINTFAN, MI_COOLDOWN, MI_COUNT
}
 

Functions

static void _load_dis (screen_t *screen)
 
static void _load_ena (screen_t *screen)
 
static void _change_dis (screen_t *screen)
 
static void _change_ena (screen_t *screen)
 
static void _deactivate_item (screen_t *screen)
 
void screen_menu_filament_init (screen_t *screen)
 
int screen_menu_filament_event (screen_t *screen, window_t *window, uint8_t event, void *param)
 

Variables

screen_t screen_menu_preheat
 
screen_t screen_preheating
 
const menu_item_t _menu_filament_items []
 
screen_t screen_menu_filament
 
const screen_tpscreen_menu_filament = &screen_menu_filament
 

Macro Definition Documentation

◆ FKNOWN

#define FKNOWN   0x01

◆ F_NOTSENSED

#define F_NOTSENSED   0x02

Enumeration Type Documentation

◆ MI_t

enum MI_t
Enumerator
MI_RETURN 
MI_RETURN 
MI_WIZARD 
MI_Z_OFFSET 
MI_AUTO_HOME 
MI_MESH_BED 
MI_SELFTEST 
MI_CALIB_FIRST 
MI_RETURN 
MI_LOAD 
MI_UNLOAD 
MI_CHANGE 
MI_PURGE 
MI_RETURN 
MI_ALWAYS 
MI_ON_RESTART 
MI_COUNT 
MI_RETURN 
MI_SYS_INFO 
MI_VERSIONS 
MI_RETURN 
MI_MOVE_X 
MI_MOVE_Y 
MI_MOVE_Z 
MI_MOVE_E 
MI_RETURN 
MI_SYS_RESET 
MI_CLR_EEPROM 
MI_WDG_TEST 
MI_PLL 
MI_SSCG 
MI_SSCG_FREQ 
MI_SSCG_DEPTH 
MI_SPI_PRESC 
MI_MESH 
MI_BSOD 
MI_BSOD_HARD_FAULT 
MI_COUNT 
MI_RETURN 
MI_TEMPERATURE 
MI_MOVE_AXIS 
MI_DISABLE_STEP 
MI_FACTORY_DEFAULTS 
MI_FW_UPDATE 
MI_FILAMENT_SENSOR 
MI_TIMEOUT 
MI_LAN_SETTINGS 
MI_RETURN 
MI_NOZZLE 
MI_HEATBED 
MI_PRINTFAN 
MI_COOLDOWN 
MI_RETURN 
MI_NOZZLE 
MI_HEAT_PWM_PERIOD 
MI_HEATBED 
MI_FAN_PWM_PERIOD 
MI_PRINTFAN 
MI_COOLDOWN 
MI_COUNT 
20  {
21  MI_RETURN,
22  MI_LOAD,
23  MI_UNLOAD,
24  MI_CHANGE,
25  MI_PURGE,
26 } MI_t;

Function Documentation

◆ _load_dis()

static void _load_dis ( screen_t screen)
static
36  {
37  psmd->items[MI_LOAD].item.type |= WI_DISABLED;
38 }
Here is the caller graph for this function:

◆ _load_ena()

static void _load_ena ( screen_t screen)
static
40  {
41  psmd->items[MI_LOAD].item.type &= ~WI_DISABLED;
42 }
Here is the caller graph for this function:

◆ _change_dis()

static void _change_dis ( screen_t screen)
static
43  {
44  psmd->items[MI_CHANGE].item.type |= WI_DISABLED;
45 }
Here is the caller graph for this function:

◆ _change_ena()

static void _change_ena ( screen_t screen)
static
46  {
47  psmd->items[MI_CHANGE].item.type &= ~WI_DISABLED;
48 }
Here is the caller graph for this function:

◆ _deactivate_item()

static void _deactivate_item ( screen_t screen)
static
50  {
51 
52  uint8_t filament = 0;
53  filament |= get_filament() != FILAMENT_NONE ? FKNOWN : 0;
54  filament |= fs_get_state() == FS_NO_FILAMENT ? F_NOTSENSED : 0;
55  switch (filament){
56  case FKNOWN://known and not "unsensed" - do not allow load
57  _load_dis(screen);
58  _change_ena(screen);
59  break;
60  case FKNOWN | F_NOTSENSED://allow both load and change
61  _load_ena(screen);
62  _change_ena(screen);
63  break;
64  case F_NOTSENSED://allow load
65  case 0://filament is not known but is sensed == most likely same as F_NOTSENSED, but user inserted filament into sensor
66  default:
67  _load_ena(screen);
68  _change_dis(screen);
69  break;
70  }
71 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ screen_menu_filament_init()

void screen_menu_filament_init ( screen_t screen)
73  {
74  //filament_not_loaded = -1;
75  int count = sizeof(_menu_filament_items) / sizeof(menu_item_t);
76  screen_menu_init(screen, "FILAMENT", count + 1, 1, 0);
77  psmd->items[0] = menu_item_return;
78  memcpy(psmd->items + 1, _menu_filament_items, count * sizeof(menu_item_t));
79  _deactivate_item(screen);
80 }
Here is the call graph for this function:

◆ screen_menu_filament_event()

int screen_menu_filament_event ( screen_t screen,
window_t window,
uint8_t  event,
void param 
)
83  {
84  _deactivate_item(screen);
85  if (event == WINDOW_EVENT_CLICK)
86  if(!(psmd->items[(int)param].item.type & WI_DISABLED))
87  switch ((int)param) {
88  case MI_LOAD:
89  p_window_header_set_text(&(psmd->header), "LOAD FILAMENT");
90  gui_dlg_load();
91  p_window_header_set_text(&(psmd->header), "FILAMENT");
92  break;
93  case MI_UNLOAD:
94  p_window_header_set_text(&(psmd->header), "UNLOAD FILAM.");
96  p_window_header_set_text(&(psmd->header), "FILAMENT");
97  break;
98  case MI_CHANGE:
99  p_window_header_set_text(&(psmd->header), "CHANGE FILAM.");
100  gui_dlg_unload();
101  gui_dlg_load();
102  p_window_header_set_text(&(psmd->header), "FILAMENT");
103  break;
104  case MI_PURGE:
105  p_window_header_set_text(&(psmd->header), "PURGE FILAM.");
106  gui_dlg_purge();
107  p_window_header_set_text(&(psmd->header), "FILAMENT");
108  break;
109  }
110  return screen_menu_event(screen, window, event, param);
111 }
Here is the call graph for this function:

Variable Documentation

◆ screen_menu_preheat

screen_t screen_menu_preheat

◆ screen_preheating

screen_t screen_preheating

◆ _menu_filament_items

const menu_item_t _menu_filament_items[]
Initial value:
= {
{ { "Load Filament", 0, WI_LABEL }, SCREEN_MENU_NO_SCREEN },
{ { "Unload Filament", 0, WI_LABEL }, SCREEN_MENU_NO_SCREEN },
{ { "Change Filament", 0, WI_LABEL }, SCREEN_MENU_NO_SCREEN },
{ { "Purge Filament", 0, WI_LABEL }, SCREEN_MENU_NO_SCREEN },
}

◆ screen_menu_filament

◆ pscreen_menu_filament

const screen_t* pscreen_menu_filament = &screen_menu_filament
_menu_item_t
Definition: screen_menu.h:19
gui_dlg_unload
dlg_result_t gui_dlg_unload(void)
Definition: window_dlg_unload.c:24
screen_menu_draw
void screen_menu_draw(screen_t *screen)
Definition: screen_menu.c:90
_load_dis
static void _load_dis(screen_t *screen)
Definition: screen_menu_filament.c:36
FILAMENT_NONE
Definition: filament.h:26
screen_menu_event
int screen_menu_event(screen_t *screen, window_t *window, uint8_t event, void *param)
Definition: screen_menu.c:92
MI_CHANGE
Definition: screen_menu_filament.c:24
screen_menu_done
void screen_menu_done(screen_t *screen)
Definition: screen_menu.c:78
MI_t
MI_t
Definition: screen_menu_filament.c:20
SCREEN_MENU_NO_SCREEN
#define SCREEN_MENU_NO_SCREEN
Definition: screen_menu.h:39
gui_dlg_load
dlg_result_t gui_dlg_load(void)
Definition: window_dlg_load.c:117
_menu_filament_items
const menu_item_t _menu_filament_items[]
Definition: screen_menu_filament.c:28
MI_RETURN
Definition: screen_menu_filament.c:21
screen_menu_filament_event
int screen_menu_filament_event(screen_t *screen, window_t *window, uint8_t event, void *param)
Definition: screen_menu_filament.c:83
screen_menu_init
void screen_menu_init(screen_t *screen, const char *label, int count, uint8_t footer, uint8_t help)
Definition: screen_menu.c:25
gui_dlg_purge
dlg_result_t gui_dlg_purge(void)
Definition: window_dlg_purge.c:26
WI_DISABLED
Definition: window_menu.h:20
MI_UNLOAD
Definition: screen_menu_filament.c:23
get_filament
FILAMENT_t get_filament()
Definition: filament.cpp:41
FS_NO_FILAMENT
Definition: filament_sensor.h:20
fs_get_state
fsensor_t fs_get_state()
Definition: filament_sensor.c:67
psmd
#define psmd
Definition: screen_menu.h:40
_change_ena
static void _change_ena(screen_t *screen)
Definition: screen_menu_filament.c:46
WI_LABEL
Definition: window_menu.h:14
uint8_t
const uint8_t[]
Definition: 404_html.c:3
MI_PURGE
Definition: screen_menu_filament.c:25
menu_item_return
const menu_item_t menu_item_return
Definition: screen_menu.c:14
_deactivate_item
static void _deactivate_item(screen_t *screen)
Definition: screen_menu_filament.c:50
WINDOW_EVENT_CLICK
#define WINDOW_EVENT_CLICK
Definition: window.h:46
screen_menu_data_t
Definition: screen_menu.h:24
_change_dis
static void _change_dis(screen_t *screen)
Definition: screen_menu_filament.c:43
FKNOWN
#define FKNOWN
Definition: screen_menu_filament.c:14
MI_LOAD
Definition: screen_menu_filament.c:22
screen_menu_filament_init
void screen_menu_filament_init(screen_t *screen)
Definition: screen_menu_filament.c:73
p_window_header_set_text
void p_window_header_set_text(window_header_t *window, const char *text)
Definition: window_header.c:152
F_NOTSENSED
#define F_NOTSENSED
Definition: screen_menu_filament.c:15
_load_ena
static void _load_ena(screen_t *screen)
Definition: screen_menu_filament.c:40