Skip to content

Commit

Permalink
Clean up CrealityUI and MarlinUI (MarlinFirmware#22586)
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead authored and Night69 committed Aug 31, 2021
1 parent f127ac9 commit 336e080
Show file tree
Hide file tree
Showing 10 changed files with 948 additions and 824 deletions.
2 changes: 1 addition & 1 deletion Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1566,7 +1566,7 @@
*/
#if HAS_MARLINUI_U8GLIB
// Show SD percentage next to the progress bar
//#define DOGM_SD_PERCENT
//#define SHOW_SD_PERCENT

// Save many cycles by drawing a hollow frame or no frame on the Info Screen
//#define XYZ_NO_FRAME
Expand Down
2 changes: 2 additions & 0 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,8 @@
#error "CUSTOM_USER_MENUS has been replaced by CUSTOM_MENU_MAIN and CUSTOM_MENU_CONFIG."
#elif defined(MKS_LCD12864)
#error "MKS_LCD12864 is now MKS_LCD12864A or MKS_LCD12864B."
#elif defined(DOGM_SD_PERCENT)
#error "DOGM_SD_PERCENT is now SHOW_SD_PERCENT."
#elif defined(NEOPIXEL_BKGD_LED_INDEX)
#error "NEOPIXEL_BKGD_LED_INDEX is now NEOPIXEL_BKGD_INDEX_FIRST."
#elif defined(TEMP_SENSOR_1_AS_REDUNDANT)
Expand Down
7 changes: 3 additions & 4 deletions Marlin/src/lcd/dogm/marlinui_DOGM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,11 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop
#if ENABLED(ADVANCED_PAUSE_FEATURE)

void MarlinUI::draw_hotend_status(const uint8_t row, const uint8_t extruder) {
row_y1 = row * (MENU_FONT_HEIGHT) + 1;
row_y2 = row_y1 + MENU_FONT_HEIGHT - 1;
u8g_uint_t y1 = row * (MENU_FONT_HEIGHT) + 1, y2 = y1 + MENU_FONT_HEIGHT - 1;

if (!PAGE_CONTAINS(row_y1 + 1, row_y2 + 2)) return;
if (!PAGE_CONTAINS(y1 + 1, y2 + 2)) return;

lcd_put_wchar(LCD_PIXEL_WIDTH - 11 * (MENU_FONT_WIDTH), row_y2, 'E');
lcd_put_wchar(LCD_PIXEL_WIDTH - 11 * (MENU_FONT_WIDTH), y2, 'E');
lcd_put_wchar((char)('1' + extruder));
lcd_put_wchar(' ');
lcd_put_u8str(i16tostr3rj(thermalManager.wholeDegHotend(extruder)));
Expand Down
24 changes: 10 additions & 14 deletions Marlin/src/lcd/dogm/status_screen_DOGM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,13 +456,13 @@ void MarlinUI::draw_status_screen() {
#endif

#if HAS_PRINT_PROGRESS
#if DISABLED(DOGM_SD_PERCENT)
#if DISABLED(SHOW_SD_PERCENT)
#define _SD_INFO_X(len) (PROGRESS_BAR_X + (PROGRESS_BAR_WIDTH) / 2 - (len) * (MENU_FONT_WIDTH) / 2)
#else
#define _SD_INFO_X(len) (LCD_PIXEL_WIDTH - (len) * (MENU_FONT_WIDTH))
#endif

#if ENABLED(DOGM_SD_PERCENT)
#if ENABLED(SHOW_SD_PERCENT)
static char progress_string[5];
#endif
static uint8_t lastElapsed = 0xFF, lastProgress = 0xFF;
Expand All @@ -471,7 +471,7 @@ void MarlinUI::draw_status_screen() {
#if ENABLED(SHOW_REMAINING_TIME)
static u8g_uint_t estimation_x_pos = 0;
static char estimation_string[10];
#if BOTH(DOGM_SD_PERCENT, ROTATE_PROGRESS_DISPLAY)
#if BOTH(SHOW_SD_PERCENT, ROTATE_PROGRESS_DISPLAY)
static u8g_uint_t progress_x_pos = 0;
static uint8_t progress_state = 0;
static bool prev_blink = 0;
Expand Down Expand Up @@ -526,7 +526,7 @@ void MarlinUI::draw_status_screen() {

progress_bar_solid_width = u8g_uint_t((PROGRESS_BAR_WIDTH - 2) * (progress / (PROGRESS_SCALE)) * 0.01f);

#if ENABLED(DOGM_SD_PERCENT)
#if ENABLED(SHOW_SD_PERCENT)
if (progress == 0) {
progress_string[0] = '\0';
#if ENABLED(SHOW_REMAINING_TIME)
Expand All @@ -543,7 +543,7 @@ void MarlinUI::draw_status_screen() {
#endif
}

constexpr bool can_show_days = DISABLED(DOGM_SD_PERCENT) || ENABLED(ROTATE_PROGRESS_DISPLAY);
constexpr bool can_show_days = DISABLED(SHOW_SD_PERCENT) || ENABLED(ROTATE_PROGRESS_DISPLAY);
if (ev != lastElapsed) {
lastElapsed = ev;
const uint8_t len = elapsed.toDigital(elapsed_string, can_show_days && elapsed.value >= 60*60*24L);
Expand All @@ -564,11 +564,7 @@ void MarlinUI::draw_status_screen() {
else {
duration_t estimation = timeval;
const uint8_t len = estimation.toDigital(estimation_string, can_show_days && estimation.value >= 60*60*24L);
estimation_x_pos = _SD_INFO_X(len
#if !BOTH(DOGM_SD_PERCENT, ROTATE_PROGRESS_DISPLAY)
+ 1
#endif
);
estimation_x_pos = _SD_INFO_X(len + !BOTH(SHOW_SD_PERCENT, ROTATE_PROGRESS_DISPLAY));
}
}
#endif
Expand Down Expand Up @@ -767,7 +763,7 @@ void MarlinUI::draw_status_screen() {

if (PAGE_CONTAINS(EXTRAS_BASELINE - INFO_FONT_ASCENT, EXTRAS_BASELINE - 1)) {

#if ALL(DOGM_SD_PERCENT, SHOW_REMAINING_TIME, ROTATE_PROGRESS_DISPLAY)
#if ALL(SHOW_SD_PERCENT, SHOW_REMAINING_TIME, ROTATE_PROGRESS_DISPLAY)

if (prev_blink != blink) {
prev_blink = blink;
Expand All @@ -789,13 +785,13 @@ void MarlinUI::draw_status_screen() {
lcd_put_u8str(elapsed_x_pos, EXTRAS_BASELINE, elapsed_string);
}

#else // !DOGM_SD_PERCENT || !SHOW_REMAINING_TIME || !ROTATE_PROGRESS_DISPLAY
#else // !SHOW_SD_PERCENT || !SHOW_REMAINING_TIME || !ROTATE_PROGRESS_DISPLAY

//
// SD Percent Complete
//

#if ENABLED(DOGM_SD_PERCENT)
#if ENABLED(SHOW_SD_PERCENT)
if (progress_string[0]) {
lcd_put_u8str(55, EXTRAS_BASELINE, progress_string); // Percent complete
lcd_put_wchar('%');
Expand All @@ -815,7 +811,7 @@ void MarlinUI::draw_status_screen() {
#endif
lcd_put_u8str(elapsed_x_pos, EXTRAS_BASELINE, elapsed_string);

#endif // !DOGM_SD_PERCENT || !SHOW_REMAINING_TIME || !ROTATE_PROGRESS_DISPLAY
#endif // !SHOW_SD_PERCENT || !SHOW_REMAINING_TIME || !ROTATE_PROGRESS_DISPLAY
}

#endif // HAS_PRINT_PROGRESS
Expand Down
Loading

0 comments on commit 336e080

Please sign in to comment.