Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 10 additions & 18 deletions Marlin/src/HAL/HAL_AVR/HAL_spi_AVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,22 +162,15 @@ void spiBegin (void) {
// away. When clock is not known, use a loop instead, which generates
// shorter code.
if (__builtin_constant_p(spiClock)) {
if (spiClock >= F_CPU / 2) {
clockDiv = 0;
} else if (spiClock >= F_CPU / 4) {
clockDiv = 1;
} else if (spiClock >= F_CPU / 8) {
clockDiv = 2;
} else if (spiClock >= F_CPU / 16) {
clockDiv = 3;
} else if (spiClock >= F_CPU / 32) {
clockDiv = 4;
} else if (spiClock >= F_CPU / 64) {
clockDiv = 5;
} else {
clockDiv = 6;
}
} else {
if (spiClock >= F_CPU / 2) clockDiv = 0;
else if (spiClock >= F_CPU / 4) clockDiv = 1;
else if (spiClock >= F_CPU / 8) clockDiv = 2;
else if (spiClock >= F_CPU / 16) clockDiv = 3;
else if (spiClock >= F_CPU / 32) clockDiv = 4;
else if (spiClock >= F_CPU / 64) clockDiv = 5;
else clockDiv = 6;
}
else {
uint32_t clockSetting = F_CPU / 2;
clockDiv = 0;
while (clockDiv < 6 && spiClock < clockSetting) {
Expand All @@ -187,8 +180,7 @@ void spiBegin (void) {
}

// Compensate for the duplicate fosc/64
if (clockDiv == 6)
clockDiv = 7;
if (clockDiv == 6) clockDiv = 7;

// Invert the SPI2X bit
clockDiv ^= 0x1;
Expand Down
1 change: 0 additions & 1 deletion Marlin/src/feature/bedlevel/ubl/ubl.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ extern uint8_t ubl_cnt;
///////////////////////////////////////////////////////////////////////////////////////////////////////

#if ENABLED(ULTRA_LCD)
extern char lcd_status_message[];
void lcd_quick_feedback(const bool clear_buttons);
#endif

Expand Down
6 changes: 0 additions & 6 deletions Marlin/src/gcode/bedlevel/G26.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,6 @@

// External references

#if ENABLED(ULTRA_LCD)
extern char lcd_status_message[];
#endif

// Private functions

static uint16_t circle_flags[16], horizontal_mesh_line_flags[16], vertical_mesh_line_flags[16];
Expand Down Expand Up @@ -508,8 +504,6 @@ inline bool prime_nozzle() {

wait_for_release();

strcpy_P(lcd_status_message, PSTR("Done Priming")); // Hack to get the message up. May be obsolete.

lcd_setstatusPGM(PSTR("Done Priming"), 99);
lcd_quick_feedback(true);
lcd_external_control = false;
Expand Down
7 changes: 2 additions & 5 deletions Marlin/src/gcode/calibrate/G33.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,15 +519,12 @@ void GcodeSuite::G33() {
}

// Report settings

const char *checkingac = PSTR("Checking... AC");
const char* checkingac = PSTR("Checking... AC");
serialprintPGM(checkingac);
if (verbose_level == 0) SERIAL_PROTOCOLPGM(" (DRY-RUN)");
if (set_up) SERIAL_PROTOCOLPGM(" (SET-UP)");
SERIAL_EOL();
char mess[11];
strcpy_P(mess, checkingac);
lcd_setstatus(mess);
lcd_setstatusPGM(checkingac);

print_calibration_settings(_endstop_results, _angle_results);

Expand Down
91 changes: 66 additions & 25 deletions Marlin/src/lcd/dogm/status_screen_DOGM.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ FORCE_INLINE void _draw_centered_temp(const int16_t temp, const uint8_t x, const
const char * const str = itostr3(temp);
lcd_moveto(x - (str[0] != ' ' ? 0 : str[1] != ' ' ? 1 : 2) * DOG_CHAR_WIDTH / 2, y);
lcd_put_u8str(str);
lcd_put_u8str_rom(PSTR(LCD_STR_DEGREE " "));
lcd_put_u8str_P(PSTR(LCD_STR_DEGREE " "));
}

#ifndef HEAT_INDICATOR_X
Expand Down Expand Up @@ -113,7 +113,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
else {
#if DISABLED(HOME_AFTER_DEACTIVATE) && DISABLED(DISABLE_REDUCED_ACCURACY_WARNING)
if (!axis_known_position[axis])
lcd_put_u8str_rom(axis == Z_AXIS ? PSTR(" ") : PSTR(" "));
lcd_put_u8str_P(axis == Z_AXIS ? PSTR(" ") : PSTR(" "));
else
#endif
lcd_put_u8str(value);
Expand All @@ -124,36 +124,77 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
inline void lcd_implementation_status_message(const bool blink) {
#if ENABLED(STATUS_MESSAGE_SCROLLING)
static bool last_blink = false;
const uint8_t slen = utf8_strlen(lcd_status_message);
const char *stat = lcd_status_message + status_scroll_pos;
if (slen <= LCD_WIDTH)
lcd_put_u8str(stat); // The string isn't scrolling

// Get the UTF8 character count of the string
uint8_t slen = utf8_strlen(lcd_status_message);

// If the string fits into the LCD, just print it and do not scroll it
if (slen <= LCD_WIDTH) {

// The string isn't scrolling and may not fill the screen
lcd_put_u8str(lcd_status_message);

// Fill the rest with spaces
while (slen < LCD_WIDTH) {
lcd_put_wchar(' ');
++slen;
}
}
else {
if (status_scroll_pos <= slen - LCD_WIDTH)
lcd_put_u8str(stat); // The string fills the screen
// String is larger than the available space in screen.

// Get a pointer to the next valid UTF8 character
const char *stat = lcd_status_message + status_scroll_offset;

// Get the string remaining length
const uint8_t rlen = utf8_strlen(stat);

// If we have enough characters to display
if (rlen >= LCD_WIDTH) {
// The remaining string fills the screen - Print it
lcd_put_u8str_max(stat, LCD_PIXEL_WIDTH);
}
else {
uint8_t chars = LCD_WIDTH;
if (status_scroll_pos < slen) { // First string still visible
lcd_put_u8str(stat); // The string leaves space
chars -= slen - status_scroll_pos; // Amount of space left
}
lcd_put_wchar('.'); // Always at 1+ spaces left, draw a dot
if (--chars) {
if (status_scroll_pos < slen + 1) // Draw a second dot if there's space
--chars, lcd_put_wchar('.');
if (chars) lcd_put_u8str_max(lcd_status_message, chars); // Print a second copy of the message
// 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('.');
if (--chars) {
// Print a second copy of the message
lcd_put_u8str_max(lcd_status_message, LCD_PIXEL_WIDTH - ((rlen+2) * DOG_CHAR_WIDTH));
}
}
}
if (last_blink != blink) {
last_blink = blink;
// Skip any non-printing bytes
if (status_scroll_pos < slen) while (!PRINTABLE(lcd_status_message[status_scroll_pos])) status_scroll_pos++;
if (++status_scroll_pos >= slen + 2) status_scroll_pos = 0;

// Adjust by complete UTF8 characters
if (status_scroll_offset < slen) {
status_scroll_offset++;
while (!START_OF_UTF8_CHAR(lcd_status_message[status_scroll_offset]))
status_scroll_offset++;
}
else
status_scroll_offset = 0;
}
}
#else
UNUSED(blink);
lcd_put_u8str(lcd_status_message);

// Get the UTF8 character count of the string
uint8_t slen = utf8_strlen(lcd_status_message);

// Just print the string to the LCD
lcd_put_u8str_max(lcd_status_message, LCD_PIXEL_WIDTH);

// Fill the rest with spaces if there are missing spaces
while (slen < LCD_WIDTH) {
lcd_put_wchar(' ');
++slen;
}
#endif
}

Expand Down Expand Up @@ -417,7 +458,7 @@ static void lcd_implementation_status_screen() {
lcd_put_wchar('%');
lcd_setFont(FONT_MENU);
lcd_moveto(47, 50);
lcd_put_wchar(LCD_STR_FILAM_DIA[0]); // lcd_put_u8str_rom(PSTR(LCD_STR_FILAM_DIA));
lcd_put_wchar(LCD_STR_FILAM_DIA[0]); // lcd_put_u8str_P(PSTR(LCD_STR_FILAM_DIA));
lcd_moveto(93, 50);
lcd_put_wchar(LCD_STR_FILAM_MUL[0]);
#endif
Expand All @@ -437,10 +478,10 @@ static void lcd_implementation_status_screen() {
lcd_implementation_status_message(blink);
}
else {
lcd_put_u8str_rom(PSTR(LCD_STR_FILAM_DIA));
lcd_put_u8str_P(PSTR(LCD_STR_FILAM_DIA));
lcd_put_wchar(':');
lcd_put_u8str(wstring);
lcd_put_u8str_rom(PSTR(" " LCD_STR_FILAM_MUL));
lcd_put_u8str_P(PSTR(" " LCD_STR_FILAM_MUL));
lcd_put_wchar(':');
lcd_put_u8str(mstring);
lcd_put_wchar('%');
Expand Down
75 changes: 55 additions & 20 deletions Marlin/src/lcd/dogm/status_screen_lite_ST7920.h
Original file line number Diff line number Diff line change
Expand Up @@ -615,36 +615,71 @@ void ST7920_Lite_Status_Screen::draw_feedrate_percentage(const uint8_t percentag
void ST7920_Lite_Status_Screen::draw_status_message(const char *str) {
set_ddram_address(DDRAM_LINE_4);
begin_data();
const uint8_t lcd_len = 16;
#if ENABLED(STATUS_MESSAGE_SCROLLING)
const uint8_t lcd_len = 16;
const uint8_t padding = 2;
uint8_t str_len = strlen(str);

// Trim whitespace at the end of the str, as for some reason
// messages like "Card Inserted" are padded with many spaces
while (str_len && str[str_len - 1] == ' ') str_len--;
uint8_t slen = utf8_strlen(str);

if (str_len <= lcd_len) {
// It all fits on the LCD without scrolling
// If the string fits into the LCD, just print it and do not scroll it
if (slen <= lcd_len) {

// The string isn't scrolling and may not fill the screen
write_str(str);

// Fill the rest with spaces
while (slen < lcd_len) {
write_byte(' ');
++slen;
}
}
else {
// Print the message repeatedly until covering the LCD
uint8_t c = status_scroll_pos;
for (uint8_t n = 0; n < lcd_len; n++) {
write_byte(c < str_len ? str[c] : ' ');
c++;
c %= str_len + padding; // Wrap around
// String is larger than the available space in screen.

// Get a pointer to the next valid UTF8 character
const char *stat = str + status_scroll_offset;

// Get the string remaining length
const uint8_t rlen = utf8_strlen(stat);

// If we have enough characters to display
if (rlen >= lcd_len) {
// The remaining string fills the screen - Print it
write_str(stat, lcd_len);
}
else {
// The remaining string does not completely fill the screen
write_str(stat); // The string leaves space
uint8_t chars = lcd_len - rlen; // Amount of space left in characters

write_byte('.'); // Always at 1+ spaces left, draw a dot
if (--chars) { // Draw a second dot if there's space
write_byte('.');
if (--chars)
write_str(str, chars); // Print a second copy of the message
}
}

// Scroll the message
if (status_scroll_pos == str_len + padding)
status_scroll_pos = 0;
// Adjust by complete UTF8 characters
if (status_scroll_offset < slen) {
status_scroll_offset++;
while (!START_OF_UTF8_CHAR(str[status_scroll_offset]))
status_scroll_offset++;
}
else
status_scroll_pos++;
status_scroll_offset = 0;
}
#else
write_str(str, 16);
// Get the UTF8 character count of the string
uint8_t slen = utf8_strlen(str);

// Just print the string to the LCD
write_str(str, lcd_len);

// Fill the rest with spaces if there are missing spaces
while (slen < lcd_len) {
write_byte(' ');
++slen;
}
#endif
}

Expand Down Expand Up @@ -792,7 +827,7 @@ void ST7920_Lite_Status_Screen::update_status_or_position(bool forceUpdate) {
*/
if (forceUpdate || status_changed()) {
#if ENABLED(STATUS_MESSAGE_SCROLLING)
status_scroll_pos = 0;
status_scroll_offset = 0;
#endif
#if STATUS_EXPIRE_SECONDS
countdown = lcd_status_message[0] ? STATUS_EXPIRE_SECONDS : 0;
Expand Down
Loading