Browse Source

Malyan LCD feedrate, better temp handling.

pull/1/head
xC0000005 7 years ago
committed by Scott Lahteine
parent
commit
b04e0c0cbb
  1. 60
      Marlin/src/lcd/malyanlcd.cpp

60
Marlin/src/lcd/malyanlcd.cpp

@ -77,6 +77,10 @@
// Track incoming command bytes from the LCD
int inbound_count;
// For sending print completion messages
bool last_printing_status = false;
uint8_t last_percent_done = 100;
// Everything written needs the high bit set.
void write_to_lcd_P(const char * const message) {
char encoded_message[MAX_CURLY_COMMAND];
@ -106,22 +110,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 +245,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 +286,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 +327,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 +344,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 +401,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 +439,28 @@ void lcd_update() {
}
#if ENABLED(SDSUPPORT)
// If there's a print in progress, we need to emit the status as
// {TQ:<PERCENT>}
// 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.
if (card.sdprinting) {
// We also need to send: T:-2538.0 E:0
// I have no idea what this means.
char message_buffer[10];
sprintf_P(message_buffer, PSTR("{TQ:%03i}"), card.percentDone());
write_to_lcd(message_buffer);
if (card.percentDone() != last_percent_done) {
char message_buffer[10];
last_percent_done = card.percentDone();
sprintf_P(message_buffer, PSTR("{TQ:%03i}"), last_percent_done);
write_to_lcd(message_buffer);
if (!last_printing_status) last_printing_status = true;
}
}
else {
// 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.
if (last_printing_status) {
last_printing_status = false;
last_percent_done = 100;
write_to_lcd_P(PSTR("{TQ:100}"));
}
}
#endif
}

Loading…
Cancel
Save