Improve Malyan progress / feedrate

Co-Authored-By: J.C. Nelson <xc0000005@users.noreply.github.com>
This commit is contained in:
Scott Lahteine 2018-07-17 17:39:15 -05:00
parent 7e648f3721
commit 6024ffedd9

View File

@ -83,6 +83,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];
@ -112,22 +115,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 'T': {
// M104 S<temperature>
char cmd[20];
sprintf_P(cmd, PSTR("M104 S%s"), command + 1);
enqueue_and_echo_command_now(cmd);
case 'C': {
int raw_feedrate = atoi(command + 1);
feedrate_percentage = raw_feedrate * 10;
feedrate_percentage = constrain(feedrate_percentage, 10, 999);
} break;
case 'T': {
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:
@ -246,6 +250,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
@ -439,14 +444,21 @@ void _O2 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
}