Skip to content

Commit

Permalink
Fix SD percent for Lite Status Screen
Browse files Browse the repository at this point in the history
Co-Authored-By: Lê Hoàng <[email protected]>
  • Loading branch information
thinkyhead and Lê Hoàng committed Aug 26, 2018
1 parent cf1b2af commit 4f0737c
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions Marlin/status_screen_lite_ST7920.h
Original file line number Diff line number Diff line change
Expand Up @@ -876,24 +876,32 @@ void ST7920_Lite_Status_Screen::update_status_or_position(bool forceUpdate) {
}

void ST7920_Lite_Status_Screen::update_progress(const bool forceUpdate) {
#if DISABLED(LCD_SET_PROGRESS_MANUALLY)
uint8_t progress_bar_percent = 0;
#endif
#if ENABLED(LCD_SET_PROGRESS_MANUALLY) || ENABLED(SDSUPPORT)

// Set current percentage from SD when actively printing
#if ENABLED(LCD_SET_PROGRESS_MANUALLY) && ENABLED(SDSUPPORT) && (ENABLED(LCD_PROGRESS_BAR) || ENABLED(DOGLCD))
if (IS_SD_PRINTING) progress_bar_percent = card.percentDone();
#endif
#if DISABLED(LCD_SET_PROGRESS_MANUALLY)
uint8_t progress_bar_percent; //=0
#endif

#if ENABLED(SDSUPPORT)
// Progress bar % comes from SD when actively printing
if (IS_SD_PRINTING) progress_bar_percent = card.percentDone();
#endif

// Since the progress bar involves writing
// quite a few bytes to GDRAM, only do this
// when an update is actually necessary.
// Since the progress bar involves writing
// quite a few bytes to GDRAM, only do this
// when an update is actually necessary.

static uint8_t last_progress = 0;
if (!forceUpdate && last_progress == progress_bar_percent) return;
last_progress = progress_bar_percent;

draw_progress_bar(progress_bar_percent);

#else

static uint8_t last_progress = 0;
if (!forceUpdate && last_progress == progress_bar_percent) return;
last_progress = progress_bar_percent;
UNUSED(forceUpdate);

draw_progress_bar(progress_bar_percent);
#endif // LCD_SET_PROGRESS_MANUALLY || SDSUPPORT
}

void ST7920_Lite_Status_Screen::update(const bool forceUpdate) {
Expand Down

0 comments on commit 4f0737c

Please sign in to comment.