parent
e9f74b2678
commit
4736a1624f
|
|
@ -82,7 +82,6 @@ uint8_t lcd_escape[8];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static uint8_t lcd_custom_characters[8] = {0};
|
static uint8_t lcd_custom_characters[8] = {0};
|
||||||
static uint8_t lcd_custom_index = 0;
|
|
||||||
|
|
||||||
static void lcd_display(void);
|
static void lcd_display(void);
|
||||||
|
|
||||||
|
|
@ -101,6 +100,7 @@ static void lcd_no_autoscroll(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void lcd_print_custom(uint8_t c);
|
static void lcd_print_custom(uint8_t c);
|
||||||
|
static void lcd_invalidate_custom_characters();
|
||||||
|
|
||||||
#ifdef VT100
|
#ifdef VT100
|
||||||
void lcd_escape_write(uint8_t chr);
|
void lcd_escape_write(uint8_t chr);
|
||||||
|
|
@ -244,12 +244,13 @@ void lcd_refresh_noclear(void)
|
||||||
lcd_begin(0);
|
lcd_begin(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear display, set cursor position to zero and unshift the display. It does not clear the custom characters memory
|
// Clear display, set cursor position to zero and unshift the display. It also invalidates all custom characters
|
||||||
void lcd_clear(void)
|
void lcd_clear(void)
|
||||||
{
|
{
|
||||||
lcd_command(LCD_CLEARDISPLAY, 1600);
|
lcd_command(LCD_CLEARDISPLAY, 1600);
|
||||||
lcd_currline = 0;
|
lcd_currline = 0;
|
||||||
lcd_ddram_address = 0;
|
lcd_ddram_address = 0;
|
||||||
|
lcd_invalidate_custom_characters();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set cursor position to zero and in DDRAM. It does not unshift the display.
|
// Set cursor position to zero and in DDRAM. It does not unshift the display.
|
||||||
|
|
@ -831,25 +832,36 @@ const CustomCharacter Font[] PROGMEM = {
|
||||||
#include "Fonts/FontTable.h"
|
#include "Fonts/FontTable.h"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// #define DEBUG_CUSTOM_CHARACTERS
|
||||||
|
|
||||||
static void lcd_print_custom(uint8_t c) {
|
static void lcd_print_custom(uint8_t c) {
|
||||||
uint8_t charToSend;
|
uint8_t charToSend;
|
||||||
// check if we already have the character in the lcd memory
|
// check if we already have the character in the lcd memory
|
||||||
for (uint8_t i = 0; i < lcd_custom_index; i++) {
|
for (uint8_t i = 0; i < 8; i++) {
|
||||||
if (lcd_custom_characters[i] == c) {
|
if ((lcd_custom_characters[i] & 0x7F) == (c & 0x7F)) {
|
||||||
// send the found custom character id
|
lcd_custom_characters[i] = c; // mark the custom character as used
|
||||||
charToSend = i;
|
charToSend = i; // send the found custom character id
|
||||||
|
#ifdef DEBUG_CUSTOM_CHARACTERS
|
||||||
|
printf_P(PSTR("found char %02x at index %u\n"), c, i);
|
||||||
|
#endif // DEBUG_CUSTOM_CHARACTERS
|
||||||
goto sendChar;
|
goto sendChar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// character not in memory.
|
// in case no empty slot is found, use the alternate character.
|
||||||
if (lcd_custom_index >= 8) { //ran out of custom characters. Use the alternate character.
|
charToSend = pgm_read_byte(&Font[c - 0x80].alternate);
|
||||||
charToSend = pgm_read_byte(&Font[c - 0x80].alternate);
|
|
||||||
}
|
// try to find a slot where it could be placed
|
||||||
else { //create a new custom character and send it
|
for (uint8_t i = 0; i < 8; i++) {
|
||||||
lcd_createChar_P(lcd_custom_index, Font[c - 0x80].data);
|
if (lcd_custom_characters[i] == 0x7F) { //found an empty slot. create a new custom character and send it
|
||||||
lcd_custom_characters[lcd_custom_index] = c;
|
lcd_createChar_P(i, Font[c - 0x80].data);
|
||||||
charToSend = lcd_custom_index++;
|
lcd_custom_characters[i] = c; // mark the custom character as used
|
||||||
|
#ifdef DEBUG_CUSTOM_CHARACTERS
|
||||||
|
printf_P(PSTR("new char %02x at slot %u\n"), c, i);
|
||||||
|
#endif // DEBUG_CUSTOM_CHARACTERS
|
||||||
|
charToSend = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sendChar:
|
sendChar:
|
||||||
|
|
@ -857,6 +869,31 @@ sendChar:
|
||||||
lcd_ddram_address++; // no need for preventing ddram overflow
|
lcd_ddram_address++; // no need for preventing ddram overflow
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcd_invalidate_custom_characters() {
|
static void lcd_invalidate_custom_characters() {
|
||||||
lcd_custom_index = 0;
|
memset(lcd_custom_characters, 0x7F, sizeof(lcd_custom_characters));
|
||||||
|
}
|
||||||
|
|
||||||
|
void lcd_frame_start() {
|
||||||
|
// check all custom characters and discard unused ones
|
||||||
|
for (uint8_t i = 0; i < 8; i++) {
|
||||||
|
uint8_t c = lcd_custom_characters[i];
|
||||||
|
if (c == 0x7F) { //slot empty
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (c & 0x80) { //slot was used on the last frame update, mark it as potentially unused this time
|
||||||
|
lcd_custom_characters[i] = c & 0x7F;
|
||||||
|
}
|
||||||
|
else { //character is no longer used (or invalid?), mark it as unused
|
||||||
|
lcd_custom_characters[i] = 0x7F;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_CUSTOM_CHARACTERS
|
||||||
|
printf_P(PSTR("frame start:"));
|
||||||
|
for (uint8_t i = 0; i < 8; i++) {
|
||||||
|
printf_P(PSTR(" %02x"), lcd_custom_characters[i]);
|
||||||
|
}
|
||||||
|
printf_P(PSTR("\n"));
|
||||||
|
#endif // DEBUG_CUSTOM_CHARACTERS
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -189,7 +189,7 @@ struct CustomCharacter {
|
||||||
const char alternate;
|
const char alternate;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void lcd_invalidate_custom_characters();
|
extern void lcd_frame_start();
|
||||||
|
|
||||||
//! @brief Consume click and longpress event
|
//! @brief Consume click and longpress event
|
||||||
inline void lcd_consume_click()
|
inline void lcd_consume_click()
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@ void menu_start(void)
|
||||||
menu_top = lcd_encoder;
|
menu_top = lcd_encoder;
|
||||||
menu_line = menu_top;
|
menu_line = menu_top;
|
||||||
menu_clicked = lcd_clicked(); // Consume click event
|
menu_clicked = lcd_clicked(); // Consume click event
|
||||||
|
if (lcd_draw_update) lcd_frame_start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void menu_end(void)
|
void menu_end(void)
|
||||||
|
|
|
||||||
|
|
@ -627,6 +627,7 @@ void lcdui_print_status_line(void) {
|
||||||
//! @endcode
|
//! @endcode
|
||||||
void lcdui_print_status_screen(void)
|
void lcdui_print_status_screen(void)
|
||||||
{
|
{
|
||||||
|
lcd_frame_start();
|
||||||
lcd_home(); //line 0
|
lcd_home(); //line 0
|
||||||
|
|
||||||
//Print the hotend temperature (9 chars total)
|
//Print the hotend temperature (9 chars total)
|
||||||
|
|
@ -680,7 +681,6 @@ void lcdui_print_status_screen(void)
|
||||||
#ifndef DEBUG_DISABLE_LCD_STATUS_LINE
|
#ifndef DEBUG_DISABLE_LCD_STATUS_LINE
|
||||||
lcdui_print_status_line();
|
lcdui_print_status_line();
|
||||||
#endif //DEBUG_DISABLE_LCD_STATUS_LINE
|
#endif //DEBUG_DISABLE_LCD_STATUS_LINE
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lcdui_refresh(uint8_t clear = true)
|
static void lcdui_refresh(uint8_t clear = true)
|
||||||
|
|
@ -2862,6 +2862,7 @@ static const char* lcd_display_message_fullscreen_nonBlocking_P(const char *msg)
|
||||||
{
|
{
|
||||||
const char *msgend = msg;
|
const char *msgend = msg;
|
||||||
bool multi_screen = false;
|
bool multi_screen = false;
|
||||||
|
lcd_frame_start();
|
||||||
for (uint8_t row = 0; row < LCD_HEIGHT; ++ row) {
|
for (uint8_t row = 0; row < LCD_HEIGHT; ++ row) {
|
||||||
lcd_set_cursor(0, row);
|
lcd_set_cursor(0, row);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue