|
|
|
@ -77,6 +77,9 @@
|
|
|
|
|
// Track incoming command bytes from the LCD
|
|
|
|
|
int inbound_count;
|
|
|
|
|
|
|
|
|
|
// For sending print completion messages
|
|
|
|
|
bool last_printing_status = false;
|
|
|
|
|
|
|
|
|
|
// Everything written needs the high bit set.
|
|
|
|
|
void write_to_lcd_P(const char * const message) {
|
|
|
|
|
char encoded_message[MAX_CURLY_COMMAND];
|
|
|
|
@ -106,22 +109,23 @@ void write_to_lcd(const char * const message) {
|
|
|
|
|
* {C:P050}
|
|
|
|
|
* Set temp for bed to 50
|
|
|
|
|
*
|
|
|
|
|
* {C:S09} set feedrate to 90 %.
|
|
|
|
|
* {C:S12} set feedrate to 120 %.
|
|
|
|
|
*
|
|
|
|
|
* the command portion begins after the :
|
|
|
|
|
*/
|
|
|
|
|
void process_lcd_c_command(const char* command) {
|
|
|
|
|
switch (command[0]) {
|
|
|
|
|
case 'C': {
|
|
|
|
|
int raw_feedrate = atoi(command + 1);
|
|
|
|
|
feedrate_percentage = raw_feedrate * 10;
|
|
|
|
|
feedrate_percentage = constrain(feedrate_percentage, 10, 999);
|
|
|
|
|
} break;
|
|
|
|
|
case 'T': {
|
|
|
|
|
// M104 S<temperature>
|
|
|
|
|
char cmd[20];
|
|
|
|
|
sprintf_P(cmd, PSTR("M104 S%s"), command + 1);
|
|
|
|
|
enqueue_and_echo_command_now(cmd);
|
|
|
|
|
thermalManager.setTargetHotend(atoi(command + 1), 0);
|
|
|
|
|
} break;
|
|
|
|
|
|
|
|
|
|
case 'P': {
|
|
|
|
|
// M140 S<temperature>
|
|
|
|
|
char cmd[20];
|
|
|
|
|
sprintf_P(cmd, PSTR("M140 S%s"), command + 1);
|
|
|
|
|
enqueue_and_echo_command_now(cmd);
|
|
|
|
|
thermalManager.setTargetBed(atoi(command + 1));
|
|
|
|
|
} break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
@ -240,6 +244,7 @@ void process_lcd_p_command(const char* command) {
|
|
|
|
|
#if ENABLED(SDSUPPORT)
|
|
|
|
|
// cancel print
|
|
|
|
|
write_to_lcd_P(PSTR("{SYS:CANCELING}"));
|
|
|
|
|
last_printing_status = false;
|
|
|
|
|
card.stopSDPrint(
|
|
|
|
|
#if SD_RESORT
|
|
|
|
|
true
|
|
|
|
@ -280,7 +285,7 @@ void process_lcd_p_command(const char* command) {
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
char message_buffer[MAX_CURLY_COMMAND];
|
|
|
|
|
sprintf_P(message_buffer, PSTR("{PRINTFILE:%s}"), card.filename);
|
|
|
|
|
sprintf_P(message_buffer, PSTR("{PRINTFILE:%s}"), card.longest_filename());
|
|
|
|
|
write_to_lcd(message_buffer);
|
|
|
|
|
write_to_lcd_P(PSTR("{SYS:BUILD}"));
|
|
|
|
|
card.openAndPrintFile(card.filename);
|
|
|
|
@ -321,7 +326,7 @@ void process_lcd_s_command(const char* command) {
|
|
|
|
|
|
|
|
|
|
case 'H':
|
|
|
|
|
// Home all axis
|
|
|
|
|
enqueue_and_echo_command("G28");
|
|
|
|
|
enqueue_and_echo_command("G28", false);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'L': {
|
|
|
|
@ -338,7 +343,7 @@ void process_lcd_s_command(const char* command) {
|
|
|
|
|
uint16_t file_count = card.get_num_Files();
|
|
|
|
|
for (uint16_t i = 0; i < file_count; i++) {
|
|
|
|
|
card.getfilename(i);
|
|
|
|
|
sprintf_P(message_buffer, card.filenameIsDir ? PSTR("{DIR:%s}") : PSTR("{FILE:%s}"), card.filename);
|
|
|
|
|
sprintf_P(message_buffer, card.filenameIsDir ? PSTR("{DIR:%s}") : PSTR("{FILE:%s}"), card.longest_filename());
|
|
|
|
|
write_to_lcd(message_buffer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -395,7 +400,7 @@ void process_lcd_command(const char* command) {
|
|
|
|
|
/**
|
|
|
|
|
* UC means connected.
|
|
|
|
|
* UD means disconnected
|
|
|
|
|
* The stock firmware considers USB initialied as "connected."
|
|
|
|
|
* The stock firmware considers USB initialized as "connected."
|
|
|
|
|
*/
|
|
|
|
|
void update_usb_status(const bool forceUpdate) {
|
|
|
|
|
static bool last_usb_connected_status = false;
|
|
|
|
@ -433,14 +438,21 @@ void lcd_update() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if ENABLED(SDSUPPORT)
|
|
|
|
|
// If there's a print in progress, we need to emit the status as
|
|
|
|
|
// {TQ:<PERCENT>}
|
|
|
|
|
if (card.sdprinting) {
|
|
|
|
|
// We also need to send: T:-2538.0 E:0
|
|
|
|
|
// I have no idea what this means.
|
|
|
|
|
// The way last printing status works is simple:
|
|
|
|
|
// The UI needs to see at least one TQ which is not 100%
|
|
|
|
|
// and then when the print is complete, one which is.
|
|
|
|
|
static uint8_t last_percent_done = 100;
|
|
|
|
|
|
|
|
|
|
// If there was a print in progress, we need to emit the final
|
|
|
|
|
// print status as {TQ:100}. Reset last percent done so a new print will
|
|
|
|
|
// issue a percent of 0.
|
|
|
|
|
const uint8_t percent_done = card.sdprinting ? card.percentDone() : last_printing_status ? 100 : 0;
|
|
|
|
|
if (percent_done != last_percent_done) {
|
|
|
|
|
char message_buffer[10];
|
|
|
|
|
sprintf_P(message_buffer, PSTR("{TQ:%03i}"), card.percentDone());
|
|
|
|
|
sprintf_P(message_buffer, PSTR("{TQ:%03i}"), percent_done);
|
|
|
|
|
write_to_lcd(message_buffer);
|
|
|
|
|
last_percent_done = percent_done;
|
|
|
|
|
last_printing_status = card.sdprinting;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|