Malyan LCD feedrate, better temp handling.
This commit is contained in:
parent
065e9c3d66
commit
b04e0c0cbb
1 changed files with 41 additions and 21 deletions
|
@ -77,6 +77,10 @@
|
||||||
// Track incoming command bytes from the LCD
|
// Track incoming command bytes from the LCD
|
||||||
int inbound_count;
|
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.
|
// 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) {
|
||||||
char encoded_message[MAX_CURLY_COMMAND];
|
char encoded_message[MAX_CURLY_COMMAND];
|
||||||
|
@ -106,22 +110,23 @@ void write_to_lcd(const char * const message) {
|
||||||
* {C:P050}
|
* {C:P050}
|
||||||
* Set temp for bed to 50
|
* Set temp for bed to 50
|
||||||
*
|
*
|
||||||
|
* {C:S09} set feedrate to 90 %.
|
||||||
|
* {C:S12} set feedrate to 120 %.
|
||||||
|
*
|
||||||
* the command portion begins after the :
|
* the command portion begins after the :
|
||||||
*/
|
*/
|
||||||
void process_lcd_c_command(const char* command) {
|
void process_lcd_c_command(const char* command) {
|
||||||
switch (command[0]) {
|
switch (command[0]) {
|
||||||
case 'T': {
|
case 'C': {
|
||||||
// M104 S<temperature>
|
int raw_feedrate = atoi(command + 1);
|
||||||
char cmd[20];
|
feedrate_percentage = raw_feedrate * 10;
|
||||||
sprintf_P(cmd, PSTR("M104 S%s"), command + 1);
|
feedrate_percentage = constrain(feedrate_percentage, 10, 999);
|
||||||
enqueue_and_echo_command_now(cmd);
|
} break;
|
||||||
|
case 'T': {
|
||||||
|
thermalManager.setTargetHotend(atoi(command + 1), 0);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case 'P': {
|
case 'P': {
|
||||||
// M140 S<temperature>
|
thermalManager.setTargetBed(atoi(command + 1));
|
||||||
char cmd[20];
|
|
||||||
sprintf_P(cmd, PSTR("M140 S%s"), command + 1);
|
|
||||||
enqueue_and_echo_command_now(cmd);
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -240,6 +245,7 @@ void process_lcd_p_command(const char* command) {
|
||||||
#if ENABLED(SDSUPPORT)
|
#if ENABLED(SDSUPPORT)
|
||||||
// cancel print
|
// cancel print
|
||||||
write_to_lcd_P(PSTR("{SYS:CANCELING}"));
|
write_to_lcd_P(PSTR("{SYS:CANCELING}"));
|
||||||
|
last_printing_status = false;
|
||||||
card.stopSDPrint(
|
card.stopSDPrint(
|
||||||
#if SD_RESORT
|
#if SD_RESORT
|
||||||
true
|
true
|
||||||
|
@ -280,7 +286,7 @@ void process_lcd_p_command(const char* command) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
char message_buffer[MAX_CURLY_COMMAND];
|
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(message_buffer);
|
||||||
write_to_lcd_P(PSTR("{SYS:BUILD}"));
|
write_to_lcd_P(PSTR("{SYS:BUILD}"));
|
||||||
card.openAndPrintFile(card.filename);
|
card.openAndPrintFile(card.filename);
|
||||||
|
@ -321,7 +327,7 @@ void process_lcd_s_command(const char* command) {
|
||||||
|
|
||||||
case 'H':
|
case 'H':
|
||||||
// Home all axis
|
// Home all axis
|
||||||
enqueue_and_echo_command("G28");
|
enqueue_and_echo_command("G28", false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'L': {
|
case 'L': {
|
||||||
|
@ -338,7 +344,7 @@ void process_lcd_s_command(const char* command) {
|
||||||
uint16_t file_count = card.get_num_Files();
|
uint16_t file_count = card.get_num_Files();
|
||||||
for (uint16_t i = 0; i < file_count; i++) {
|
for (uint16_t i = 0; i < file_count; i++) {
|
||||||
card.getfilename(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);
|
write_to_lcd(message_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,7 +401,7 @@ void process_lcd_command(const char* command) {
|
||||||
/**
|
/**
|
||||||
* UC means connected.
|
* UC means connected.
|
||||||
* UD means disconnected
|
* 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) {
|
void update_usb_status(const bool forceUpdate) {
|
||||||
static bool last_usb_connected_status = false;
|
static bool last_usb_connected_status = false;
|
||||||
|
@ -433,14 +439,28 @@ void lcd_update() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLED(SDSUPPORT)
|
#if ENABLED(SDSUPPORT)
|
||||||
// If there's a print in progress, we need to emit the status as
|
// The way last printing status works is simple:
|
||||||
// {TQ:<PERCENT>}
|
// 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) {
|
if (card.sdprinting) {
|
||||||
// We also need to send: T:-2538.0 E:0
|
if (card.percentDone() != last_percent_done) {
|
||||||
// I have no idea what this means.
|
|
||||||
char message_buffer[10];
|
char message_buffer[10];
|
||||||
sprintf_P(message_buffer, PSTR("{TQ:%03i}"), card.percentDone());
|
last_percent_done = card.percentDone();
|
||||||
|
sprintf_P(message_buffer, PSTR("{TQ:%03i}"), last_percent_done);
|
||||||
write_to_lcd(message_buffer);
|
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue