Browse Source

Unify status scrolling further

pull/1/head
Scott Lahteine 6 years ago
parent
commit
58bca67883
  1. 43
      Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp
  2. 41
      Marlin/src/lcd/dogm/status_screen_DOGM.cpp
  3. 36
      Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp
  4. 17
      Marlin/src/lcd/ultralcd.cpp
  5. 12
      Marlin/src/lcd/ultralcd.h

43
Marlin/src/lcd/HD44780/ultralcd_HD44780.cpp

@ -660,33 +660,22 @@ void MarlinUI::draw_status_message(const bool blink) {
lcd_put_u8str(status_message); lcd_put_u8str(status_message);
// Fill the rest with spaces // Fill the rest with spaces
while (slen < LCD_WIDTH) { while (slen < LCD_WIDTH) { lcd_put_wchar(' '); ++slen; }
lcd_put_wchar(' ');
++slen;
}
} }
else { else {
// String is larger than the available space in screen. // String is larger than the available space in screen.
// Get a pointer to the next valid UTF8 character // Get a pointer to the next valid UTF8 character
const char *stat = status_message + status_scroll_offset; // and the string remaining length
uint8_t rlen;
// Get the string remaining length const char *stat = status_and_len(rlen);
const uint8_t rlen = utf8_strlen(stat); lcd_put_u8str_max(stat, LCD_WIDTH); // The string leaves space
// If we have enough characters to display // If the remaining string doesn't completely fill the screen
if (rlen >= LCD_WIDTH) { if (rlen < LCD_WIDTH) {
// The remaining string fills the screen - Print it lcd_put_wchar('.'); // Always at 1+ spaces left, draw a dot
lcd_put_u8str_max(stat, LCD_WIDTH); uint8_t chars = LCD_WIDTH - rlen; // Amount of space left in characters
} if (--chars) { // Draw a second dot if there's space
else {
// The remaining string does not completely fill the screen
lcd_put_u8str_max(stat, LCD_WIDTH); // The string leaves space
uint8_t chars = LCD_WIDTH - rlen; // Amount of space left in characters
lcd_put_wchar('.'); // Always at 1+ spaces left, draw a dot
if (--chars) { // Draw a second dot if there's space
lcd_put_wchar('.'); lcd_put_wchar('.');
if (--chars) if (--chars)
lcd_put_u8str_max(status_message, chars); // Print a second copy of the message lcd_put_u8str_max(status_message, chars); // Print a second copy of the message
@ -694,15 +683,7 @@ void MarlinUI::draw_status_message(const bool blink) {
} }
if (last_blink != blink) { if (last_blink != blink) {
last_blink = blink; last_blink = blink;
advance_status_scroll();
// Adjust by complete UTF8 characters
if (status_scroll_offset < slen) {
status_scroll_offset++;
while (!START_OF_UTF8_CHAR(status_message[status_scroll_offset]))
status_scroll_offset++;
}
else
status_scroll_offset = 0;
} }
} }
#else #else

41
Marlin/src/lcd/dogm/status_screen_DOGM.cpp

@ -612,31 +612,24 @@ void MarlinUI::draw_status_message(const bool blink) {
if (slen <= LCD_WIDTH) { if (slen <= LCD_WIDTH) {
// The string fits within the line. Print with no scrolling // The string fits within the line. Print with no scrolling
lcd_put_u8str(status_message); lcd_put_u8str(status_message);
for (; slen < LCD_WIDTH; ++slen) lcd_put_wchar(' '); while (slen < LCD_WIDTH) { lcd_put_wchar(' '); ++slen; }
} }
else { else {
// String is longer than the available space // String is longer than the available space
// Get a pointer to the next valid UTF8 character // Get a pointer to the next valid UTF8 character
const char *stat = status_message + status_scroll_offset; // and the string remaining length
uint8_t rlen;
// Get the string remaining length const char *stat = status_and_len(rlen);
const uint8_t rlen = utf8_strlen(stat); lcd_put_u8str_max(stat, LCD_PIXEL_WIDTH);
if (rlen >= LCD_WIDTH) { // If the remaining string doesn't completely fill the screen
// The remaining string fills the screen - Print it if (rlen < LCD_WIDTH) {
lcd_put_u8str_max(stat, LCD_PIXEL_WIDTH); lcd_put_wchar('.'); // Always at 1+ spaces left, draw a dot
} uint8_t chars = LCD_WIDTH - rlen; // Amount of space left in characters
else { if (--chars) { // Draw a second dot if there's space
// The remaining string does not completely fill the screen
lcd_put_u8str_max(stat, LCD_PIXEL_WIDTH); // The string leaves space
uint8_t chars = LCD_WIDTH - rlen; // Amount of space left in characters
lcd_put_wchar('.'); // Always at 1+ spaces left, draw a dot
if (--chars) { // Draw a second dot if there's space
lcd_put_wchar('.'); lcd_put_wchar('.');
if (--chars) { if (--chars) { // Print a second copy of the message
// Print a second copy of the message
lcd_put_u8str_max(status_message, LCD_PIXEL_WIDTH - (rlen + 2) * (MENU_FONT_WIDTH)); lcd_put_u8str_max(status_message, LCD_PIXEL_WIDTH - (rlen + 2) * (MENU_FONT_WIDTH));
lcd_put_wchar(' '); lcd_put_wchar(' ');
} }
@ -644,15 +637,7 @@ void MarlinUI::draw_status_message(const bool blink) {
} }
if (last_blink != blink) { if (last_blink != blink) {
last_blink = blink; last_blink = blink;
advance_status_scroll();
// Adjust by complete UTF8 characters
if (status_scroll_offset < slen) {
status_scroll_offset++;
while (!START_OF_UTF8_CHAR(status_message[status_scroll_offset]))
status_scroll_offset++;
}
else
status_scroll_offset = 0;
} }
} }

36
Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp

@ -627,43 +627,27 @@ void ST7920_Lite_Status_Screen::draw_status_message() {
if (slen <= LCD_WIDTH) { if (slen <= LCD_WIDTH) {
// String fits the LCD, so just print it // String fits the LCD, so just print it
write_str(str); write_str(str);
for (; slen < LCD_WIDTH; ++slen) write_byte(' '); while (slen < LCD_WIDTH) { write_byte(' '); ++slen; }
} }
else { else {
// String is larger than the available space in screen. // String is larger than the available space in screen.
// Get a pointer to the next valid UTF8 character // Get a pointer to the next valid UTF8 character
const char *stat = str + ui.status_scroll_offset; // and the string remaining length
uint8_t rlen;
// Get the string remaining length const char *stat = ui.status_and_len(rlen);
const uint8_t rlen = utf8_strlen(stat); write_str(stat, LCD_WIDTH);
// If we have enough characters to display
if (rlen >= LCD_WIDTH) {
// The remaining string fills the screen - Print it
write_str(stat, LCD_WIDTH);
}
else {
// The remaining string does not completely fill the screen
write_str(stat); // The string leaves space
uint8_t chars = LCD_WIDTH - rlen; // Amount of space left in characters
// If the remaining string doesn't completely fill the screen
if (rlen < LCD_WIDTH) {
write_byte('.'); // Always at 1+ spaces left, draw a dot write_byte('.'); // Always at 1+ spaces left, draw a dot
uint8_t chars = LCD_WIDTH - rlen; // Amount of space left in characters
if (--chars) { // Draw a second dot if there's space if (--chars) { // Draw a second dot if there's space
write_byte('.'); write_byte('.');
if (--chars) if (--chars) write_str(str, chars); // Print a second copy of the message
write_str(str, chars); // Print a second copy of the message
} }
} }
ui.advance_status_scroll();
// Adjust by complete UTF8 characters
if (ui.status_scroll_offset < slen) {
ui.status_scroll_offset++;
while (!START_OF_UTF8_CHAR(str[ui.status_scroll_offset]))
ui.status_scroll_offset++;
}
else
ui.status_scroll_offset = 0;
} }
#else #else

17
Marlin/src/lcd/ultralcd.cpp

@ -1162,6 +1162,21 @@ void MarlinUI::update() {
/////////////// Status Line //////////////// /////////////// Status Line ////////////////
//////////////////////////////////////////// ////////////////////////////////////////////
#if ENABLED(STATUS_MESSAGE_SCROLLING)
void MarlinUI::advance_status_scroll() {
// Advance by one UTF8 code-word
if (status_scroll_offset < utf8_strlen(status_message))
while (!START_OF_UTF8_CHAR(status_message[++status_scroll_offset]));
else
status_scroll_offset = 0;
}
char* MarlinUI::status_and_len(uint8_t &len) {
char *out = status_message + status_scroll_offset;
len = utf8_strlen(out);
return out;
}
#endif
void MarlinUI::finish_status(const bool persist) { void MarlinUI::finish_status(const bool persist) {
#if !(ENABLED(LCD_PROGRESS_BAR) && (PROGRESS_MSG_EXPIRE > 0)) #if !(ENABLED(LCD_PROGRESS_BAR) && (PROGRESS_MSG_EXPIRE > 0))
@ -1179,7 +1194,7 @@ void MarlinUI::update() {
next_filament_display = millis() + 5000UL; // Show status message for 5s next_filament_display = millis() + 5000UL; // Show status message for 5s
#endif #endif
#if ENABLED(STATUS_MESSAGE_SCROLLING) #if HAS_SPI_LCD && ENABLED(STATUS_MESSAGE_SCROLLING)
status_scroll_offset = 0; status_scroll_offset = 0;
#endif #endif

12
Marlin/src/lcd/ultralcd.h

@ -277,10 +277,15 @@ public:
static char status_message[]; static char status_message[];
static bool has_status(); static bool has_status();
static uint8_t status_message_level; // Higher levels block lower levels static uint8_t status_message_level; // Higher levels block lower levels
static inline void reset_alert_level() { status_message_level = 0; } static inline void reset_alert_level() { status_message_level = 0; }
#if ENABLED(STATUS_MESSAGE_SCROLLING)
static uint8_t status_scroll_offset;
static void advance_status_scroll();
static char* status_and_len(uint8_t &len);
#endif
#if HAS_PRINT_PROGRESS #if HAS_PRINT_PROGRESS
#if ENABLED(LCD_SET_PROGRESS_MANUALLY) #if ENABLED(LCD_SET_PROGRESS_MANUALLY)
static uint8_t progress_bar_percent; static uint8_t progress_bar_percent;
@ -327,9 +332,6 @@ public:
#endif #endif
#if ENABLED(STATUS_MESSAGE_SCROLLING)
static uint8_t status_scroll_offset;
#endif
static uint8_t lcd_status_update_delay; static uint8_t lcd_status_update_delay;
#if HAS_LCD_CONTRAST #if HAS_LCD_CONTRAST
@ -520,7 +522,7 @@ private:
static void _synchronize(); static void _synchronize();
#if HAS_SPI_LCD || ENABLED(EXTENSIBLE_UI) #if HAS_SPI_LCD || ENABLED(EXTENSIBLE_UI)
static void finishstatus(const bool persist); static void finish_status(const bool persist);
#endif #endif
#if HAS_SPI_LCD #if HAS_SPI_LCD

Loading…
Cancel
Save