Fix up LCD init / charset

2.0.x
Scott Lahteine 7 years ago
parent c2fc78c3a8
commit 9406c87a97

@ -802,9 +802,6 @@ void setup() {
#if ENABLED(SHOW_BOOTSCREEN)
lcd_bootscreen();
#if DISABLED(DOGLCD) && ENABLED(ULTRA_LCD) && DISABLED(SDSUPPORT)
lcd_init();
#endif
#endif
#if ENABLED(MIXING_EXTRUDER) && MIXING_VIRTUAL_TOOLS > 1

@ -522,13 +522,15 @@ uint16_t max_display_update_time = 0;
lcd_implementation_clear();
// Re-initialize custom characters that may be re-used
#if DISABLED(DOGLCD) && ENABLED(AUTO_BED_LEVELING_UBL)
if (!ubl.lcd_map_control) lcd_set_custom_characters(
#if ENABLED(LCD_PROGRESS_BAR)
screen == lcd_status_screen
#endif
);
if (!ubl.lcd_map_control) {
lcd_set_custom_characters(
#if ENABLED(LCD_PROGRESS_BAR)
screen == lcd_status_screen ? CHARSET_INFO : CHARSET_MENU
#endif
);
}
#elif ENABLED(LCD_PROGRESS_BAR)
lcd_set_custom_characters(screen == lcd_status_screen);
lcd_set_custom_characters(screen == lcd_status_screen ? CHARSET_INFO : CHARSET_MENU);
#endif
lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
screen_changed = true;
@ -670,7 +672,7 @@ void lcd_status_screen() {
#endif
lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
#if ENABLED(LCD_PROGRESS_BAR)
false
CHARSET_MENU
#endif
);
lcd_goto_screen(lcd_main_menu);
@ -849,7 +851,7 @@ void kill_screen(const char* lcd_msg) {
static int8_t bar_percent = 0;
if (lcd_clicked) {
lcd_goto_previous_menu();
lcd_set_custom_characters(false);
lcd_set_custom_characters(CHARSET_MENU);
return;
}
bar_percent += (int8_t)encoderPosition;
@ -4458,11 +4460,7 @@ void kill_screen(const char* lcd_msg) {
void lcd_init() {
lcd_implementation_init(
#if ENABLED(LCD_PROGRESS_BAR)
true
#endif
);
lcd_implementation_init();
#if ENABLED(NEWPANEL)
@ -4636,7 +4634,7 @@ void lcd_update() {
lcdDrawUpdate = LCDVIEW_CLEAR_CALL_REDRAW;
lcd_implementation_init( // to maybe revive the LCD if static electricity killed it.
#if ENABLED(LCD_PROGRESS_BAR)
currentScreen == lcd_status_screen
currentScreen == lcd_status_screen ? CHARSET_INFO : CHARSET_MENU
#endif
);
}

@ -221,11 +221,57 @@ static void createChar_P(const char c, const byte * const ptr) {
lcd.createChar(c, temp);
}
#define CHARSET_MENU 0
#define CHARSET_INFO 1
#define CHARSET_BOOT 2
static void lcd_set_custom_characters(
#if ENABLED(LCD_PROGRESS_BAR)
const bool info_screen_charset = true
#if ENABLED(LCD_PROGRESS_BAR) || ENABLED(SHOW_BOOTSCREEN)
const uint8_t screen_charset=CHARSET_INFO
#endif
) {
// CHARSET_BOOT
#if ENABLED(SHOW_BOOTSCREEN)
const static PROGMEM byte corner[4][8] = { {
B00000,
B00000,
B00000,
B00000,
B00001,
B00010,
B00100,
B00100
}, {
B00000,
B00000,
B00000,
B11100,
B11100,
B01100,
B00100,
B00100
}, {
B00100,
B00010,
B00001,
B00000,
B00000,
B00000,
B00000,
B00000
}, {
B00100,
B01000,
B10000,
B00000,
B00000,
B00000,
B00000,
B00000
} };
#endif // SHOW_BOOTSCREEN
// CHARSET_INFO
const static PROGMEM byte bedTemp[8] = {
B00000,
B11111,
@ -293,6 +339,8 @@ static void lcd_set_custom_characters(
};
#if ENABLED(SDSUPPORT)
// CHARSET_MENU
const static PROGMEM byte refresh[8] = {
B00000,
B00110,
@ -315,6 +363,8 @@ static void lcd_set_custom_characters(
};
#if ENABLED(LCD_PROGRESS_BAR)
// CHARSET_INFO
const static PROGMEM byte progress[3][8] = { {
B00000,
B10000,
@ -343,43 +393,61 @@ static void lcd_set_custom_characters(
B10101,
B00000
} };
#endif
#endif
createChar_P(LCD_BEDTEMP_CHAR, bedTemp);
createChar_P(LCD_DEGREE_CHAR, degree);
createChar_P(LCD_STR_THERMOMETER[0], thermometer);
createChar_P(LCD_FEEDRATE_CHAR, feedrate);
createChar_P(LCD_CLOCK_CHAR, clock);
#endif // LCD_PROGRESS_BAR
#if ENABLED(SDSUPPORT)
#if ENABLED(LCD_PROGRESS_BAR)
static bool char_mode = false;
if (info_screen_charset != char_mode) {
char_mode = info_screen_charset;
if (info_screen_charset) { // Progress bar characters for info screen
for (int16_t i = 3; i--;) createChar_P(LCD_STR_PROGRESS[i], progress[i]);
}
else { // Custom characters for submenus
createChar_P(LCD_UPLEVEL_CHAR, uplevel);
createChar_P(LCD_STR_REFRESH[0], refresh);
createChar_P(LCD_STR_FOLDER[0], folder);
}
}
#else
createChar_P(LCD_UPLEVEL_CHAR, uplevel);
createChar_P(LCD_STR_REFRESH[0], refresh);
createChar_P(LCD_STR_FOLDER[0], folder);
#endif
#endif // SDSUPPORT
#if ENABLED(SHOW_BOOTSCREEN) || ENABLED(LCD_PROGRESS_BAR)
static uint8_t char_mode = 0;
#define CHAR_COND (screen_charset != char_mode)
#else
createChar_P(LCD_UPLEVEL_CHAR, uplevel);
#define CHAR_COND true
#endif
if (CHAR_COND) {
#if ENABLED(SHOW_BOOTSCREEN) || ENABLED(LCD_PROGRESS_BAR)
char_mode = screen_charset;
#if ENABLED(SHOW_BOOTSCREEN)
// Set boot screen corner characters
if (screen_charset == CHARSET_BOOT) {
for (uint8_t i = 4; i--;)
createChar_P(i, corner[i]);
}
else
#endif
#endif
{ // Info Screen uses 5 special characters
createChar_P(LCD_BEDTEMP_CHAR, bedTemp);
createChar_P(LCD_DEGREE_CHAR, degree);
createChar_P(LCD_STR_THERMOMETER[0], thermometer);
createChar_P(LCD_FEEDRATE_CHAR, feedrate);
createChar_P(LCD_CLOCK_CHAR, clock);
#if ENABLED(SDSUPPORT)
#if ENABLED(LCD_PROGRESS_BAR)
if (screen_charset == CHARSET_INFO) { // 3 Progress bar characters for info screen
for (int16_t i = 3; i--;)
createChar_P(LCD_STR_PROGRESS[i], progress[i]);
}
else
#endif
{ // SD Card sub-menu special characters
createChar_P(LCD_UPLEVEL_CHAR, uplevel);
createChar_P(LCD_STR_REFRESH[0], refresh);
createChar_P(LCD_STR_FOLDER[0], folder);
}
#else
// With no SD support, only need the uplevel character
createChar_P(LCD_UPLEVEL_CHAR, uplevel);
#endif
}
}
}
static void lcd_implementation_init(
#if ENABLED(LCD_PROGRESS_BAR)
const bool info_screen_charset = true
const uint8_t screen_charset=CHARSET_INFO
#endif
) {
@ -409,7 +477,7 @@ static void lcd_implementation_init(
lcd_set_custom_characters(
#if ENABLED(LCD_PROGRESS_BAR)
info_screen_charset
screen_charset
#endif
);

Loading…
Cancel
Save