Prusa MINI Firmware overview
|
#include "screen_print_preview.h"
#include "dbg.h"
#include "ff.h"
#include "gcode_file.h"
#include "gui.h"
#include "marlin_client.h"
#include "resource.h"
#include "screen_printing.h"
#include "window_dlg_load.h"
#include "filament_sensor.h"
#include <stdarg.h>
#include <stdbool.h>
◆ DBG
◆ HEADER_HEIGHT
◆ PADDING
◆ SCREEN_WIDTH
◆ SCREEN_HEIGHT
#define SCREEN_HEIGHT 320 |
◆ THUMBNAIL_HEIGHT
#define THUMBNAIL_HEIGHT 124 |
◆ TITLE_HEIGHT
◆ LINE_HEIGHT
◆ LINE_SPACING
◆ BACK_BUTTON_ID
#define BACK_BUTTON_ID 0x11 |
◆ PRINT_BUTTON_ID
#define PRINT_BUTTON_ID 0x12 |
◆ pd
◆ name_equals
#define name_equals |
( |
|
str | ) |
(!strncmp(name_buffer, str, sizeof(name_buffer))) |
◆ screen_print_preview_init()
241 if (
pd->gcode_has_thumbnail) {
244 pd->redraw_thumbnail =
true;
◆ screen_print_preview_done()
284 if (
pd->gcode_file_opened) {
286 pd->gcode_file_opened =
false;
287 pd->gcode_has_thumbnail =
false;
◆ screen_print_preview_draw()
◆ screen_print_preview_event()
315 const char *btns[3] = {
"YES",
"NO",
"IGNORE" };
316 switch (gui_msgbox_ex(0,
317 "Filament not detected. Load filament now? Select NO to cancel, or IGNORE to disable the filament sensor and continue.",
340 pd->redraw_thumbnail) {
348 DBG(
"print preview: f_gcode_thumb_open returned non-zero value");
350 pd->redraw_thumbnail =
false;
◆ screen_print_preview_set_gcode_filepath()
void screen_print_preview_set_gcode_filepath |
( |
const char * |
fpath | ) |
|
◆ screen_print_preview_get_gcode_filepath()
const char * screen_print_preview_get_gcode_filepath |
( |
| ) |
|
◆ screen_print_preview_set_gcode_filename()
void screen_print_preview_set_gcode_filename |
( |
const char * |
fname | ) |
|
◆ screen_print_preview_set_on_action()
◆ initialize_description_line()
static void initialize_description_line |
( |
screen_t * |
screen, |
|
|
int |
idx, |
|
|
int |
y_pos, |
|
|
const char * |
title, |
|
|
const char * |
value_fmt, |
|
|
|
... |
|
) |
| |
|
static |
119 va_start(
args, value_fmt);
◆ initialize_description_lines()
static void initialize_description_lines |
( |
screen_t * |
screen, |
|
|
int |
y |
|
) |
| |
|
static |
132 if (
pd->gcode_printing_time[0]) {
134 pd->gcode_printing_time);
141 if (
pd->gcode_has_thumbnail) {
143 if (
pd->gcode_filament_type[0] &&
pd->gcode_filament_used_mm &&
pd->gcode_filament_used_g) {
145 screen, line_idx++, y,
"material",
"%s/%u g/%0.2f m",
146 pd->gcode_filament_type,
pd->gcode_filament_used_g,
147 (
double)((
float)
pd->gcode_filament_used_mm / 1000.0F));
152 if (
pd->gcode_filament_type[0]) {
154 pd->gcode_filament_type);
158 if (
pd->gcode_filament_used_mm &&
pd->gcode_filament_used_g) {
160 screen, line_idx++, y,
"used filament",
"%.2f m",
161 (
double)((
float)
pd->gcode_filament_used_mm / 1000.0F));
165 (
double)
pd->gcode_filament_used_g);
◆ initialize_gcode_file()
172 memset(&
pd->gcode_file, 1,
sizeof(
FIL));
173 pd->gcode_file_opened =
false;
174 pd->gcode_has_thumbnail =
false;
180 pd->gcode_file_opened =
true;
187 pd->gcode_has_thumbnail = fread((
void *)&buffer, 1, 1, &f) > 0;
193 pd->gcode_printing_time[0] = 0;
194 pd->gcode_filament_type[0] = 0;
195 pd->gcode_filament_used_mm = 0;
196 pd->gcode_filament_used_g = 0;
197 const unsigned search_last_x_bytes = 10000;
199 f_lseek(&
pd->gcode_file, filesize > search_last_x_bytes ? filesize - search_last_x_bytes : 0);
200 char name_buffer[64];
201 char value_buffer[32];
203 &
pd->gcode_file, name_buffer,
sizeof(name_buffer), value_buffer,
204 sizeof(value_buffer))) {
206 #define name_equals(str) (!strncmp(name_buffer, str, sizeof(name_buffer)))
208 if (
name_equals(
"estimated printing time (normal mode)")) {
209 snprintf(
pd->gcode_printing_time,
sizeof(
pd->gcode_printing_time),
212 snprintf(
pd->gcode_filament_type,
sizeof(
pd->gcode_filament_type),
215 sscanf(value_buffer,
"%u", &
pd->gcode_filament_used_mm);
217 sscanf(value_buffer,
"%u", &
pd->gcode_filament_used_g);
◆ gcode_file_exists()
static bool gcode_file_exists |
( |
screen_t * |
screen | ) |
|
|
static |
◆ gcode_file_name
◆ gcode_file_path
◆ action_handler
◆ screen_print_preview
◆ menu_icons
const uint16_t menu_icons[2] |
◆ pscreen_print_preview
◆ suppress_draw
void window_set_alignment(int16_t id, uint8_t alignment)
Definition: window.c:561
int f_gcode_thumb_close(FILE *fp)
Definition: gcode_file.cpp:52
#define PADDING
Definition: screen_print_preview.c:41
static const char * gcode_file_name
Definition: screen_print_preview.c:52
Definition: screen_print_preview.h:10
#define PRINT_BUTTON_ID
Definition: screen_print_preview.c:50
#define SCREEN_WIDTH
Definition: screen_print_preview.c:42
static void initialize_description_line(screen_t *screen, int idx, int y_pos, const char *title, const char *value_fmt,...)
Definition: screen_print_preview.c:98
uint16_t y
Definition: guitypes.h:71
uint16_t w
Definition: guitypes.h:72
#define THUMBNAIL_HEIGHT
Definition: screen_print_preview.c:44
void window_set_padding(int16_t id, padding_ui8_t padding)
Definition: window.c:549
#define TITLE_HEIGHT
Definition: screen_print_preview.c:45
FRESULT f_stat(const TCHAR *path, FILINFO *fno)
Definition: ff.c:4412
#define IDR_PNG_menu_icon_stop
Definition: resource.h:36
void window_set_color_back(int16_t id, color_t clr)
Definition: window.c:431
#define SCREEN_HEIGHT
Definition: screen_print_preview.c:43
#define LINE_HEIGHT
Definition: screen_print_preview.c:46
#define MSGBOX_RES_CUSTOM1
Definition: window_msgbox.h:50
FRESULT f_open(FIL *fp, const TCHAR *path, BYTE mode)
Definition: ff.c:3296
#define ALIGN_CENTER
Definition: guitypes.h:19
static rect_ui16_t rect_ui16(uint16_t x, uint16_t y, uint16_t w, uint16_t h)
Definition: guitypes.h:159
void window_destroy(int16_t id)
Definition: window.c:132
Definition: screen_print_preview.c:22
static padding_ui8_t padding_ui8(uint8_t l, uint8_t t, uint8_t r, uint8_t b)
Definition: guitypes.h:164
#define DBG
Definition: screen_print_preview.c:14
bool f_gcode_get_next_comment_assignment(FIL *fp, char *name_buffer, int name_buffer_len, char *value_buffer, int value_buffer_len)
Definition: gcode_file.cpp:94
rect_ui16_t msg_box_sz
Definition: guitypes.h:114
void window_set_icon_id(int16_t id, uint16_t id_res)
Definition: window.c:659
Definition: screen_print_preview.c:16
DWORD FSIZE_t
Definition: ff.h:78
static void screen_print_preview_draw(screen_t *screen)
Definition: screen_print_preview.c:292
#define NULL
Definition: usbd_def.h:53
#define ALIGN_LEFT_BOTTOM
Definition: guitypes.h:22
int16_t window_id(window_t *ptr)
Definition: window.c:86
static void screen_print_preview_done(screen_t *screen)
Definition: screen_print_preview.c:283
void screen_close(void)
Definition: screen.c:80
Definition: screen_print_preview.h:9
#define COLOR_GRAY
Definition: guitypes.h:50
#define ALIGN_RIGHT_BOTTOM
Definition: guitypes.h:25
void window_set_text(int16_t id, const char *text)
Definition: window.c:340
window_text_t title
Definition: screen_print_preview.c:17
#define pd
Definition: screen_print_preview.c:79
#define MSGBOX_RES_CUSTOM2
Definition: window_msgbox.h:51
static int suppress_draw
Definition: screen_print_preview.c:302
#define FA_READ
Definition: ff.h:326
static print_preview_action_handler_t action_handler
Definition: screen_print_preview.c:54
int f_gcode_thumb_open(FILE *fp, FIL *gcode_fp)
Definition: gcode_file.cpp:29
#define WINDOW_CLS_FRAME
Definition: window.h:9
#define f_size(fp)
Definition: ff.h:280
#define BACK_BUTTON_ID
Definition: screen_print_preview.c:49
void reset_print_state(void)
Definition: screen_printing.cpp:131
static void initialize_gcode_file(screen_t *screen)
Definition: screen_print_preview.c:171
uint8_t w
Definition: guitypes.h:77
display_draw_png_t * draw_png
Definition: display.h:37
#define MSGBOX_RES_CUSTOM0
Definition: window_msgbox.h:49
static bool gcode_file_exists(screen_t *screen)
Definition: screen_print_preview.c:295
void window_set_tag(int16_t id, uint8_t tag)
Definition: window.c:329
FRESULT f_lseek(FIL *fp, FSIZE_t ofs)
Definition: ff.c:4060
dlg_result_t gui_dlg_load_forced(void)
Definition: window_dlg_load.c:124
#define IDR_FNT_BIG
Definition: resource.h:11
display_t * display
Definition: display.c:6
#define WINDOW_CLS_ICON
Definition: window.h:12
static void initialize_description_lines(screen_t *screen, int y)
Definition: screen_print_preview.c:128
static void screen_print_preview_init(screen_t *screen)
Definition: screen_print_preview.c:222
#define MSGBOX_BTN_CUSTOM3
Definition: window_msgbox.h:28
#define WINDOW_CLS_TEXT
Definition: window.h:10
font_t * resource_font(uint16_t id)
Definition: guitypes.c:186
#define WINDOW_EVENT_CLICK
Definition: window.h:46
int16_t window_create_ptr(int16_t cls_id, int16_t id_parent, rect_ui16_t rect, void *ptr)
Definition: window.c:102
void window_enable(int16_t id)
Definition: window.c:517
#define IDR_FNT_SMALL
Definition: resource.h:9
#define WINDOW_EVENT_LOOP
Definition: window.h:49
#define IDR_PNG_menu_icon_print
Definition: resource.h:28
void window_draw(int16_t id)
Definition: window.c:277
font_t * font
Definition: window_text.h:19
static int screen_print_preview_event(screen_t *screen, window_t *window, uint8_t event, void *param)
Definition: screen_print_preview.c:304
gui_defaults_t gui_defaults
Definition: gui.c:20
char value_buffer[32]
Definition: screen_print_preview.c:19
args
Definition: createSpeedLookupTable.py:17
void fs_disable()
Definition: filament_sensor.c:97
static const char * gcode_file_path
Definition: screen_print_preview.c:53
window_text_t value
Definition: screen_print_preview.c:18
#define IDR_PNG_menu_icon_back
Definition: resource.h:74
int fs_did_filament_runout()
Definition: filament_sensor.c:72
#define LINE_SPACING
Definition: screen_print_preview.c:47
FRESULT f_close(FIL *fp)
Definition: ff.c:3801
static point_ui16_t point_ui16(uint16_t x, uint16_t y)
Definition: guitypes.h:154