🚸 Adjust Progress / Completion (#26466)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
parent
a1c3a2b03a
commit
473817f2f4
|
@ -33,7 +33,7 @@ void GcodeSuite::M31() {
|
||||||
char buffer[22];
|
char buffer[22];
|
||||||
duration_t(print_job_timer.duration()).toString(buffer);
|
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);
|
SERIAL_ECHO_MSG("Print time: ", buffer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -852,7 +852,11 @@
|
||||||
#define HAS_MEDIA_SUBCALLS 1
|
#define HAS_MEDIA_SUBCALLS 1
|
||||||
#endif
|
#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
|
#define HAS_EXTRA_PROGRESS 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -22,15 +22,15 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Fontname: -Misc-Fixed-Medium-R-Normal--9-90-75-75-C-60-ISO10646-1
|
* Fontname: -Misc-Fixed-Medium-R-Normal--9-90-75-75-C-60-ISO10646-1
|
||||||
Copyright: Public domain font. Share and enjoy.
|
* Copyright: Public domain font. Share and enjoy.
|
||||||
Capital A Height: 6, '1' Height: 6
|
* 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
|
* 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
|
* Font Bounding box w= 6 h= 9 x= 0 y=-2
|
||||||
Calculated Min Values x= 0 y=-2 dx= 0 dy= 0
|
* Calculated Min Values x= 0 y=-2 dx= 0 dy= 0
|
||||||
Pure Font ascent = 6 descent=-2
|
* Pure Font ascent = 6 descent=-2
|
||||||
X Font ascent = 6 descent=-2
|
* X Font ascent = 6 descent=-2
|
||||||
Max Font ascent = 7 descent=-2
|
* Max Font ascent = 7 descent=-2
|
||||||
*/
|
*/
|
||||||
#include <U8glib-HAL.h>
|
#include <U8glib-HAL.h>
|
||||||
const u8g_fntpgm_uint8_t u8g_font_6x9[2434] U8G_FONT_SECTION(".progmem.u8g_font_6x9") = {
|
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,
|
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,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,0xE0,0x80,0x80,0x04,0x08,0x08,0x06,0x01,0xFE,0x50,0x00,0x90,0x90,0x90,0x70,
|
||||||
0x90,0x60};
|
0x90,0x60
|
||||||
|
};
|
||||||
|
|
|
@ -91,6 +91,18 @@
|
||||||
#define EXTRAS_BASELINE (40 + INFO_FONT_ASCENT)
|
#define EXTRAS_BASELINE (40 + INFO_FONT_ASCENT)
|
||||||
#define STATUS_BASELINE (LCD_PIXEL_HEIGHT - INFO_FONT_DESCENT)
|
#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
|
#if ANIM_HBCC
|
||||||
enum HeatBits : uint8_t {
|
enum HeatBits : uint8_t {
|
||||||
DRAWBIT_HOTEND,
|
DRAWBIT_HOTEND,
|
||||||
|
@ -188,10 +200,6 @@
|
||||||
}
|
}
|
||||||
#endif
|
#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) {
|
FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, const uint8_t ty) {
|
||||||
const char *str;
|
const char *str;
|
||||||
uint8_t len;
|
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
|
// Prepare strings for progress display
|
||||||
#if ANY(HAS_EXTRA_PROGRESS, HAS_PRINT_PROGRESS)
|
#if ANY(HAS_EXTRA_PROGRESS, HAS_PRINT_PROGRESS)
|
||||||
static MarlinUI::progress_t progress = 0;
|
static MarlinUI::progress_t progress = 0;
|
||||||
static char bufferc[13];
|
static MString<12> progressString;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAS_EXTRA_PROGRESS
|
#if HAS_EXTRA_PROGRESS
|
||||||
|
|
||||||
static void prepare_time_string(const duration_t &time, char prefix) {
|
#if HAS_TIME_DISPLAY
|
||||||
char str[13];
|
static void prepare_time_string(const duration_t &time, char prefix) {
|
||||||
memset(&bufferc[2], 0x20, 5); // partialy fill with spaces to avoid artifacts and terminator
|
char str[10];
|
||||||
bufferc[0] = prefix;
|
const uint8_t time_len = time.toDigital(str, time.value >= 60*60*24L); // 5 to 8 chars
|
||||||
bufferc[1] = ':';
|
progressString.set(prefix, ':', spaces_t(10 - time_len), str); // 2 to 5 spaces
|
||||||
int str_length = time.toDigital(str, time.value >= 60*60*24L);
|
}
|
||||||
strcpy(&bufferc[sizeof(bufferc) - str_length - 1], str);
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
#if ENABLED(SHOW_PROGRESS_PERCENT)
|
#if ENABLED(SHOW_PROGRESS_PERCENT)
|
||||||
void MarlinUI::drawPercent() {
|
void MarlinUI::drawPercent() {
|
||||||
if (progress != 0) {
|
if (progress == 0) return;
|
||||||
#define PCENTERED 1 // center percent value over progress bar, else align to the right
|
progressString.set(
|
||||||
#define PPOS TERN(PCENTERED, 4, 0)
|
OPTITEM(PCENTERED, spaces_t(4))
|
||||||
#define PLEN TERN(PRINT_PROGRESS_SHOW_DECIMALS, 4, 3)
|
TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(progress), ui8tostr3rj(progress / (PROGRESS_SCALE))), '%'
|
||||||
memset(&bufferc, 0x20, 12);
|
);
|
||||||
memcpy(&bufferc[PPOS], TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(progress), ui8tostr3rj(progress / (PROGRESS_SCALE))), PLEN);
|
|
||||||
bufferc[PPOS+PLEN] = '%';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if ENABLED(SHOW_REMAINING_TIME)
|
#if ENABLED(SHOW_REMAINING_TIME)
|
||||||
void MarlinUI::drawRemain() {
|
void MarlinUI::drawRemain() {
|
||||||
if (printJobOngoing() && get_remaining_time() != 0)
|
if (printJobOngoing() && get_remaining_time() != 0)
|
||||||
prepare_time_string(get_remaining_time(), 'R'); }
|
prepare_time_string(get_remaining_time(), 'R');
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#if ENABLED(SHOW_INTERACTION_TIME)
|
#if ENABLED(SHOW_INTERACTION_TIME)
|
||||||
void MarlinUI::drawInter() {
|
void MarlinUI::drawInter() {
|
||||||
if (printingIsActive() && interaction_time)
|
if (printingIsActive() && interaction_time)
|
||||||
prepare_time_string(interaction_time, 'C'); }
|
prepare_time_string(interaction_time, 'C');
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#if ENABLED(SHOW_ELAPSED_TIME)
|
#if ENABLED(SHOW_ELAPSED_TIME)
|
||||||
void MarlinUI::drawElapsed() {
|
void MarlinUI::drawElapsed() {
|
||||||
if (printJobOngoing())
|
if (printJobOngoing())
|
||||||
prepare_time_string(print_job_timer.duration(), 'E'); }
|
prepare_time_string(print_job_timer.duration(), 'E');
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // HAS_EXTRA_PROGRESS
|
#endif // HAS_EXTRA_PROGRESS
|
||||||
|
@ -779,17 +785,17 @@ void MarlinUI::draw_status_screen() {
|
||||||
|
|
||||||
#if HAS_PRINT_PROGRESS
|
#if HAS_PRINT_PROGRESS
|
||||||
// Progress bar frame
|
// Progress bar frame
|
||||||
if (PAGE_CONTAINS(PROGRESS_BAR_Y, PROGRESS_BAR_Y + 3))
|
if (PAGE_CONTAINS(PROGRESS_BAR_Y, PROGRESS_BAR_Y + PROGRESS_BAR_HEIGHT - 1))
|
||||||
u8g.drawFrame(PROGRESS_BAR_X, PROGRESS_BAR_Y, PROGRESS_BAR_WIDTH, 4);
|
u8g.drawFrame(PROGRESS_BAR_X, PROGRESS_BAR_Y, PROGRESS_BAR_WIDTH, PROGRESS_BAR_HEIGHT);
|
||||||
|
|
||||||
// Progress bar solid part
|
// Progress bar solid part
|
||||||
if (PAGE_CONTAINS(PROGRESS_BAR_Y + 1, PROGRESS_BAR_Y + 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, 2);
|
u8g.drawBox(PROGRESS_BAR_X + 1, PROGRESS_BAR_Y + 1, progress_bar_solid_width, PROGRESS_BAR_HEIGHT - 2);
|
||||||
|
|
||||||
// Progress strings
|
// 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();
|
ui.rotate_progress();
|
||||||
lcd_put_u8str(PROGRESS_BAR_X, EXTRAS_BASELINE, bufferc);
|
lcd_put_u8str(PCT_X, PCT_Y, progressString);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -664,15 +664,17 @@ bool ST7920_Lite_Status_Screen::indicators_changed() {
|
||||||
#if HAS_PRINT_PROGRESS
|
#if HAS_PRINT_PROGRESS
|
||||||
static char screenstr[8];
|
static char screenstr[8];
|
||||||
|
|
||||||
char * ST7920_Lite_Status_Screen::prepare_time_string(const duration_t &time, char prefix) {
|
#if HAS_TIME_DISPLAY
|
||||||
static char str[6];
|
char * ST7920_Lite_Status_Screen::prepare_time_string(const duration_t &time, char prefix) {
|
||||||
memset(&screenstr, 0x20, 8); // fill with spaces to avoid artifacts, not doing right-justification to save cycles
|
static char str[6];
|
||||||
screenstr[0] = prefix;
|
memset(&screenstr, ' ', 8); // fill with spaces to avoid artifacts, not doing right-justification to save cycles
|
||||||
TERN_(HOTENDS == 1, screenstr[1] = 0x07;) // add bullet • separator when there is space
|
screenstr[0] = prefix;
|
||||||
int str_length = time.toDigital(str);
|
TERN_(HOTENDS == 1, screenstr[1] = 0x07;) // add bullet • separator when there is space
|
||||||
memcpy(&screenstr[TERN(HOTENDS == 1, 2, 1)], str, str_length); //memcpy because we can't have terminator
|
int str_length = time.toDigital(str);
|
||||||
return screenstr;
|
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) {
|
void ST7920_Lite_Status_Screen::draw_progress_string(uint8_t addr, const char *str) {
|
||||||
set_ddram_address(addr);
|
set_ddram_address(addr);
|
||||||
|
@ -687,7 +689,7 @@ bool ST7920_Lite_Status_Screen::indicators_changed() {
|
||||||
void ST7920_Lite_Status_Screen::drawPercent() {
|
void ST7920_Lite_Status_Screen::drawPercent() {
|
||||||
#define LSHIFT TERN(HOTENDS == 1, 0, 1)
|
#define LSHIFT TERN(HOTENDS == 1, 0, 1)
|
||||||
const uint8_t progress = ui.get_progress_percent();
|
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){
|
if (progress){
|
||||||
memcpy(&screenstr[2 - LSHIFT], \
|
memcpy(&screenstr[2 - LSHIFT], \
|
||||||
TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(ui.get_progress_permyriad()), ui8tostr3rj(progress)), \
|
TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(ui.get_progress_permyriad()), ui8tostr3rj(progress)), \
|
||||||
|
|
|
@ -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_bed_temp(const int16_t temp, const int16_t target, bool forceUpdate=false);
|
||||||
static void draw_fan_speed(const uint8_t value);
|
static void draw_fan_speed(const uint8_t value);
|
||||||
#if HAS_PRINT_PROGRESS
|
#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 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 draw_progress_string(uint8_t addr, const char *str);
|
||||||
static void update_progress(const bool forceUpdate);
|
static void update_progress(const bool forceUpdate);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -105,7 +105,7 @@ void DGUSTxHandler::sdCardInsertionStatus(DGUS_VP &vp) {
|
||||||
}
|
}
|
||||||
#endif // PIDTEMPBED
|
#endif // PIDTEMPBED
|
||||||
|
|
||||||
static duration_t _PrintRemainingDurationEstimate() {
|
static duration_t _printRemainingDurationEstimate() {
|
||||||
duration_t remainingDuration = 0;
|
duration_t remainingDuration = 0;
|
||||||
|
|
||||||
if (ExtUI::isPrinting()) {
|
if (ExtUI::isPrinting()) {
|
||||||
|
@ -120,12 +120,12 @@ static duration_t _PrintRemainingDurationEstimate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DGUSTxHandler::printRemainingHours(DGUS_VP &vp) {
|
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));
|
dgus.write((uint16_t)vp.addr, Endianness::toBE(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DGUSTxHandler::printRemainingMinutes(DGUS_VP &vp) {
|
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));
|
dgus.write((uint16_t)vp.addr, Endianness::toBE(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue