Support Malyan LCD without SD
This commit is contained in:
parent
f28e366b77
commit
336a022529
@ -45,8 +45,6 @@
|
||||
|
||||
#if ENABLED(MALYAN_LCD)
|
||||
|
||||
#include "../sd/cardreader.h"
|
||||
#include "../sd/SdFatConfig.h"
|
||||
#include "../module/temperature.h"
|
||||
#include "../module/planner.h"
|
||||
#include "../module/stepper.h"
|
||||
@ -60,6 +58,13 @@
|
||||
|
||||
#include "../Marlin.h"
|
||||
|
||||
#if ENABLED(SDSUPPORT)
|
||||
#include "../sd/cardreader.h"
|
||||
#include "../sd/SdFatConfig.h"
|
||||
#else
|
||||
#define LONG_FILENAME_LENGTH 0
|
||||
#endif
|
||||
|
||||
// On the Malyan M200, this will be Serial1. On a RAMPS board,
|
||||
// it might not be.
|
||||
#define LCD_SERIAL Serial1
|
||||
@ -135,8 +140,6 @@ void process_lcd_c_command(const char* command) {
|
||||
void process_lcd_eb_command(const char* command) {
|
||||
char elapsed_buffer[10];
|
||||
duration_t elapsed;
|
||||
bool has_days;
|
||||
uint8_t len;
|
||||
switch (command[0]) {
|
||||
case '0': {
|
||||
elapsed = print_job_timer.duration();
|
||||
@ -147,9 +150,17 @@ void process_lcd_eb_command(const char* command) {
|
||||
PSTR("{T0:%03.0f/%03i}{T1:000/000}{TP:%03.0f/%03i}{TQ:%03i}{TT:%s}"),
|
||||
thermalManager.degHotend(0),
|
||||
thermalManager.degTargetHotend(0),
|
||||
thermalManager.degBed(),
|
||||
thermalManager.degTargetBed(),
|
||||
card.percentDone(),
|
||||
#if HAS_HEATED_BED
|
||||
thermalManager.degBed(),
|
||||
thermalManager.degTargetBed(),
|
||||
#else
|
||||
0, 0,
|
||||
#endif
|
||||
#if ENABLED(SDSUPPORT)
|
||||
card.percentDone(),
|
||||
#else
|
||||
0,
|
||||
#endif
|
||||
elapsed_buffer);
|
||||
write_to_lcd(message_buffer);
|
||||
} break;
|
||||
@ -226,51 +237,55 @@ void process_lcd_p_command(const char* command) {
|
||||
|
||||
switch (command[0]) {
|
||||
case 'X':
|
||||
// cancel print
|
||||
write_to_lcd_P(PSTR("{SYS:CANCELING}"));
|
||||
card.stopSDPrint(
|
||||
#if SD_RESORT
|
||||
true
|
||||
#if ENABLED(SDSUPPORT)
|
||||
// cancel print
|
||||
write_to_lcd_P(PSTR("{SYS:CANCELING}"));
|
||||
card.stopSDPrint(
|
||||
#if SD_RESORT
|
||||
true
|
||||
#endif
|
||||
);
|
||||
clear_command_queue();
|
||||
quickstop_stepper();
|
||||
print_job_timer.stop();
|
||||
thermalManager.disable_all_heaters();
|
||||
#if FAN_COUNT > 0
|
||||
for (uint8_t i = 0; i < FAN_COUNT; i++) fanSpeeds[i] = 0;
|
||||
#endif
|
||||
);
|
||||
clear_command_queue();
|
||||
quickstop_stepper();
|
||||
print_job_timer.stop();
|
||||
thermalManager.disable_all_heaters();
|
||||
#if FAN_COUNT > 0
|
||||
for (uint8_t i = 0; i < FAN_COUNT; i++) fanSpeeds[i] = 0;
|
||||
wait_for_heatup = false;
|
||||
write_to_lcd_P(PSTR("{SYS:STARTED}"));
|
||||
#endif
|
||||
wait_for_heatup = false;
|
||||
write_to_lcd_P(PSTR("{SYS:STARTED}"));
|
||||
break;
|
||||
case 'H':
|
||||
// Home all axis
|
||||
enqueue_and_echo_commands_now_P(PSTR("G28"));
|
||||
break;
|
||||
default: {
|
||||
// Print file 000 - a three digit number indicating which
|
||||
// file to print in the SD card. If it's a directory,
|
||||
// then switch to the directory.
|
||||
#if ENABLED(SDSUPPORT)
|
||||
// Print file 000 - a three digit number indicating which
|
||||
// file to print in the SD card. If it's a directory,
|
||||
// then switch to the directory.
|
||||
|
||||
// Find the name of the file to print.
|
||||
// It's needed to echo the PRINTFILE option.
|
||||
// The {S:L} command should've ensured the SD card was mounted.
|
||||
card.getfilename(atoi(command));
|
||||
// Find the name of the file to print.
|
||||
// It's needed to echo the PRINTFILE option.
|
||||
// The {S:L} command should've ensured the SD card was mounted.
|
||||
card.getfilename(atoi(command));
|
||||
|
||||
// There may be a difference in how V1 and V2 LCDs handle subdirectory
|
||||
// prints. Investigate more. This matches the V1 motion controller actions
|
||||
// but the V2 LCD switches to "print" mode on {SYS:DIR} response.
|
||||
if (card.filenameIsDir) {
|
||||
card.chdir(card.filename);
|
||||
write_to_lcd_P(PSTR("{SYS:DIR}"));
|
||||
}
|
||||
else {
|
||||
char message_buffer[MAX_CURLY_COMMAND];
|
||||
sprintf_P(message_buffer, PSTR("{PRINTFILE:%s}"), card.filename);
|
||||
write_to_lcd(message_buffer);
|
||||
write_to_lcd_P(PSTR("{SYS:BUILD}"));
|
||||
card.openAndPrintFile(card.filename);
|
||||
}
|
||||
// There may be a difference in how V1 and V2 LCDs handle subdirectory
|
||||
// prints. Investigate more. This matches the V1 motion controller actions
|
||||
// but the V2 LCD switches to "print" mode on {SYS:DIR} response.
|
||||
if (card.filenameIsDir) {
|
||||
card.chdir(card.filename);
|
||||
write_to_lcd_P(PSTR("{SYS:DIR}"));
|
||||
}
|
||||
else {
|
||||
char message_buffer[MAX_CURLY_COMMAND];
|
||||
sprintf_P(message_buffer, PSTR("{PRINTFILE:%s}"), card.filename);
|
||||
write_to_lcd(message_buffer);
|
||||
write_to_lcd_P(PSTR("{SYS:BUILD}"));
|
||||
card.openAndPrintFile(card.filename);
|
||||
}
|
||||
#endif
|
||||
} break; // default
|
||||
} // switch
|
||||
}
|
||||
@ -295,34 +310,40 @@ void process_lcd_s_command(const char* command) {
|
||||
char message_buffer[MAX_CURLY_COMMAND];
|
||||
sprintf_P(message_buffer, PSTR("{T0:%03.0f/%03i}{T1:000/000}{TP:%03.0f/%03i}"),
|
||||
thermalManager.degHotend(0), thermalManager.degTargetHotend(0),
|
||||
thermalManager.degBed(), thermalManager.degTargetBed()
|
||||
#if HAS_HEATED_BED
|
||||
thermalManager.degBed(), thermalManager.degTargetBed()
|
||||
#else
|
||||
0, 0
|
||||
#endif
|
||||
);
|
||||
write_to_lcd(message_buffer);
|
||||
} break;
|
||||
|
||||
case 'H':
|
||||
// Home all axis
|
||||
enqueue_and_echo_commands_P(PSTR("G28"));
|
||||
enqueue_and_echo_command("G28");
|
||||
break;
|
||||
|
||||
case 'L': {
|
||||
if (!card.cardOK) card.initsd();
|
||||
#if ENABLED(SDSUPPORT)
|
||||
if (!card.cardOK) card.initsd();
|
||||
|
||||
// A more efficient way to do this would be to
|
||||
// implement a callback in the ls_SerialPrint code, but
|
||||
// that requires changes to the core cardreader class that
|
||||
// would not benefit the majority of users. Since one can't
|
||||
// select a file for printing during a print, there's
|
||||
// little reason not to do it this way.
|
||||
char message_buffer[MAX_CURLY_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);
|
||||
write_to_lcd(message_buffer);
|
||||
}
|
||||
// A more efficient way to do this would be to
|
||||
// implement a callback in the ls_SerialPrint code, but
|
||||
// that requires changes to the core cardreader class that
|
||||
// would not benefit the majority of users. Since one can't
|
||||
// select a file for printing during a print, there's
|
||||
// little reason not to do it this way.
|
||||
char message_buffer[MAX_CURLY_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);
|
||||
write_to_lcd(message_buffer);
|
||||
}
|
||||
|
||||
write_to_lcd_P(PSTR("{SYS:OK}"));
|
||||
write_to_lcd_P(PSTR("{SYS:OK}"));
|
||||
#endif
|
||||
} break;
|
||||
|
||||
default:
|
||||
@ -382,7 +403,7 @@ void update_usb_status(const bool forceUpdate) {
|
||||
// appears to use the usb discovery status.
|
||||
// This is more logical.
|
||||
if (last_usb_connected_status != Serial || forceUpdate) {
|
||||
last_usb_connected_status = Serial;
|
||||
last_usb_connected_status = Serial;
|
||||
write_to_lcd_P(last_usb_connected_status ? PSTR("{R:UC}\r\n") : PSTR("{R:UD}\r\n"));
|
||||
}
|
||||
}
|
||||
@ -411,15 +432,17 @@ void lcd_update() {
|
||||
}
|
||||
}
|
||||
|
||||
// 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.
|
||||
char message_buffer[10];
|
||||
sprintf_P(message_buffer, PSTR("{TQ:%03i}"), card.percentDone());
|
||||
write_to_lcd(message_buffer);
|
||||
}
|
||||
#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.
|
||||
char message_buffer[10];
|
||||
sprintf_P(message_buffer, PSTR("{TQ:%03i}"), card.percentDone());
|
||||
write_to_lcd(message_buffer);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user