Prusa MINI Firmware overview
window_progress.c File Reference
#include "window_progress.h"
#include "gui.h"

Macros

#define WINDOW_PROGRESS_MAX_TEXT   16
 

Functions

void window_progress_init (window_progress_t *window)
 
void window_progress_draw (window_progress_t *window)
 

Variables

const window_class_progress_t window_class_progress
 

Macro Definition Documentation

◆ WINDOW_PROGRESS_MAX_TEXT

#define WINDOW_PROGRESS_MAX_TEXT   16

Function Documentation

◆ window_progress_init()

void window_progress_init ( window_progress_t window)
7  {
10  window->color_progress = COLOR_LIME;
11  window->font = gui_defaults.font;
12  window->padding = gui_defaults.padding;
13  window->alignment = ALIGN_CENTER;
14  window->height_progress = 8;
15  window->format = "%.0f%%";
16  window->value = 0;
17  window->min = 0;
18  window->max = 100;
19 }

◆ window_progress_draw()

void window_progress_draw ( window_progress_t window)
21  {
23  rect_ui16_t rc = window->win.rect;
24  char text[WINDOW_PROGRESS_MAX_TEXT];
25  sprintf(text, window->format, (double)window->value);
26  int progress_w = (int)(rc.w * (window->value - window->min) / (window->max - window->min));
27  rc.h = window->height_progress;
28 
29  if (1) { // TODO: border attribute, default is no border (Prusa GUI)
30  rc.x += progress_w;
31  rc.w -= progress_w;
32  display->fill_rect(rc, window->color_back);
33  rc.x = window->win.rect.x;
34  rc.w = progress_w;
35  display->fill_rect(rc, window->color_progress);
36  } else {
37  display->fill_rect(rc, window->color_progress);
38  rc.x += progress_w;
39  rc.w = window->win.rect.w - progress_w;
40  display->draw_rect(rc, window->color_progress);
41  rc = rect_ui16_sub_padding_ui8(rc, padding_ui8(1, 1, 1, 1));
42  display->fill_rect(rc, window->color_back);
43  }
44 
45  rc = window->win.rect;
46  if (rc.h > window->height_progress) {
47  rc.y += window->height_progress;
48  rc.h -= window->height_progress;
50  text,
51  window->font,
52  window->color_back,
53  window->color_text,
54  window->padding,
55  window->alignment);
56  }
57  window->win.flg &= ~WINDOW_FLG_INVALID;
58  }
59 }
Here is the call graph for this function:

Variable Documentation

◆ window_class_progress

window_draw_t
void() window_draw_t(void *window)
Definition: window.h:57
_window_progress_t::color_text
color_t color_text
Definition: window_progress.h:18
_rect_ui16_t::y
uint16_t y
Definition: guitypes.h:71
_window_progress_t::color_back
color_t color_back
Definition: window_progress.h:17
_rect_ui16_t::w
uint16_t w
Definition: guitypes.h:72
_gui_defaults_t::color_text
color_t color_text
Definition: guitypes.h:108
_window_progress_t::color_progress
color_t color_progress
Definition: window_progress.h:19
ALIGN_CENTER
#define ALIGN_CENTER
Definition: guitypes.h:19
_gui_defaults_t::font
font_t * font
Definition: guitypes.h:110
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_FLG_VISIBLE
#define WINDOW_FLG_VISIBLE
Definition: window.h:24
window_progress_t
struct _window_progress_t window_progress_t
COLOR_LIME
#define COLOR_LIME
Definition: guitypes.h:44
WINDOW_PROGRESS_MAX_TEXT
#define WINDOW_PROGRESS_MAX_TEXT
Definition: window_progress.c:5
_window_progress_t::font
font_t * font
Definition: window_progress.h:20
rect_ui16_sub_padding_ui8
rect_ui16_t rect_ui16_sub_padding_ui8(rect_ui16_t rc, padding_ui8_t pad)
Definition: guitypes.c:55
_display_t::fill_rect
display_fill_rect_t * fill_rect
Definition: display.h:33
_window_progress_t::alignment
uint8_t alignment
Definition: window_progress.h:22
_gui_defaults_t::padding
padding_ui8_t padding
Definition: guitypes.h:112
window_progress_init
void window_progress_init(window_progress_t *window)
Definition: window_progress.c:7
WINDOW_CLS_PROGRESS
#define WINDOW_CLS_PROGRESS
Definition: window.h:20
_window_progress_t::max
float max
Definition: window_progress.h:27
_gui_defaults_t::color_back
color_t color_back
Definition: guitypes.h:107
_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
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
_display_t::draw_rect
display_draw_rect_t * draw_rect
Definition: display.h:32
_window_progress_t::min
float min
Definition: window_progress.h:26
_window_progress_t::format
char * format
Definition: window_progress.h:24
_rect_ui16_t::x
uint16_t x
Definition: guitypes.h:70
_window_progress_t::padding
padding_ui8_t padding
Definition: window_progress.h:21
_window_progress_t::value
float value
Definition: window_progress.h:25
createSpeedLookupTable.int
int
Definition: createSpeedLookupTable.py:15
window_progress_draw
void window_progress_draw(window_progress_t *window)
Definition: window_progress.c:21
window_init_t
void() window_init_t(void *window)
Definition: window.h:55
gui_defaults
gui_defaults_t gui_defaults
Definition: gui.c:20
_window_progress_t::height_progress
uint8_t height_progress
Definition: window_progress.h:23
_window_progress_t::win
window_t win
Definition: window_progress.h:16
_window_t::flg
uint32_t flg
Definition: window.h:81
WINDOW_FLG_INVALID
#define WINDOW_FLG_INVALID
Definition: window.h:26