Prusa MINI Firmware overview
window_dlg_statemachine.h
Go to the documentation of this file.
1 // window_dlg_statemachine.h
2 
3 #ifndef _WINDOW_DLG_STATEMACHINE_H
4 #define _WINDOW_DLG_STATEMACHINE_H
5 
6 #include "window.h"
7 #include "dlg_result.h"
8 
10 
11 extern int16_t WINDOW_CLS_DLG_LOADUNLOAD;
12 
13 //button flags
14 //combination of enabled and not visible == do not clear
15 #define BT_ENABLED ((uint8_t)(1 << 0))
16 //#define BT_VISIBLE ((uint8_t)(1 << 1))
17 #define BT_AUTOEXIT ((uint8_t)(1 << 2))
18 
19 #define DLG_BT_FLG ((uint8_t)(1 << 0)) //button flag
20 #define DLG_CH_CMD ((uint8_t)(1 << 1)) //check marlin_command()
21 
22 //flags for draw_cb function (user callback)
23 #define DLG_DI_US0 ((uint8_t)(1 << 4)) //user flag 0
24 #define DLG_DI_US1 ((uint8_t)(1 << 5)) //user flag 1
25 #define DLG_DI_US2 ((uint8_t)(1 << 6)) //user flag 2
26 #define DLG_DI_US3 ((uint8_t)(1 << 7)) //user flag 3
27 
29 //this type does not match to window_event_t .. p_event is pointer
30 typedef void(window_event_dlg_cb_t)(window_dlg_statemachine_t *window, uint8_t event, void *param);
31 
32 #pragma pack(push)
33 #pragma pack(1)
34 
35 //universal dialog vars
36 typedef struct
37 {
39  int8_t phase;
40  int8_t prev_phase;
46  uint32_t tick_part_start;
47  uint32_t time_total;
48 } _dlg_vars;
49 
50 typedef enum {
54 
55 typedef int (*dlg_state_func)(_dlg_vars *p_vars, void *p_additional_vars); //prototype of state function
56 typedef void (*dlg_cb_t)(void); //dialog callback
57 typedef loop_result_t (*dlg_loop_cb_t)(_dlg_vars *p_vars, void *p_additional_vars); //dialog loop callback can break loop
58 
59 typedef struct
60 {
61  const char **labels;
66 
67 typedef struct
68 {
69  uint32_t time;
71  const char *text;
74 } _dlg_state;
75 
76 typedef struct
77 {
78  const char *title;
80  const size_t count;
81  const dlg_cb_t on_load; //after start
82  const dlg_loop_cb_t on_loop; //begin of each cycle
83  const dlg_cb_t on_timeout; //check inside loop
84  const dlg_cb_t on_done; //before finish
85 } _cl_dlg;
86 
94  uint16_t flags;
95  uint8_t last_text_h; //hack todo remove me
96 
97  const _cl_dlg *_ths;
100 
104 
105 #pragma pack(pop)
106 
107 #ifdef __cplusplus
108 extern "C" {
109 #endif //__cplusplus
110 
111 //flags are not directly accessible from outside
114 
118 
120 
121 extern dlg_result_t _gui_dlg(const _cl_dlg *_ths, void *p_additional_vars, int32_t ttl);
122 
124 
125 //button draw mwthods
129  window_dlg_statemachine_t *window, uint8_t event, void *param);
130 
131 #ifdef __cplusplus
132 }
133 #endif //__cplusplus
134 
135 #endif //_WINDOW_DLG_STATEMACHINE_H
_cl_dlg::on_timeout
const dlg_cb_t on_timeout
Definition: window_dlg_statemachine.h:83
_window_class_dlg_statemachine_t::cls
window_class_t cls
Definition: window_dlg_statemachine.h:102
phase_changed_log
static void phase_changed_log(int phase, int base_progress)
Definition: window_dlg_statemachine.c:461
window_draw_t
void() window_draw_t(void *window)
Definition: window.h:57
_window_dlg_statemachine_t::_ths
const _cl_dlg * _ths
Definition: window_dlg_statemachine.h:97
_cl_dlg::p_states
const _dlg_state * p_states
Definition: window_dlg_statemachine.h:79
_window_class_dlg_statemachine_t
Definition: window_dlg_statemachine.h:101
BT_ENABLED
#define BT_ENABLED
Definition: window_dlg_statemachine.h:15
WINDOW_CLS_DLG_LOADUNLOAD
int16_t WINDOW_CLS_DLG_LOADUNLOAD
Definition: window_dlg_statemachine.c:37
progress_draw
void progress_draw(rect_ui16_t win_rect, font_t *font, color_t color_back, color_t color_text, padding_ui8_t padding, uint8_t progress)
Definition: window_dlg_statemachine.c:108
_gui_dlg
dlg_result_t _gui_dlg(const _cl_dlg *_ths, void *p_additional_vars, int32_t ttl)
Definition: window_dlg_statemachine.c:257
window_capture
int16_t window_capture(void)
Definition: window.c:169
_rect_ui16_t::y
uint16_t y
Definition: guitypes.h:71
_font_t::h
uint8_t h
Definition: guitypes.h:78
_window_dlg_statemachine_t::color_back
color_t color_back
Definition: window_dlg_statemachine.h:89
_cl_dlg
Definition: window_dlg_statemachine.h:76
_display_t::h
uint16_t h
Definition: display.h:26
_rect_ui16_t::w
uint16_t w
Definition: guitypes.h:72
DLG_BT_FLG
#define DLG_BT_FLG
Definition: window_dlg_statemachine.h:19
_window_dlg_statemachine_draw_phase_text
void _window_dlg_statemachine_draw_phase_text(window_dlg_statemachine_t *window)
Definition: window_dlg_statemachine.c:160
_font_t
Definition: guitypes.h:76
_dlg_vars::flags
uint8_t flags
Definition: window_dlg_statemachine.h:38
DLG_PRX_CH
#define DLG_PRX_CH
Definition: window_dlg_statemachine.c:31
WINDOW_CLS_DLG_LOADUNLOAD
int16_t WINDOW_CLS_DLG_LOADUNLOAD
Definition: window_dlg_statemachine.c:37
MARLIN_VAR_INDEX_E
#define MARLIN_VAR_INDEX_E
Definition: marlin_vars.h:67
_gui_dlg
dlg_result_t _gui_dlg(const _cl_dlg *_ths, void *p_additional_vars, int32_t ttl)
Definition: window_dlg_statemachine.c:257
_dlg_state::progress_draw
window_draw_dlg_cb_t * progress_draw
Definition: window_dlg_statemachine.h:70
_gui_defaults_t::color_text
color_t color_text
Definition: guitypes.h:108
BT_AUTOEXIT
#define BT_AUTOEXIT
Definition: window_dlg_statemachine.h:17
set_repaint_btn_flg
void set_repaint_btn_flg(window_dlg_statemachine_t *window)
Definition: window_dlg_statemachine.c:49
is_repaint_btn_flg
int is_repaint_btn_flg(window_dlg_statemachine_t *window)
Definition: window_dlg_statemachine.c:53
_cl_dlg::on_loop
const dlg_loop_cb_t on_loop
Definition: window_dlg_statemachine.h:82
DLG_PPR_CH
#define DLG_PPR_CH
Definition: window_dlg_statemachine.c:30
MARLIN_VAR_MOTION
#define MARLIN_VAR_MOTION
Definition: marlin_vars.h:8
is_repaint_btn_flg
int is_repaint_btn_flg(window_dlg_statemachine_t *window)
Definition: window_dlg_statemachine.c:53
ALIGN_CENTER
#define ALIGN_CENTER
Definition: guitypes.h:19
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
progress_clr
void progress_clr(rect_ui16_t win_rect, font_t *font, color_t color_back)
Definition: window_dlg_statemachine.c:130
_dlg_state::state_fnc
dlg_state_func state_fnc
Definition: window_dlg_statemachine.h:73
_gui_defaults_t::font
font_t * font
Definition: guitypes.h:110
_dlg_state::text
const char * text
Definition: window_dlg_statemachine.h:71
_dlg_state
Definition: window_dlg_statemachine.h:67
window_destroy
void window_destroy(int16_t id)
Definition: window.c:132
_window_dlg_statemachine_t::last_text_h
uint8_t last_text_h
Definition: window_dlg_statemachine.h:95
window_dlg_statemachine_draw_progress_none
void window_dlg_statemachine_draw_progress_none(window_dlg_statemachine_t *window)
Definition: window_dlg_statemachine.c:156
window_dlg_statemachine_event_1bt
void window_dlg_statemachine_event_1bt(window_dlg_statemachine_t *window, uint8_t event, void *param)
Definition: window_dlg_statemachine.c:235
WINDOW_CLS_USER
#define WINDOW_CLS_USER
Definition: window.h:21
DLG_BTN_CH
#define DLG_BTN_CH
Definition: window_dlg_statemachine.c:27
_gui_defaults_t::msg_box_sz
rect_ui16_t msg_box_sz
Definition: guitypes.h:114
_dlg_button_t::draw_cb
window_draw_dlg_cb_t * draw_cb
Definition: window_dlg_statemachine.h:63
window_dlg_statemachine_init
void window_dlg_statemachine_init(window_dlg_statemachine_t *window)
Definition: window_dlg_statemachine.c:57
print_log
static void print_log()
Definition: window_dlg_statemachine.c:463
_dlg_vars::phase
int8_t phase
Definition: window_dlg_statemachine.h:39
_window_dlg_statemachine_draw_frame
void _window_dlg_statemachine_draw_frame(window_dlg_statemachine_t *window)
Definition: window_dlg_statemachine.c:100
dbg.h
window_dlg_statemachine_draw_progress_tot
void window_dlg_statemachine_draw_progress_tot(window_dlg_statemachine_t *window)
Definition: window_dlg_statemachine.c:144
window_dlg_statemachine_draw_progress_part
void window_dlg_statemachine_draw_progress_part(window_dlg_statemachine_t *window)
Definition: window_dlg_statemachine.c:150
NULL
#define NULL
Definition: usbd_def.h:53
_window_dlg_statemachine_t::color_text
color_t color_text
Definition: window_dlg_statemachine.h:90
dlg_loop_cb_t
loop_result_t(* dlg_loop_cb_t)(_dlg_vars *p_vars, void *p_additional_vars)
Definition: window_dlg_statemachine.h:57
_window_dlg_statemachine_t
Definition: window_dlg_statemachine.h:87
_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
button_draw.h
_window_dlg_statemachine_t::vars
_dlg_vars vars
Definition: window_dlg_statemachine.h:98
window_draw_dlg_cb_t
void() window_draw_dlg_cb_t(window_dlg_statemachine_t *window)
Definition: window_dlg_statemachine.h:28
_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
is_part_log
static void is_part_log(int part_progress)
Definition: window_dlg_statemachine.c:457
dlg_state_func
int(* dlg_state_func)(_dlg_vars *p_vars, void *p_additional_vars)
Definition: window_dlg_statemachine.h:55
_dlg_vars::time_total
uint32_t time_total
Definition: window_dlg_statemachine.h:47
button_draw
void button_draw(rect_ui16_t rc_btn, const char *text, font_t *pf, int is_selected)
Definition: button_draw.c:5
window_event_dlg_cb_t
void() window_event_dlg_cb_t(window_dlg_statemachine_t *window, uint8_t event, void *param)
Definition: window_dlg_statemachine.h:30
gui_invalidate
void gui_invalidate(void)
Definition: gui.c:66
LOOP_RESULT_BREAK
Definition: window_dlg_statemachine.h:52
_window_dlg_statemachine_t::font_title
font_t * font_title
Definition: window_dlg_statemachine.h:92
COLOR_ORANGE
#define COLOR_ORANGE
Definition: guitypes.h:57
_dlg_button_t::event_cb
window_event_dlg_cb_t * event_cb
Definition: window_dlg_statemachine.h:64
dlg_result.h
_window_dlg_statemachine_t::win
window_t win
Definition: window_dlg_statemachine.h:88
LOOP_RESULT_CONTINUE
Definition: window_dlg_statemachine.h:51
rect_empty_ui16
static int rect_empty_ui16(rect_ui16_t rc)
Definition: guitypes.h:177
_window_t
Definition: window.h:76
_cl_dlg::on_done
const dlg_cb_t on_done
Definition: window_dlg_statemachine.h:84
window_dlg_statemachine_event
void window_dlg_statemachine_event(window_dlg_statemachine_t *window, uint8_t event, void *param)
Definition: window_dlg_statemachine.c:228
_dlg_vars::base_progress
uint8_t base_progress
Definition: window_dlg_statemachine.h:44
menu_vars.h
void
void
Definition: png.h:1083
_dlg_button_t::flags
uint8_t flags
Definition: window_dlg_statemachine.h:62
_gui_defaults_t::color_back
color_t color_back
Definition: guitypes.h:107
display_helper.h
window_set_capture
void window_set_capture(int16_t id)
Definition: window.c:500
_padding_ui8_t
Definition: guitypes.h:86
if
if(size<=((png_alloc_size_t) -1) - ob)
Definition: pngwrite.c:2176
_phase_time_total
static uint32_t _phase_time_total(int phase, const _cl_dlg *_ths)
Definition: window_dlg_statemachine.c:375
MARLIN_VAR_POS_E
#define MARLIN_VAR_POS_E
Definition: marlin_vars.h:18
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
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
_dlg_vars::prev_phase
int8_t prev_phase
Definition: window_dlg_statemachine.h:40
dlg_result_t
dlg_result_t
Definition: dlg_result.h:9
_dlg_state::time
uint32_t time
Definition: window_dlg_statemachine.h:69
window_dlg_statemachine_draw_0bt
void window_dlg_statemachine_draw_0bt(window_dlg_statemachine_t *window)
Definition: window_dlg_statemachine.c:94
uint8_t
const uint8_t[]
Definition: 404_html.c:3
_window_class_t
Definition: window.h:67
_dbg
#define _dbg(...)
Definition: dbg.h:50
progress_changed_log
static void progress_changed_log(int progress)
Definition: window_dlg_statemachine.c:459
DLG_OK
Definition: dlg_result.h:10
MARLIN_VAR_MSK
#define MARLIN_VAR_MSK(v_id)
Definition: marlin_vars.h:35
_dlg_vars
Definition: window_dlg_statemachine.h:36
display
display_t * display
Definition: display.c:6
_rect_ui16_t::h
uint16_t h
Definition: guitypes.h:73
_dlg_vars::part_progress
uint8_t part_progress
Definition: window_dlg_statemachine.h:43
_window_t::rect
rect_ui16_t rect
Definition: window.h:101
_cl_dlg::title
const char * title
Definition: window_dlg_statemachine.h:78
_dlg_state::p_button
const _dlg_button_t * p_button
Definition: window_dlg_statemachine.h:72
window_dlg_statemachine_draw
void window_dlg_statemachine_draw(window_dlg_statemachine_t *window)
Definition: window_dlg_statemachine.c:187
_window_t::f_visible
uint32_t f_visible
Definition: window.h:85
WINDOW_EVENT_CLICK
#define WINDOW_EVENT_CLICK
Definition: window.h:46
_window_dlg_statemachine_t::font
font_t * font
Definition: window_dlg_statemachine.h:91
_get_dlg_statemachine_button_size
rect_ui16_t _get_dlg_statemachine_button_size(window_dlg_statemachine_t *window)
Definition: window_dlg_statemachine.c:78
stm32f4xx_hal.h
This file contains all the functions prototypes for the HAL module driver.
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_dlg_statemachine_draw_progress_none
void window_dlg_statemachine_draw_progress_none(window_dlg_statemachine_t *window)
Definition: window_dlg_statemachine.c:156
DLG_TXT_CH
#define DLG_TXT_CH
Definition: window_dlg_statemachine.c:28
DLG_PRO_CH
#define DLG_PRO_CH
Definition: window_dlg_statemachine.c:29
window_dlg_statemachine_draw_1bt
void window_dlg_statemachine_draw_1bt(window_dlg_statemachine_t *window)
Definition: window_dlg_statemachine.c:87
window_class_dlg_statemachine
const window_class_dlg_statemachine_t window_class_dlg_statemachine
Definition: window_dlg_statemachine.c:246
window.h
_marlin_vars_t
Definition: marlin_vars.h:77
_rect_ui16_t::x
uint16_t x
Definition: guitypes.h:70
_window_dlg_statemachine_t::padding
padding_ui8_t padding
Definition: window_dlg_statemachine.h:93
_display_t::w
uint16_t w
Definition: display.h:25
MARLIN_VAR_INDEX_Z
#define MARLIN_VAR_INDEX_Z
Definition: marlin_vars.h:66
createSpeedLookupTable.int
int
Definition: createSpeedLookupTable.py:15
window_class_dlg_statemachine
const window_class_dlg_statemachine_t window_class_dlg_statemachine
Definition: window_dlg_statemachine.c:246
_dlg_vars::prev_part_progress
uint8_t prev_part_progress
Definition: window_dlg_statemachine.h:45
color_t
uint32_t color_t
Definition: guitypes.h:62
window_dlg_statemachine_draw_progress_tot
void window_dlg_statemachine_draw_progress_tot(window_dlg_statemachine_t *window)
Definition: window_dlg_statemachine.c:144
_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
_marlin_vars_t::pos
float pos[4]
Definition: marlin_vars.h:82
gui.h
window_dlg_statemachine_draw_progress_part
void window_dlg_statemachine_draw_progress_part(window_dlg_statemachine_t *window)
Definition: window_dlg_statemachine.c:150
gui_defaults
gui_defaults_t gui_defaults
Definition: gui.c:20
WINDOW_EVENT_BTN_DN
#define WINDOW_EVENT_BTN_DN
Definition: window.h:38
_cl_dlg::count
const size_t count
Definition: window_dlg_statemachine.h:80
_dlg_vars::progress
uint8_t progress
Definition: window_dlg_statemachine.h:41
window_1
window_t * window_1
Definition: window.c:14
_get_dlg_statemachine_button_size
rect_ui16_t _get_dlg_statemachine_button_size(window_dlg_statemachine_t *window)
Definition: window_dlg_statemachine.c:78
window_dlg_statemachine.h
DLG_PHA_CH
#define DLG_PHA_CH
Definition: window_dlg_statemachine.c:32
window_dlg_statemachine_draw_1bt
void window_dlg_statemachine_draw_1bt(window_dlg_statemachine_t *window)
Definition: window_dlg_statemachine.c:87
_dlg_vars::tick_part_start
uint32_t tick_part_start
Definition: window_dlg_statemachine.h:46
DLG_DRA_FR
#define DLG_DRA_FR
Definition: window_dlg_statemachine.c:25
_dlg_button_t::labels
const char ** labels
Definition: window_dlg_statemachine.h:61
_window_t::flg
uint32_t flg
Definition: window.h:81
_display_t::draw_line
display_draw_line_t * draw_line
Definition: display.h:31
window_class_dlg_statemachine_t
struct _window_class_dlg_statemachine_t window_class_dlg_statemachine_t
window_dlg_statemachine_event_1bt
void window_dlg_statemachine_event_1bt(window_dlg_statemachine_t *window, uint8_t event, void *param)
Definition: window_dlg_statemachine.c:235
clr_logs
static void clr_logs()
Definition: window_dlg_statemachine.c:455
dlg_cb_t
void(* dlg_cb_t)(void)
Definition: window_dlg_statemachine.h:56
loop_result_t
loop_result_t
Definition: window_dlg_statemachine.h:50
_cl_dlg::on_load
const dlg_cb_t on_load
Definition: window_dlg_statemachine.h:81
WINDOW_FLG_ENABLED
#define WINDOW_FLG_ENABLED
Definition: window.h:25
_window_dlg_statemachine_t::flags
uint16_t flags
Definition: window_dlg_statemachine.h:94
window_dlg_statemachine_draw_0bt
void window_dlg_statemachine_draw_0bt(window_dlg_statemachine_t *window)
Definition: window_dlg_statemachine.c:94
_dlg_vars::prev_progress
uint8_t prev_progress
Definition: window_dlg_statemachine.h:42
_dlg_button_t
Definition: window_dlg_statemachine.h:59
point_ui16
static point_ui16_t point_ui16(uint16_t x, uint16_t y)
Definition: guitypes.h:154
set_repaint_btn_flg
void set_repaint_btn_flg(window_dlg_statemachine_t *window)
Definition: window_dlg_statemachine.c:49
window_dlg_statemachine_t
struct _window_dlg_statemachine_t window_dlg_statemachine_t
Definition: window_dlg_statemachine.h:9