🚸 Adjust Progress / Completion (#26466)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
mikemerryguy 2023-12-09 02:38:31 -05:00 committed by GitHub
parent a1c3a2b03a
commit 473817f2f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 72 additions and 57 deletions

View file

@ -33,7 +33,7 @@ void GcodeSuite::M31() {
char buffer[22];
duration_t(print_job_timer.duration()).toString(buffer);
ui.set_status(buffer, ENABLED(DWIN_LCD_PROUI)); // No expire on ProUI
ui.set_status_no_expire(buffer);
SERIAL_ECHO_MSG("Print time: ", buffer);
}

View file

@ -852,7 +852,11 @@
#define HAS_MEDIA_SUBCALLS 1
#endif
#if ANY(SHOW_PROGRESS_PERCENT, SHOW_ELAPSED_TIME, SHOW_REMAINING_TIME, SHOW_INTERACTION_TIME) && !HAS_GRAPHICAL_TFT
#if ANY(SHOW_ELAPSED_TIME, SHOW_REMAINING_TIME, SHOW_INTERACTION_TIME)
#define HAS_TIME_DISPLAY 1
#endif
#if ANY(SHOW_PROGRESS_PERCENT, HAS_TIME_DISPLAY) && !HAS_GRAPHICAL_TFT
#define HAS_EXTRA_PROGRESS 1
#endif

View file

@ -22,15 +22,15 @@
#pragma once
/**
Fontname: -Misc-Fixed-Medium-R-Normal--9-90-75-75-C-60-ISO10646-1
Copyright: Public domain font. Share and enjoy.
Capital A Height: 6, '1' Height: 6
Calculated Max Values w= 6 h= 9 x= 5 y= 5 dx= 6 dy= 0 ascent= 7 len= 9
Font Bounding box w= 6 h= 9 x= 0 y=-2
Calculated Min Values x= 0 y=-2 dx= 0 dy= 0
Pure Font ascent = 6 descent=-2
X Font ascent = 6 descent=-2
Max Font ascent = 7 descent=-2
* Fontname: -Misc-Fixed-Medium-R-Normal--9-90-75-75-C-60-ISO10646-1
* Copyright: Public domain font. Share and enjoy.
* Capital A Height: 6, '1' Height: 6
* Calculated Max Values w= 6 h= 9 x= 5 y= 5 dx= 6 dy= 0 ascent= 7 len= 9
* Font Bounding box w= 6 h= 9 x= 0 y=-2
* Calculated Min Values x= 0 y=-2 dx= 0 dy= 0
* Pure Font ascent = 6 descent=-2
* X Font ascent = 6 descent=-2
* Max Font ascent = 7 descent=-2
*/
#include <U8glib-HAL.h>
const u8g_fntpgm_uint8_t u8g_font_6x9[2434] U8G_FONT_SECTION(".progmem.u8g_font_6x9") = {
@ -186,4 +186,5 @@ const u8g_fntpgm_uint8_t u8g_font_6x9[2434] U8G_FONT_SECTION(".progmem.u8g_font_
0x00,0x50,0x00,0x90,0x90,0x90,0x70,0x04,0x09,0x09,0x06,0x01,0xFE,0x20,0x40,0x00,
0x90,0x90,0x90,0x70,0x90,0x60,0x04,0x08,0x08,0x06,0x01,0xFE,0x80,0x80,0xE0,0x90,
0x90,0xE0,0x80,0x80,0x04,0x08,0x08,0x06,0x01,0xFE,0x50,0x00,0x90,0x90,0x90,0x70,
0x90,0x60};
0x90,0x60
};

View file

@ -91,6 +91,18 @@
#define EXTRAS_BASELINE (40 + INFO_FONT_ASCENT)
#define STATUS_BASELINE (LCD_PIXEL_HEIGHT - INFO_FONT_DESCENT)
#define PCENTERED // Center percent value over progress bar, else right-align
#define PROGRESS_BAR_X TERN(PCENTERED, 54, 40)
#define PROGRESS_BAR_Y (EXTRAS_BASELINE + TERN(PCENTERED, 1, -3))
#define PCT_X TERN(PCENTERED, PROGRESS_BAR_X, LCD_PIXEL_WIDTH - TERN(PRINT_PROGRESS_SHOW_DECIMALS, 5, 4) * INFO_FONT_WIDTH)
#define PCT_Y (EXTRAS_BASELINE + TERN(PCENTERED, 0, 3))
#define PROGRESS_BAR_WIDTH TERN(PCENTERED, LCD_PIXEL_WIDTH - PROGRESS_BAR_X, PCT_X - PROGRESS_BAR_X - 1)
#define PROGRESS_BAR_HEIGHT TERN(PCENTERED, 4, 5)
#if DISABLED(PCENTERED) && HAS_TIME_DISPLAY
#error "PCENTERED is required for extra progress display options."
#endif
#if ANIM_HBCC
enum HeatBits : uint8_t {
DRAWBIT_HOTEND,
@ -188,10 +200,6 @@
}
#endif
#define PROGRESS_BAR_X 54
#define PROGRESS_BAR_Y (EXTRAS_BASELINE + 1)
#define PROGRESS_BAR_WIDTH (LCD_PIXEL_WIDTH - PROGRESS_BAR_X)
FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, const uint8_t ty) {
const char *str;
uint8_t len;
@ -471,46 +479,44 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
// Prepare strings for progress display
#if ANY(HAS_EXTRA_PROGRESS, HAS_PRINT_PROGRESS)
static MarlinUI::progress_t progress = 0;
static char bufferc[13];
static MString<12> progressString;
#endif
#if HAS_EXTRA_PROGRESS
static void prepare_time_string(const duration_t &time, char prefix) {
char str[13];
memset(&bufferc[2], 0x20, 5); // partialy fill with spaces to avoid artifacts and terminator
bufferc[0] = prefix;
bufferc[1] = ':';
int str_length = time.toDigital(str, time.value >= 60*60*24L);
strcpy(&bufferc[sizeof(bufferc) - str_length - 1], str);
}
#if HAS_TIME_DISPLAY
static void prepare_time_string(const duration_t &time, char prefix) {
char str[10];
const uint8_t time_len = time.toDigital(str, time.value >= 60*60*24L); // 5 to 8 chars
progressString.set(prefix, ':', spaces_t(10 - time_len), str); // 2 to 5 spaces
}
#endif
#if ENABLED(SHOW_PROGRESS_PERCENT)
void MarlinUI::drawPercent() {
if (progress != 0) {
#define PCENTERED 1 // center percent value over progress bar, else align to the right
#define PPOS TERN(PCENTERED, 4, 0)
#define PLEN TERN(PRINT_PROGRESS_SHOW_DECIMALS, 4, 3)
memset(&bufferc, 0x20, 12);
memcpy(&bufferc[PPOS], TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(progress), ui8tostr3rj(progress / (PROGRESS_SCALE))), PLEN);
bufferc[PPOS+PLEN] = '%';
}
if (progress == 0) return;
progressString.set(
OPTITEM(PCENTERED, spaces_t(4))
TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(progress), ui8tostr3rj(progress / (PROGRESS_SCALE))), '%'
);
}
#endif
#if ENABLED(SHOW_REMAINING_TIME)
void MarlinUI::drawRemain() {
if (printJobOngoing() && get_remaining_time() != 0)
prepare_time_string(get_remaining_time(), 'R'); }
prepare_time_string(get_remaining_time(), 'R');
}
#endif
#if ENABLED(SHOW_INTERACTION_TIME)
void MarlinUI::drawInter() {
if (printingIsActive() && interaction_time)
prepare_time_string(interaction_time, 'C'); }
prepare_time_string(interaction_time, 'C');
}
#endif
#if ENABLED(SHOW_ELAPSED_TIME)
void MarlinUI::drawElapsed() {
if (printJobOngoing())
prepare_time_string(print_job_timer.duration(), 'E'); }
prepare_time_string(print_job_timer.duration(), 'E');
}
#endif
#endif // HAS_EXTRA_PROGRESS
@ -779,17 +785,17 @@ void MarlinUI::draw_status_screen() {
#if HAS_PRINT_PROGRESS
// Progress bar frame
if (PAGE_CONTAINS(PROGRESS_BAR_Y, PROGRESS_BAR_Y + 3))
u8g.drawFrame(PROGRESS_BAR_X, PROGRESS_BAR_Y, PROGRESS_BAR_WIDTH, 4);
if (PAGE_CONTAINS(PROGRESS_BAR_Y, PROGRESS_BAR_Y + PROGRESS_BAR_HEIGHT - 1))
u8g.drawFrame(PROGRESS_BAR_X, PROGRESS_BAR_Y, PROGRESS_BAR_WIDTH, PROGRESS_BAR_HEIGHT);
// Progress bar solid part
if (PAGE_CONTAINS(PROGRESS_BAR_Y + 1, PROGRESS_BAR_Y + 2))
u8g.drawBox(PROGRESS_BAR_X + 1, PROGRESS_BAR_Y + 1, progress_bar_solid_width, 2);
if (PAGE_CONTAINS(PROGRESS_BAR_Y + 1, PROGRESS_BAR_Y + PROGRESS_BAR_HEIGHT - 3))
u8g.drawBox(PROGRESS_BAR_X + 1, PROGRESS_BAR_Y + 1, progress_bar_solid_width, PROGRESS_BAR_HEIGHT - 2);
// Progress strings
if (PAGE_CONTAINS(EXTRAS_BASELINE - INFO_FONT_ASCENT, EXTRAS_BASELINE - 1)) {
if (PAGE_CONTAINS(PCT_Y - INFO_FONT_ASCENT, PCT_Y - 1)) {
ui.rotate_progress();
lcd_put_u8str(PROGRESS_BAR_X, EXTRAS_BASELINE, bufferc);
lcd_put_u8str(PCT_X, PCT_Y, progressString);
}
#endif

View file

@ -664,15 +664,17 @@ bool ST7920_Lite_Status_Screen::indicators_changed() {
#if HAS_PRINT_PROGRESS
static char screenstr[8];
char * ST7920_Lite_Status_Screen::prepare_time_string(const duration_t &time, char prefix) {
static char str[6];
memset(&screenstr, 0x20, 8); // fill with spaces to avoid artifacts, not doing right-justification to save cycles
screenstr[0] = prefix;
TERN_(HOTENDS == 1, screenstr[1] = 0x07;) // add bullet • separator when there is space
int str_length = time.toDigital(str);
memcpy(&screenstr[TERN(HOTENDS == 1, 2, 1)], str, str_length); //memcpy because we can't have terminator
return screenstr;
}
#if HAS_TIME_DISPLAY
char * ST7920_Lite_Status_Screen::prepare_time_string(const duration_t &time, char prefix) {
static char str[6];
memset(&screenstr, ' ', 8); // fill with spaces to avoid artifacts, not doing right-justification to save cycles
screenstr[0] = prefix;
TERN_(HOTENDS == 1, screenstr[1] = 0x07;) // add bullet • separator when there is space
int str_length = time.toDigital(str);
memcpy(&screenstr[TERN(HOTENDS == 1, 2, 1)], str, str_length); //memcpy because we can't have terminator
return screenstr;
}
#endif
void ST7920_Lite_Status_Screen::draw_progress_string(uint8_t addr, const char *str) {
set_ddram_address(addr);
@ -687,7 +689,7 @@ bool ST7920_Lite_Status_Screen::indicators_changed() {
void ST7920_Lite_Status_Screen::drawPercent() {
#define LSHIFT TERN(HOTENDS == 1, 0, 1)
const uint8_t progress = ui.get_progress_percent();
memset(&screenstr, 0x20, 8); // fill with spaces to avoid artifacts
memset(&screenstr, ' ', 8); // fill with spaces to avoid artifacts
if (progress){
memcpy(&screenstr[2 - LSHIFT], \
TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(ui.get_progress_permyriad()), ui8tostr3rj(progress)), \

View file

@ -83,8 +83,10 @@ class ST7920_Lite_Status_Screen {
static void draw_bed_temp(const int16_t temp, const int16_t target, bool forceUpdate=false);
static void draw_fan_speed(const uint8_t value);
#if HAS_PRINT_PROGRESS
#if HAS_TIME_DISPLAY
static char* prepare_time_string(const duration_t &time, char prefix=' ');
#endif
static void draw_progress_bar(const uint8_t value);
static char* prepare_time_string(const duration_t &time, char prefix=' ');
static void draw_progress_string(uint8_t addr, const char *str);
static void update_progress(const bool forceUpdate);
#endif

View file

@ -105,7 +105,7 @@ void DGUSTxHandler::sdCardInsertionStatus(DGUS_VP &vp) {
}
#endif // PIDTEMPBED
static duration_t _PrintRemainingDurationEstimate() {
static duration_t _printRemainingDurationEstimate() {
duration_t remainingDuration = 0;
if (ExtUI::isPrinting()) {
@ -120,12 +120,12 @@ static duration_t _PrintRemainingDurationEstimate() {
}
void DGUSTxHandler::printRemainingHours(DGUS_VP &vp) {
const int16_t data = _PrintRemainingDurationEstimate().hour();
const int16_t data = _printRemainingDurationEstimate().hour();
dgus.write((uint16_t)vp.addr, Endianness::toBE(data));
}
void DGUSTxHandler::printRemainingMinutes(DGUS_VP &vp) {
const int16_t data = _PrintRemainingDurationEstimate().minute() % 60;
const int16_t data = _printRemainingDurationEstimate().minute() % 60;
dgus.write((uint16_t)vp.addr, Endianness::toBE(data));
}