Skip to content

Commit

Permalink
Fix Lightweight UI
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Dec 22, 2023
1 parent a8601c6 commit 04041ec
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,39 +662,36 @@ bool ST7920_Lite_Status_Screen::indicators_changed() {

// Process progress strings
#if HAS_PRINT_PROGRESS
static char screenstr[8];
static MString<8> 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;
static char time_str[6];
(void)time.toDigital(time_str); // Up to 5 chars
screenstr = prefix;
if (HOTENDS == 1) screenstr += char(0x07); // Add bullet • separator when there is space
screenstr += time_str;
screenstr += Spaces(3);
return &screenstr;
}
#endif

void ST7920_Lite_Status_Screen::draw_progress_string(uint8_t addr, const char *str) {
set_ddram_address(addr);
begin_data();
write_str(str, TERN(HOTENDS == 1, 8, 6));
write_str(str, HOTENDS == 1 ? 8 : 6);
}

#define PPOS (DDRAM_LINE_3 + TERN(HOTENDS == 1, 4, 5)) // progress string position, in 16-bit words
constexpr uint8_t PPOS = (DDRAM_LINE_3 + (HOTENDS == 1 ? 4 : 5)); // Progress string position, in 16-bit words

#if ENABLED(SHOW_PROGRESS_PERCENT)
void MarlinUI::drawPercent() { lightUI.drawPercent(); }
void ST7920_Lite_Status_Screen::drawPercent() {
#define LSHIFT TERN(HOTENDS == 1, 0, 1)
const uint8_t progress = ui.get_progress_percent();
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)), \
TERN(PRINT_PROGRESS_SHOW_DECIMALS, 4, 3));
screenstr[(TERN(PRINT_PROGRESS_SHOW_DECIMALS, 6, 5) - LSHIFT)] = '%';
if (progress) {
screenstr += Spaces(1 + (HOTENDS == 1));
screenstr += TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(ui.get_progress_permyriad()), ui8tostr3rj(progress));
screenstr += "% ";
draw_progress_string(PPOS, screenstr);
}
}
Expand Down

0 comments on commit 04041ec

Please sign in to comment.