Support Malyan LCD without SD

This commit is contained in:
Scott Lahteine 2018-05-24 04:39:34 -05:00
parent f28e366b77
commit 336a022529

View file

@ -45,8 +45,6 @@
#if ENABLED(MALYAN_LCD) #if ENABLED(MALYAN_LCD)
#include "../sd/cardreader.h"
#include "../sd/SdFatConfig.h"
#include "../module/temperature.h" #include "../module/temperature.h"
#include "../module/planner.h" #include "../module/planner.h"
#include "../module/stepper.h" #include "../module/stepper.h"
@ -60,6 +58,13 @@
#include "../Marlin.h" #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, // On the Malyan M200, this will be Serial1. On a RAMPS board,
// it might not be. // it might not be.
#define LCD_SERIAL Serial1 #define LCD_SERIAL Serial1
@ -135,8 +140,6 @@ void process_lcd_c_command(const char* command) {
void process_lcd_eb_command(const char* command) { void process_lcd_eb_command(const char* command) {
char elapsed_buffer[10]; char elapsed_buffer[10];
duration_t elapsed; duration_t elapsed;
bool has_days;
uint8_t len;
switch (command[0]) { switch (command[0]) {
case '0': { case '0': {
elapsed = print_job_timer.duration(); 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}"), PSTR("{T0:%03.0f/%03i}{T1:000/000}{TP:%03.0f/%03i}{TQ:%03i}{TT:%s}"),
thermalManager.degHotend(0), thermalManager.degHotend(0),
thermalManager.degTargetHotend(0), thermalManager.degTargetHotend(0),
#if HAS_HEATED_BED
thermalManager.degBed(), thermalManager.degBed(),
thermalManager.degTargetBed(), thermalManager.degTargetBed(),
#else
0, 0,
#endif
#if ENABLED(SDSUPPORT)
card.percentDone(), card.percentDone(),
#else
0,
#endif
elapsed_buffer); elapsed_buffer);
write_to_lcd(message_buffer); write_to_lcd(message_buffer);
} break; } break;
@ -226,6 +237,7 @@ void process_lcd_p_command(const char* command) {
switch (command[0]) { switch (command[0]) {
case 'X': case 'X':
#if ENABLED(SDSUPPORT)
// cancel print // cancel print
write_to_lcd_P(PSTR("{SYS:CANCELING}")); write_to_lcd_P(PSTR("{SYS:CANCELING}"));
card.stopSDPrint( card.stopSDPrint(
@ -242,12 +254,14 @@ void process_lcd_p_command(const char* command) {
#endif #endif
wait_for_heatup = false; wait_for_heatup = false;
write_to_lcd_P(PSTR("{SYS:STARTED}")); write_to_lcd_P(PSTR("{SYS:STARTED}"));
#endif
break; break;
case 'H': case 'H':
// Home all axis // Home all axis
enqueue_and_echo_commands_now_P(PSTR("G28")); enqueue_and_echo_commands_now_P(PSTR("G28"));
break; break;
default: { default: {
#if ENABLED(SDSUPPORT)
// Print file 000 - a three digit number indicating which // Print file 000 - a three digit number indicating which
// file to print in the SD card. If it's a directory, // file to print in the SD card. If it's a directory,
// then switch to the directory. // then switch to the directory.
@ -271,6 +285,7 @@ void process_lcd_p_command(const char* command) {
write_to_lcd_P(PSTR("{SYS:BUILD}")); write_to_lcd_P(PSTR("{SYS:BUILD}"));
card.openAndPrintFile(card.filename); card.openAndPrintFile(card.filename);
} }
#endif
} break; // default } break; // default
} // switch } // switch
} }
@ -295,17 +310,22 @@ void process_lcd_s_command(const char* command) {
char message_buffer[MAX_CURLY_COMMAND]; char message_buffer[MAX_CURLY_COMMAND];
sprintf_P(message_buffer, PSTR("{T0:%03.0f/%03i}{T1:000/000}{TP:%03.0f/%03i}"), sprintf_P(message_buffer, PSTR("{T0:%03.0f/%03i}{T1:000/000}{TP:%03.0f/%03i}"),
thermalManager.degHotend(0), thermalManager.degTargetHotend(0), thermalManager.degHotend(0), thermalManager.degTargetHotend(0),
#if HAS_HEATED_BED
thermalManager.degBed(), thermalManager.degTargetBed() thermalManager.degBed(), thermalManager.degTargetBed()
#else
0, 0
#endif
); );
write_to_lcd(message_buffer); write_to_lcd(message_buffer);
} break; } break;
case 'H': case 'H':
// Home all axis // Home all axis
enqueue_and_echo_commands_P(PSTR("G28")); enqueue_and_echo_command("G28");
break; break;
case 'L': { case 'L': {
#if ENABLED(SDSUPPORT)
if (!card.cardOK) card.initsd(); if (!card.cardOK) card.initsd();
// A more efficient way to do this would be to // A more efficient way to do this would be to
@ -323,6 +343,7 @@ void process_lcd_s_command(const char* command) {
} }
write_to_lcd_P(PSTR("{SYS:OK}")); write_to_lcd_P(PSTR("{SYS:OK}"));
#endif
} break; } break;
default: default:
@ -411,6 +432,7 @@ void lcd_update() {
} }
} }
#if ENABLED(SDSUPPORT)
// If there's a print in progress, we need to emit the status as // If there's a print in progress, we need to emit the status as
// {TQ:<PERCENT>} // {TQ:<PERCENT>}
if (card.sdprinting) { if (card.sdprinting) {
@ -420,6 +442,7 @@ void lcd_update() {
sprintf_P(message_buffer, PSTR("{TQ:%03i}"), card.percentDone()); sprintf_P(message_buffer, PSTR("{TQ:%03i}"), card.percentDone());
write_to_lcd(message_buffer); write_to_lcd(message_buffer);
} }
#endif
} }
/** /**