Browse Source

Reduce TQ message code size

pull/1/head
Scott Lahteine 6 years ago
parent
commit
8c40f0c6c7
  1. 32
      Marlin/src/lcd/malyanlcd.cpp

32
Marlin/src/lcd/malyanlcd.cpp

@ -79,7 +79,6 @@ int inbound_count;
// For sending print completion messages // For sending print completion messages
bool last_printing_status = false; bool last_printing_status = false;
uint8_t last_percent_done = 100;
// Everything written needs the high bit set. // Everything written needs the high bit set.
void write_to_lcd_P(const char * const message) { void write_to_lcd_P(const char * const message) {
@ -442,25 +441,18 @@ void lcd_update() {
// The way last printing status works is simple: // The way last printing status works is simple:
// The UI needs to see at least one TQ which is not 100% // The UI needs to see at least one TQ which is not 100%
// and then when the print is complete, one which is. // and then when the print is complete, one which is.
if (card.sdprinting) { static uint8_t last_percent_done = 100;
if (card.percentDone() != last_percent_done) {
char message_buffer[10]; // If there was a print in progress, we need to emit the final
last_percent_done = card.percentDone(); // print status as {TQ:100}. Reset last percent done so a new print will
sprintf_P(message_buffer, PSTR("{TQ:%03i}"), last_percent_done); // issue a percent of 0.
write_to_lcd(message_buffer); const uint8_t percent_done = card.sdprinting ? card.percentDone() : last_printing_status ? 100 : 0;
if (percent_done != last_percent_done) {
if (!last_printing_status) last_printing_status = true; char message_buffer[10];
} sprintf_P(message_buffer, PSTR("{TQ:%03i}"), percent_done);
} write_to_lcd(message_buffer);
else { last_percent_done = percent_done;
// If there was a print in progress, we need to emit the final last_printing_status = card.sdprinting;
// print status as {TQ:100}. Reset last percent done so a new print will
// issue a percent of 0.
if (last_printing_status) {
last_printing_status = false;
last_percent_done = 100;
write_to_lcd_P(PSTR("{TQ:100}"));
}
} }
#endif #endif
} }

Loading…
Cancel
Save