Skip to content

Commit

Permalink
🩹 Fix ProUI _remain_time
Browse files Browse the repository at this point in the history
Followup to #25982
  • Loading branch information
thinkyhead committed Jul 2, 2023
1 parent b50add4 commit c483fe7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Marlin/src/lcd/e3v2/proui/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ void drawPrintProgressElapsed() {
}

#if ENABLED(SHOW_REMAINING_TIME)
uint32_t _remain_time = 0;
void drawPrintProgressRemain() {
MString<12> buf;
buf.setf(F("%02i:%02i "), _remain_time / 3600, (_remain_time % 3600) / 60);
Expand Down Expand Up @@ -1319,7 +1320,6 @@ void eachMomentUpdate() {

// Remaining time
#if ENABLED(SHOW_REMAINING_TIME)
static uint32_t _remain_time = 0;
if (_remain_time != ui.get_remaining_time()) {
_remain_time = ui.get_remaining_time();
drawPrintProgressRemain();
Expand Down

1 comment on commit c483fe7

@classicrocker883
Copy link
Contributor

@classicrocker883 classicrocker883 commented on c483fe7 Jul 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is what actually worked for me. I wasn't getting remain time or print time to show correctly. but this works great now.

static uint8_t _percent_done = 255;
void Draw_Print_ProgressBar() {
  const uint8_t percent_done = _percent_done;
  DWINUI::Draw_IconWB(ICON_Bar, 15, 93);
  DWIN_Draw_Rectangle(1, HMI_data.Barfill_Color, 16 + (percent_done * 240) / 100, 93, 256, 113);
  DWINUI::Draw_Int(HMI_data.PercentTxt_Color, HMI_data.Background_Color, 3, 117, 133, percent_done);
  DWINUI::Draw_String(HMI_data.PercentTxt_Color, 142, 133, F("%"));
}

static uint16_t _printtime = 0;
void Draw_Print_ProgressElapsed() {
  MString<12> buf;
  duration_t elapsed = print_job_timer.duration(); // Print timer
  buf.setf(F("%02i:%02i "), uint16_t(elapsed.value / 3600), (uint16_t(elapsed.value) % 3600) / 60);
  DWINUI::Draw_String(HMI_data.Text_Color, HMI_data.Background_Color, 47, 192, buf);
}

static uint32_t _remain_time = 0;
#if ENABLED(SHOW_REMAINING_TIME)
  void Draw_Print_ProgressRemain() {
    uint32_t remain_time = _remain_time;
    MString<12> buf;
    buf.setf(F("%02i:%02i "), remain_time / 3600, (remain_time % 3600) / 60);
    DWINUI::Draw_String(HMI_data.Text_Color, HMI_data.Background_Color, 181, 192, buf);
  }
#endif

then under

if (checkkey == ID_PrintProcess) { // Print process

I omitted:
static uint16_t _printtime = 0; | under // Elapsed print time
static uint8_t _percent_done = 255; | under // Progress percent

Please sign in to comment.