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

Macros

#define DLG_W8_HOUR_CHNG   0x0300
 
#define DLG_W8_HOUR_REDRW   0x0100
 
#define DLG_W8_ANI_FLG   0x0010
 
#define DLG_W8_FRAME_FLG   0x4000
 
#define DLG_W8_PROGRESS   0x8000
 
#define DLG_W8_HOUR_ROT   0x0200
 
#define DLG_W8_FPS   2
 

Functions

void window_dlg_wait_init (window_dlg_wait_t *window)
 
void window_dlg_wait_draw (window_dlg_wait_t *window)
 
void window_dlg_wait_event (window_dlg_wait_t *window, uint8_t event, void *param)
 
int gui_dlg_wait (int8_t(*callback)())
 
int8_t gui_marlin_busy_callback ()
 

Variables

int16_t WINDOW_CLS_DLG_WAIT = 0
 
window_twindow_1
 
const window_class_dlg_wait_t window_class_dlg_wait
 

Macro Definition Documentation

◆ DLG_W8_HOUR_CHNG

#define DLG_W8_HOUR_CHNG   0x0300

◆ DLG_W8_HOUR_REDRW

#define DLG_W8_HOUR_REDRW   0x0100

◆ DLG_W8_ANI_FLG

#define DLG_W8_ANI_FLG   0x0010

◆ DLG_W8_FRAME_FLG

#define DLG_W8_FRAME_FLG   0x4000

◆ DLG_W8_PROGRESS

#define DLG_W8_PROGRESS   0x8000

◆ DLG_W8_HOUR_ROT

#define DLG_W8_HOUR_ROT   0x0200

◆ DLG_W8_FPS

#define DLG_W8_FPS   2

Function Documentation

◆ window_dlg_wait_init()

void window_dlg_wait_init ( window_dlg_wait_t window)
29  {
30  //if (rect_empty_ui16(window->win.rect)) //use display rect if current rect is empty
31  //window->win.rect = rect_ui16(0, 0, display->w, display->h);
32  window->win.flg |= WINDOW_FLG_ENABLED; //enabled by default
35  window->font = gui_defaults.font;
37  window->padding = gui_defaults.padding;
38  window->progress = 0;
39 }

◆ window_dlg_wait_draw()

void window_dlg_wait_draw ( window_dlg_wait_t window)
41  {
42  if (window->win.f_visible) {
43  rect_ui16_t rc = window->win.rect;
44 
45  if (window->win.f_invalid) {
46  display->fill_rect(rc, window->color_back);
47  rect_ui16_t rc_tit = rc;
48  rc_tit.y += 10;
49  rc_tit.h = 30; // 30pixels for title
50  render_text_align(rc_tit, "Please wait", window->font_title, window->color_back, window->color_text, window->padding, ALIGN_CENTER);
51  window->win.f_invalid = 0;
52  if (window->flags & DLG_W8_FRAME_FLG) { //draw frame
53  display->draw_line(point_ui16(rc.x, rc.y), point_ui16(239, rc.y), COLOR_GRAY);
54  display->draw_line(point_ui16(rc.x, rc.y), point_ui16(rc.x, 320 - 67), COLOR_GRAY);
55  display->draw_line(point_ui16(239, rc.y), point_ui16(239, 320 - 67), COLOR_GRAY);
56  display->draw_line(point_ui16(rc.x, 320 - 67), point_ui16(239, 320 - 67), COLOR_GRAY);
57  }
58  }
59  if (window->flags & DLG_W8_HOUR_CHNG) { //hourglass animation (just sand 0x0100, whole icon 0x0200)
60 
61  rect_ui16_t icon_rc = rc;
62  icon_rc.h = icon_rc.w = 30;
63  icon_rc.x += 110;
64  icon_rc.y += 50;
65 
66  if (window->flags & DLG_W8_HOUR_REDRW) {
68  if (window->flags & 0x0010) {
69  display->draw_line(point_ui16(icon_rc.x + 15, icon_rc.y + 24), point_ui16(icon_rc.x + 15, icon_rc.y + 29), COLOR_ORANGE);
70  display->draw_line(point_ui16(icon_rc.x + 13, icon_rc.y + 33), point_ui16(icon_rc.x + 17, icon_rc.y + 33), COLOR_ORANGE);
71  } else if (window->flags & 0x0020) {
72  display->draw_line(point_ui16(icon_rc.x + 11, icon_rc.y + 13), point_ui16(icon_rc.x + 20, icon_rc.y + 13), COLOR_BLACK);
73  display->draw_line(point_ui16(icon_rc.x + 15, icon_rc.y + 19), point_ui16(icon_rc.x + 15, icon_rc.y + 24), COLOR_ORANGE);
74  display->draw_line(point_ui16(icon_rc.x + 15, icon_rc.y + 29), point_ui16(icon_rc.x + 15, icon_rc.y + 34), COLOR_ORANGE);
75  display->draw_line(point_ui16(icon_rc.x + 10, icon_rc.y + 33), point_ui16(icon_rc.x + 20, icon_rc.y + 33), COLOR_ORANGE);
76  } else if (window->flags & 0x0040) {
77  display->draw_line(point_ui16(icon_rc.x + 11, icon_rc.y + 13), point_ui16(icon_rc.x + 20, icon_rc.y + 13), COLOR_BLACK);
78  display->draw_line(point_ui16(icon_rc.x + 12, icon_rc.y + 14), point_ui16(icon_rc.x + 19, icon_rc.y + 14), COLOR_BLACK);
79  display->draw_line(point_ui16(icon_rc.x + 15, icon_rc.y + 24), point_ui16(icon_rc.x + 15, icon_rc.y + 29), COLOR_ORANGE);
80  display->draw_line(point_ui16(icon_rc.x + 6, icon_rc.y + 33), point_ui16(icon_rc.x + 24, icon_rc.y + 33), COLOR_ORANGE);
81  display->draw_line(point_ui16(icon_rc.x + 12, icon_rc.y + 32), point_ui16(icon_rc.x + 18, icon_rc.y + 32), COLOR_ORANGE);
82  } else if (window->flags & 0x0080) {
83  display->draw_line(point_ui16(icon_rc.x + 11, icon_rc.y + 13), point_ui16(icon_rc.x + 20, icon_rc.y + 13), COLOR_BLACK);
84  display->draw_line(point_ui16(icon_rc.x + 12, icon_rc.y + 14), point_ui16(icon_rc.x + 19, icon_rc.y + 14), COLOR_BLACK);
85  display->draw_line(point_ui16(icon_rc.x + 13, icon_rc.y + 15), point_ui16(icon_rc.x + 18, icon_rc.y + 15), COLOR_BLACK);
86  display->draw_line(point_ui16(icon_rc.x + 13, icon_rc.y + 16), point_ui16(icon_rc.x + 17, icon_rc.y + 16), COLOR_BLACK);
87  display->draw_line(point_ui16(icon_rc.x + 14, icon_rc.y + 17), point_ui16(icon_rc.x + 17, icon_rc.y + 17), COLOR_BLACK);
88  display->draw_line(point_ui16(icon_rc.x + 14, icon_rc.y + 18), point_ui16(icon_rc.x + 16, icon_rc.y + 18), COLOR_BLACK);
89  display->draw_line(point_ui16(icon_rc.x + 15, icon_rc.y + 26), point_ui16(icon_rc.x + 15, icon_rc.y + 34), COLOR_ORANGE);
90  display->draw_line(point_ui16(icon_rc.x + 10, icon_rc.y + 31), point_ui16(icon_rc.x + 20, icon_rc.y + 31), COLOR_ORANGE);
91  display->draw_line(point_ui16(icon_rc.x + 6, icon_rc.y + 32), point_ui16(icon_rc.x + 24, icon_rc.y + 32), COLOR_ORANGE);
92  display->draw_line(point_ui16(icon_rc.x + 6, icon_rc.y + 33), point_ui16(icon_rc.x + 24, icon_rc.y + 33), COLOR_ORANGE);
93  }
94  } else
96 
97  window->flags &= 0xF00F; //reset animation flags
98  }
99  if (window->flags & DLG_W8_PROGRESS) //progress changed
100  {
101  rect_ui16_t rc_pro = rc;
102  rc_pro.x = 10;
103  rc_pro.w -= 20;
104  char text[16];
105  rc_pro.h = 16;
106  rc_pro.y += 120;
107  uint16_t w = rc_pro.w;
108  rc_pro.w = w * window->progress / 100;
109  display->fill_rect(rc_pro, COLOR_ORANGE);
110  rc_pro.x += rc_pro.w;
111  rc_pro.w = w - rc_pro.w;
112  display->fill_rect(rc_pro, COLOR_GRAY);
113  rc_pro.y += rc_pro.h;
114  rc_pro.w = rc.w - 120;
115  rc_pro.x = rc.x + 60;
116  rc_pro.h = 30;
117  sprintf(text, "%d%%", window->progress);
118  render_text_align(rc_pro, text, window->font_title, window->color_back, window->color_text, window->padding, ALIGN_CENTER);
119  window->flags &= 0x7FFF;
120  }
121  }
122 }
Here is the call graph for this function:

◆ window_dlg_wait_event()

void window_dlg_wait_event ( window_dlg_wait_t window,
uint8_t  event,
void param 
)
124  {
125  //must handle it here
126 };

◆ gui_dlg_wait()

int gui_dlg_wait ( int8_t(*)()  callback)
139  { //callback
140 
141  window_dlg_wait_t dlg;
142 
143  int16_t id_capture = window_capture();
145  window_1 = (window_t *)&dlg;
146  gui_reset_jogwheel();
147  gui_invalidate();
148  window_set_capture(id);
149 
150  dlg.progress = (*callback)();
151  dlg.flags |= DLG_W8_FRAME_FLG; //draw gray frame
152  dlg.flags |= DLG_W8_HOUR_REDRW; //redraw hourglass icon
153 
154  dlg.timer = HAL_GetTick();
155  uint32_t tmp = DLG_W8_ANI_FLG;
156  uint8_t tmp_timer, last_time = 0;
157 
158  if (dlg.progress < 0) {
159  while ((*callback)()) {
160  tmp_timer = ((HAL_GetTick() - dlg.timer) / (1000 / DLG_W8_FPS));
161  if (tmp_timer != last_time && tmp_timer < 5) {
162  if (tmp <= 0x0080) {
163  dlg.flags |= tmp; //redraw sand animation
164  dlg.flags |= DLG_W8_HOUR_REDRW;
165  gui_invalidate();
166  }
167  if (tmp < 0x0080)
168  tmp <<= 1;
169  }
170  if (tmp_timer >= 5) {
171  dlg.flags |= DLG_W8_HOUR_ROT; //redraw next phase of hourglass animation ADD ICON 0x0200
172  dlg.timer = HAL_GetTick();
173  tmp = DLG_W8_ANI_FLG;
174  tmp_timer = last_time = 0;
175  gui_invalidate();
176  }
177  last_time = tmp_timer;
178  gui_loop();
179  }
180  } else {
181 
182  while (dlg.progress < 100) {
183  int8_t tmp_progress = (*callback)();
184  if (dlg.progress != tmp_progress) {
185  dlg.progress = tmp_progress;
186  dlg.flags |= DLG_W8_PROGRESS;
187  }
188  tmp_timer = ((HAL_GetTick() - dlg.timer) / (1000 / DLG_W8_FPS));
189  if (tmp_timer != last_time && tmp_timer < 5) {
190  if (tmp <= 0x0080) {
191  dlg.flags |= tmp; //redraw sand animation and progressbar
192  dlg.flags |= DLG_W8_HOUR_REDRW;
193  gui_invalidate();
194  }
195  if (tmp < 0x0080)
196  tmp <<= 1;
197  }
198  if (tmp_timer >= 5) {
199  dlg.flags |= DLG_W8_HOUR_ROT; //redraw next phase of hourglass animation ADD ICON 0x0200
200  dlg.timer = HAL_GetTick();
201  tmp = DLG_W8_ANI_FLG;
202  tmp_timer = last_time = 0;
203  gui_invalidate();
204  }
205  last_time = tmp_timer;
206  gui_loop();
207  }
208  }
209 
210  window_destroy(id);
211  window_set_capture(id_capture);
213  return 0;
214 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ gui_marlin_busy_callback()

int8_t gui_marlin_busy_callback ( void  )
216  {
217  if (marlin_motion() || marlin_busy())
218  return -1;
219  else
220  return 0;
221 }
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ WINDOW_CLS_DLG_WAIT

int16_t WINDOW_CLS_DLG_WAIT = 0

◆ window_1

window_t* window_1

◆ window_class_dlg_wait

window_dlg_wait_t
struct _window_dlg_wait_t window_dlg_wait_t
Definition: window_dlg_wait.h:13
window_draw_t
void() window_draw_t(void *window)
Definition: window.h:57
DLG_W8_HOUR_ROT
#define DLG_W8_HOUR_ROT
Definition: window_dlg_wait.c:22
window_capture
int16_t window_capture(void)
Definition: window.c:169
_rect_ui16_t::y
uint16_t y
Definition: guitypes.h:71
_rect_ui16_t::w
uint16_t w
Definition: guitypes.h:72
_gui_defaults_t::color_text
color_t color_text
Definition: guitypes.h:108
DLG_W8_FRAME_FLG
#define DLG_W8_FRAME_FLG
Definition: window_dlg_wait.c:20
_window_dlg_wait_t::flags
uint16_t flags
Definition: window_dlg_wait.h:29
ALIGN_CENTER
#define ALIGN_CENTER
Definition: guitypes.h:19
window_invalidate
void window_invalidate(int16_t id)
Definition: window.c:304
_gui_defaults_t::font
font_t * font
Definition: guitypes.h:110
window_destroy
void window_destroy(int16_t id)
Definition: window.c:132
WINDOW_CLS_USER
#define WINDOW_CLS_USER
Definition: window.h:21
_gui_defaults_t::msg_box_sz
rect_ui16_t msg_box_sz
Definition: guitypes.h:114
_window_dlg_wait_t::color_back
color_t color_back
Definition: window_dlg_wait.h:22
_window_dlg_wait_t::padding
padding_ui8_t padding
Definition: window_dlg_wait.h:26
window_dlg_wait_init
void window_dlg_wait_init(window_dlg_wait_t *window)
Definition: window_dlg_wait.c:29
DLG_W8_FPS
#define DLG_W8_FPS
Definition: window_dlg_wait.c:23
DLG_W8_HOUR_REDRW
#define DLG_W8_HOUR_REDRW
Definition: window_dlg_wait.c:18
WINDOW_CLS_DLG_WAIT
int16_t WINDOW_CLS_DLG_WAIT
Definition: window_dlg_wait.c:25
_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::f_invalid
uint32_t f_invalid
Definition: window.h:87
_gui_defaults_t::padding
padding_ui8_t padding
Definition: guitypes.h:112
COLOR_GRAY
#define COLOR_GRAY
Definition: guitypes.h:50
window_dlg_wait_draw
void window_dlg_wait_draw(window_dlg_wait_t *window)
Definition: window_dlg_wait.c:41
window_1
window_t * window_1
Definition: window.c:14
gui_invalidate
void gui_invalidate(void)
Definition: gui.c:66
marlin_motion
int marlin_motion(void)
Definition: marlin_client.c:182
DLG_W8_HOUR_CHNG
#define DLG_W8_HOUR_CHNG
Definition: window_dlg_wait.c:17
COLOR_ORANGE
#define COLOR_ORANGE
Definition: guitypes.h:57
_window_t
Definition: window.h:76
_window_dlg_wait_t::font
font_t * font
Definition: window_dlg_wait.h:24
_gui_defaults_t::color_back
color_t color_back
Definition: guitypes.h:107
marlin_busy
int marlin_busy(void)
Definition: marlin_client.c:152
window_set_capture
void window_set_capture(int16_t id)
Definition: window.c:500
_window_dlg_wait_t::font_title
font_t * font_title
Definition: window_dlg_wait.h:25
DLG_W8_PROGRESS
#define DLG_W8_PROGRESS
Definition: window_dlg_wait.c:21
_window_dlg_wait_t::progress
int8_t progress
Definition: window_dlg_wait.h:28
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
render_text_align
void render_text_align(rect_ui16_t rc, const char *text, font_t *font, color_t clr0, color_t clr1, padding_ui8_t padding, uint16_t flags)
Definition: display_helper.c:6
_window_dlg_wait_t::timer
uint32_t timer
Definition: window_dlg_wait.h:27
uint8_t
const uint8_t[]
Definition: 404_html.c:3
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_t::f_visible
uint32_t f_visible
Definition: window.h:85
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
COLOR_BLACK
#define COLOR_BLACK
Definition: guitypes.h:40
_rect_ui16_t::x
uint16_t x
Definition: guitypes.h:70
_window_dlg_wait_t::win
window_t win
Definition: window_dlg_wait.h:21
window_dlg_wait_event
void window_dlg_wait_event(window_dlg_wait_t *window, uint8_t event, void *param)
Definition: window_dlg_wait.c:124
DLG_W8_ANI_FLG
#define DLG_W8_ANI_FLG
Definition: window_dlg_wait.c:19
_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
render_icon_align
void render_icon_align(rect_ui16_t rc, uint16_t id_res, color_t clr0, uint16_t flags)
Definition: display_helper.c:55
_window_dlg_wait_t::color_text
color_t color_text
Definition: window_dlg_wait.h:23
_window_t::flg
uint32_t flg
Definition: window.h:81
_display_t::draw_line
display_draw_line_t * draw_line
Definition: display.h:31
IDR_PNG_wizard_icon_hourglass
#define IDR_PNG_wizard_icon_hourglass
Definition: resource.h:56
WINDOW_FLG_ENABLED
#define WINDOW_FLG_ENABLED
Definition: window.h:25
point_ui16
static point_ui16_t point_ui16(uint16_t x, uint16_t y)
Definition: guitypes.h:154
_window_dlg_wait_t
Definition: window_dlg_wait.h:20