Prusa MINI Firmware overview
window_dlg_preheat.c File Reference
#include "window_dlg_preheat.h"
#include "display_helper.h"
#include "gui.h"
#include "dbg.h"
#include "stm32f4xx_hal.h"
#include "filament.h"
#include "marlin_client.h"
#include "resource.h"
#include "stdlib.h"

Macros

#define _PREHEAT_FILAMENT_CNT   (FILAMENTS_END - FILAMENT_PLA)
 

Functions

void window_frame_done (window_frame_t *window)
 
void window_frame_draw (window_frame_t *window)
 
void window_frame_event (window_frame_t *window, uint8_t event, void *param)
 
void window_list_filament_item_forced_cb (window_list_t *pwindow_list, uint16_t index, const char **pptext, uint16_t *pid_icon)
 
void window_list_filament_item_cb (window_list_t *pwindow_list, uint16_t index, const char **pptext, uint16_t *pid_icon)
 
static void _set_filament (FILAMENT_t index)
 
void window_dlg_preheat_click_forced_cb (window_dlg_preheat_t *window)
 
void window_dlg_preheat_click_cb (window_dlg_preheat_t *window)
 
void window_dlg_preheat_init (window_dlg_preheat_t *window)
 
void window_dlg_preheat_event (window_dlg_preheat_t *window, uint8_t event, void *param)
 
int gui_dlg_preheat (const char *caption)
 
int gui_dlg_preheat_autoselect_if_able (const char *caption)
 
int gui_dlg_preheat_forced (const char *caption)
 
int gui_dlg_preheat_autoselect_if_able_forced (const char *caption)
 
int gui_dlg_list (const char *caption, window_list_item_t *filament_items, dlg_on_click_cb *on_click, size_t count, int32_t ttl)
 

Variables

int16_t WINDOW_CLS_DLG_PREHEAT = 0
 
window_twindow_1
 
const window_class_dlg_preheat_t window_class_dlg_preheat
 

Macro Definition Documentation

◆ _PREHEAT_FILAMENT_CNT

#define _PREHEAT_FILAMENT_CNT   (FILAMENTS_END - FILAMENT_PLA)

Function Documentation

◆ window_frame_done()

void window_frame_done ( window_frame_t window)
12  {
13 }

◆ window_frame_draw()

void window_frame_draw ( window_frame_t window)
15  {
16  if (window->win.f_visible) {
17  if (window->win.f_invalid) {
18  rect_ui16_t rc = window->win.rect;
19  display->fill_rect(rc, window->color_back);
20  window->win.f_invalid = 0;
22  }
23  window_draw_children(window->win.id);
24  }
25 }

◆ window_frame_event()

void window_frame_event ( window_frame_t window,
uint8_t  event,
void param 
)
27  {
28  int16_t id;
29  int dif;
30  switch (event) {
35  break;
37  dif = (int)param;
38  id = window_focused();
39  while (dif--)
40  id = window_prev_enabled(id);
41  if (id >= 0)
42  window_set_focus(id);
43  break;
45  dif = (int)param;
46  id = window_focused();
47  while (dif--)
48  id = window_next_enabled(id);
49  if (id >= 0)
50  window_set_focus(id);
51  break;
53  break;
55  if (window_parent(window_focused()) != window->win.id) {
56  id = window_first_child(0);
57  if (!window_is_enabled(id))
58  id = window_next_enabled(id);
59  window_set_focus(id);
60  }
61  break;
62  }
63 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ window_list_filament_item_forced_cb()

void window_list_filament_item_forced_cb ( window_list_t pwindow_list,
uint16_t  index,
const char **  pptext,
uint16_t *  pid_icon 
)
30  {
31  if (index <= pwindow_list->count) {
32  *pptext = filaments[index + FILAMENT_PLA].long_name;
33  } else
34  *pptext = "Index ERROR";
35 
36  *pid_icon = 0;
37 }
Here is the caller graph for this function:

◆ window_list_filament_item_cb()

void window_list_filament_item_cb ( window_list_t pwindow_list,
uint16_t  index,
const char **  pptext,
uint16_t *  pid_icon 
)
40  {
41  if (index == 0) {
42  *pptext = "Return";
44  } else {
45  window_list_filament_item_forced_cb(pwindow_list, index - 1, pptext, pid_icon);
46  }
47 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _set_filament()

static void _set_filament ( FILAMENT_t  index)
static
49  {
50  marlin_gcode_printf("M104 S%d", (int)filaments[index].nozzle);
51  marlin_gcode_printf("M140 S%d", (int)filaments[index].heatbed);
52  set_filament(index);
53 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ window_dlg_preheat_click_forced_cb()

void window_dlg_preheat_click_forced_cb ( window_dlg_preheat_t window)
55  {
56  FILAMENT_t index = window->list.index + FILAMENT_PLA;
57  _set_filament(index);
58 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ window_dlg_preheat_click_cb()

void window_dlg_preheat_click_cb ( window_dlg_preheat_t window)
60  {
61  if (window->list.index > 0) {
62  FILAMENT_t index = window->list.index + FILAMENT_PLA - 1;
63  _set_filament(index);
64  }
65 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ window_dlg_preheat_init()

void window_dlg_preheat_init ( window_dlg_preheat_t window)
67  {
68  //inherit from frame
69  window_class_frame.cls.init(window);
73  window->font = gui_defaults.font;
75  window->padding = gui_defaults.padding;
76 
77  int16_t id;
79  if (window->caption) {
80  rect.h = window->font_title->h + 2;
81  id = window_create_ptr(WINDOW_CLS_TEXT, window->win.id, rect, &(window->text));
82  window_set_text(id, window->caption);
83  rect = gui_defaults.msg_box_sz;
84  rect.y += window->font_title->h + 4;
85  rect.h -= window->font_title->h + 4;
86  }
87 
88  id = window_create_ptr(WINDOW_CLS_LIST, window->win.id, rect, &(window->list));
89  window->list.padding = padding_ui8(20, 6, 2, 6);
90  window->list.icon_rect = rect_ui16(0, 0, 16, 30);
91 
92  //window_set_item_count(id, window->filaments_count);
93  window_set_item_index(id, 0);
95 }
Here is the call graph for this function:

◆ window_dlg_preheat_event()

void window_dlg_preheat_event ( window_dlg_preheat_t window,
uint8_t  event,
void param 
)
97  {
98  //todo, fixme, error i will not get WINDOW_EVENT_BTN_DN event here first time when it is clicked
99  //but list reacts to it
100  switch (event) {
101  case WINDOW_EVENT_BTN_DN:
102  case WINDOW_EVENT_BTN_UP:
103  case WINDOW_EVENT_CLICK:
104  if (window->timer != -1) {
105  window->timer = -1; //close
106  window->on_click(window);
107  }
108  return;
109  default:
110  window_frame_event((void *)window, event, param);
111  }
112 }
Here is the call graph for this function:

◆ gui_dlg_preheat()

int gui_dlg_preheat ( const char *  caption)
126  {
127  return gui_dlg_list(
128  caption,
131  _PREHEAT_FILAMENT_CNT + 1, //+1 back option
132  30000);
133 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ gui_dlg_preheat_autoselect_if_able()

int gui_dlg_preheat_autoselect_if_able ( const char *  caption)
135  {
136  const FILAMENT_t fil = get_filament();
137  if (fil == FILAMENT_NONE) {
138  //no filament selected
139  return gui_dlg_preheat(caption);
140  } else {
141  //when filament is known, but heating is off, just turn it on and do not ask
143  if (p_vars->target_nozzle != filaments[fil].nozzle) {
144  marlin_gcode_printf("M104 S%d", (int)filaments[fil].nozzle);
145  marlin_gcode_printf("M140 S%d", (int)filaments[fil].heatbed);
146  }
147  }
148  return fil;
149 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ gui_dlg_preheat_forced()

int gui_dlg_preheat_forced ( const char *  caption)
152  {
153  return gui_dlg_list(
154  caption,
158  -1 //do not leave
159  );
160 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ gui_dlg_preheat_autoselect_if_able_forced()

int gui_dlg_preheat_autoselect_if_able_forced ( const char *  caption)
163  {
164  const FILAMENT_t fil = get_filament();
165  if (fil == FILAMENT_NONE) {
166  //no filament selected
167  return gui_dlg_preheat_forced(caption);
168  } else {
169  //when filament is known, but heating is off, just turn it on and do not ask
171  if (p_vars->target_nozzle != filaments[fil].nozzle) {
172  marlin_gcode_printf("M104 S%d", (int)filaments[fil].nozzle);
173  marlin_gcode_printf("M140 S%d", (int)filaments[fil].heatbed);
174  }
175  }
176  return fil;
177 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ gui_dlg_list()

int gui_dlg_list ( const char *  caption,
window_list_item_t filament_items,
dlg_on_click_cb on_click,
size_t  count,
int32_t  ttl 
)
184  {
186  dlg.caption = caption;
187  dlg.filament_items = filament_items;
188  dlg.on_click = on_click;
189  //dlg.filaments_count = count;
190 
191  //parent 0 would be first screen
192  //here must be -1
193  int16_t id_capture = window_capture();
195 
196  window_set_item_count(dlg.list.win.id, count);
197 
198  window_1 = (window_t *)&dlg;
199  window_set_capture(dlg.list.win.id); //get inside list
200 
201  gui_reset_jogwheel();
202  gui_invalidate();
203 
204  //window_disable(id);
205 
206  dlg.timer = HAL_GetTick();
207 
208  //ttl retyped to uint - so "-1" == for ever (or very long)
209  while ((dlg.timer != -1) && ((uint32_t)(HAL_GetTick() - dlg.timer) < (uint32_t)ttl)) {
210  gui_loop();
211  }
212 
213  int ret;
214  if (dlg.timer != -1) {
215  ret = -1;
216  } else {
217  ret = dlg.list.index;
218  }
219 
220  window_destroy(id); //msg box does not call this, should I
222  window_set_capture(id_capture);
223  return ret;
224 }
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ WINDOW_CLS_DLG_PREHEAT

int16_t WINDOW_CLS_DLG_PREHEAT = 0

◆ window_1

window_t* window_1

◆ window_class_dlg_preheat

window_draw_t
void() window_draw_t(void *window)
Definition: window.h:57
WINDOW_EVENT_CAPT_0
#define WINDOW_EVENT_CAPT_0
Definition: window.h:44
WINDOW_EVENT_CAPT_1
#define WINDOW_EVENT_CAPT_1
Definition: window.h:45
window_capture
int16_t window_capture(void)
Definition: window.c:169
_window_dlg_preheat_t::on_click
dlg_on_click_cb * on_click
Definition: window_dlg_preheat.h:36
_rect_ui16_t::y
uint16_t y
Definition: guitypes.h:71
_font_t::h
uint8_t h
Definition: guitypes.h:78
_gui_defaults_t::color_text
color_t color_text
Definition: guitypes.h:108
set_filament
void set_filament(FILAMENT_t filament)
Definition: filament.cpp:32
FILAMENT_NONE
Definition: filament.h:26
_window_dlg_preheat_t::list
window_list_t list
Definition: window_dlg_preheat.h:34
window_list_filament_item_cb
void window_list_filament_item_cb(window_list_t *pwindow_list, uint16_t index, const char **pptext, uint16_t *pid_icon)
Definition: window_dlg_preheat.c:39
gui_dlg_preheat
int gui_dlg_preheat(const char *caption)
Definition: window_dlg_preheat.c:126
WINDOW_EVENT_ENC_UP
#define WINDOW_EVENT_ENC_UP
Definition: window.h:41
window_invalidate
void window_invalidate(int16_t id)
Definition: window.c:304
rect_ui16
static rect_ui16_t rect_ui16(uint16_t x, uint16_t y, uint16_t w, uint16_t h)
Definition: guitypes.h:159
window_dlg_preheat_event
void window_dlg_preheat_event(window_dlg_preheat_t *window, uint8_t event, void *param)
Definition: window_dlg_preheat.c:97
_gui_defaults_t::font
font_t * font
Definition: guitypes.h:110
_window_class_frame_t::cls
window_class_t cls
Definition: window_frame.h:15
_window_list_t::icon_rect
rect_ui16_t icon_rect
Definition: window_list.h:22
window_destroy
void window_destroy(int16_t id)
Definition: window.c:132
_window_dlg_preheat_t::color_back
color_t color_back
Definition: window_dlg_preheat.h:26
padding_ui8
static padding_ui8_t padding_ui8(uint8_t l, uint8_t t, uint8_t r, uint8_t b)
Definition: guitypes.h:164
WINDOW_CLS_USER
#define WINDOW_CLS_USER
Definition: window.h:21
fil
FIL fil
Definition: pngview.c:11
_gui_defaults_t::msg_box_sz
rect_ui16_t msg_box_sz
Definition: guitypes.h:114
WINDOW_CLS_DLG_PREHEAT
int16_t WINDOW_CLS_DLG_PREHEAT
Definition: window_dlg_preheat.c:22
filaments
const filament_t filaments[FILAMENTS_END]
Definition: filament.cpp:20
FILAMENT_PLA
Definition: filament.h:27
_window_frame_t::color_back
color_t color_back
Definition: window_frame.h:20
_display_t::fill_rect
display_fill_rect_t * fill_rect
Definition: display.h:33
HAL_GetTick
uint32_t HAL_GetTick(void)
Provides a tick value in millisecond.
Definition: stm32f4xx_hal.c:339
_window_t::id
int16_t id
Definition: window.h:79
window_first_child
int16_t window_first_child(int16_t id)
Definition: window.c:218
_gui_defaults_t::padding
padding_ui8_t padding
Definition: guitypes.h:112
_window_t::f_invalid
uint32_t f_invalid
Definition: window.h:87
WINDOW_CLS_LIST
#define WINDOW_CLS_LIST
Definition: window.h:13
window_done_t
void() window_done_t(void *window)
Definition: window.h:56
window_set_text
void window_set_text(int16_t id, const char *text)
Definition: window.c:340
_window_list_t::win
window_t win
Definition: window_list.h:16
gui_invalidate
void gui_invalidate(void)
Definition: gui.c:66
_window_dlg_preheat_t::filament_items
window_list_item_t * filament_items
Definition: window_dlg_preheat.h:35
WINDOW_EVENT_BTN_UP
#define WINDOW_EVENT_BTN_UP
Definition: window.h:39
_window_t
Definition: window.h:76
_window_list_t::padding
padding_ui8_t padding
Definition: window_list.h:20
window_dlg_preheat_t
struct _window_dlg_preheat_t window_dlg_preheat_t
Definition: window_dlg_preheat.h:15
get_filament
FILAMENT_t get_filament()
Definition: filament.cpp:41
_marlin_vars_t::target_nozzle
float target_nozzle
Definition: marlin_vars.h:85
filament_t::long_name
const char * long_name
Definition: filament.h:18
window_draw_children
void window_draw_children(int16_t id)
Definition: window.c:284
_gui_defaults_t::color_back
color_t color_back
Definition: guitypes.h:107
filament_t::nozzle
uint16_t nozzle
Definition: filament.h:19
window_class_frame
const window_class_frame_t window_class_frame
Definition: window_frame.c:65
gui_dlg_preheat_forced
int gui_dlg_preheat_forced(const char *caption)
Definition: window_dlg_preheat.c:152
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
_window_class_t::init
window_init_t * init
Definition: window.h:70
IDR_PNG_filescreen_icon_up_folder
#define IDR_PNG_filescreen_icon_up_folder
Definition: resource.h:42
_window_dlg_preheat_t::font
font_t * font
Definition: window_dlg_preheat.h:28
window_focused_ptr
window_t * window_focused_ptr
Definition: window.c:19
marlin_update_vars
marlin_vars_t * marlin_update_vars(uint64_t msk)
Definition: marlin_client.c:368
window_event_t
void() window_event_t(void *window, uint8_t event, void *param)
Definition: window.h:58
_rect_ui16_t
Definition: guitypes.h:69
_window_dlg_preheat_t::color_text
color_t color_text
Definition: window_dlg_preheat.h:27
_set_filament
static void _set_filament(FILAMENT_t index)
Definition: window_dlg_preheat.c:49
window_frame_event
void window_frame_event(window_frame_t *window, uint8_t event, void *param)
Definition: window_frame.c:27
MARLIN_VAR_MSK
#define MARLIN_VAR_MSK(v_id)
Definition: marlin_vars.h:35
display
display_t * display
Definition: display.c:6
_rect_ui16_t::h
uint16_t h
Definition: guitypes.h:73
_window_t::rect
rect_ui16_t rect
Definition: window.h:101
_window_frame_t::win
window_t win
Definition: window_frame.h:19
_window_dlg_preheat_t
Definition: window_dlg_preheat.h:24
window_invalidate_children
void window_invalidate_children(int16_t id)
Definition: window.c:320
WINDOW_CLS_TEXT
#define WINDOW_CLS_TEXT
Definition: window.h:10
_window_dlg_preheat_t::timer
uint32_t timer
Definition: window_dlg_preheat.h:31
_window_t::f_visible
uint32_t f_visible
Definition: window.h:85
WINDOW_EVENT_CLICK
#define WINDOW_EVENT_CLICK
Definition: window.h:46
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_next_enabled
int16_t window_next_enabled(int16_t id)
Definition: window.c:211
_window_list_t::index
int index
Definition: window_list.h:24
window_dlg_preheat_click_cb
void window_dlg_preheat_click_cb(window_dlg_preheat_t *window)
Definition: window_dlg_preheat.c:60
gui_dlg_list
int gui_dlg_list(const char *caption, window_list_item_t *filament_items, dlg_on_click_cb *on_click, size_t count, int32_t ttl)
Definition: window_dlg_preheat.c:183
_marlin_vars_t
Definition: marlin_vars.h:77
window_frame_done
void window_frame_done(window_frame_t *window)
Definition: window_frame.c:12
FILAMENT_t
FILAMENT_t
Definition: filament.h:25
window_is_enabled
int window_is_enabled(int16_t id)
Definition: window.c:257
_PREHEAT_FILAMENT_CNT
#define _PREHEAT_FILAMENT_CNT
Definition: window_dlg_preheat.c:26
window_1
window_t * window_1
Definition: window.c:14
createSpeedLookupTable.int
int
Definition: createSpeedLookupTable.py:15
_window_dlg_preheat_t::padding
padding_ui8_t padding
Definition: window_dlg_preheat.h:30
_window_dlg_preheat_t::text
window_text_t text
Definition: window_dlg_preheat.h:33
_gui_defaults_t::font_big
font_t * font_big
Definition: guitypes.h:111
window_init_t
void() window_init_t(void *window)
Definition: window.h:55
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
window_set_item_count
void window_set_item_count(int16_t id, int count)
Definition: window.c:573
window_dlg_preheat_init
void window_dlg_preheat_init(window_dlg_preheat_t *window)
Definition: window_dlg_preheat.c:67
window_focused
int16_t window_focused(void)
Definition: window.c:165
_window_t::flg
uint32_t flg
Definition: window.h:81
window_set_item_callback
void window_set_item_callback(int16_t id, window_list_item_t *fnc)
Definition: window.c:787
screen_dispatch_event
void screen_dispatch_event(window_t *window, uint8_t event, void *param)
Definition: screen.c:103
window_parent
int16_t window_parent(int16_t id)
Definition: window.c:173
window_set_item_index
void window_set_item_index(int16_t id, int index)
Definition: window.c:598
nozzle
Nozzle nozzle
Definition: nozzle.cpp:29
_window_dlg_preheat_t::caption
const char * caption
Definition: window_dlg_preheat.h:37
marlin_gcode_printf
int marlin_gcode_printf(const char *format,...)
Definition: marlin_client.c:206
window_frame_draw
void window_frame_draw(window_frame_t *window)
Definition: window_frame.c:15
WINDOW_FLG_INVALID
#define WINDOW_FLG_INVALID
Definition: window.h:26
_window_t::f_tag
uint32_t f_tag
Definition: window.h:98
WINDOW_FLG_ENABLED
#define WINDOW_FLG_ENABLED
Definition: window.h:25
window_prev_enabled
int16_t window_prev_enabled(int16_t id)
Definition: window.c:204
_window_dlg_preheat_t::win
window_t win
Definition: window_dlg_preheat.h:25
WINDOW_EVENT_ENC_DN
#define WINDOW_EVENT_ENC_DN
Definition: window.h:40
window_list_filament_item_forced_cb
void window_list_filament_item_forced_cb(window_list_t *pwindow_list, uint16_t index, const char **pptext, uint16_t *pid_icon)
Definition: window_dlg_preheat.c:29
_window_dlg_preheat_t::font_title
font_t * font_title
Definition: window_dlg_preheat.h:29
window_dlg_preheat_click_forced_cb
void window_dlg_preheat_click_forced_cb(window_dlg_preheat_t *window)
Definition: window_dlg_preheat.c:55