From 68b3c8b8e87e0ef01f94653fade70d23d8f5f493 Mon Sep 17 00:00:00 2001 From: Marcio Teixeira Date: Tue, 5 Sep 2017 08:18:34 -0600 Subject: [PATCH] Long filenames now scroll (T335) --- Marlin/Conditionals_LulzBot.h | 1 + Marlin/SdFatConfig.h | 4 ++++ Marlin/ultralcd.cpp | 9 +++++++++ Marlin/ultralcd_impl_DOGM.h | 22 ++++++++++++++++++---- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/Marlin/Conditionals_LulzBot.h b/Marlin/Conditionals_LulzBot.h index 0b2822109..e7099b5c7 100644 --- a/Marlin/Conditionals_LulzBot.h +++ b/Marlin/Conditionals_LulzBot.h @@ -478,6 +478,7 @@ */ #define LULZBOT_HIDE_ACTIVE_NOZZLE_IN_LCD #define LULZBOT_HIDE_PID_CONFIG_IN_LCD + #define LULZBOT_SCROLL_LONG_FILE_NAMES #endif /*********************************************** COMMON TOOLHEADS PARAMETERS *****************************/ diff --git a/Marlin/SdFatConfig.h b/Marlin/SdFatConfig.h index d3406a028..9b3ba7e08 100644 --- a/Marlin/SdFatConfig.h +++ b/Marlin/SdFatConfig.h @@ -125,7 +125,11 @@ * Defines for long (vfat) filenames */ /** Number of VFAT entries used. Every entry has 13 UTF-16 characters */ + #if defined(LULZBOT_SCROLL_LONG_FILE_NAMES) + #define MAX_VFAT_ENTRIES (5) + #else #define MAX_VFAT_ENTRIES (2) + #endif /** Total size of the buffer used to store the long filenames */ #define LONG_FILENAME_LENGTH (FILENAME_LENGTH*MAX_VFAT_ENTRIES+1) #endif // SdFatConfig_h diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 8988fbacc..7ba58c6f3 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -4353,6 +4353,15 @@ void lcd_update() { lcdDrawUpdate = LCDVIEW_REDRAW_NOW; } + #if ENABLED(LULZBOT_SCROLL_LONG_FILE_NAMES) + if(currentScreen == lcd_sdcard_menu && scroll_offset < scroll_max && !lcd_status_update_delay--) { + lcd_status_update_delay = 6; + lcdDrawUpdate = LCDVIEW_REDRAW_NOW; + scroll_offset++; + return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS; + } + #endif + // then we want to use 1/2 of the time only. uint16_t bbr2 = planner.block_buffer_runtime() >> 1; diff --git a/Marlin/ultralcd_impl_DOGM.h b/Marlin/ultralcd_impl_DOGM.h index 7b2e2aa12..ccb8fb14f 100644 --- a/Marlin/ultralcd_impl_DOGM.h +++ b/Marlin/ultralcd_impl_DOGM.h @@ -755,6 +755,12 @@ static void lcd_implementation_status_screen() { #endif // ADVANCED_PAUSE_FEATURE + #if defined(LULZBOT_SCROLL_LONG_FILE_NAMES) + static int scroll_offset; + static int scroll_max; + static int scroll_row; + #endif + // Set the colors for a menu item based on whether it is selected static void lcd_implementation_mark_as_selected(const uint8_t row, const bool isSelected) { row_y1 = row * row_height + 1; @@ -941,14 +947,22 @@ static void lcd_implementation_status_screen() { uint8_t n = LCD_WIDTH - (START_COL) - 1; if (longFilename[0]) { filename = longFilename; - longFilename[n] = '\0'; + #if defined(LULZBOT_SCROLL_LONG_FILE_NAMES) + if (isSelected) { + if(scroll_row != row) { + scroll_max = max(0, strlen(longFilename) - n); + scroll_row = row; + scroll_offset = 0; + } + filename += scroll_offset; + } + #endif } if (isDir) lcd_print(LCD_STR_FOLDER[0]); - while (char c = *filename) { - n -= lcd_print_and_count(c); - filename++; + for(const char *c = filename; *c && n > 0; c++) { + n -= lcd_print_and_count(*c); } while (n--) u8g.print(' '); }