🎨 Apply F() to kill / sendinfoscreen
This commit is contained in:
@ -74,35 +74,36 @@ uint16_t inbound_count;
|
||||
bool last_printing_status = false;
|
||||
|
||||
// Everything written needs the high bit set.
|
||||
void write_to_lcd_P(PGM_P const message) {
|
||||
void write_to_lcd(FSTR_P const fmsg) {
|
||||
PGM_P pmsg = FTOP(fmsg);
|
||||
char encoded_message[MAX_CURLY_COMMAND];
|
||||
uint8_t message_length = _MIN(strlen_P(message), sizeof(encoded_message));
|
||||
uint8_t message_length = _MIN(strlen_P(pmsg), sizeof(encoded_message));
|
||||
|
||||
LOOP_L_N(i, message_length)
|
||||
encoded_message[i] = pgm_read_byte(&message[i]) | 0x80;
|
||||
encoded_message[i] = pgm_read_byte(&pmsg[i]) | 0x80;
|
||||
|
||||
LCD_SERIAL.Print::write(encoded_message, message_length);
|
||||
}
|
||||
|
||||
void write_to_lcd(const char * const message) {
|
||||
void write_to_lcd(const char * const cmsg) {
|
||||
char encoded_message[MAX_CURLY_COMMAND];
|
||||
const uint8_t message_length = _MIN(strlen(message), sizeof(encoded_message));
|
||||
const uint8_t message_length = _MIN(strlen(cmsg), sizeof(encoded_message));
|
||||
|
||||
LOOP_L_N(i, message_length)
|
||||
encoded_message[i] = message[i] | 0x80;
|
||||
encoded_message[i] = cmsg[i] | 0x80;
|
||||
|
||||
LCD_SERIAL.Print::write(encoded_message, message_length);
|
||||
}
|
||||
|
||||
// {E:<msg>} is for error states.
|
||||
void set_lcd_error_P(PGM_P const error, PGM_P const component/*=nullptr*/) {
|
||||
write_to_lcd_P(PSTR("{E:"));
|
||||
write_to_lcd_P(error);
|
||||
void set_lcd_error(FSTR_P const error, FSTR_P const component/*=nullptr*/) {
|
||||
write_to_lcd(F("{E:"));
|
||||
write_to_lcd(error);
|
||||
if (component) {
|
||||
write_to_lcd_P(PSTR(" "));
|
||||
write_to_lcd_P(component);
|
||||
write_to_lcd(F(" "));
|
||||
write_to_lcd(component);
|
||||
}
|
||||
write_to_lcd_P(PSTR("}"));
|
||||
write_to_lcd(F("}"));
|
||||
}
|
||||
|
||||
|
||||
@ -243,16 +244,16 @@ void process_lcd_p_command(const char *command) {
|
||||
switch (command[0]) {
|
||||
case 'P':
|
||||
ExtUI::pausePrint();
|
||||
write_to_lcd_P(PSTR("{SYS:PAUSED}"));
|
||||
write_to_lcd(F("{SYS:PAUSED}"));
|
||||
break;
|
||||
case 'R':
|
||||
ExtUI::resumePrint();
|
||||
write_to_lcd_P(PSTR("{SYS:RESUMED}"));
|
||||
write_to_lcd(F("{SYS:RESUMED}"));
|
||||
break;
|
||||
case 'X':
|
||||
write_to_lcd_P(PSTR("{SYS:CANCELING}"));
|
||||
write_to_lcd(F("{SYS:CANCELING}"));
|
||||
ExtUI::stopPrint();
|
||||
write_to_lcd_P(PSTR("{SYS:STARTED}"));
|
||||
write_to_lcd(F("{SYS:STARTED}"));
|
||||
break;
|
||||
case 'H': queue.enqueue_now_P(G28_STR); break; // Home all axes
|
||||
default: {
|
||||
@ -271,13 +272,13 @@ void process_lcd_p_command(const char *command) {
|
||||
// but the V2 LCD switches to "print" mode on {SYS:DIR} response.
|
||||
if (card.flag.filenameIsDir) {
|
||||
card.cd(card.filename);
|
||||
write_to_lcd_P(PSTR("{SYS:DIR}"));
|
||||
write_to_lcd(F("{SYS:DIR}"));
|
||||
}
|
||||
else {
|
||||
char message_buffer[MAX_CURLY_COMMAND];
|
||||
sprintf_P(message_buffer, PSTR("{PRINTFILE:%s}"), card.longest_filename());
|
||||
write_to_lcd(message_buffer);
|
||||
write_to_lcd_P(PSTR("{SYS:BUILD}"));
|
||||
write_to_lcd(F("{SYS:BUILD}"));
|
||||
card.openAndPrintFile(card.filename);
|
||||
}
|
||||
#endif
|
||||
@ -332,7 +333,7 @@ void process_lcd_s_command(const char *command) {
|
||||
write_to_lcd(message_buffer);
|
||||
}
|
||||
|
||||
write_to_lcd_P(PSTR("{SYS:OK}"));
|
||||
write_to_lcd(F("{SYS:OK}"));
|
||||
#endif
|
||||
} break;
|
||||
|
||||
@ -413,7 +414,7 @@ void update_usb_status(const bool forceUpdate) {
|
||||
// This is more logical.
|
||||
if (last_usb_connected_status != MYSERIAL1.connected() || forceUpdate) {
|
||||
last_usb_connected_status = MYSERIAL1.connected();
|
||||
write_to_lcd_P(last_usb_connected_status ? PSTR("{R:UC}\r\n") : PSTR("{R:UD}\r\n"));
|
||||
write_to_lcd(last_usb_connected_status ? F("{R:UC}\r\n") : F("{R:UD}\r\n"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,10 +33,10 @@ extern uint16_t inbound_count;
|
||||
// For sending print completion messages
|
||||
extern bool last_printing_status;
|
||||
|
||||
void write_to_lcd_P(PGM_P const message);
|
||||
void write_to_lcd(const char * const message);
|
||||
void write_to_lcd(FSTR_P const fmsg);
|
||||
void write_to_lcd(const char * const cmsg);
|
||||
|
||||
void set_lcd_error_P(PGM_P const error, PGM_P const component=nullptr);
|
||||
void set_lcd_error(FSTR_P const error, FSTR_P const component=nullptr);
|
||||
|
||||
void process_lcd_c_command(const char *command);
|
||||
void process_lcd_eb_command(const char *command);
|
||||
|
@ -55,13 +55,13 @@ namespace ExtUI {
|
||||
LCD_SERIAL.begin(LCD_BAUDRATE);
|
||||
|
||||
// Signal init
|
||||
write_to_lcd_P(PSTR("{SYS:STARTED}\r\n"));
|
||||
write_to_lcd(F("{SYS:STARTED}\r\n"));
|
||||
|
||||
// send a version that says "unsupported"
|
||||
write_to_lcd_P(PSTR("{VER:99}\r\n"));
|
||||
write_to_lcd(F("{VER:99}\r\n"));
|
||||
|
||||
// No idea why it does this twice.
|
||||
write_to_lcd_P(PSTR("{SYS:STARTED}\r\n"));
|
||||
write_to_lcd(F("{SYS:STARTED}\r\n"));
|
||||
update_usb_status(true);
|
||||
}
|
||||
|
||||
@ -98,8 +98,8 @@ namespace ExtUI {
|
||||
#endif
|
||||
}
|
||||
|
||||
void onPrinterKilled(PGM_P const error, PGM_P const component) {
|
||||
set_lcd_error_P(error, component);
|
||||
void onPrinterKilled(FSTR_P const error, FSTR_P const component) {
|
||||
set_lcd_error(error, component);
|
||||
}
|
||||
|
||||
#if HAS_PID_HEATING
|
||||
@ -109,28 +109,28 @@ namespace ExtUI {
|
||||
//SERIAL_ECHOLNPGM("OnPidTuning:", rst);
|
||||
switch (rst) {
|
||||
case PID_STARTED:
|
||||
set_lcd_error_P(GET_TEXT(MSG_PID_AUTOTUNE));
|
||||
set_lcd_error(GET_TEXT_F(MSG_PID_AUTOTUNE));
|
||||
break;
|
||||
case PID_BAD_EXTRUDER_NUM:
|
||||
set_lcd_error_P(GET_TEXT(MSG_PID_BAD_EXTRUDER_NUM));
|
||||
set_lcd_error(GET_TEXT_F(MSG_PID_BAD_EXTRUDER_NUM));
|
||||
break;
|
||||
case PID_TEMP_TOO_HIGH:
|
||||
set_lcd_error_P(GET_TEXT(MSG_PID_TEMP_TOO_HIGH));
|
||||
set_lcd_error(GET_TEXT_F(MSG_PID_TEMP_TOO_HIGH));
|
||||
break;
|
||||
case PID_TUNING_TIMEOUT:
|
||||
set_lcd_error_P(GET_TEXT(MSG_PID_TIMEOUT));
|
||||
set_lcd_error(GET_TEXT_F(MSG_PID_TIMEOUT));
|
||||
break;
|
||||
case PID_DONE:
|
||||
set_lcd_error_P(GET_TEXT(MSG_PID_AUTOTUNE_DONE));
|
||||
set_lcd_error(GET_TEXT_F(MSG_PID_AUTOTUNE_DONE));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void onPrintTimerStarted() { write_to_lcd_P(PSTR("{SYS:BUILD}")); }
|
||||
void onPrintTimerStarted() { write_to_lcd(F("{SYS:BUILD}")); }
|
||||
void onPrintTimerPaused() {}
|
||||
void onPrintTimerStopped() { write_to_lcd_P(PSTR("{TQ:100}")); }
|
||||
void onPrintTimerStopped() { write_to_lcd(F("{TQ:100}")); }
|
||||
|
||||
// Not needed for Malyan LCD
|
||||
void onStatusChanged(const char * const) {}
|
||||
|
Reference in New Issue
Block a user