Prusa MINI Firmware overview
screen_menu.c File Reference
#include "screen_menu.h"
#include "config.h"
#include "stdlib.h"

Functions

void window_set_capture (int16_t id)
 
void screen_menu_item (window_menu_t *pwindow_menu, uint16_t index, window_menu_item_t **ppitem, void *data)
 
void screen_menu_init (screen_t *screen, const char *label, int count, uint8_t footer, uint8_t help)
 
void screen_menu_done (screen_t *screen)
 
void screen_menu_draw (screen_t *screen)
 
int screen_menu_event (screen_t *screen, window_t *window, uint8_t event, void *param)
 

Variables

const menu_item_t menu_item_return
 

Function Documentation

◆ window_set_capture()

void window_set_capture ( int16_t  id)
500  {
501  window_t *window;
502  if ((window = window_ptr(id)) != 0) {
503  if (window->f_visible && window->f_enabled && window->event) {
504  if (window_capture_ptr) {
508  }
509  window_capture_ptr = window;
510  window->f_capture = 1;
511  window->event(window, WINDOW_EVENT_CAPT_1, 0);
512  gui_invalidate();
513  }
514  }
515 }
Here is the caller graph for this function:

◆ screen_menu_item()

void screen_menu_item ( window_menu_t pwindow_menu,
uint16_t  index,
window_menu_item_t **  ppitem,
void data 
)
20  {
21  screen_t *screen = (screen_t *)data;
22  *ppitem = &(psmd->items[index].item);
23 }
Here is the caller graph for this function:

◆ screen_menu_init()

void screen_menu_init ( screen_t screen,
const char *  label,
int  count,
uint8_t  footer,
uint8_t  help 
)
26  {
27  psmd->items = (menu_item_t *)malloc(sizeof(menu_item_t) * count);
28  memset(psmd->items, '\0', sizeof(menu_item_t) * count);
29 
30  rect_ui16_t menu_rect = rect_ui16(10, 32, 220, 278);
31  if (help) {
32  menu_rect.h -= 115;
33  }
34  if (footer) {
35  menu_rect.h -= 41;
36  }
37 
38  int16_t id;
39  int16_t root = window_create_ptr(WINDOW_CLS_FRAME, -1,
40  rect_ui16(0, 0, 0, 0),
41  &(psmd->root));
42  window_disable(root);
43 
45  rect_ui16(0, 0, 240, 31), &(psmd->header));
46  // p_window_header_set_icon(&(psmd->header), IDR_PNG_status_icon_menu);
47  p_window_header_set_text(&(psmd->header), label);
48 
50  menu_rect, &(psmd->menu));
51  psmd->menu.padding = padding_ui8(20, 6, 2, 6);
52  psmd->menu.icon_rect = rect_ui16(0, 0, 16, 30);
53  psmd->menu.count = count;
54  psmd->menu.menu_items = screen_menu_item;
55  psmd->menu.data = (void *)screen;
56  //window_set_item_index(id, 1); // 0 = return
57  window_set_capture(id); // set capture to list
58  window_set_focus(id);
59 
60  if (help) {
61  psmd->phelp = (window_text_t *)gui_malloc(sizeof(window_text_t));
63  (footer) ? rect_ui16(10, 154, 220, 115) : rect_ui16(10, 195, 220, 115),
64  psmd->phelp);
65  psmd->phelp->font = resource_font(IDR_FNT_SPECIAL);
66  } else {
67  psmd->phelp = NULL;
68  }
69 
70  if (footer) {
71  psmd->pfooter = (status_footer_t *)gui_malloc(sizeof(status_footer_t));
72  status_footer_init(psmd->pfooter, root);
73  } else {
74  psmd->pfooter = NULL;
75  }
76 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ screen_menu_done()

void screen_menu_done ( screen_t screen)
78  {
79  window_destroy(psmd->root.win.id);
80  if (psmd->phelp) {
81  free(psmd->phelp);
82  }
83 
84  if (psmd->pfooter) {
85  free(psmd->pfooter);
86  }
87  free(psmd->items);
88 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ screen_menu_draw()

void screen_menu_draw ( screen_t screen)
90 {}

◆ screen_menu_event()

int screen_menu_event ( screen_t screen,
window_t window,
uint8_t  event,
void param 
)
93  {
94  if (psmd->pfooter) {
95  status_footer_event(psmd->pfooter, window, event, param);
96  }
97 
98  window_header_events(&(psmd->header));
99 
100  if (event != WINDOW_EVENT_CLICK) {
101  return 0;
102  }
103 
104  const menu_item_t *item = &(psmd->items[(int)param]);
105  if (!(item->item.type & WI_DISABLED) && item->screen == SCREEN_MENU_RETURN) {
106  screen_close();
107  return 1;
108  }
109 
110  if (!(item->item.type & WI_DISABLED) && item->screen != SCREEN_MENU_NO_SCREEN) {
111  screen_open(item->screen->id);
112  return 1;
113  }
114  return 0;
115 }
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ menu_item_return

const menu_item_t menu_item_return
Initial value:
WINDOW_EVENT_CAPT_0
#define WINDOW_EVENT_CAPT_0
Definition: window.h:44
window_ptr
window_t * window_ptr(int16_t id)
Definition: window.c:82
_window_text_t
Definition: window_text.h:15
WINDOW_EVENT_CAPT_1
#define WINDOW_EVENT_CAPT_1
Definition: window.h:45
_menu_item_t
Definition: screen_menu.h:19
_window_t::f_enabled
uint32_t f_enabled
Definition: window.h:86
window_header_events
#define window_header_events(window)
Definition: window_header.h:72
_menu_item_t::screen
screen_t * screen
Definition: screen_menu.h:21
rect_ui16
static rect_ui16_t rect_ui16(uint16_t x, uint16_t y, uint16_t w, uint16_t h)
Definition: guitypes.h:159
gui_malloc
void * gui_malloc(unsigned int size)
Definition: gui.c:35
data
uint8_t data[8]
Definition: masstorage.h:49
window_destroy
void window_destroy(int16_t id)
Definition: window.c:132
padding_ui8
static padding_ui8_t padding_ui8(uint8_t l, uint8_t t, uint8_t r, uint8_t b)
Definition: guitypes.h:164
createSpeedLookupTable.help
help
Definition: createSpeedLookupTable.py:15
IDR_FNT_SPECIAL
#define IDR_FNT_SPECIAL
Definition: resource.h:13
SCREEN_MENU_NO_SCREEN
#define SCREEN_MENU_NO_SCREEN
Definition: screen_menu.h:39
screen_open
void screen_open(int16_t screen_id)
Definition: screen.c:62
NULL
#define NULL
Definition: usbd_def.h:53
screen_close
void screen_close(void)
Definition: screen.c:80
window_disable
void window_disable(int16_t id)
Definition: window.c:523
gui_invalidate
void gui_invalidate(void)
Definition: gui.c:66
WI_DISABLED
Definition: window_menu.h:20
_menu_item_t::item
window_menu_item_t item
Definition: screen_menu.h:20
SCREEN_MENU_RETURN
#define SCREEN_MENU_RETURN
Definition: screen_menu.h:38
_window_t
Definition: window.h:76
WINDOW_CLS_FRAME
#define WINDOW_CLS_FRAME
Definition: window.h:9
WINDOW_CLS_MENU
#define WINDOW_CLS_MENU
Definition: window.h:18
window_set_focus
void window_set_focus(int16_t id)
Definition: window.c:480
window_set_capture
void window_set_capture(int16_t id)
Definition: window.c:500
psmd
#define psmd
Definition: screen_menu.h:40
IDR_PNG_filescreen_icon_up_folder
#define IDR_PNG_filescreen_icon_up_folder
Definition: resource.h:42
_rect_ui16_t
Definition: guitypes.h:69
WI_LABEL
Definition: window_menu.h:14
_rect_ui16_t::h
uint16_t h
Definition: guitypes.h:73
_screen_t
Definition: screen.h:18
_window_t::f_capture
uint32_t f_capture
Definition: window.h:90
WINDOW_CLS_TEXT
#define WINDOW_CLS_TEXT
Definition: window.h:10
resource_font
font_t * resource_font(uint16_t id)
Definition: guitypes.c:186
_window_t::f_visible
uint32_t f_visible
Definition: window.h:85
_window_menu_item_t::type
uint16_t type
Definition: window_menu.h:65
WINDOW_EVENT_CLICK
#define WINDOW_EVENT_CLICK
Definition: window.h:46
_window_t::event
window_event_t * event
Definition: window.h:102
window_create_ptr
int16_t window_create_ptr(int16_t cls_id, int16_t id_parent, rect_ui16_t rect, void *ptr)
Definition: window.c:102
window_capture_ptr
window_t * window_capture_ptr
Definition: window.c:21
_screen_t::id
int16_t id
Definition: screen.h:19
createSpeedLookupTable.int
int
Definition: createSpeedLookupTable.py:15
WINDOW_CLS_HEADER
int16_t WINDOW_CLS_HEADER
Definition: window_header.c:24
screen_menu_item
void screen_menu_item(window_menu_t *pwindow_menu, uint16_t index, window_menu_item_t **ppitem, void *data)
Definition: screen_menu.c:19
p_window_header_set_text
void p_window_header_set_text(window_header_t *window, const char *text)
Definition: window_header.c:152