Skip to content

Commit

Permalink
make "scrolling filenames" an adjustable option
Browse files Browse the repository at this point in the history
  • Loading branch information
TinkerGnome committed Feb 19, 2017
1 parent e1a20c3 commit 2e6d723
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 34 deletions.
15 changes: 9 additions & 6 deletions Marlin/UltiLCD2_hi_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ int16_t lcd_setting_min;
int16_t lcd_setting_max;
int16_t lcd_setting_start_value;

uint16_t lineEntryPos = 0;
int8_t lineEntryWait = 0;

uint8_t heater_timeout = 3;
uint16_t backup_temperature[EXTRUDERS] = { 0 };

Expand All @@ -37,12 +40,10 @@ void eeprom_write_float(const float* addr, float f)
eeprom_write_dword((uint32_t*)addr, n.i);
}

uint16_t lineEntryPos = 0;
int8_t lineEntryWait = 0;
void line_entry_pos_update (uint16_t maxStep)
{
if (lineEntryPos > maxStep) lineEntryPos = 0;
//
//
lineEntryWait++;
if (lineEntryWait >= LINE_ENTRY_WAIT_END)
{
Expand Down Expand Up @@ -206,7 +207,7 @@ void lcd_draw_scroll_entry(uint8_t offsetY, char * buffer, uint8_t flags)
uint8_t backup_pos = 0;
if (flags & MENU_SELECTED)
{
if (buffer_len > LINE_ENTRY_TEXT_LENGHT)
if ((ui_mode & UI_SCROLL_ENTRY) && (buffer_len > LINE_ENTRY_TEXT_LENGHT))
{
line_entry_pos_update(LINE_ENTRY_MAX_STEP(buffer_len - LINE_ENTRY_TEXT_LENGHT));
buffer += LINE_ENTRY_TEXT_BEGIN();
Expand All @@ -220,8 +221,10 @@ void lcd_draw_scroll_entry(uint8_t offsetY, char * buffer, uint8_t flags)
//
if (backup != '\0')
buffer[backup_pos] = backup;
}else{
if (buffer_len > LINE_ENTRY_TEXT_LENGHT)
}
else
{
if ((ui_mode & UI_SCROLL_ENTRY) && (buffer_len > LINE_ENTRY_TEXT_LENGHT))
{
backup = buffer[LINE_ENTRY_TEXT_LENGHT];
buffer[LINE_ENTRY_TEXT_LENGHT] = '\0';
Expand Down
16 changes: 3 additions & 13 deletions Marlin/UltiLCD2_hi_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ extern int16_t lcd_setting_start_value;
extern menuFunc_t postMenuCheck;
extern uint8_t minProgress;

extern uint16_t lineEntryPos;
extern int8_t lineEntryWait;

#define LCD_EDIT_SETTING(_setting, _name, _postfix, _min, _max) do { \
menu.add_menu(menu_t(lcd_menu_edit_setting)); \
lcd_setting_name = PSTR(_name); \
Expand Down Expand Up @@ -106,19 +109,6 @@ extern uint8_t minProgress;
lcd_setting_max = (_max) / 60 + 0.5; \
} while(0)

extern uint16_t lineEntryPos;
extern int8_t lineEntryWait;
#define LINE_ENTRY_STEP 2
#define LINE_ENTRY_WAIT_END 24
#define LINE_ENTRY_GFX_LENGHT (LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-LCD_CHAR_MARGIN_LEFT)
#define LINE_ENTRY_TEXT_LENGHT (LINE_ENTRY_GFX_LENGHT / LCD_CHAR_SPACING)
#define LINE_ENTRY_TEXT_OFFSET() ((lineEntryPos%LCD_CHAR_SPACING == 0) ? 0 : -1)
#define LINE_ENTRY_TEXT_BEGIN() ((lineEntryPos + LCD_CHAR_SPACING-1) / LCD_CHAR_SPACING)
#define LINE_ENTRY_GFX_BEGIN() (LCD_CHAR_SPACING-1 - (lineEntryPos + LCD_CHAR_SPACING-1) % LCD_CHAR_SPACING)
#define LINE_ENTRY_MAX_STEP(text_length) ((text_length) * LCD_CHAR_SPACING)
void line_entry_pos_update (uint16_t maxStep);
inline void line_entry_pos_reset ();

//If we have a heated bed, then the heated bed menu entries have a size of 1, else they have a size of 0.
#if TEMP_SENSOR_BED != 0
#define BED_MENU_OFFSET 1
Expand Down
1 change: 0 additions & 1 deletion Marlin/UltiLCD2_low_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "pins.h"
#include "preferences.h"
#include "UltiLCD2_low_lib.h"
#include "UltiLCD2_hi_lib.h"
#include "tinkergnome.h"

/**
Expand Down
9 changes: 9 additions & 0 deletions Marlin/UltiLCD2_low_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ char* float_to_string2(float f, char* temp_buffer, const char* p_postfix = NULL,
#define LCD_CHAR_SPACING 6
#define LCD_CHAR_HEIGHT 7

#define LINE_ENTRY_STEP 2
#define LINE_ENTRY_WAIT_END 24
#define LINE_ENTRY_GFX_LENGHT (LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-LCD_CHAR_MARGIN_LEFT)
#define LINE_ENTRY_TEXT_LENGHT (LINE_ENTRY_GFX_LENGHT / LCD_CHAR_SPACING)
#define LINE_ENTRY_TEXT_OFFSET() ((lineEntryPos%LCD_CHAR_SPACING == 0) ? 0 : -1)
#define LINE_ENTRY_TEXT_BEGIN() ((lineEntryPos + LCD_CHAR_SPACING-1) / LCD_CHAR_SPACING)
#define LINE_ENTRY_GFX_BEGIN() (LCD_CHAR_SPACING-1 - (lineEntryPos + LCD_CHAR_SPACING-1) % LCD_CHAR_SPACING)
#define LINE_ENTRY_MAX_STEP(text_length) ((text_length) * LCD_CHAR_SPACING)

FORCE_INLINE void lcd_lib_draw_string_left(uint8_t y, const char* str) { lcd_lib_draw_string(LCD_CHAR_MARGIN_LEFT, y, str); }
FORCE_INLINE void lcd_lib_draw_string_leftP(uint8_t y, const char* pstr) { lcd_lib_draw_stringP(LCD_CHAR_MARGIN_LEFT, y, pstr); }
FORCE_INLINE void lcd_lib_draw_string_right(uint8_t x, uint8_t y, const char* str) { lcd_lib_draw_string(x - (strlen(str) * LCD_CHAR_SPACING), y, str); }
Expand Down
77 changes: 69 additions & 8 deletions Marlin/UltiLCD2_menu_maintenance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,14 @@ static void lcd_preferences_item(uint8_t nr, uint8_t offsetY, uint8_t flags)
strcpy_P(buffer, PSTR("LED settings"));
else if (nr == index++)
strcpy_P(buffer, PSTR("Click sound"));
else if (nr == index++)
strcpy_P(buffer, PSTR("Scroll filenames"));
else if (nr == index++)
strcpy_P(buffer, PSTR("Sleep timer"));
else if (nr == index++)
strcpy_P(buffer, PSTR("Screen contrast"));
else if (nr == index++)
strcpy_P(buffer, PSTR("Heater timeout"));
//#if TEMP_SENSOR_BED != 0
// else if (nr == index++)
// strcpy_P(buffer, PSTR("Buildplate PID"));
//#endif
else if (nr == index++)
strcpy_P(buffer, PSTR("Temperature control"));
else if (nr == index++)
Expand Down Expand Up @@ -214,11 +212,22 @@ static void lcd_preferences_details(uint8_t nr)
strcpy_P(buffer, PSTR("Standard"));
}
}
else if (nr == 5)
else if (nr == 4)
{
int_to_string(float(lcd_contrast)*100/255 + 0.5f, buffer, PSTR("%"));
if (ui_mode & UI_SCROLL_ENTRY)
{
strcpy_P(buffer, PSTR("Enabled"));
}
else
{
strcpy_P(buffer, PSTR("Disabled"));
}
}
else if (nr == 6)
{
int_to_string(float(lcd_contrast)*100/255 + 0.5f, buffer, PSTR("%"));
}
else if (nr == 7)
{
char *c = buffer;
if (heater_timeout)
Expand All @@ -239,7 +248,7 @@ static void lcd_preferences_details(uint8_t nr)
strcpy_P(c, PSTR("off"));
}
}
else if (nr == 12)
else if (nr == 13)
{
strcpy_P(buffer, PSTR(STRING_CONFIG_H_AUTHOR));
}
Expand Down Expand Up @@ -763,6 +772,34 @@ static void lcd_clicksound_item(uint8_t nr, uint8_t offsetY, uint8_t flags)
lcd_draw_scroll_entry(offsetY, buffer, flags);
}

static void lcd_scrollentry_item(uint8_t nr, uint8_t offsetY, uint8_t flags)
{
char buffer[20] = {' '};

if (nr == 0)
{
strcpy_P(buffer, PSTR("< RETURN"));
}
else if (nr == 1)
{
if (!(ui_mode & UI_SCROLL_ENTRY))
{
strcpy_P(buffer, PSTR(">"));
}
strcpy_P(buffer+1, PSTR("No scrolling"));
}
else if (nr == 2)
{
if (ui_mode & UI_SCROLL_ENTRY)
{
strcpy_P(buffer, PSTR(">"));
}
strcpy_P(buffer+1, PSTR("Scroll filenames"));
}

lcd_draw_scroll_entry(offsetY, buffer, flags);
}

static void lcd_menu_uimode()
{
lcd_scroll_menu(PSTR("User interface"), 3, lcd_uimode_item, NULL);
Expand Down Expand Up @@ -814,6 +851,28 @@ static void lcd_menu_clicksound()
lcd_lib_update_screen();
}

static void lcd_menu_scrollentry()
{
lcd_scroll_menu(PSTR("Scroll filenames"), 3, lcd_scrollentry_item, NULL);
if (lcd_lib_button_pressed)
{
if (IS_SELECTED_SCROLL(1))
{
ui_mode &= ~UI_SCROLL_ENTRY;
}
else if (IS_SELECTED_SCROLL(2))
{
ui_mode |= UI_SCROLL_ENTRY;
}
if (ui_mode != GET_UI_MODE())
{
SET_UI_MODE(ui_mode);
}
menu.return_to_previous();
}
lcd_lib_update_screen();
}

static void lcd_menu_screen_contrast()
{
if (lcd_tune_byte(lcd_contrast, 0, 100))
Expand Down Expand Up @@ -843,7 +902,7 @@ static void lcd_menu_screen_contrast()

static void lcd_menu_preferences()
{
lcd_scroll_menu(PSTR("PREFERENCES"), BED_MENU_OFFSET + 14, lcd_preferences_item, lcd_preferences_details);
lcd_scroll_menu(PSTR("PREFERENCES"), BED_MENU_OFFSET + 15, lcd_preferences_item, lcd_preferences_details);
if (lcd_lib_button_pressed)
{
uint8_t index = 0;
Expand All @@ -855,6 +914,8 @@ static void lcd_menu_preferences()
menu.add_menu(menu_t(init_maintenance_led, lcd_menu_maintenance_led, NULL));
else if (IS_SELECTED_SCROLL(index++))
menu.add_menu(menu_t(lcd_menu_clicksound));
else if (IS_SELECTED_SCROLL(index++))
menu.add_menu(menu_t(lcd_menu_scrollentry));
else if (IS_SELECTED_SCROLL(index++))
menu.add_menu(menu_t(lcd_menu_sleeptimer));
else if (IS_SELECTED_SCROLL(index++))
Expand Down
2 changes: 0 additions & 2 deletions Marlin/UltiLCD2_menu_print.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ extern uint8_t lcd_cache[LCD_CACHE_SIZE];

extern unsigned long predictedTime;

void getFilenameFromNr(char* buffer, uint8_t nr);

void lcd_menu_print_select();
void lcd_clear_cache();

Expand Down
9 changes: 5 additions & 4 deletions Marlin/preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@
#define SET_AXIS_DIRECTION(n) do { eeprom_write_byte((uint8_t*)EEPROM_AXIS_DIRECTION, n); } while(0)

// UI Mode
#define UI_MODE_STANDARD 0
#define UI_MODE_EXPERT 1
// UI Mode
#define UI_MODE_EXPERT 0x01
#define UI_SCROLL_ENTRY 0x02

#define UI_BEEP_SHORT 32
#define UI_BEEP_OFF 64
#define UI_BEEP_SHORT 0x20
#define UI_BEEP_OFF 0x40


// SLEEP/LCD/SERIAL STATE
Expand Down

0 comments on commit 2e6d723

Please sign in to comment.