|
@@ -55,8 +55,6 @@
|
|
|
#endif
|
|
|
|
|
|
|
|
|
-int scrollstuff = 0;
|
|
|
-char longFilenameOLD[LONG_FILENAME_LENGTH];
|
|
|
int clock_interval = 0;
|
|
|
|
|
|
static void lcd_sd_updir();
|
|
@@ -64,7 +62,7 @@ static void lcd_mesh_bed_leveling_settings();
|
|
|
static void lcd_backlight_menu();
|
|
|
|
|
|
int8_t ReInitLCD = 0;
|
|
|
-
|
|
|
+uint8_t scrollstuff = 0;
|
|
|
|
|
|
int8_t SilentModeMenu = SILENT_MODE_OFF;
|
|
|
uint8_t SilentModeMenu_MMU = 1; //activate mmu unit stealth mode
|
|
@@ -326,113 +324,31 @@ bool bSettings; // flag (i.e. 'fake parameter'
|
|
|
|
|
|
const char STR_SEPARATOR[] PROGMEM = "------------";
|
|
|
|
|
|
-
|
|
|
-static void lcd_implementation_drawmenu_sdfile_selected(uint8_t row, const char* filename, char* longFilename)
|
|
|
-{
|
|
|
- char c;
|
|
|
- int enc_dif = lcd_encoder_diff / ENCODER_PULSES_PER_STEP;
|
|
|
- uint8_t n = LCD_WIDTH - 1;
|
|
|
-
|
|
|
- for(uint_least8_t g = 0; g<4;g++){
|
|
|
- lcd_putc_at(0, g, ' ');
|
|
|
- }
|
|
|
- lcd_putc_at(0, row, '>');
|
|
|
-
|
|
|
- if (longFilename[0] == '\0')
|
|
|
- {
|
|
|
- longFilename = filename;
|
|
|
- }
|
|
|
-
|
|
|
- int i = 1;
|
|
|
- int j = 0;
|
|
|
- char* longFilenameTMP = longFilename;
|
|
|
-
|
|
|
- while((c = *longFilenameTMP) != '\0')
|
|
|
- {
|
|
|
- lcd_set_cursor(i, row);
|
|
|
- lcd_print(c);
|
|
|
- i++;
|
|
|
- longFilenameTMP++;
|
|
|
- if(i==LCD_WIDTH){
|
|
|
- i=1;
|
|
|
- j++;
|
|
|
- longFilenameTMP = longFilename + j;
|
|
|
- n = LCD_WIDTH - 1;
|
|
|
- for(int g = 0; g<300 ;g++){
|
|
|
- manage_heater();
|
|
|
- if(LCD_CLICKED || ( enc_dif != (lcd_encoder_diff / ENCODER_PULSES_PER_STEP))){
|
|
|
- longFilenameTMP = longFilename;
|
|
|
- *(longFilenameTMP + LCD_WIDTH - 2) = '\0';
|
|
|
- i = 1;
|
|
|
- j = 0;
|
|
|
- break;
|
|
|
- }else{
|
|
|
- if (j == 1) _delay_ms(3); //wait around 1.2 s to start scrolling text
|
|
|
- _delay_ms(1); //then scroll with redrawing every 300 ms
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if(c!='\0'){
|
|
|
- lcd_putc_at(i, row, c);
|
|
|
- i++;
|
|
|
- }
|
|
|
- n=n-i+1;
|
|
|
- lcd_space(n);
|
|
|
-}
|
|
|
-static void lcd_implementation_drawmenu_sdfile(uint8_t row, const char* filename, char* longFilename)
|
|
|
+static void lcd_implementation_drawmenu_sdfile(uint8_t row, const char* longFilename)
|
|
|
{
|
|
|
char c;
|
|
|
uint8_t n = LCD_WIDTH - 1;
|
|
|
- lcd_putc_at(0, row, ' ');
|
|
|
- if (longFilename[0] != '\0')
|
|
|
- {
|
|
|
- filename = longFilename;
|
|
|
- longFilename[LCD_WIDTH-1] = '\0';
|
|
|
- }
|
|
|
- while( ((c = *filename) != '\0') && (n>0) )
|
|
|
- {
|
|
|
- lcd_print(c);
|
|
|
- filename++;
|
|
|
- n--;
|
|
|
- }
|
|
|
- lcd_space(n);
|
|
|
-}
|
|
|
-static void lcd_implementation_drawmenu_sddirectory_selected(uint8_t row, const char* filename, char* longFilename)
|
|
|
-{
|
|
|
- char c;
|
|
|
- uint8_t n = LCD_WIDTH - 2;
|
|
|
- lcd_putc_at(0, row, '>');
|
|
|
- lcd_print(LCD_STR_FOLDER[0]);
|
|
|
- if (longFilename[0] != '\0')
|
|
|
- {
|
|
|
- filename = longFilename;
|
|
|
- longFilename[LCD_WIDTH-2] = '\0';
|
|
|
- }
|
|
|
- while( ((c = *filename) != '\0') && (n>0) )
|
|
|
+ lcd_set_cursor(0, row);
|
|
|
+ lcd_print((lcd_encoder == menu_item)?'>':' ');
|
|
|
+ while( ((c = *longFilename) != '\0') && (n>0) )
|
|
|
{
|
|
|
lcd_print(c);
|
|
|
- filename++;
|
|
|
+ longFilename++;
|
|
|
n--;
|
|
|
}
|
|
|
lcd_space(n);
|
|
|
}
|
|
|
-static void lcd_implementation_drawmenu_sddirectory(uint8_t row, const char* filename, char* longFilename)
|
|
|
+static void lcd_implementation_drawmenu_sddirectory(uint8_t row, const char* longFilename)
|
|
|
{
|
|
|
char c;
|
|
|
uint8_t n = LCD_WIDTH - 2;
|
|
|
- lcd_putc_at(0, row, ' ');
|
|
|
- lcd_print(LCD_STR_FOLDER[0]);
|
|
|
- if (longFilename[0] != '\0')
|
|
|
- {
|
|
|
- filename = longFilename;
|
|
|
- longFilename[LCD_WIDTH-2] = '\0';
|
|
|
- }
|
|
|
- while( ((c = *filename) != '\0') && (n>0) )
|
|
|
+ lcd_set_cursor(0, row);
|
|
|
+ lcd_print((lcd_encoder == menu_item)?'>':' ');
|
|
|
+ lcd_print(LCD_STR_FOLDER[0]);
|
|
|
+ while( ((c = *longFilename) != '\0') && (n>0) )
|
|
|
{
|
|
|
lcd_print(c);
|
|
|
- filename++;
|
|
|
+ longFilename++;
|
|
|
n--;
|
|
|
}
|
|
|
lcd_space(n);
|
|
@@ -441,48 +357,16 @@ static void lcd_implementation_drawmenu_sddirectory(uint8_t row, const char* fil
|
|
|
|
|
|
|
|
|
#define MENU_ITEM_SDDIR(str_fn, str_fnl) do { if (menu_item_sddir(str_fn, str_fnl)) return; } while (0)
|
|
|
-//#define MENU_ITEM_SDDIR(str, str_fn, str_fnl) MENU_ITEM(sddirectory, str, str_fn, str_fnl)
|
|
|
-//extern uint8_t menu_item_sddir(const char* str, const char* str_fn, char* str_fnl);
|
|
|
-
|
|
|
-#define MENU_ITEM_SDFILE(str, str_fn, str_fnl) do { if (menu_item_sdfile(str, str_fn, str_fnl)) return; } while (0)
|
|
|
-//#define MENU_ITEM_SDFILE(str, str_fn, str_fnl) MENU_ITEM(sdfile, str, str_fn, str_fnl)
|
|
|
-//extern uint8_t menu_item_sdfile(const char* str, const char* str_fn, char* str_fnl);
|
|
|
+#define MENU_ITEM_SDFILE(str_fn, str_fnl) do { if (menu_item_sdfile(str_fn, str_fnl)) return; } while (0)
|
|
|
|
|
|
|
|
|
uint8_t menu_item_sddir(const char* str_fn, char* str_fnl)
|
|
|
{
|
|
|
-#ifdef NEW_SD_MENU
|
|
|
-// str_fnl[18] = 0;
|
|
|
-// printf_P(PSTR("menu dir %d '%s' '%s'\n"), menu_row, str_fn, str_fnl);
|
|
|
- if (menu_item == menu_line)
|
|
|
- {
|
|
|
- if (lcd_draw_update)
|
|
|
- {
|
|
|
- lcd_set_cursor(0, menu_row);
|
|
|
- int cnt = lcd_printf_P(PSTR("%c%c%-18s"), (lcd_encoder == menu_item)?'>':' ', LCD_STR_FOLDER[0], str_fnl[0]?str_fnl:str_fn);
|
|
|
-// int cnt = lcd_printf_P(PSTR("%c%c%-18s"), (lcd_encoder == menu_item)?'>':' ', LCD_STR_FOLDER[0], str_fn);
|
|
|
- }
|
|
|
- if (menu_clicked && (lcd_encoder == menu_item))
|
|
|
- {
|
|
|
- uint8_t depth = (uint8_t)card.getWorkDirDepth();
|
|
|
- strcpy(dir_names[depth], str_fn);
|
|
|
-// printf_P(PSTR("%s\n"), dir_names[depth]);
|
|
|
- card.chdir(str_fn);
|
|
|
- lcd_encoder = 0;
|
|
|
- return menu_item_ret();
|
|
|
- }
|
|
|
- }
|
|
|
- menu_item++;
|
|
|
- return 0;
|
|
|
-#else //NEW_SD_MENU
|
|
|
if (menu_item == menu_line)
|
|
|
{
|
|
|
if (lcd_draw_update)
|
|
|
{
|
|
|
- if (lcd_encoder == menu_item)
|
|
|
- lcd_implementation_drawmenu_sddirectory_selected(menu_row, str_fn, str_fnl);
|
|
|
- else
|
|
|
- lcd_implementation_drawmenu_sddirectory(menu_row, str_fn, str_fnl);
|
|
|
+ lcd_implementation_drawmenu_sddirectory(menu_row, (str_fnl[0] == '\0') ? str_fn : str_fnl);
|
|
|
}
|
|
|
if (menu_clicked && (lcd_encoder == menu_item))
|
|
|
{
|
|
@@ -490,80 +374,32 @@ uint8_t menu_item_sddir(const char* str_fn, char* str_fnl)
|
|
|
lcd_update_enabled = 0;
|
|
|
menu_action_sddirectory(str_fn);
|
|
|
lcd_update_enabled = 1;
|
|
|
- return menu_item_ret();
|
|
|
+ /* return */ menu_item_ret();
|
|
|
+ return 1;
|
|
|
}
|
|
|
}
|
|
|
menu_item++;
|
|
|
return 0;
|
|
|
-
|
|
|
-#endif //NEW_SD_MENU
|
|
|
}
|
|
|
|
|
|
-static uint8_t menu_item_sdfile(const char*
|
|
|
-#ifdef NEW_SD_MENU
|
|
|
- str
|
|
|
-#endif //NEW_SD_MENU
|
|
|
- ,const char* str_fn, char* str_fnl)
|
|
|
+static uint8_t menu_item_sdfile(const char* str_fn, char* str_fnl)
|
|
|
{
|
|
|
-#ifdef NEW_SD_MENU
|
|
|
-// printf_P(PSTR("menu sdfile\n"));
|
|
|
-// str_fnl[19] = 0;
|
|
|
-// printf_P(PSTR("menu file %d '%s' '%s'\n"), menu_row, str_fn, str_fnl);
|
|
|
- if (menu_item == menu_line)
|
|
|
- {
|
|
|
- if (lcd_draw_update)
|
|
|
- {
|
|
|
-// printf_P(PSTR("menu file %d %d '%s'\n"), menu_row, menuData.sdcard_menu.viewState, str_fnl[0]?str_fnl:str_fn);
|
|
|
- lcd_set_cursor(0, menu_row);
|
|
|
-/* if (lcd_encoder == menu_item)
|
|
|
- {
|
|
|
- lcd_printf_P(PSTR("%c%-19s"), (lcd_encoder == menu_item)?'>':' ', (str_fnl[0]?str_fnl:str_fn) + 1);
|
|
|
- if (menuData.sdcard_menu.viewState == 0)
|
|
|
- {
|
|
|
- menuData.sdcard_menu.viewState++;
|
|
|
- lcd_printf_P(PSTR("%c%-19s"), (lcd_encoder == menu_item)?'>':' ', (str_fnl[0]?str_fnl:str_fn) + 1);
|
|
|
- }
|
|
|
- else if (menuData.sdcard_menu.viewState == 1)
|
|
|
- {
|
|
|
- lcd_printf_P(PSTR("%c%-19s"), (lcd_encoder == menu_item)?'>':' ', (str_fnl[0]?str_fnl:str_fn) + 2);
|
|
|
- }
|
|
|
- }
|
|
|
- else*/
|
|
|
- {
|
|
|
- str_fnl[19] = 0;
|
|
|
- lcd_printf_P(PSTR("%c%-19s"), (lcd_encoder == menu_item)?'>':' ', str_fnl[0]?str_fnl:str_fn);
|
|
|
- }
|
|
|
-
|
|
|
-// int cnt = lcd_printf_P(PSTR("%c%-19s"), (lcd_encoder == menu_item)?'>':' ', str_fnl);
|
|
|
-// int cnt = lcd_printf_P(PSTR("%cTESTIK.gcode"), (lcd_encoder == menu_item)?'>':' ');
|
|
|
- }
|
|
|
- if (menu_clicked && (lcd_encoder == menu_item))
|
|
|
- {
|
|
|
- return menu_item_ret();
|
|
|
- }
|
|
|
- }
|
|
|
- menu_item++;
|
|
|
- return 0;
|
|
|
-#else //NEW_SD_MENU
|
|
|
if (menu_item == menu_line)
|
|
|
{
|
|
|
if (lcd_draw_update)
|
|
|
{
|
|
|
- if (lcd_encoder == menu_item)
|
|
|
- lcd_implementation_drawmenu_sdfile_selected(menu_row, str_fn, str_fnl);
|
|
|
- else
|
|
|
- lcd_implementation_drawmenu_sdfile(menu_row, str_fn, str_fnl);
|
|
|
+ lcd_implementation_drawmenu_sdfile(menu_row, (str_fnl[0] == '\0') ? str_fn : str_fnl);
|
|
|
}
|
|
|
if (menu_clicked && (lcd_encoder == menu_item))
|
|
|
{
|
|
|
- lcd_consume_click();
|
|
|
+ lcd_consume_click();
|
|
|
menu_action_sdfile(str_fn);
|
|
|
- return menu_item_ret();
|
|
|
+ /* return */ menu_item_ret();
|
|
|
+ return 1;
|
|
|
}
|
|
|
}
|
|
|
menu_item++;
|
|
|
return 0;
|
|
|
-#endif //NEW_SD_MENU
|
|
|
}
|
|
|
|
|
|
// Print temperature (nozzle/bed) (9 chars total)
|
|
@@ -735,14 +571,6 @@ void lcdui_print_time(void)
|
|
|
//! @Brief Print status line on status screen
|
|
|
void lcdui_print_status_line(void)
|
|
|
{
|
|
|
- if (IS_SD_PRINTING) {
|
|
|
- if (strcmp(longFilenameOLD, (card.longFilename[0] ? card.longFilename : card.filename)) != 0) {
|
|
|
- memset(longFilenameOLD, '\0', strlen(longFilenameOLD));
|
|
|
- sprintf_P(longFilenameOLD, PSTR("%s"), (card.longFilename[0] ? card.longFilename : card.filename));
|
|
|
- scrollstuff = 0;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
if (heating_status) { // If heating flag, show progress of heating
|
|
|
heating_status_counter++;
|
|
|
if (heating_status_counter > 13) {
|
|
@@ -776,6 +604,7 @@ void lcdui_print_status_line(void)
|
|
|
}
|
|
|
}
|
|
|
else if ((IS_SD_PRINTING) && (custom_message_type == CustomMsg::Status)) { // If printing from SD, show what we are printing
|
|
|
+ const char* longFilenameOLD = (card.longFilename[0] ? card.longFilename : card.filename);
|
|
|
if(strlen(longFilenameOLD) > LCD_WIDTH) {
|
|
|
int inters = 0;
|
|
|
int gh = scrollstuff;
|
|
@@ -4196,7 +4025,7 @@ static void prusa_stat_printinfo()
|
|
|
SERIAL_ECHOPGM("][FEM:");
|
|
|
SERIAL_ECHO(itostr3(feedmultiply));
|
|
|
SERIAL_ECHOPGM("][FNM:");
|
|
|
- SERIAL_ECHO(longFilenameOLD);
|
|
|
+ SERIAL_ECHO(card.longFilename[0] ? card.longFilename : card.filename);
|
|
|
SERIAL_ECHOPGM("][TIM:");
|
|
|
if (starttime != 0)
|
|
|
{
|
|
@@ -4511,17 +4340,10 @@ static void lcd_fsensor_state_set()
|
|
|
}
|
|
|
#endif //FILAMENT_SENSOR
|
|
|
|
|
|
-
|
|
|
-#if !SDSORT_USES_RAM
|
|
|
void lcd_set_degree() {
|
|
|
lcd_set_custom_characters_degree();
|
|
|
}
|
|
|
|
|
|
-void lcd_set_progress() {
|
|
|
- lcd_set_custom_characters_progress();
|
|
|
-}
|
|
|
-#endif
|
|
|
-
|
|
|
#if (LANG_MODE != 0)
|
|
|
|
|
|
void menu_setlang(unsigned char lang)
|
|
@@ -7166,17 +6988,25 @@ static void lcd_control_temperature_menu()
|
|
|
}
|
|
|
|
|
|
|
|
|
-#if SDCARDDETECT == -1
|
|
|
+
|
|
|
static void lcd_sd_refresh()
|
|
|
{
|
|
|
+#if SDCARDDETECT == -1
|
|
|
card.initsd();
|
|
|
+#else
|
|
|
+ card.presort();
|
|
|
+#endif
|
|
|
menu_top = 0;
|
|
|
+ lcd_encoder = 0;
|
|
|
+ menu_data_reset(); //Forces reloading of cached variables.
|
|
|
}
|
|
|
-#endif
|
|
|
+
|
|
|
static void lcd_sd_updir()
|
|
|
{
|
|
|
card.updir();
|
|
|
menu_top = 0;
|
|
|
+ lcd_encoder = 0;
|
|
|
+ menu_data_reset(); //Forces reloading of cached variables.
|
|
|
}
|
|
|
|
|
|
void lcd_print_stop()
|
|
@@ -7272,57 +7102,156 @@ void lcd_sdcard_stop()
|
|
|
|
|
|
void lcd_sdcard_menu()
|
|
|
{
|
|
|
- uint8_t sdSort = eeprom_read_byte((uint8_t*)EEPROM_SD_SORT);
|
|
|
-
|
|
|
- if (card.presort_flag == true) {
|
|
|
- card.presort_flag = false;
|
|
|
- card.presort();
|
|
|
- }
|
|
|
- if (lcd_draw_update == 0 && LCD_CLICKED == 0)
|
|
|
- //_delay(100);
|
|
|
- return; // nothing to do (so don't thrash the SD card)
|
|
|
- uint16_t fileCnt = card.getnrfilenames();
|
|
|
-
|
|
|
-
|
|
|
- MENU_BEGIN();
|
|
|
- MENU_ITEM_BACK_P(_T(bMain?MSG_MAIN:MSG_BACK)); // i.e. default menu-item / menu-item after card insertion
|
|
|
- card.getWorkDirName();
|
|
|
- if (card.filename[0] == '/')
|
|
|
- {
|
|
|
+ enum menuState_t : uint8_t {_uninitialized, _standard, _scrolling};
|
|
|
+ typedef struct
|
|
|
+ {
|
|
|
+ menuState_t menuState = _uninitialized;
|
|
|
+ uint8_t offset;
|
|
|
+ bool isDir;
|
|
|
+ const char* scrollPointer;
|
|
|
+ uint16_t selectedFileID;
|
|
|
+ uint16_t fileCnt;
|
|
|
+ int8_t row;
|
|
|
+ uint8_t sdSort;
|
|
|
+ ShortTimer lcd_scrollTimer;
|
|
|
+ } _menu_data_sdcard_t;
|
|
|
+ static_assert(sizeof(menu_data)>= sizeof(_menu_data_sdcard_t),"_menu_data_sdcard_t doesn't fit into menu_data");
|
|
|
+ _menu_data_sdcard_t* _md = (_menu_data_sdcard_t*)&(menu_data[0]);
|
|
|
+
|
|
|
+ switch(_md->menuState)
|
|
|
+ {
|
|
|
+ case _uninitialized: //Initialize menu data
|
|
|
+ {
|
|
|
+ if (card.presort_flag == true) //used to force resorting if sorting type is changed.
|
|
|
+ {
|
|
|
+ card.presort_flag = false;
|
|
|
+ card.presort();
|
|
|
+ }
|
|
|
+ _md->fileCnt = card.getnrfilenames();
|
|
|
+ _md->sdSort = eeprom_read_byte((uint8_t*)EEPROM_SD_SORT);
|
|
|
+ _md->menuState = _standard;
|
|
|
+ // FALLTHRU
|
|
|
+ }
|
|
|
+ case _standard: //normal menu structure.
|
|
|
+ {
|
|
|
+ if (!_md->lcd_scrollTimer.running()) //if the timer is not running, then the menu state was just switched, so redraw the screen.
|
|
|
+ {
|
|
|
+ _md->lcd_scrollTimer.start();
|
|
|
+ lcd_draw_update = 1;
|
|
|
+ }
|
|
|
+ if (_md->lcd_scrollTimer.expired(500) && (_md->row != -1)) //switch to the scrolling state on timeout if a file/dir is selected.
|
|
|
+ {
|
|
|
+ _md->menuState = _scrolling;
|
|
|
+ _md->offset = 0;
|
|
|
+ _md->scrollPointer = NULL;
|
|
|
+ _md->lcd_scrollTimer.start();
|
|
|
+ lcd_draw_update = 1; //forces last load before switching to scrolling.
|
|
|
+ }
|
|
|
+ if (lcd_draw_update == 0 && !LCD_CLICKED)
|
|
|
+ return; // nothing to do (so don't thrash the SD card)
|
|
|
+
|
|
|
+ _md->row = -1; // assume that no SD file/dir is currently selected. Once they are rendered, it will be changed to the correct row for the _scrolling state.
|
|
|
+
|
|
|
+ //if we reached this point it means that the encoder moved or clicked or the state is being switched. Reset the scrollTimer.
|
|
|
+ _md->lcd_scrollTimer.start();
|
|
|
+
|
|
|
+ MENU_BEGIN();
|
|
|
+ MENU_ITEM_BACK_P(_T(bMain?MSG_MAIN:MSG_BACK)); // i.e. default menu-item / menu-item after card insertion
|
|
|
+ card.getWorkDirName();
|
|
|
+ if (card.filename[0] == '/')
|
|
|
+ {
|
|
|
#if SDCARDDETECT == -1
|
|
|
- MENU_ITEM_FUNCTION_P(_T(MSG_REFRESH), lcd_sd_refresh);
|
|
|
+ MENU_ITEM_FUNCTION_P(_T(MSG_REFRESH), lcd_sd_refresh);
|
|
|
+#else
|
|
|
+ if (card.ToshibaFlashAir_isEnabled())
|
|
|
+ MENU_ITEM_FUNCTION_P(_T(MSG_REFRESH), lcd_sd_refresh); //show the refresh option if in flashAir mode.
|
|
|
#endif
|
|
|
- } else {
|
|
|
- MENU_ITEM_FUNCTION_P(PSTR(LCD_STR_FOLDER ".."), lcd_sd_updir);
|
|
|
- }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ MENU_ITEM_FUNCTION_P(PSTR(LCD_STR_FOLDER ".."), lcd_sd_updir); //Show the updir button if in a subdir.
|
|
|
|
|
|
- for (uint16_t i = 0; i < fileCnt; i++)
|
|
|
- {
|
|
|
- if (menu_item == menu_line)
|
|
|
- {
|
|
|
- const uint16_t nr = ((sdSort == SD_SORT_NONE) || farm_mode || (sdSort == SD_SORT_TIME)) ? (fileCnt - 1 - i) : i;
|
|
|
- /*#ifdef SDCARD_RATHERRECENTFIRST
|
|
|
- #ifndef SDCARD_SORT_ALPHA
|
|
|
- fileCnt - 1 -
|
|
|
- #endif
|
|
|
- #endif
|
|
|
- i;*/
|
|
|
- #ifdef SDCARD_SORT_ALPHA
|
|
|
- if (sdSort == SD_SORT_NONE) card.getfilename(nr);
|
|
|
- else card.getfilename_sorted(nr);
|
|
|
- #else
|
|
|
- card.getfilename(nr);
|
|
|
- #endif
|
|
|
+ for (uint16_t i = _md->fileCnt; i-- > 0;) // Every file, from top to bottom.
|
|
|
+ {
|
|
|
+ if (menu_item == menu_line) //If the file is on the screen.
|
|
|
+ {
|
|
|
+ //load filename to memory.
|
|
|
+#ifdef SDCARD_SORT_ALPHA
|
|
|
+ if (_md->sdSort == SD_SORT_NONE)
|
|
|
+ card.getfilename(i);
|
|
|
+ else
|
|
|
+ card.getfilename_sorted(i, _md->sdSort);
|
|
|
+#else
|
|
|
+ card.getfilename(i);
|
|
|
+#endif
|
|
|
+ if (lcd_encoder == menu_item) //If the file is selected.
|
|
|
+ {
|
|
|
+
|
|
|
+ _md->selectedFileID = i;
|
|
|
+ _md->isDir = card.filenameIsDir;
|
|
|
+ _md->row = menu_row;
|
|
|
+ }
|
|
|
+ if (card.filenameIsDir)
|
|
|
+ MENU_ITEM_SDDIR(card.filename, card.longFilename);
|
|
|
+ else
|
|
|
+ MENU_ITEM_SDFILE(card.filename, card.longFilename);
|
|
|
+ }
|
|
|
+ else MENU_ITEM_DUMMY(); //dummy item that just increments the internal menu counters.
|
|
|
+ }
|
|
|
+ MENU_END();
|
|
|
+ } break;
|
|
|
+ case _scrolling: //scrolling filename
|
|
|
+ {
|
|
|
+ const bool rewindFlag = LCD_CLICKED || lcd_draw_update; //flag that says whether the menu should return to _standard state.
|
|
|
|
|
|
- if (card.filenameIsDir)
|
|
|
- MENU_ITEM_SDDIR(card.filename, card.longFilename);
|
|
|
- else
|
|
|
- MENU_ITEM_SDFILE(_T(MSG_CARD_MENU), card.filename, card.longFilename);
|
|
|
- } else {
|
|
|
- MENU_ITEM_DUMMY();
|
|
|
- }
|
|
|
- }
|
|
|
- MENU_END();
|
|
|
+ if (_md->scrollPointer == NULL)
|
|
|
+ {
|
|
|
+ //load filename to memory.
|
|
|
+#ifdef SDCARD_SORT_ALPHA
|
|
|
+ if (_md->sdSort == SD_SORT_NONE)
|
|
|
+ card.getfilename(_md->selectedFileID);
|
|
|
+ else
|
|
|
+ card.getfilename_sorted(_md->selectedFileID, _md->sdSort);
|
|
|
+#else
|
|
|
+ card.getfilename(_md->selectedFileID);
|
|
|
+#endif
|
|
|
+ _md->scrollPointer = (card.longFilename[0] == '\0') ? card.filename : card.longFilename;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (rewindFlag == 1)
|
|
|
+ _md->offset = 0; //redraw once again from the beginning.
|
|
|
+ if (_md->lcd_scrollTimer.expired(300) || rewindFlag)
|
|
|
+ {
|
|
|
+ uint8_t i = LCD_WIDTH - ((_md->isDir)?2:1);
|
|
|
+ lcd_set_cursor(0, _md->row);
|
|
|
+ lcd_print('>');
|
|
|
+ if (_md->isDir)
|
|
|
+ lcd_print(LCD_STR_FOLDER[0]);
|
|
|
+ for (; i != 0; i--)
|
|
|
+ {
|
|
|
+ const char* c = (_md->scrollPointer + _md->offset + ((LCD_WIDTH - ((_md->isDir)?2:1)) - i));
|
|
|
+ lcd_print(c[0]);
|
|
|
+ if (c[1])
|
|
|
+ _md->lcd_scrollTimer.start();
|
|
|
+ else
|
|
|
+ {
|
|
|
+ _md->lcd_scrollTimer.stop();
|
|
|
+ break; //stop at the end of the string
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (i != 0) //adds spaces if string is incomplete or at the end (instead of null).
|
|
|
+ {
|
|
|
+ lcd_space(i);
|
|
|
+ }
|
|
|
+ _md->offset++;
|
|
|
+ }
|
|
|
+ if (rewindFlag) //go back to sd_menu.
|
|
|
+ {
|
|
|
+ _md->lcd_scrollTimer.stop(); //forces redraw in _standard state
|
|
|
+ _md->menuState = _standard;
|
|
|
+ }
|
|
|
+ } break;
|
|
|
+ default: _md->menuState = _uninitialized; //shouldn't ever happen. Anyways, initialize the menu.
|
|
|
+ }
|
|
|
}
|
|
|
#ifdef TMC2130
|
|
|
static void lcd_belttest_v()
|
|
@@ -8577,7 +8506,6 @@ static bool check_file(const char* filename) {
|
|
|
const uint32_t filesize = card.getFileSize();
|
|
|
uint32_t startPos = 0;
|
|
|
const uint16_t bytesToCheck = min(END_FILE_SECTION, filesize);
|
|
|
- uint8_t blocksPrinted = 0;
|
|
|
if (filesize > END_FILE_SECTION) {
|
|
|
startPos = filesize - END_FILE_SECTION;
|
|
|
card.setIndex(startPos);
|
|
@@ -8585,22 +8513,15 @@ static bool check_file(const char* filename) {
|
|
|
cmdqueue_reset();
|
|
|
cmdqueue_serial_disabled = true;
|
|
|
|
|
|
- lcd_clear();
|
|
|
- lcd_puts_at_P(0, 1, _i("Checking file"));////c=20 r=1
|
|
|
- lcd_set_cursor(0, 2);
|
|
|
+ menu_progressbar_init(bytesToCheck, _i("Checking file"));
|
|
|
while (!card.eof() && !result) {
|
|
|
- for (; blocksPrinted < (((card.get_sdpos() - startPos) * LCD_WIDTH) / bytesToCheck); blocksPrinted++)
|
|
|
- lcd_print('\xFF'); //simple progress bar
|
|
|
-
|
|
|
+ menu_progressbar_update(card.get_sdpos() - startPos);
|
|
|
card.sdprinting = true;
|
|
|
get_command();
|
|
|
result = check_commands();
|
|
|
}
|
|
|
-
|
|
|
- for (; blocksPrinted < LCD_WIDTH; blocksPrinted++)
|
|
|
- lcd_print('\xFF'); //simple progress bar
|
|
|
- _delay(100); //for the user to see the end of the progress bar.
|
|
|
-
|
|
|
+
|
|
|
+ menu_progressbar_finish();
|
|
|
|
|
|
cmdqueue_serial_disabled = false;
|
|
|
card.printingHasFinished();
|
|
@@ -8659,6 +8580,7 @@ void menu_action_sddirectory(const char* filename)
|
|
|
{
|
|
|
card.chdir(filename, true);
|
|
|
lcd_encoder = 0;
|
|
|
+ menu_data_reset(); //Forces reloading of cached variables.
|
|
|
}
|
|
|
|
|
|
/** LCD API **/
|
|
@@ -8723,7 +8645,6 @@ static void lcd_connect_printer() {
|
|
|
|
|
|
int i = 0;
|
|
|
int t = 0;
|
|
|
- lcd_set_custom_characters_progress();
|
|
|
lcd_puts_at_P(0, 0, _i("Connect printer to"));
|
|
|
lcd_puts_at_P(0, 1, _i("monitoring or hold"));
|
|
|
lcd_puts_at_P(0, 2, _i("the knob to continue"));
|
|
@@ -8740,12 +8661,11 @@ static void lcd_connect_printer() {
|
|
|
i = 0;
|
|
|
lcd_puts_at_P(0, 3, PSTR(" "));
|
|
|
}
|
|
|
- if (i!=0) lcd_puts_at_P((i * 20) / (NC_BUTTON_LONG_PRESS * 10), 3, "\x01");
|
|
|
+ if (i!=0) lcd_puts_at_P((i * 20) / (NC_BUTTON_LONG_PRESS * 10), 3, "\xFF");
|
|
|
if (i == NC_BUTTON_LONG_PRESS * 10) {
|
|
|
no_response = false;
|
|
|
}
|
|
|
}
|
|
|
- lcd_set_custom_characters_degree();
|
|
|
lcd_update_enable(true);
|
|
|
lcd_update(2);
|
|
|
}
|