Add SCROLL_LONG_FILENAMES advanced option

Based on #7637 by @marcio-ao
This commit is contained in:
Scott Lahteine 2017-10-18 20:26:19 -05:00
parent 259cf1b0b2
commit 91c5c2538a
35 changed files with 267 additions and 117 deletions

View file

@ -934,19 +934,36 @@ static void lcd_implementation_status_screen() {
if (!PAGE_CONTAINS(row_y1, row_y2)) return;
uint8_t n = LCD_WIDTH - (START_COL) - 1;
constexpr uint8_t maxlen = LCD_WIDTH - (START_COL) - 1;
const char *outstr = longFilename[0] ? longFilename : filename;
if (longFilename[0]) {
filename = longFilename;
longFilename[n] = '\0'; // cutoff at screen edge
#if ENABLED(SCROLL_LONG_FILENAMES)
if (isSelected) {
uint8_t name_hash = row;
for (uint8_t l = FILENAME_LENGTH; l--;)
name_hash = ((name_hash << 1) | (name_hash >> 7)) ^ filename[l]; // rotate, xor
if (filename_scroll_hash != name_hash) { // If the hash changed...
filename_scroll_hash = name_hash; // Save the new hash
filename_scroll_max = max(0, lcd_strlen(longFilename) - maxlen); // Update the scroll limit
filename_scroll_pos = 0; // Reset scroll to the start
lcd_status_update_delay = 8; // Don't scroll right away
}
outstr += filename_scroll_pos;
}
#else
longFilename[maxlen] = '\0'; // cutoff at screen edge
#endif
}
if (isDir) lcd_print(LCD_STR_FOLDER[0]);
while (char c = *filename) {
char c;
uint8_t n = maxlen;
while (n && (c = *outstr)) {
n -= lcd_print_and_count(c);
filename++;
++outstr;
}
while (n--) u8g.print(' ');
while (n) { --n; u8g.print(' '); }
}
#define lcd_implementation_drawmenu_sdfile(sel, row, pstr, filename, longFilename) _drawmenu_sd(sel, row, pstr, filename, longFilename, false)