Prusa MINI Firmware overview
guimain.c File Reference
#include <stdio.h>
#include "stm32f4xx_hal.h"
#include "gui.h"
#include "config.h"
#include "marlin_client.h"
#include "window_logo.h"
#include "window_file_list.h"
#include "window_header.h"
#include "window_temp_graph.h"
#include "window_dlg_statemachine.h"
#include "window_dlg_wait.h"
#include "window_dlg_preheat.h"
#include "window_dlg_change.h"
#include "screen_print_preview.h"
#include "screen_lan_settings.h"
#include "screen_menu_fw_update.h"
#include "gpio.h"
#include "st7789v.h"
#include "jogwheel.h"
#include "hwio_a3ides.h"
#include "diag.h"
#include "sys.h"
#include "dbg.h"
#include "marlin_host.h"

Functions

void update_firmware_screen (void)
 
void gui_run (void)
 

Variables

screen_tpscreen_splash
 
screen_tpscreen_watchdog
 
screen_tpscreen_test
 
screen_tpscreen_test_gui
 
screen_tpscreen_test_term
 
screen_tpscreen_test_msgbox
 
screen_tpscreen_test_graph
 
screen_tpscreen_test_temperature
 
screen_tpscreen_home
 
screen_tpscreen_filebrowser
 
screen_tpscreen_printing
 
screen_tpscreen_menu_preheat
 
screen_tpscreen_menu_filament
 
screen_tpscreen_preheating
 
screen_tpscreen_menu_calibration
 
screen_tpscreen_menu_settings
 
screen_tpscreen_menu_temperature
 
screen_tpscreen_menu_move
 
screen_tpscreen_menu_info
 
screen_tpscreen_menu_tune
 
screen_tpscreen_menu_service
 
screen_tpscreen_sysinfo
 
screen_tpscreen_version_info
 
screen_tpscreen_test_disp_mem
 
screen_tpscreen_messages
 
screen_tpscreen_mesh_bed_lv
 
screen_tpscreen_wizard
 
int HAL_IWDG_Reset
 
SPI_HandleTypeDef hspi2
 
IWDG_HandleTypeDef hiwdg
 
int guimain_spi_test = 0
 
const st7789v_config_t st7789v_cfg
 
const jogwheel_config_t jogwheel_cfg
 
marlin_vars_tgui_marlin_vars = 0
 
int8_t menu_timeout_enabled = 1
 

Function Documentation

◆ update_firmware_screen()

void update_firmware_screen ( void  )
247  {
250  display->fill_rect(rect_ui16(0, 0, 240, 320), COLOR_BLACK);
252  display->draw_text(rect_ui16(10, 115, 240, 60), "Hi, this is your\nOriginal Prusa MINI.", font, COLOR_BLACK, COLOR_WHITE);
253  display->draw_text(rect_ui16(10, 160, 240, 80), "Please insert the USB\ndrive that came with\nyour MINI and reset\nthe printer to flash\nthe firmware", font, COLOR_BLACK, COLOR_WHITE);
254  render_text_align(rect_ui16(5, 250, 230, 40), "RESET PRINTER", font1, COLOR_ORANGE, COLOR_WHITE, padding_ui8(2, 6, 2, 2), ALIGN_CENTER);
255  while (1) {
256  if (jogwheel_button_down > 50)
257  sys_reset();
258  osDelay(1);
259 #ifndef _DEBUG
260  HAL_IWDG_Refresh(&hiwdg); //watchdog reset
261 #endif //_DEBUG
262  }
263 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ gui_run()

void gui_run ( void  )
107  {
108  if (diag_fastboot)
109  return;
110 
113  gui_init();
114 
115  // select jogwheel type by meassured 'reset delay'
116  // original displays with 15 position encoder returns values 1-2 (short delay - no capacitor)
117  // new displays with MK3 encoder returns values around 16000 (long delay - 100nF capacitor)
118  if (st7789v_reset_delay > 1000) // threshold value is 1000
120  //_dbg("delay=%u", st7789v_reset_delay);
121 
124  window_msgbox_id_icon[0] = 0; //IDR_PNG_icon_pepa;
129 
130  if (!sys_fw_is_valid())
132 
134 
135  hwio_beeper_tone2(440.0, 100, 0.0125); //start beep
136 
139 
141 #ifdef LCDSIM
144 #else //LCDSIM
150  #ifdef _DEBUG
152  #endif //_DEBUG
176  #ifdef PIDCALIBRATION
177  screen_register(pscreen_PID);
178  #endif //PIDCALIBRATION
184 #endif // LCDSIM
185 
186 #ifndef _DEBUG
187  if (HAL_IWDG_Reset) {
190  } else
191 #endif // _DEBUG
193 
194  //set loop callback (will be called every time inside gui_loop)
196  int8_t gui_timeout_id;
197  while (1) {
198  float vol = 0.01F;
199  //simple jogwheel acoustic feedback
200  if ((jogwheel_changed & 1) && jogwheel_button_down) //button changed and pressed
201  hwio_beeper_tone2(200.0, 50, (double)(vol * 0.125F)); //beep
202  else if (jogwheel_changed & 2) // encoder changed
203  hwio_beeper_tone2(50.0, 25, (double)(vol * 0.125F)); //short click
204  // show warning dialog on safety timer expiration
206  gui_msgbox("Heating disabled due to 30 minutes of inactivity.", MSGBOX_BTN_OK | MSGBOX_ICO_WARNING);
207  }
208  gui_loop();
209 #ifndef LCDSIM
210  if (marlin_message_received()) {
211  screen_t *curr = screen_get_curr();
212  if (curr == pscreen_printing) {
214  }
215  }
216  if (menu_timeout_enabled) {
217  gui_timeout_id = gui_get_menu_timeout_id();
218  if (gui_timer_expired(gui_timeout_id) == 1) {
219  screen_t *curr = screen_get_curr();
220  if (
221  curr != pscreen_menu_tune && curr != pscreen_wizard && curr != pscreen_print_preview) { //timeout screen black list
222  #ifdef PIDCALIBRATION
223  if (curr != pscreen_PID) {
224  #endif //PIDCALIBRATION
225  while (curr != pscreen_printing && curr != pscreen_home && curr != pscreen_menu_tune) {
226  screen_close();
227  curr = screen_get_curr();
228  }
229  #ifdef PIDCALIBRATION
230  }
231  #endif //PIDCALIBRATION
232  }
233  gui_timer_delete(gui_timeout_id);
234  }
235  }
237  if (marlin_command() == MARLIN_CMD_M600) {
238  _dbg("M600 start");
239  gui_dlg_change();
240  _dbg("M600 end");
241  }
242  }
243 #endif //LCDSIM
244  }
245 }

Variable Documentation

◆ pscreen_splash

screen_t* pscreen_splash

◆ pscreen_watchdog

screen_t* pscreen_watchdog

◆ pscreen_test

screen_t* pscreen_test

◆ pscreen_test_gui

screen_t* pscreen_test_gui

◆ pscreen_test_term

screen_t* pscreen_test_term

◆ pscreen_test_msgbox

screen_t* pscreen_test_msgbox

◆ pscreen_test_graph

screen_t* pscreen_test_graph

◆ pscreen_test_temperature

screen_t* pscreen_test_temperature

◆ pscreen_home

screen_t* pscreen_home

◆ pscreen_filebrowser

screen_t* pscreen_filebrowser

◆ pscreen_printing

screen_t* pscreen_printing

◆ pscreen_menu_preheat

screen_t* pscreen_menu_preheat

◆ pscreen_menu_filament

screen_t* pscreen_menu_filament

◆ pscreen_preheating

screen_t* pscreen_preheating

◆ pscreen_menu_calibration

screen_t* pscreen_menu_calibration

◆ pscreen_menu_settings

screen_t* pscreen_menu_settings

◆ pscreen_menu_temperature

screen_t* pscreen_menu_temperature

◆ pscreen_menu_move

screen_t* pscreen_menu_move

◆ pscreen_menu_info

screen_t* pscreen_menu_info

◆ pscreen_menu_tune

screen_t* pscreen_menu_tune

◆ pscreen_menu_service

screen_t* pscreen_menu_service

◆ pscreen_sysinfo

screen_t* pscreen_sysinfo

◆ pscreen_version_info

screen_t* pscreen_version_info

◆ pscreen_test_disp_mem

screen_t* pscreen_test_disp_mem

◆ pscreen_messages

screen_t* pscreen_messages

◆ pscreen_mesh_bed_lv

screen_t* pscreen_mesh_bed_lv

◆ pscreen_wizard

screen_t* pscreen_wizard

◆ HAL_IWDG_Reset

int HAL_IWDG_Reset

◆ hspi2

◆ hiwdg

Marlin 3D Printer Firmware Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]

Based on Sprinter and grbl. Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

◆ guimain_spi_test

int guimain_spi_test = 0

◆ st7789v_cfg

◆ jogwheel_cfg

◆ gui_marlin_vars

marlin_vars_t* gui_marlin_vars = 0

◆ menu_timeout_enabled

int8_t menu_timeout_enabled = 1
RENDER_FLG
#define RENDER_FLG(a, r)
Definition: display_helper.h:10
pscreen_test_msgbox
screen_t * pscreen_test_msgbox
Definition: screen_test_msgbox.c:147
pscreen_test_term
screen_t * pscreen_test_term
Definition: screen_test_term.c:78
window_register_class
int16_t window_register_class(window_class_t *cls)
Definition: window.c:90
jogwheel_config
jogwheel_config_t jogwheel_config
Definition: jogwheel.c:95
WINDOW_CLS_DLG_LOADUNLOAD
int16_t WINDOW_CLS_DLG_LOADUNLOAD
Definition: window_dlg_statemachine.c:37
window_msgbox_id_icon
uint16_t window_msgbox_id_icon[5]
Definition: window_msgbox.c:62
pscreen_lan_settings
screen_t *const pscreen_lan_settings
Definition: screen_lan_settings.c:294
gui_loop_cb
gui_loop_cb_t * gui_loop_cb
Definition: gui.c:32
MARLIN_EVT_SafetyTimerExpired
#define MARLIN_EVT_SafetyTimerExpired
Definition: marlin_events.h:35
_font_t
Definition: guitypes.h:76
WINDOW_CLS_LCDSIM
int16_t WINDOW_CLS_LCDSIM
Definition: window_lcdsim.c:6
COLOR_WHITE
#define COLOR_WHITE
Definition: guitypes.h:41
jogwheel_changed
uint8_t jogwheel_changed
Definition: jogwheel.c:14
sys_reset
void sys_reset(void)
Definition: sys.cpp:20
update_firmware_screen
void update_firmware_screen(void)
Definition: guimain.c:247
gui_init
void gui_init(void)
Definition: gui.c:43
marlin_message_received
uint8_t marlin_message_received(void)
Definition: marlin_client.c:507
window_class_dlg_preheat
const window_class_dlg_preheat_t window_class_dlg_preheat
Definition: window_dlg_preheat.c:114
pscreen_menu_calibration
screen_t * pscreen_menu_calibration
Definition: screen_menu_calibration.c:101
screen_register
int16_t screen_register(screen_t *pscreen)
Definition: screen.c:24
ALIGN_CENTER
#define ALIGN_CENTER
Definition: guitypes.h:19
window_class_dlg_popup
const window_class_dlg_popup_t window_class_dlg_popup
Definition: window_dlg_popup.c:51
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_defaults_t::font
font_t * font
Definition: guitypes.h:110
jogwheel_cfg
const jogwheel_config_t jogwheel_cfg
Definition: guimain.c:95
padding_ui8
static padding_ui8_t padding_ui8(uint8_t l, uint8_t t, uint8_t r, uint8_t b)
Definition: guitypes.h:164
IDR_FNT_NORMAL
#define IDR_FNT_NORMAL
Definition: resource.h:10
WINDOW_CLS_DLG_PREHEAT
int16_t WINDOW_CLS_DLG_PREHEAT
Definition: window_dlg_preheat.c:22
MSGBOX_ICO_WARNING
#define MSGBOX_ICO_WARNING
Definition: window_msgbox.h:35
IDR_FNT_SPECIAL
#define IDR_FNT_SPECIAL
Definition: resource.h:13
pscreen_menu_service
screen_t * pscreen_menu_service
Definition: screen_menu_service.c:147
pscreen_filebrowser
screen_t * pscreen_filebrowser
Definition: screen_filebrowser.cpp:177
MARLIN_CMD_M600
#define MARLIN_CMD_M600
Definition: marlin_events.h:57
IDR_PNG_icon_pepa
#define IDR_PNG_icon_pepa
Definition: resource.h:44
_display_t::draw_text
display_draw_text_t * draw_text
Definition: display.h:35
ST7789V_DEF_MADCTL
#define ST7789V_DEF_MADCTL
Definition: st7789v.h:14
diag_fastboot
int diag_fastboot
Definition: diag.c:11
screen_open
void screen_open(int16_t screen_id)
Definition: screen.c:62
pscreen_menu_preheat
screen_t * pscreen_menu_preheat
Definition: screen_menu_preheat.cpp:93
marlin_client_loop
void marlin_client_loop(void)
Definition: marlin_client.c:118
NULL
#define NULL
Definition: usbd_def.h:53
F
#define F(str)
Definition: UHS_macros.h:164
WINDOW_CLS_LOGO
int16_t WINDOW_CLS_LOGO
Definition: window_logo.c:11
pscreen_marlin
const screen_t * pscreen_marlin
Definition: screen_marlin.c:33
pscreen_menu_filament
screen_t * pscreen_menu_filament
Definition: screen_menu_filament.c:124
screen_get_curr
screen_t * screen_get_curr(void)
Definition: screen.c:114
window_class_dlg_wait
const window_class_dlg_wait_t window_class_dlg_wait
Definition: window_dlg_wait.c:128
MSGBOX_BTN_OK
#define MSGBOX_BTN_OK
Definition: window_msgbox.h:20
window_class_file_list
const window_class_file_list_t window_class_file_list
Definition: window_file_list.c:250
WINDOW_CLS_DLG_WAIT
int16_t WINDOW_CLS_DLG_WAIT
Definition: window_dlg_wait.c:25
osDelay
osStatus osDelay(uint32_t millisec)
Wait for Timeout (Time Delay)
Definition: cmsis_os.c:365
_display_t::fill_rect
display_fill_rect_t * fill_rect
Definition: display.h:33
gui_dlg_change
dlg_result_t gui_dlg_change(void)
Definition: window_dlg_change.c:35
screen_close
void screen_close(void)
Definition: screen.c:80
IDR_PNG_header_icon_question
#define IDR_PNG_header_icon_question
Definition: resource.h:69
pscreen_wizard
screen_t * pscreen_wizard
Definition: screen_wizard.c:559
pscreen_splash
screen_t * pscreen_splash
Definition: screen_splash.c:144
window_class_temp_graph
const window_class_temp_graph_t window_class_temp_graph
Definition: window_temp_graph.c:132
HAL_IWDG_Refresh
HAL_StatusTypeDef HAL_IWDG_Refresh(IWDG_HandleTypeDef *hiwdg)
st7789v_cfg
const st7789v_config_t st7789v_cfg
Definition: guimain.c:85
pscreen_mesh_bed_lv
screen_t * pscreen_mesh_bed_lv
Definition: screen_mesh_bed_lv.cpp:228
COLOR_ORANGE
#define COLOR_ORANGE
Definition: guitypes.h:57
marlin_client_init
marlin_vars_t * marlin_client_init(void)
Definition: marlin_client.c:84
pscreen_printing
screen_t * pscreen_printing
Definition: screen_printing.cpp:161
pscreen_menu_info
screen_t * pscreen_menu_info
Definition: screen_menu_info.c:66
pscreen_menu_move
screen_t * pscreen_menu_move
Definition: screen_menu_move.c:85
sys_fw_is_valid
int sys_fw_is_valid(void)
Definition: sys.cpp:266
pscreen_test_temperature
screen_t * pscreen_test_temperature
Definition: screen_test_temperature.cpp:109
JOGWHEEL_PIN_EN1
#define JOGWHEEL_PIN_EN1
Definition: config_a3ides2209_02.h:59
MARLIN_EVT_CommandBegin
#define MARLIN_EVT_CommandBegin
Definition: marlin_events.h:33
JOGWHEEL_PIN_ENC
#define JOGWHEEL_PIN_ENC
Definition: config_a3ides2209_02.h:61
hspi2
SPI_HandleTypeDef hspi2
Definition: main.c:81
IDR_PNG_header_icon_error
#define IDR_PNG_header_icon_error
Definition: resource.h:67
JOGWHEEL_DEF_FLG
#define JOGWHEEL_DEF_FLG
Definition: jogwheel.h:15
screen_stack_push
void screen_stack_push(int16_t screen_id)
Definition: screen.c:48
_jogwheel_config_t::flg
uint8_t flg
Definition: jogwheel.h:24
jogwheel_button_down
uint16_t jogwheel_button_down
Definition: jogwheel.c:13
pscreen_menu_fw_update
screen_t *const pscreen_menu_fw_update
Definition: screen_menu_fw_update.c:75
HAL_IWDG_Reset
int HAL_IWDG_Reset
Definition: main.c:103
hiwdg
IWDG_HandleTypeDef hiwdg
Definition: watchdog.h:24
window_class_logo
const window_class_logo_t window_class_logo
Definition: window_logo.c:51
JOGWHEEL_FLG_INV_DIR
#define JOGWHEEL_FLG_INV_DIR
Definition: jogwheel.h:8
WINDOW_CLS_DLG_POPUP
int16_t WINDOW_CLS_DLG_POPUP
Definition: window_dlg_popup.c:16
gui_marlin_vars
marlin_vars_t * gui_marlin_vars
Definition: guimain.c:102
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
IDR_PNG_header_icon_info
#define IDR_PNG_header_icon_info
Definition: resource.h:66
pscreen_test_gui
screen_t * pscreen_test_gui
Definition: screen_test_gui.c:131
_window_class_t
Definition: window.h:67
IDR_FNT_BIG
#define IDR_FNT_BIG
Definition: resource.h:11
_dbg
#define _dbg(...)
Definition: dbg.h:50
IDR_PNG_header_icon_warning
#define IDR_PNG_header_icon_warning
Definition: resource.h:68
display
display_t * display
Definition: display.c:6
_screen_t
Definition: screen.h:18
pscreen_menu_settings
screen_t * pscreen_menu_settings
Definition: screen_menu_settings.c:133
pscreen_test_graph
screen_t * pscreen_test_graph
Definition: screen_test_graph.c:111
marlin_command
uint32_t marlin_command(void)
Definition: marlin_client.c:159
pscreen_home
screen_t * pscreen_home
Definition: screen_home.cpp:278
window_class_header
const window_class_header_t window_class_header
Definition: window_header.c:183
resource_font
font_t * resource_font(uint16_t id)
Definition: guitypes.c:186
WINDOW_CLS_FILE_LIST
int16_t WINDOW_CLS_FILE_LIST
Definition: window_file_list.c:24
ST7789V_DEF_COLMOD
#define ST7789V_DEF_COLMOD
Definition: st7789v.h:13
gui_get_menu_timeout_id
int8_t gui_get_menu_timeout_id(void)
Definition: gui_timer.c:147
ST7789V_FLG_DMA
#define ST7789V_FLG_DMA
Definition: st7789v.h:9
ST7789V_PIN_RS
#define ST7789V_PIN_RS
Definition: config_a3ides2209_02.h:54
COLOR_BLACK
#define COLOR_BLACK
Definition: guitypes.h:40
_screen_t::id
int16_t id
Definition: screen.h:19
window_class_dlg_statemachine
const window_class_dlg_statemachine_t window_class_dlg_statemachine
Definition: window_dlg_statemachine.c:246
JOGWHEEL_PIN_EN2
#define JOGWHEEL_PIN_EN2
Definition: config_a3ides2209_02.h:60
WINDOW_EVENT_MESSAGE
#define WINDOW_EVENT_MESSAGE
Definition: window.h:51
pscreen_test
screen_t * pscreen_test
Definition: screen_test.c:157
WINDOW_CLS_HEADER
int16_t WINDOW_CLS_HEADER
Definition: window_header.c:24
ST7789V_PIN_CS
#define ST7789V_PIN_CS
Definition: config_a3ides2209_02.h:53
_gui_defaults_t::font_big
font_t * font_big
Definition: guitypes.h:111
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
st7789v_reset_delay
uint16_t st7789v_reset_delay
Definition: st7789v.c:920
hwio_beeper_tone2
void hwio_beeper_tone2(float frq, uint32_t del, float vol)
Definition: hwio_a3ides_2209_02.c:530
pscreen_sysinfo
screen_t * pscreen_sysinfo
Definition: screen_sysinf.c:123
screen_dispatch_event
void screen_dispatch_event(window_t *window, uint8_t event, void *param)
Definition: screen.c:103
gui_timer_expired
int8_t gui_timer_expired(int8_t id)
Definition: gui_timer.c:139
ST7789V_PIN_RST
#define ST7789V_PIN_RST
Definition: config_a3ides2209_02.h:55
menu_timeout_enabled
int8_t menu_timeout_enabled
Definition: guimain.c:103
pscreen_menu_tune
screen_t * pscreen_menu_tune
Definition: screen_menu_tune.cpp:203
pscreen_print_preview
screen_t *const pscreen_print_preview
Definition: screen_print_preview.c:77
pscreen_watchdog
screen_t * pscreen_watchdog
Definition: screen_watchdog.c:78
gui_timer_delete
void gui_timer_delete(int8_t id)
Definition: gui_timer.c:79
WINDOW_CLS_TEMP_GRAPH
int16_t WINDOW_CLS_TEMP_GRAPH
Definition: window_temp_graph.c:8
pscreen_menu_temperature
screen_t * pscreen_menu_temperature
Definition: screen_menu_temperature.c:76
pscreen_messages
screen_t * pscreen_messages
Definition: screen_messages.c:122
pscreen_version_info
screen_t * pscreen_version_info
Definition: screen_version_info.cpp:109
window_class_lcdsim
const window_class_lcdsim_t window_class_lcdsim
Definition: window_lcdsim.c:58
marlin_event_clr
int marlin_event_clr(uint8_t evt_id)
Definition: marlin_client.c:252
st7789v_config
st7789v_config_t st7789v_config
Definition: st7789v.c:905
pscreen_test_disp_mem
screen_t * pscreen_test_disp_mem
Definition: screen_test_disp_mem.c:629