🧑‍💻 Misc. ExtUI LCD cleanup (#25872)

This commit is contained in:
Scott Lahteine
2023-05-24 01:05:55 -05:00
committed by GitHub
parent 9036cec562
commit 37d0f49a82
42 changed files with 3173 additions and 3200 deletions

View File

@@ -140,7 +140,7 @@ typedef Servo hal_servo_t;
#endif #endif
#define LCD_SERIAL lcdSerial #define LCD_SERIAL lcdSerial
#if HAS_DGUS_LCD #if HAS_DGUS_LCD
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.get_tx_buffer_free() #define LCD_SERIAL_TX_BUFFER_FREE() LCD_SERIAL.get_tx_buffer_free()
#endif #endif
#endif #endif

View File

@@ -101,7 +101,7 @@ extern DefaultSerial1 USBSerial;
#error "LCD_SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB." #error "LCD_SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB."
#endif #endif
#if HAS_DGUS_LCD #if HAS_DGUS_LCD
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.available() #define LCD_SERIAL_TX_BUFFER_FREE() LCD_SERIAL.available()
#endif #endif
#endif #endif

View File

@@ -114,7 +114,7 @@
#error "LCD_SERIAL_PORT must be from 1 to 6, or -1 for Native USB." #error "LCD_SERIAL_PORT must be from 1 to 6, or -1 for Native USB."
#endif #endif
#if HAS_DGUS_LCD #if HAS_DGUS_LCD
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite() #define LCD_SERIAL_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
#endif #endif
#endif #endif

View File

@@ -140,7 +140,7 @@
static_assert(false, "LCD_SERIAL_PORT must be from 1 to " STRINGIFY(NUM_UARTS) ". You can also use -1 if the board supports Native USB.") static_assert(false, "LCD_SERIAL_PORT must be from 1 to " STRINGIFY(NUM_UARTS) ". You can also use -1 if the board supports Native USB.")
#endif #endif
#if HAS_DGUS_LCD #if HAS_DGUS_LCD
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite() #define LCD_SERIAL_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
#endif #endif
#endif #endif

View File

@@ -60,21 +60,21 @@ using namespace ExtUI;
namespace Anycubic { namespace Anycubic {
FileNavigator filenavigator; FileNavigator filenavigator;
FileList FileNavigator::filelist; // Instance of the Marlin file API FileList FileNavigator::filelist; // ExtUI file API
uint16_t FileNavigator::lastpanelindex; uint16_t FileNavigator::lastpanelindex;
uint16_t FileNavigator::currentindex; // override the panel request uint16_t FileNavigator::currentindex; // override the panel request
uint8_t FileNavigator::folderdepth; uint8_t FileNavigator::folderdepth;
uint16_t FileNavigator::currentfolderindex[MAX_FOLDER_DEPTH]; // track folder pos for iteration uint16_t FileNavigator::currentDirIndex[MAX_FOLDER_DEPTH]; // track folder pos for iteration
char FileNavigator::currentfoldername[MAX_PATH_LEN + 1]; // Current folder path char FileNavigator::currentDirPath[MAX_PATH_LEN + 1]; // Current folder path
FileNavigator::FileNavigator() { reset(); } FileNavigator::FileNavigator() { reset(); }
void FileNavigator::reset() { void FileNavigator::reset() {
currentfoldername[0] = '\0'; currentDirPath[0] = '\0';
folderdepth = 0; folderdepth = 0;
currentindex = 0; currentindex = 0;
lastpanelindex = 0; lastpanelindex = 0;
ZERO(currentfolderindex); ZERO(currentDirIndex);
// Start at root folder // Start at root folder
while (!filelist.isAtRootDir()) filelist.upDir(); while (!filelist.isAtRootDir()) filelist.upDir();
@@ -85,9 +85,9 @@ void FileNavigator::refresh() { filelist.refresh(); }
void FileNavigator::changeDIR(const char *folder) { void FileNavigator::changeDIR(const char *folder) {
if (folderdepth >= MAX_FOLDER_DEPTH) return; // limit the folder depth if (folderdepth >= MAX_FOLDER_DEPTH) return; // limit the folder depth
currentfolderindex[folderdepth] = currentindex; currentDirIndex[folderdepth] = currentindex;
strcat(currentfoldername, folder); strcat(currentDirPath, folder);
strcat(currentfoldername, "/"); strcat(currentDirPath, "/");
filelist.changeDir(folder); filelist.changeDir(folder);
folderdepth++; folderdepth++;
currentindex = 0; currentindex = 0;
@@ -97,15 +97,15 @@ void FileNavigator::upDIR() {
if (!filelist.isAtRootDir()) { if (!filelist.isAtRootDir()) {
filelist.upDir(); filelist.upDir();
folderdepth--; folderdepth--;
currentindex = currentfolderindex[folderdepth]; // restore last position in the folder currentindex = currentDirIndex[folderdepth]; // restore last position in the folder
filelist.seek(currentindex); // restore file information filelist.seek(currentindex); // restore file information
} }
// Remove the child folder from the stored path // Remove the child folder from the stored path
if (folderdepth == 0) if (folderdepth == 0)
currentfoldername[0] = '\0'; currentDirPath[0] = '\0';
else { else {
char * const pos = strchr(currentfoldername, '/'); char * const pos = strchr(currentDirPath, '/');
*(pos + 1) = '\0'; *(pos + 1) = '\0';
} }
} }
@@ -151,7 +151,7 @@ void FileNavigator::skiptofileindex(uint16_t skip) {
// The new panel ignores entries that don't end in .GCO or .gcode so add and pad them. // The new panel ignores entries that don't end in .GCO or .gcode so add and pad them.
if (paneltype <= AC_panel_new) { if (paneltype <= AC_panel_new) {
TFTSer.println("<<.GCO"); TFTSer.println("<<.GCO");
Chiron.SendtoTFTLN(F(".. .gcode")); chiron.tftSendLn(F(".. .gcode"));
} }
else { else {
TFTSer.println("<<"); TFTSer.println("<<");
@@ -186,7 +186,7 @@ void FileNavigator::skiptofileindex(uint16_t skip) {
} }
else { // Not DIR else { // Not DIR
TFTSer.write('/'); TFTSer.write('/');
if (folderdepth > 0) TFTSer.print(currentfoldername); if (folderdepth > 0) TFTSer.print(currentDirPath);
TFTSer.println(filelist.shortFilename()); TFTSer.println(filelist.shortFilename());
TFTSer.print(filelist.longFilename()); TFTSer.print(filelist.longFilename());
@@ -233,9 +233,9 @@ void FileNavigator::skiptofileindex(uint16_t skip) {
void FileNavigator::sendFile(panel_type_t paneltype) { void FileNavigator::sendFile(panel_type_t paneltype) {
TFTSer.write('/'); TFTSer.write('/');
if (folderdepth > 0) TFTSer.print(currentfoldername); if (folderdepth > 0) TFTSer.print(currentDirPath);
TFTSer.println(filelist.shortFilename()); TFTSer.println(filelist.shortFilename());
if (folderdepth > 0) TFTSer.print(currentfoldername); if (folderdepth > 0) TFTSer.print(currentDirPath);
TFTSer.println(filelist.longFilename()); TFTSer.println(filelist.longFilename());
} }

View File

@@ -52,8 +52,8 @@ namespace Anycubic {
static uint16_t lastpanelindex; static uint16_t lastpanelindex;
static uint16_t currentindex; static uint16_t currentindex;
static uint8_t folderdepth; static uint8_t folderdepth;
static uint16_t currentfolderindex[MAX_FOLDER_DEPTH]; static uint16_t currentDirIndex[MAX_FOLDER_DEPTH];
static char currentfoldername[MAX_PATH_LEN + 1]; static char currentDirPath[MAX_PATH_LEN + 1];
}; };
extern FileNavigator filenavigator; extern FileNavigator filenavigator;

View File

@@ -37,17 +37,17 @@ using namespace Anycubic;
namespace ExtUI { namespace ExtUI {
void onStartup() { Chiron.Startup(); } void onStartup() { chiron.startup(); }
void onIdle() { Chiron.IdleLoop(); } void onIdle() { chiron.idleLoop(); }
void onPrinterKilled(FSTR_P const error, FSTR_P const component) { void onPrinterKilled(FSTR_P const error, FSTR_P const component) {
Chiron.PrinterKilled(error, component); chiron.printerKilled(error, component);
} }
void onMediaInserted() { Chiron.MediaEvent(AC_media_inserted); } void onMediaInserted() { chiron.mediaEvent(AC_media_inserted); }
void onMediaError() { Chiron.MediaEvent(AC_media_error); } void onMediaError() { chiron.mediaEvent(AC_media_error); }
void onMediaRemoved() { Chiron.MediaEvent(AC_media_removed); } void onMediaRemoved() { chiron.mediaEvent(AC_media_removed); }
void onPlayTone(const uint16_t frequency, const uint16_t duration) { void onPlayTone(const uint16_t frequency, const uint16_t duration) {
#if ENABLED(SPEAKER) #if ENABLED(SPEAKER)
@@ -55,15 +55,15 @@ namespace ExtUI {
#endif #endif
} }
void onPrintTimerStarted() { Chiron.TimerEvent(AC_timer_started); } void onPrintTimerStarted() { chiron.timerEvent(AC_timer_started); }
void onPrintTimerPaused() { Chiron.TimerEvent(AC_timer_paused); } void onPrintTimerPaused() { chiron.timerEvent(AC_timer_paused); }
void onPrintTimerStopped() { Chiron.TimerEvent(AC_timer_stopped); } void onPrintTimerStopped() { chiron.timerEvent(AC_timer_stopped); }
void onPrintDone() {} void onPrintDone() {}
void onFilamentRunout(const extruder_t) { Chiron.FilamentRunout(); } void onFilamentRunout(const extruder_t) { chiron.filamentRunout(); }
void onUserConfirmRequired(const char * const msg) { Chiron.ConfirmationRequest(msg); } void onUserConfirmRequired(const char * const msg) { chiron.confirmationRequest(msg); }
void onStatusChanged(const char * const msg) { Chiron.StatusChange(msg); } void onStatusChanged(const char * const msg) { chiron.statusChange(msg); }
void onHomingStart() {} void onHomingStart() {}
void onHomingDone() {} void onHomingDone() {}
@@ -127,7 +127,7 @@ namespace ExtUI {
// Called when power-loss state is detected // Called when power-loss state is detected
} }
// Called on resume from power-loss // Called on resume from power-loss
void onPowerLossResume() { Chiron.PowerLossRecovery(); } void onPowerLossResume() { chiron.powerLossRecovery(); }
#endif #endif
#if HAS_PID_HEATING #if HAS_PID_HEATING

View File

@@ -42,9 +42,13 @@
#include "../../../libs/numtostr.h" #include "../../../libs/numtostr.h"
#include "../../../MarlinCore.h" #include "../../../MarlinCore.h"
#define DEBUG_OUT ACDEBUGLEVEL
#include "../../../core/debug_out.h"
namespace Anycubic { namespace Anycubic {
ChironTFT Chiron; ChironTFT chiron;
#if AUTO_DETECT_CHIRON_TFT #if AUTO_DETECT_CHIRON_TFT
panel_type_t ChironTFT::panel_type = AC_panel_unknown; panel_type_t ChironTFT::panel_type = AC_panel_unknown;
#endif #endif
@@ -60,7 +64,7 @@ uint8_t ChironTFT::command_len;
float ChironTFT::live_Zoffset; float ChironTFT::live_Zoffset;
file_menu_t ChironTFT::file_menu; file_menu_t ChironTFT::file_menu;
void ChironTFT::Startup() { void ChironTFT::startup() {
selectedfile[0] = '\0'; selectedfile[0] = '\0';
panel_command[0] = '\0'; panel_command[0] = '\0';
command_len = 0; command_len = 0;
@@ -92,73 +96,73 @@ void ChironTFT::Startup() {
break; break;
default: default:
SERIAL_ECHOLNF(AC_msg_auto_panel_detection); SERIAL_ECHOLNF(AC_msg_auto_panel_detection);
DetectPanelType(); detectPanelType();
break; break;
} }
// Signal Board has reset // Signal Board has reset
SendtoTFTLN(AC_msg_main_board_has_reset); tftSendLn(AC_msg_main_board_has_reset);
// Enable leveling and Disable end stops during print // Enable leveling and Disable end stops during print
// as Z home places nozzle above the bed so we need to allow it past the end stops // as Z home places nozzle above the bed so we need to allow it past the end stops
injectCommands(AC_cmnd_enable_leveling); injectCommands(AC_cmnd_enable_leveling);
// Startup tunes are defined in Tunes.h // startup tunes are defined in Tunes.h
PlayTune(TERN(AC_DEFAULT_STARTUP_TUNE, Anycubic_PowerOn, GB_PowerOn)); PlayTune(TERN(AC_DEFAULT_STARTUP_TUNE, Anycubic_PowerOn, GB_PowerOn));
#if ACDEBUGLEVEL #if ACDEBUGLEVEL
SERIAL_ECHOLNPGM("AC Debug Level ", ACDEBUGLEVEL); DEBUG_ECHOLNPGM("AC Debug Level ", ACDEBUGLEVEL);
#endif #endif
SendtoTFTLN(AC_msg_ready); tftSendLn(AC_msg_ready);
} }
void ChironTFT::DetectPanelType() { void ChironTFT::detectPanelType() {
#if AUTO_DETECT_CHIRON_TFT #if AUTO_DETECT_CHIRON_TFT
// Send a query to the TFT // Send a query to the TFT
SendtoTFTLN(AC_Test_for_OldPanel); // The panel will respond with 'SXY 480 320' tftSendLn(AC_Test_for_OldPanel); // The panel will respond with 'SXY 480 320'
SendtoTFTLN(AC_Test_for_NewPanel); // the panel will respond with '[0]=0 ' to '[19]=0 ' tftSendLn(AC_Test_for_NewPanel); // the panel will respond with '[0]=0 ' to '[19]=0 '
#endif #endif
} }
void ChironTFT::IdleLoop() { void ChironTFT::idleLoop() {
if (ReadTFTCommand()) { if (readTFTCommand()) {
ProcessPanelRequest(); processPanelRequest();
command_len = 0; command_len = 0;
} }
CheckHeaters(); checkHeaters();
} }
void ChironTFT::PrinterKilled(FSTR_P const error, FSTR_P const component) { void ChironTFT::printerKilled(FSTR_P const error, FSTR_P const component) {
SendtoTFTLN(AC_msg_kill_lcd); tftSendLn(AC_msg_kill_lcd);
#if ACDEBUG(AC_MARLIN) #if ACDEBUG(AC_MARLIN)
SERIAL_ECHOLNPGM("PrinterKilled()\nerror: ", error , "\ncomponent: ", component); DEBUG_ECHOLNPGM("printerKilled()\nerror: ", error , "\ncomponent: ", component);
#endif #endif
} }
void ChironTFT::MediaEvent(media_event_t event) { void ChironTFT::mediaEvent(media_event_t event) {
#if ACDEBUG(AC_MARLIN) #if ACDEBUG(AC_MARLIN)
SERIAL_ECHOLNPGM("ProcessMediaStatus() ", event); DEBUG_ECHOLNPGM("ProcessMediaStatus() ", event);
#endif #endif
switch (event) { switch (event) {
case AC_media_inserted: case AC_media_inserted:
SendtoTFTLN(AC_msg_sd_card_inserted); tftSendLn(AC_msg_sd_card_inserted);
break; break;
case AC_media_removed: case AC_media_removed:
SendtoTFTLN(AC_msg_sd_card_removed); tftSendLn(AC_msg_sd_card_removed);
break; break;
case AC_media_error: case AC_media_error:
last_error = AC_error_noSD; last_error = AC_error_noSD;
SendtoTFTLN(AC_msg_no_sd_card); tftSendLn(AC_msg_no_sd_card);
break; break;
} }
} }
void ChironTFT::TimerEvent(timer_event_t event) { void ChironTFT::timerEvent(timer_event_t event) {
#if ACDEBUG(AC_MARLIN) #if ACDEBUG(AC_MARLIN)
SERIAL_ECHOLNPGM("TimerEvent() ", event); DEBUG_ECHOLNPGM("timerEvent() ", event);
SERIAL_ECHOLNPGM("Printer State: ", printer_state); DEBUG_ECHOLNPGM("Printer State: ", printer_state);
#endif #endif
switch (event) { switch (event) {
@@ -166,44 +170,44 @@ void ChironTFT::TimerEvent(timer_event_t event) {
live_Zoffset = 0.0; // reset print offset live_Zoffset = 0.0; // reset print offset
setSoftEndstopState(false); // disable endstops to print setSoftEndstopState(false); // disable endstops to print
printer_state = AC_printer_printing; printer_state = AC_printer_printing;
SendtoTFTLN(AC_msg_print_from_sd_card); tftSendLn(AC_msg_print_from_sd_card);
} break; } break;
case AC_timer_paused: { case AC_timer_paused: {
printer_state = AC_printer_paused; printer_state = AC_printer_paused;
pause_state = AC_paused_idle; pause_state = AC_paused_idle;
SendtoTFTLN(AC_msg_paused); tftSendLn(AC_msg_paused);
} break; } break;
case AC_timer_stopped: { case AC_timer_stopped: {
if (printer_state != AC_printer_idle) { if (printer_state != AC_printer_idle) {
printer_state = AC_printer_stopping; printer_state = AC_printer_stopping;
SendtoTFTLN(AC_msg_print_complete); tftSendLn(AC_msg_print_complete);
} }
setSoftEndstopState(true); // enable endstops setSoftEndstopState(true); // enable endstops
} break; } break;
} }
} }
void ChironTFT::FilamentRunout() { void ChironTFT::filamentRunout() {
#if ACDEBUG(AC_MARLIN) #if ACDEBUG(AC_MARLIN)
SERIAL_ECHOLNPGM("FilamentRunout() printer_state ", printer_state); DEBUG_ECHOLNPGM("filamentRunout() printer_state ", printer_state);
#endif #endif
// 1 Signal filament out // 1 Signal filament out
last_error = AC_error_filament_runout; last_error = AC_error_filament_runout;
SendtoTFTLN(isPrintingFromMedia() ? AC_msg_filament_out_alert : AC_msg_filament_out_block); tftSendLn(isPrintingFromMedia() ? AC_msg_filament_out_alert : AC_msg_filament_out_block);
PlayTune(FilamentOut); PlayTune(FilamentOut);
} }
void ChironTFT::ConfirmationRequest(const char * const msg) { void ChironTFT::confirmationRequest(const char * const msg) {
// M108 continue // M108 continue
#if ACDEBUG(AC_MARLIN) #if ACDEBUG(AC_MARLIN)
SERIAL_ECHOLNPGM("ConfirmationRequest() ", msg, " printer_state:", printer_state); DEBUG_ECHOLNPGM("confirmationRequest() ", msg, " printer_state:", printer_state);
#endif #endif
switch (printer_state) { switch (printer_state) {
case AC_printer_pausing: { case AC_printer_pausing: {
if (strcmp_P(msg, MARLIN_msg_print_paused) == 0 || strcmp_P(msg, MARLIN_msg_nozzle_parked) == 0) { if (strcmp_P(msg, MARLIN_msg_print_paused) == 0 || strcmp_P(msg, MARLIN_msg_nozzle_parked) == 0) {
SendtoTFTLN(AC_msg_paused); // enable continue button tftSendLn(AC_msg_paused); // enable continue button
printer_state = AC_printer_paused; printer_state = AC_printer_paused;
} }
} break; } break;
@@ -214,18 +218,18 @@ void ChironTFT::ConfirmationRequest(const char * const msg) {
// Heater timeout, send acknowledgement // Heater timeout, send acknowledgement
if (strcmp_P(msg, MARLIN_msg_heater_timeout) == 0) { if (strcmp_P(msg, MARLIN_msg_heater_timeout) == 0) {
pause_state = AC_paused_heater_timed_out; pause_state = AC_paused_heater_timed_out;
SendtoTFTLN(AC_msg_paused); // enable continue button tftSendLn(AC_msg_paused); // enable continue button
PlayTune(HeaterTimeout); PlayTune(HeaterTimeout);
} }
// Reheat finished, send acknowledgement // Reheat finished, send acknowledgement
else if (strcmp_P(msg, MARLIN_msg_reheat_done) == 0) { else if (strcmp_P(msg, MARLIN_msg_reheat_done) == 0) {
pause_state = AC_paused_idle; pause_state = AC_paused_idle;
SendtoTFTLN(AC_msg_paused); // enable continue button tftSendLn(AC_msg_paused); // enable continue button
} }
// Filament Purging, send acknowledgement enter run mode // Filament Purging, send acknowledgement enter run mode
else if (strcmp_P(msg, MARLIN_msg_filament_purging) == 0) { else if (strcmp_P(msg, MARLIN_msg_filament_purging) == 0) {
pause_state = AC_paused_purging_filament; pause_state = AC_paused_purging_filament;
SendtoTFTLN(AC_msg_paused); // enable continue button tftSendLn(AC_msg_paused); // enable continue button
} }
} break; } break;
default: default:
@@ -233,10 +237,10 @@ void ChironTFT::ConfirmationRequest(const char * const msg) {
} }
} }
void ChironTFT::StatusChange(const char * const msg) { void ChironTFT::statusChange(const char * const msg) {
#if ACDEBUG(AC_MARLIN) #if ACDEBUG(AC_MARLIN)
SERIAL_ECHOLNPGM("StatusChange() ", msg); DEBUG_ECHOLNPGM("statusChange() ", msg);
SERIAL_ECHOLNPGM("printer_state:", printer_state); DEBUG_ECHOLNPGM("printer_state:", printer_state);
#endif #endif
bool msg_matched = false; bool msg_matched = false;
// The only way to get printer status is to parse messages // The only way to get printer status is to parse messages
@@ -247,7 +251,7 @@ void ChironTFT::StatusChange(const char * const msg) {
// Ignore the custom machine name // Ignore the custom machine name
if (strcmp_P(msg + strlen(MACHINE_NAME), MARLIN_msg_ready) == 0) { if (strcmp_P(msg + strlen(MACHINE_NAME), MARLIN_msg_ready) == 0) {
injectCommands(F("M500\nG27")); injectCommands(F("M500\nG27"));
SendtoTFTLN(AC_msg_probing_complete); tftSendLn(AC_msg_probing_complete);
printer_state = AC_printer_idle; printer_state = AC_printer_idle;
msg_matched = true; msg_matched = true;
} }
@@ -255,7 +259,7 @@ void ChironTFT::StatusChange(const char * const msg) {
if (strcmp_P(msg, MARLIN_msg_probing_failed) == 0) { if (strcmp_P(msg, MARLIN_msg_probing_failed) == 0) {
PlayTune(BeepBeepBeeep); PlayTune(BeepBeepBeeep);
injectCommands(F("G1 Z50 F500")); injectCommands(F("G1 Z50 F500"));
SendtoTFTLN(AC_msg_probing_complete); tftSendLn(AC_msg_probing_complete);
printer_state = AC_printer_idle; printer_state = AC_printer_idle;
msg_matched = true; msg_matched = true;
} }
@@ -263,14 +267,14 @@ void ChironTFT::StatusChange(const char * const msg) {
case AC_printer_printing: { case AC_printer_printing: {
if (strcmp_P(msg, MARLIN_msg_reheating) == 0) { if (strcmp_P(msg, MARLIN_msg_reheating) == 0) {
SendtoTFTLN(AC_msg_paused); // enable continue button tftSendLn(AC_msg_paused); // enable continue button
msg_matched = true; msg_matched = true;
} }
} break; } break;
case AC_printer_pausing: { case AC_printer_pausing: {
if (strcmp_P(msg, MARLIN_msg_print_paused) == 0) { if (strcmp_P(msg, MARLIN_msg_print_paused) == 0) {
SendtoTFTLN(AC_msg_paused); tftSendLn(AC_msg_paused);
printer_state = AC_printer_paused; printer_state = AC_printer_paused;
pause_state = AC_paused_idle; pause_state = AC_paused_idle;
msg_matched = true; msg_matched = true;
@@ -279,7 +283,7 @@ void ChironTFT::StatusChange(const char * const msg) {
case AC_printer_stopping: { case AC_printer_stopping: {
if (strcmp_P(msg, MARLIN_msg_print_aborted) == 0) { if (strcmp_P(msg, MARLIN_msg_print_aborted) == 0) {
SendtoTFTLN(AC_msg_stop); tftSendLn(AC_msg_stop);
printer_state = AC_printer_idle; printer_state = AC_printer_idle;
msg_matched = true; msg_matched = true;
} }
@@ -291,11 +295,11 @@ void ChironTFT::StatusChange(const char * const msg) {
// If not matched earlier see if this was a heater message // If not matched earlier see if this was a heater message
if (!msg_matched) { if (!msg_matched) {
if (strcmp_P(msg, MARLIN_msg_extruder_heating) == 0) { if (strcmp_P(msg, MARLIN_msg_extruder_heating) == 0) {
SendtoTFTLN(AC_msg_nozzle_heating); tftSendLn(AC_msg_nozzle_heating);
hotend_state = AC_heater_temp_set; hotend_state = AC_heater_temp_set;
} }
else if (strcmp_P(msg, MARLIN_msg_bed_heating) == 0) { else if (strcmp_P(msg, MARLIN_msg_bed_heating) == 0) {
SendtoTFTLN(AC_msg_bed_heating); tftSendLn(AC_msg_bed_heating);
hotbed_state = AC_heater_temp_set; hotbed_state = AC_heater_temp_set;
} }
else if (strcmp_P(msg, MARLIN_msg_EEPROM_version) == 0) { else if (strcmp_P(msg, MARLIN_msg_EEPROM_version) == 0) {
@@ -304,33 +308,33 @@ void ChironTFT::StatusChange(const char * const msg) {
} }
} }
void ChironTFT::PowerLossRecovery() { void ChironTFT::powerLossRecovery() {
printer_state = AC_printer_resuming_from_power_outage; // Play tune to notify user we can recover. printer_state = AC_printer_resuming_from_power_outage; // Play tune to notify user we can recover.
last_error = AC_error_powerloss; last_error = AC_error_powerloss;
PlayTune(SOS); PlayTune(SOS);
SERIAL_ECHOLNF(AC_msg_powerloss_recovery); SERIAL_ECHOLNF(AC_msg_powerloss_recovery);
} }
void ChironTFT::PrintComplete() { void ChironTFT::printComplete() {
SendtoTFT(AC_msg_print_complete); tftSend(AC_msg_print_complete);
printer_state = AC_printer_idle; printer_state = AC_printer_idle;
setSoftEndstopState(true); // enable endstops setSoftEndstopState(true); // enable endstops
} }
void ChironTFT::SendtoTFT(FSTR_P const fstr/*=nullptr*/) { // A helper to print PROGMEM string to the panel void ChironTFT::tftSend(FSTR_P const fstr/*=nullptr*/) { // A helper to print PROGMEM string to the panel
#if ACDEBUG(AC_SOME) #if ACDEBUG(AC_SOME)
SERIAL_ECHOF(fstr); DEBUG_ECHOF(fstr);
#endif #endif
PGM_P str = FTOP(fstr); PGM_P str = FTOP(fstr);
while (const char c = pgm_read_byte(str++)) TFTSer.write(c); while (const char c = pgm_read_byte(str++)) TFTSer.write(c);
} }
void ChironTFT::SendtoTFTLN(FSTR_P const fstr/*=nullptr*/) { void ChironTFT::tftSendLn(FSTR_P const fstr/*=nullptr*/) {
if (fstr) { if (fstr) {
#if ACDEBUG(AC_SOME) #if ACDEBUG(AC_SOME)
SERIAL_ECHOPGM("> "); DEBUG_ECHOPGM("> ");
#endif #endif
SendtoTFT(fstr); tftSend(fstr);
#if ACDEBUG(AC_SOME) #if ACDEBUG(AC_SOME)
SERIAL_EOL(); SERIAL_EOL();
#endif #endif
@@ -338,7 +342,7 @@ void ChironTFT::SendtoTFTLN(FSTR_P const fstr/*=nullptr*/) {
TFTSer.println(); TFTSer.println();
} }
bool ChironTFT::ReadTFTCommand() { bool ChironTFT::readTFTCommand() {
bool command_ready = false; bool command_ready = false;
while (TFTSer.available() > 0 && command_len < MAX_CMND_LEN) { while (TFTSer.available() > 0 && command_len < MAX_CMND_LEN) {
panel_command[command_len] = TFTSer.read(); panel_command[command_len] = TFTSer.read();
@@ -352,29 +356,29 @@ bool ChironTFT::ReadTFTCommand() {
if (command_ready || command_len == MAX_CMND_LEN) { if (command_ready || command_len == MAX_CMND_LEN) {
panel_command[command_len] = '\0'; panel_command[command_len] = '\0';
#if ACDEBUG(AC_ALL) #if ACDEBUG(AC_ALL)
SERIAL_ECHOLNPGM("len(",command_len,") < ", panel_command); DEBUG_ECHOLNPGM("len(",command_len,") < ", panel_command);
#endif #endif
command_ready = true; command_ready = true;
} }
return command_ready; return command_ready;
} }
int8_t ChironTFT::FindToken(char c) { int8_t ChironTFT::findToken(char c) {
for (int8_t pos = 0; pos < command_len; pos++) { for (int8_t pos = 0; pos < command_len; pos++) {
if (panel_command[pos] == c) { if (panel_command[pos] == c) {
#if ACDEBUG(AC_INFO) #if ACDEBUG(AC_INFO)
SERIAL_ECHOLNPGM("Tpos:", pos, " ", c); DEBUG_ECHOLNPGM("Tpos:", pos, " ", c);
#endif #endif
return pos; return pos;
} }
} }
#if ACDEBUG(AC_INFO) #if ACDEBUG(AC_INFO)
SERIAL_ECHOLNPGM("Not found: ", c); DEBUG_ECHOLNPGM("Not found: ", c);
#endif #endif
return -1; return -1;
} }
void ChironTFT::CheckHeaters() { void ChironTFT::checkHeaters() {
uint8_t faultDuration = 0; uint8_t faultDuration = 0;
// if the hotend temp is abnormal, confirm state before signalling panel // if the hotend temp is abnormal, confirm state before signalling panel
@@ -382,7 +386,7 @@ void ChironTFT::CheckHeaters() {
while (!WITHIN(temp, HEATER_0_MINTEMP, HEATER_0_MAXTEMP)) { while (!WITHIN(temp, HEATER_0_MINTEMP, HEATER_0_MAXTEMP)) {
faultDuration++; faultDuration++;
if (faultDuration >= AC_HEATER_FAULT_VALIDATION_TIME) { if (faultDuration >= AC_HEATER_FAULT_VALIDATION_TIME) {
SendtoTFTLN(AC_msg_nozzle_temp_abnormal); tftSendLn(AC_msg_nozzle_temp_abnormal);
last_error = AC_error_abnormal_temp_t0; last_error = AC_error_abnormal_temp_t0;
SERIAL_ECHOLNPGM("Extruder temp abnormal! : ", temp); SERIAL_ECHOLNPGM("Extruder temp abnormal! : ", temp);
break; break;
@@ -397,7 +401,7 @@ void ChironTFT::CheckHeaters() {
while (!WITHIN(temp, BED_MINTEMP, BED_MAXTEMP)) { while (!WITHIN(temp, BED_MINTEMP, BED_MAXTEMP)) {
faultDuration++; faultDuration++;
if (faultDuration >= AC_HEATER_FAULT_VALIDATION_TIME) { if (faultDuration >= AC_HEATER_FAULT_VALIDATION_TIME) {
SendtoTFTLN(AC_msg_nozzle_temp_abnormal); tftSendLn(AC_msg_nozzle_temp_abnormal);
last_error = AC_error_abnormal_temp_bed; last_error = AC_error_abnormal_temp_bed;
SERIAL_ECHOLNPGM("Bed temp abnormal! : ", temp); SERIAL_ECHOLNPGM("Bed temp abnormal! : ", temp);
break; break;
@@ -409,7 +413,7 @@ void ChironTFT::CheckHeaters() {
// Update panel with hotend heater status // Update panel with hotend heater status
if (hotend_state != AC_heater_temp_reached) { if (hotend_state != AC_heater_temp_reached) {
if (WITHIN(getActualTemp_celsius(E0) - getTargetTemp_celsius(E0), -(TEMP_WINDOW), TEMP_WINDOW)) { if (WITHIN(getActualTemp_celsius(E0) - getTargetTemp_celsius(E0), -(TEMP_WINDOW), TEMP_WINDOW)) {
SendtoTFTLN(AC_msg_nozzle_heating_done); tftSendLn(AC_msg_nozzle_heating_done);
hotend_state = AC_heater_temp_reached; hotend_state = AC_heater_temp_reached;
} }
} }
@@ -417,23 +421,23 @@ void ChironTFT::CheckHeaters() {
// Update panel with bed heater status // Update panel with bed heater status
if (hotbed_state != AC_heater_temp_reached) { if (hotbed_state != AC_heater_temp_reached) {
if (WITHIN(getActualTemp_celsius(BED) - getTargetTemp_celsius(BED), -(TEMP_BED_WINDOW), TEMP_BED_WINDOW)) { if (WITHIN(getActualTemp_celsius(BED) - getTargetTemp_celsius(BED), -(TEMP_BED_WINDOW), TEMP_BED_WINDOW)) {
SendtoTFTLN(AC_msg_bed_heating_done); tftSendLn(AC_msg_bed_heating_done);
hotbed_state = AC_heater_temp_reached; hotbed_state = AC_heater_temp_reached;
} }
} }
} }
void ChironTFT::SendFileList(int8_t startindex) { void ChironTFT::sendFileList(int8_t startindex) {
// Respond to panel request for 4 files starting at index // Respond to panel request for 4 files starting at index
#if ACDEBUG(AC_INFO) #if ACDEBUG(AC_INFO)
SERIAL_ECHOLNPGM("## SendFileList ## ", startindex); DEBUG_ECHOLNPGM("## sendFileList ## ", startindex);
#endif #endif
SendtoTFTLN(F("FN ")); tftSendLn(F("FN "));
filenavigator.getFiles(startindex, panel_type, 4); filenavigator.getFiles(startindex, panel_type, 4);
SendtoTFTLN(F("END")); tftSendLn(F("END"));
} }
void ChironTFT::SelectFile() { void ChironTFT::selectFile() {
if (panel_type <= AC_panel_new) { if (panel_type <= AC_panel_new) {
strncpy(selectedfile, panel_command + 4, command_len - 3); strncpy(selectedfile, panel_command + 4, command_len - 3);
selectedfile[command_len - 4] = '\0'; selectedfile[command_len - 4] = '\0';
@@ -443,50 +447,50 @@ void ChironTFT::SelectFile() {
selectedfile[command_len - 5] = '\0'; selectedfile[command_len - 5] = '\0';
} }
#if ACDEBUG(AC_FILE) #if ACDEBUG(AC_FILE)
SERIAL_ECHOLNPGM(" Selected File: ",selectedfile); DEBUG_ECHOLNPGM(" Selected File: ",selectedfile);
#endif #endif
switch (selectedfile[0]) { switch (selectedfile[0]) {
case '/': // Valid file selected case '/': // Valid file selected
SendtoTFTLN(AC_msg_sd_file_open_success); tftSendLn(AC_msg_sd_file_open_success);
break; break;
case '<': // .. (go up folder level) case '<': // .. (go up folder level)
filenavigator.upDIR(); filenavigator.upDIR();
SendtoTFTLN(AC_msg_sd_file_open_failed); tftSendLn(AC_msg_sd_file_open_failed);
SendFileList( 0 ); sendFileList( 0 );
break; break;
default: // enter sub folder default: // enter sub folder
// for new panel remove the '.GCO' tag that was added to the end of the path // for new panel remove the '.GCO' tag that was added to the end of the path
if (panel_type <= AC_panel_new) if (panel_type <= AC_panel_new)
selectedfile[strlen(selectedfile) - 4] = '\0'; selectedfile[strlen(selectedfile) - 4] = '\0';
filenavigator.changeDIR(selectedfile); filenavigator.changeDIR(selectedfile);
SendtoTFTLN(AC_msg_sd_file_open_failed); tftSendLn(AC_msg_sd_file_open_failed);
SendFileList( 0 ); sendFileList( 0 );
break; break;
} }
} }
void ChironTFT::ProcessPanelRequest() { void ChironTFT::processPanelRequest() {
// Break these up into logical blocks // as its easier to navigate than one huge switch case! // Break these up into logical blocks // as its easier to navigate than one huge switch case!
int8_t tpos = FindToken('A'); int8_t tpos = findToken('A');
// Panel request are 'A0' - 'A36' // Panel request are 'A0' - 'A36'
if (tpos >= 0) { if (tpos >= 0) {
const int8_t req = atoi(&panel_command[tpos + 1]); const int8_t req = atoi(&panel_command[tpos + 1]);
// Information requests A0 - A8 and A33 // Information requests A0 - A8 and A33
if (req <= 8 || req == 33) PanelInfo(req); if (req <= 8 || req == 33) panelInfo(req);
// Simple Actions A9 - A28 // Simple Actions A9 - A28
else if (req <= 28) PanelAction(req); else if (req <= 28) panelAction(req);
// Process Initiation // Process Initiation
else if (req <= 36) PanelProcess(req); else if (req <= 36) panelProcess(req);
} }
else { else {
#if AUTO_DETECT_CHIRON_TFT #if AUTO_DETECT_CHIRON_TFT
// This may be a response to a panel type detection query // This may be a response to a panel type detection query
if (panel_type == AC_panel_unknown) { if (panel_type == AC_panel_unknown) {
tpos = FindToken('S'); // old panel will respond to 'SIZE' with 'SXY 480 320' tpos = findToken('S'); // old panel will respond to 'SIZE' with 'SXY 480 320'
if (tpos >= 0) { if (tpos >= 0) {
if (panel_command[tpos + 1] == 'X' && panel_command[tpos + 2] =='Y') { if (panel_command[tpos + 1] == 'X' && panel_command[tpos + 2] =='Y') {
panel_type = AC_panel_standard; panel_type = AC_panel_standard;
@@ -496,7 +500,7 @@ void ChironTFT::ProcessPanelRequest() {
else { else {
// new panel will respond to 'J200' with '[0]=0' // new panel will respond to 'J200' with '[0]=0'
// it seems only after a power cycle so detection assumes a new panel // it seems only after a power cycle so detection assumes a new panel
tpos = FindToken('['); tpos = findToken('[');
if (tpos >= 0) { if (tpos >= 0) {
if (panel_command[tpos + 1] == '0' && panel_command[tpos + 2] ==']') { if (panel_command[tpos + 1] == '0' && panel_command[tpos + 2] ==']') {
panel_type = AC_panel_new; panel_type = AC_panel_new;
@@ -508,94 +512,94 @@ void ChironTFT::ProcessPanelRequest() {
} }
#endif #endif
SendtoTFTLN(); // Ignore unknown requests tftSendLn(); // Ignore unknown requests
} }
} }
void ChironTFT::PanelInfo(uint8_t req) { void ChironTFT::panelInfo(uint8_t req) {
// information requests A0-A8 and A33 // information requests A0-A8 and A33
switch (req) { switch (req) {
case 0: // A0 Get HOTEND Temp case 0: // A0 Get HOTEND Temp
SendtoTFT(F("A0V ")); tftSend(F("A0V "));
TFTSer.println(getActualTemp_celsius(E0)); TFTSer.println(getActualTemp_celsius(E0));
break; break;
case 1: // A1 Get HOTEND Target Temp case 1: // A1 Get HOTEND Target Temp
SendtoTFT(F("A1V ")); tftSend(F("A1V "));
TFTSer.println(getTargetTemp_celsius(E0)); TFTSer.println(getTargetTemp_celsius(E0));
break; break;
case 2: // A2 Get BED Temp case 2: // A2 Get BED Temp
SendtoTFT(F("A2V ")); tftSend(F("A2V "));
TFTSer.println(getActualTemp_celsius(BED)); TFTSer.println(getActualTemp_celsius(BED));
break; break;
case 3: // A3 Get BED Target Temp case 3: // A3 Get BED Target Temp
SendtoTFT(F("A3V ")); tftSend(F("A3V "));
TFTSer.println(getTargetTemp_celsius(BED)); TFTSer.println(getTargetTemp_celsius(BED));
break; break;
case 4: // A4 Get FAN Speed case 4: // A4 Get FAN Speed
SendtoTFT(F("A4V ")); tftSend(F("A4V "));
TFTSer.println(getActualFan_percent(FAN0)); TFTSer.println(getActualFan_percent(FAN0));
break; break;
case 5: // A5 Get Current Coordinates case 5: // A5 Get Current Coordinates
SendtoTFT(F("A5V X: ")); tftSend(F("A5V X: "));
TFTSer.print(getAxisPosition_mm(X)); TFTSer.print(getAxisPosition_mm(X));
SendtoTFT(F(" Y: ")); tftSend(F(" Y: "));
TFTSer.print(getAxisPosition_mm(Y)); TFTSer.print(getAxisPosition_mm(Y));
SendtoTFT(F(" Z: ")); tftSend(F(" Z: "));
TFTSer.println(getAxisPosition_mm(Z)); TFTSer.println(getAxisPosition_mm(Z));
break; break;
case 6: // A6 Get printing progress case 6: // A6 Get printing progress
if (isPrintingFromMedia()) { if (isPrintingFromMedia()) {
SendtoTFT(F("A6V ")); tftSend(F("A6V "));
TFTSer.println(ui8tostr2(getProgress_percent())); TFTSer.println(ui8tostr2(getProgress_percent()));
} }
else else
SendtoTFTLN(F("A6V ---")); tftSendLn(F("A6V ---"));
break; break;
case 7: { // A7 Get Printing Time case 7: { // A7 Get Printing Time
uint32_t time = getProgress_seconds_elapsed() / 60; uint32_t time = getProgress_seconds_elapsed() / 60;
SendtoTFT(F("A7V ")); tftSend(F("A7V "));
TFTSer.print(ui8tostr2(time / 60)); TFTSer.print(ui8tostr2(time / 60));
SendtoTFT(F(" H ")); tftSend(F(" H "));
TFTSer.print(ui8tostr2(time % 60)); TFTSer.print(ui8tostr2(time % 60));
SendtoTFT(F(" M")); tftSend(F(" M"));
#if ACDEBUG(AC_ALL) #if ACDEBUG(AC_ALL)
SERIAL_ECHOLNPGM("Print time ", ui8tostr2(time / 60), ":", ui8tostr2(time % 60)); DEBUG_ECHOLNPGM("Print time ", ui8tostr2(time / 60), ":", ui8tostr2(time % 60));
#endif #endif
} break; } break;
case 8: // A8 Get SD Card list A8 S0 case 8: // A8 Get SD Card list A8 S0
if (!isMediaInserted()) safe_delay(500); if (!isMediaInserted()) safe_delay(500);
if (!isMediaInserted()) // Make sure the card is removed if (!isMediaInserted()) // Make sure the card is removed
SendtoTFTLN(AC_msg_no_sd_card); tftSendLn(AC_msg_no_sd_card);
else if (panel_command[3] == 'S') else if (panel_command[3] == 'S')
SendFileList( atoi( &panel_command[4] ) ); sendFileList( atoi( &panel_command[4] ) );
break; break;
case 33: // A33 Get firmware info case 33: // A33 Get firmware info
SendtoTFT(F("J33 ")); tftSend(F("J33 "));
// If there is an error recorded, show that instead of the FW version // If there is an error recorded, show that instead of the FW version
if (!GetLastError()) SendtoTFTLN(F(SHORT_BUILD_VERSION)); if (!getLastError()) tftSendLn(F(SHORT_BUILD_VERSION));
break; break;
} }
} }
void ChironTFT::PanelAction(uint8_t req) { void ChironTFT::panelAction(uint8_t req) {
switch (req) { switch (req) {
case 9: // A9 Pause SD print case 9: // A9 Pause SD print
if (isPrintingFromMedia()) { if (isPrintingFromMedia()) {
SendtoTFTLN(AC_msg_pause); tftSendLn(AC_msg_pause);
pausePrint(); pausePrint();
printer_state = AC_printer_pausing; printer_state = AC_printer_pausing;
} }
else else
SendtoTFTLN(AC_msg_stop); tftSendLn(AC_msg_stop);
break; break;
case 10: // A10 Resume SD Print case 10: // A10 Resume SD Print
@@ -613,7 +617,7 @@ void ChironTFT::PanelAction(uint8_t req) {
else { else {
if (printer_state == AC_printer_resuming_from_power_outage) if (printer_state == AC_printer_resuming_from_power_outage)
injectCommands(F("M1000 C")); // Cancel recovery injectCommands(F("M1000 C")); // Cancel recovery
SendtoTFTLN(AC_msg_stop); tftSendLn(AC_msg_stop);
printer_state = AC_printer_idle; printer_state = AC_printer_idle;
} }
break; break;
@@ -623,7 +627,7 @@ void ChironTFT::PanelAction(uint8_t req) {
break; break;
case 13: // A13 Select file case 13: // A13 Select file
SelectFile(); selectFile();
break; break;
case 14: // A14 Start Printing case 14: // A14 Start Printing
@@ -632,11 +636,9 @@ void ChironTFT::PanelAction(uint8_t req) {
injectCommands(F("M1000 C")); // Cancel recovery injectCommands(F("M1000 C")); // Cancel recovery
printer_state = AC_printer_idle; printer_state = AC_printer_idle;
} }
#if ACDebugLevel >= 1 DEBUG_ECHOLNPGM("Print: ", selectedfile);
SERIAL_ECHOLNPGM("Print: ", selectedfile);
#endif
printFile(selectedfile); printFile(selectedfile);
SendtoTFTLN(AC_msg_print_from_sd_card); tftSendLn(AC_msg_print_from_sd_card);
break; break;
case 15: // A15 Resuming from outage case 15: // A15 Resuming from outage
@@ -671,7 +673,7 @@ void ChironTFT::PanelAction(uint8_t req) {
case 19: // A19 Motors off case 19: // A19 Motors off
if (!isPrinting()) { if (!isPrinting()) {
stepper.disable_all_steppers(); stepper.disable_all_steppers();
SendtoTFTLN(AC_msg_ready); tftSendLn(AC_msg_ready);
} }
break; break;
@@ -679,7 +681,7 @@ void ChironTFT::PanelAction(uint8_t req) {
if (panel_command[4] == 'S') if (panel_command[4] == 'S')
setFeedrate_percent(atoi(&panel_command[5])); setFeedrate_percent(atoi(&panel_command[5]));
else { else {
SendtoTFT(F("A20V ")); tftSend(F("A20V "));
TFTSer.println(getFeedrate_percent()); TFTSer.println(getFeedrate_percent());
} }
break; break;
@@ -707,7 +709,7 @@ void ChironTFT::PanelAction(uint8_t req) {
char MoveCmnd[30]; char MoveCmnd[30];
sprintf_P(MoveCmnd, PSTR("G91\nG0%s\nG90"), panel_command + 3); sprintf_P(MoveCmnd, PSTR("G91\nG0%s\nG90"), panel_command + 3);
#if ACDEBUG(AC_ACTION) #if ACDEBUG(AC_ACTION)
SERIAL_ECHOLNPGM("Move: ", MoveCmnd); DEBUG_ECHOLNPGM("Move: ", MoveCmnd);
#endif #endif
setSoftEndstopState(true); // enable endstops setSoftEndstopState(true); // enable endstops
injectCommands(MoveCmnd); injectCommands(MoveCmnd);
@@ -720,7 +722,7 @@ void ChironTFT::PanelAction(uint8_t req) {
// Temps defined in configuration.h // Temps defined in configuration.h
setTargetTemp_celsius(PREHEAT_1_TEMP_BED, BED); setTargetTemp_celsius(PREHEAT_1_TEMP_BED, BED);
setTargetTemp_celsius(PREHEAT_1_TEMP_HOTEND, E0); setTargetTemp_celsius(PREHEAT_1_TEMP_HOTEND, E0);
SendtoTFTLN(); tftSendLn();
hotbed_state = AC_heater_temp_set; hotbed_state = AC_heater_temp_set;
hotend_state = AC_heater_temp_set; hotend_state = AC_heater_temp_set;
} }
@@ -731,7 +733,7 @@ void ChironTFT::PanelAction(uint8_t req) {
if (!isPrinting()) { if (!isPrinting()) {
setTargetTemp_celsius(PREHEAT_2_TEMP_BED, BED); setTargetTemp_celsius(PREHEAT_2_TEMP_BED, BED);
setTargetTemp_celsius(PREHEAT_2_TEMP_HOTEND, E0); setTargetTemp_celsius(PREHEAT_2_TEMP_HOTEND, E0);
SendtoTFTLN(); tftSendLn();
hotbed_state = AC_heater_temp_set; hotbed_state = AC_heater_temp_set;
hotend_state = AC_heater_temp_set; hotend_state = AC_heater_temp_set;
} }
@@ -742,7 +744,7 @@ void ChironTFT::PanelAction(uint8_t req) {
if (!isPrinting()) { if (!isPrinting()) {
setTargetTemp_celsius(0, E0); setTargetTemp_celsius(0, E0);
setTargetTemp_celsius(0, BED); setTargetTemp_celsius(0, BED);
SendtoTFTLN(AC_msg_ready); tftSendLn(AC_msg_ready);
hotbed_state = AC_heater_off; hotbed_state = AC_heater_off;
hotend_state = AC_heater_off; hotend_state = AC_heater_off;
} }
@@ -761,21 +763,21 @@ void ChironTFT::PanelAction(uint8_t req) {
case 28: // A28 Filament set A28 O/C case 28: // A28 Filament set A28 O/C
// Ignore request if printing // Ignore request if printing
if (isPrinting()) break; if (isPrinting()) break;
SendtoTFTLN(); tftSendLn();
break; break;
} }
} }
void ChironTFT::PanelProcess(uint8_t req) { void ChironTFT::panelProcess(uint8_t req) {
switch (req) { switch (req) {
case 29: { // A29 Read Mesh Point A29 X1 Y1 case 29: { // A29 Read Mesh Point A29 X1 Y1
xy_uint8_t pos; xy_uint8_t pos;
float pos_z; float pos_z;
pos.x = atoi(&panel_command[FindToken('X')+1]); pos.x = atoi(&panel_command[findToken('X')+1]);
pos.y = atoi(&panel_command[FindToken('Y')+1]); pos.y = atoi(&panel_command[findToken('Y')+1]);
pos_z = getMeshPoint(pos); pos_z = getMeshPoint(pos);
SendtoTFT(F("A29V ")); tftSend(F("A29V "));
TFTSer.println(pos_z * 100); TFTSer.println(pos_z * 100);
if (!isPrinting()) { if (!isPrinting()) {
setSoftEndstopState(true); // disable endstops setSoftEndstopState(true); // disable endstops
@@ -786,7 +788,7 @@ void ChironTFT::PanelProcess(uint8_t req) {
if (isPositionKnown()) { if (isPositionKnown()) {
#if ACDEBUG(AC_INFO) #if ACDEBUG(AC_INFO)
SERIAL_ECHOLNPGM("Moving to mesh point at x: ", pos.x, " y: ", pos.y, " z: ", pos_z); DEBUG_ECHOLNPGM("Moving to mesh point at x: ", pos.x, " y: ", pos.y, " z: ", pos_z);
#endif #endif
// Go up before moving // Go up before moving
setAxisPosition_mm(3.0,Z); setAxisPosition_mm(3.0,Z);
@@ -795,7 +797,7 @@ void ChironTFT::PanelProcess(uint8_t req) {
setAxisPosition_mm(20 + (93 * pos.y), Y); setAxisPosition_mm(20 + (93 * pos.y), Y);
setAxisPosition_mm(0.0, Z); setAxisPosition_mm(0.0, Z);
#if ACDEBUG(AC_INFO) #if ACDEBUG(AC_INFO)
SERIAL_ECHOLNPGM("Current Z: ", getAxisPosition_mm(Z)); DEBUG_ECHOLNPGM("Current Z: ", getAxisPosition_mm(Z));
#endif #endif
} }
} }
@@ -805,24 +807,24 @@ void ChironTFT::PanelProcess(uint8_t req) {
} break; } break;
case 30: // A30 Auto leveling case 30: // A30 Auto leveling
if (FindToken('S') >= 0) { // Start probing New panel adds spaces.. if (findToken('S') >= 0) { // Start probing New panel adds spaces..
// Ignore request if printing // Ignore request if printing
if (isPrinting()) if (isPrinting())
SendtoTFTLN(AC_msg_probing_not_allowed); // forbid auto leveling tftSendLn(AC_msg_probing_not_allowed); // forbid auto leveling
else { else {
SendtoTFTLN(AC_msg_start_probing); tftSendLn(AC_msg_start_probing);
injectCommands(F("G28\nG29")); injectCommands(F("G28\nG29"));
printer_state = AC_printer_probing; printer_state = AC_printer_probing;
} }
} }
else else
SendtoTFTLN(AC_msg_start_probing); // Just enter levelling menu tftSendLn(AC_msg_start_probing); // Just enter levelling menu
break; break;
case 31: // A31 Adjust all Probe Points case 31: // A31 Adjust all Probe Points
// The tokens can occur in different places on the new panel so we need to find it. // The tokens can occur in different places on the new panel so we need to find it.
if (FindToken('C') >= 0) { // Restore and apply original offsets if (findToken('C') >= 0) { // Restore and apply original offsets
if (!isPrinting()) { if (!isPrinting()) {
injectCommands(F("M501\nM420 S1")); injectCommands(F("M501\nM420 S1"));
selectedmeshpoint.x = selectedmeshpoint.y = 99; selectedmeshpoint.x = selectedmeshpoint.y = 99;
@@ -830,7 +832,7 @@ void ChironTFT::PanelProcess(uint8_t req) {
} }
} }
else if (FindToken('D') >= 0) { // Save Z Offset tables and restore leveling state else if (findToken('D') >= 0) { // Save Z Offset tables and restore leveling state
if (!isPrinting()) { if (!isPrinting()) {
setAxisPosition_mm(1.0,Z); // Lift nozzle before any further movements are made setAxisPosition_mm(1.0,Z); // Lift nozzle before any further movements are made
injectCommands(F("M500")); injectCommands(F("M500"));
@@ -839,8 +841,8 @@ void ChironTFT::PanelProcess(uint8_t req) {
} }
} }
else if (FindToken('G') >= 0) { // Get current offset else if (findToken('G') >= 0) { // Get current offset
SendtoTFT(F("A31V ")); tftSend(F("A31V "));
// When printing use the live z Offset position // When printing use the live z Offset position
// we will use babystepping to move the print head // we will use babystepping to move the print head
if (isPrinting()) if (isPrinting())
@@ -852,7 +854,7 @@ void ChironTFT::PanelProcess(uint8_t req) {
} }
else { else {
int8_t tokenpos = FindToken('S'); int8_t tokenpos = findToken('S');
if (tokenpos >= 0) { // Set offset (adjusts all points by value) if (tokenpos >= 0) { // Set offset (adjusts all points by value)
float Zshift = atof(&panel_command[tokenpos+1]); float Zshift = atof(&panel_command[tokenpos+1]);
setSoftEndstopState(false); // disable endstops setSoftEndstopState(false); // disable endstops
@@ -860,22 +862,22 @@ void ChironTFT::PanelProcess(uint8_t req) {
// From the leveling panel use the all points UI to adjust the print pos. // From the leveling panel use the all points UI to adjust the print pos.
if (isPrinting()) { if (isPrinting()) {
#if ACDEBUG(AC_INFO) #if ACDEBUG(AC_INFO)
SERIAL_ECHOLNPGM("Change Zoffset from:", live_Zoffset, " to ", live_Zoffset + Zshift); DEBUG_ECHOLNPGM("Change Zoffset from:", live_Zoffset, " to ", live_Zoffset + Zshift);
#endif #endif
if (isAxisPositionKnown(Z)) { if (isAxisPositionKnown(Z)) {
#if ACDEBUG(AC_INFO) #if ACDEBUG(AC_INFO)
const float currZpos = getAxisPosition_mm(Z); const float currZpos = getAxisPosition_mm(Z);
SERIAL_ECHOLNPGM("Nudge Z pos from ", currZpos, " to ", currZpos + constrain(Zshift, -0.05, 0.05)); DEBUG_ECHOLNPGM("Nudge Z pos from ", currZpos, " to ", currZpos + constrain(Zshift, -0.05, 0.05));
#endif #endif
// Use babystepping to adjust the head position // Use babystepping to adjust the head position
int16_t steps = mmToWholeSteps(constrain(Zshift,-0.05,0.05), Z); int16_t steps = mmToWholeSteps(constrain(Zshift,-0.05,0.05), Z);
#if ACDEBUG(AC_INFO) #if ACDEBUG(AC_INFO)
SERIAL_ECHOLNPGM("Steps to move Z: ", steps); DEBUG_ECHOLNPGM("Steps to move Z: ", steps);
#endif #endif
babystepAxis_steps(steps, Z); babystepAxis_steps(steps, Z);
live_Zoffset += Zshift; live_Zoffset += Zshift;
} }
SendtoTFT(F("A31V ")); tftSend(F("A31V "));
TFTSer.println(live_Zoffset); TFTSer.println(live_Zoffset);
} }
else { else {
@@ -884,23 +886,23 @@ void ChironTFT::PanelProcess(uint8_t req) {
const float currval = getMeshPoint(pos); const float currval = getMeshPoint(pos);
setMeshPoint(pos, constrain(currval + Zshift, AC_LOWEST_MESHPOINT_VAL, 2)); setMeshPoint(pos, constrain(currval + Zshift, AC_LOWEST_MESHPOINT_VAL, 2));
#if ACDEBUG(AC_INFO) #if ACDEBUG(AC_INFO)
SERIAL_ECHOLNPGM("Change mesh point X", x," Y",y ," from ", currval, " to ", getMeshPoint(pos) ); DEBUG_ECHOLNPGM("Change mesh point X", x," Y",y ," from ", currval, " to ", getMeshPoint(pos) );
#endif #endif
} }
const float currZOffset = getZOffset_mm(); const float currZOffset = getZOffset_mm();
#if ACDEBUG(AC_INFO) #if ACDEBUG(AC_INFO)
SERIAL_ECHOLNPGM("Change probe offset from ", currZOffset, " to ", currZOffset + Zshift); DEBUG_ECHOLNPGM("Change probe offset from ", currZOffset, " to ", currZOffset + Zshift);
#endif #endif
setZOffset_mm(currZOffset + Zshift); setZOffset_mm(currZOffset + Zshift);
SendtoTFT(F("A31V ")); tftSend(F("A31V "));
TFTSer.println(getZOffset_mm()); TFTSer.println(getZOffset_mm());
if (isAxisPositionKnown(Z)) { if (isAxisPositionKnown(Z)) {
// Move Z axis // Move Z axis
const float currZpos = getAxisPosition_mm(Z); const float currZpos = getAxisPosition_mm(Z);
#if ACDEBUG(AC_INFO) #if ACDEBUG(AC_INFO)
SERIAL_ECHOLNPGM("Move Z pos from ", currZpos, " to ", currZpos + constrain(Zshift, -0.05, 0.05)); DEBUG_ECHOLNPGM("Move Z pos from ", currZpos, " to ", currZpos + constrain(Zshift, -0.05, 0.05));
#endif #endif
setAxisPosition_mm(currZpos+constrain(Zshift,-0.05,0.05),Z); setAxisPosition_mm(currZpos+constrain(Zshift,-0.05,0.05),Z);
} }
@@ -916,7 +918,7 @@ void ChironTFT::PanelProcess(uint8_t req) {
//TFTSer.println(); //TFTSer.println();
break; break;
// A33 firmware info request see PanelInfo() // A33 firmware info request see panelInfo()
case 34: // A34 Adjust single mesh point A34 C/S X1 Y1 V123 case 34: // A34 Adjust single mesh point A34 C/S X1 Y1 V123
if (panel_command[3] == 'C') { // Restore original offsets if (panel_command[3] == 'C') { // Restore original offsets
@@ -932,8 +934,8 @@ void ChironTFT::PanelProcess(uint8_t req) {
float currmesh = getMeshPoint(pos); float currmesh = getMeshPoint(pos);
float newval = atof(&panel_command[11])/100; float newval = atof(&panel_command[11])/100;
#if ACDEBUG(AC_INFO) #if ACDEBUG(AC_INFO)
SERIAL_ECHOLNPGM("Change mesh point x:", pos.x, " y:", pos.y); DEBUG_ECHOLNPGM("Change mesh point x:", pos.x, " y:", pos.y);
SERIAL_ECHOLNPGM("from ", currmesh, " to ", newval); DEBUG_ECHOLNPGM("from ", currmesh, " to ", newval);
#endif #endif
// Update Meshpoint // Update Meshpoint
setMeshPoint(pos,newval); setMeshPoint(pos,newval);
@@ -944,7 +946,7 @@ void ChironTFT::PanelProcess(uint8_t req) {
setSoftEndstopState(false); setSoftEndstopState(false);
float currZpos = getAxisPosition_mm(Z); float currZpos = getAxisPosition_mm(Z);
#if ACDEBUG(AC_INFO) #if ACDEBUG(AC_INFO)
SERIAL_ECHOLNPGM("Move Z pos from ", currZpos, " to ", currZpos + constrain(newval - currmesh, -0.05, 0.05)); DEBUG_ECHOLNPGM("Move Z pos from ", currZpos, " to ", currZpos + constrain(newval - currmesh, -0.05, 0.05));
#endif #endif
setAxisPosition_mm(currZpos + constrain(newval - currmesh, -0.05, 0.05), Z); setAxisPosition_mm(currZpos + constrain(newval - currmesh, -0.05, 0.05), Z);
} }
@@ -953,19 +955,19 @@ void ChironTFT::PanelProcess(uint8_t req) {
break; break;
case 36: // A36 Auto leveling for new TFT bet that was a typo in the panel code! case 36: // A36 Auto leveling for new TFT bet that was a typo in the panel code!
SendtoTFTLN(AC_msg_start_probing); tftSendLn(AC_msg_start_probing);
break; break;
} }
} }
bool ChironTFT::GetLastError() { bool ChironTFT::getLastError() {
switch (last_error) { switch (last_error) {
case AC_error_abnormal_temp_bed: SendtoTFTLN(AC_msg_error_bed_temp); break; case AC_error_abnormal_temp_bed: tftSendLn(AC_msg_error_bed_temp); break;
case AC_error_abnormal_temp_t0: SendtoTFTLN(AC_msg_error_hotend_temp); break; case AC_error_abnormal_temp_t0: tftSendLn(AC_msg_error_hotend_temp); break;
case AC_error_noSD: SendtoTFTLN(AC_msg_error_sd_card); break; case AC_error_noSD: tftSendLn(AC_msg_error_sd_card); break;
case AC_error_powerloss: SendtoTFTLN(AC_msg_power_loss); break; case AC_error_powerloss: tftSendLn(AC_msg_power_loss); break;
case AC_error_EEPROM: SendtoTFTLN(AC_msg_eeprom_version); break; case AC_error_EEPROM: tftSendLn(AC_msg_eeprom_version); break;
case AC_error_filament_runout: SendtoTFTLN(AC_msg_filament_out); break; case AC_error_filament_runout: tftSendLn(AC_msg_filament_out); break;
default: return false; default: return false;
} }
last_error = AC_error_none; last_error = AC_error_none;

View File

@@ -57,32 +57,32 @@ class ChironTFT {
static float live_Zoffset; static float live_Zoffset;
static file_menu_t file_menu; static file_menu_t file_menu;
public: public:
static void Startup(); static void startup();
static void IdleLoop(); static void idleLoop();
static void PrinterKilled(FSTR_P, FSTR_P); static void printerKilled(FSTR_P, FSTR_P);
static void MediaEvent(media_event_t); static void mediaEvent(media_event_t);
static void TimerEvent(timer_event_t); static void timerEvent(timer_event_t);
static void FilamentRunout(); static void filamentRunout();
static void ConfirmationRequest(const char * const); static void confirmationRequest(const char * const);
static void StatusChange(const char * const); static void statusChange(const char * const);
static void PowerLossRecovery(); static void powerLossRecovery();
static void PrintComplete(); static void printComplete();
static void SendtoTFT(FSTR_P const=nullptr); static void tftSend(FSTR_P const=nullptr);
static void SendtoTFTLN(FSTR_P const=nullptr); static void tftSendLn(FSTR_P const=nullptr);
private: private:
static void DetectPanelType(); static void detectPanelType();
static bool ReadTFTCommand(); static bool readTFTCommand();
static int8_t FindToken(char); static int8_t findToken(char);
static void CheckHeaters(); static void checkHeaters();
static void SendFileList(int8_t); static void sendFileList(int8_t);
static void SelectFile(); static void selectFile();
static void ProcessPanelRequest(); static void processPanelRequest();
static void PanelInfo(uint8_t); static void panelInfo(uint8_t);
static void PanelAction(uint8_t); static void panelAction(uint8_t);
static void PanelProcess(uint8_t); static void panelProcess(uint8_t);
static bool GetLastError(); static bool getLastError();
}; };
extern ChironTFT Chiron; extern ChironTFT chiron;
} // Anycubic namespace } // Anycubic namespace

View File

@@ -35,20 +35,20 @@
namespace ExtUI { namespace ExtUI {
void onStartup() { AnycubicTFT.OnSetup(); } void onStartup() { anycubicTFT.onSetup(); }
void onIdle() { AnycubicTFT.OnCommandScan(); } void onIdle() { anycubicTFT.onCommandScan(); }
void onPrinterKilled(FSTR_P const error, FSTR_P const component) { AnycubicTFT.OnKillTFT(); } void onPrinterKilled(FSTR_P const error, FSTR_P const component) { anycubicTFT.onKillTFT(); }
void onMediaInserted() { AnycubicTFT.OnSDCardStateChange(true); } void onMediaInserted() { anycubicTFT.onSDCardStateChange(true); }
void onMediaError() { AnycubicTFT.OnSDCardError(); } void onMediaError() { anycubicTFT.onSDCardError(); }
void onMediaRemoved() { AnycubicTFT.OnSDCardStateChange(false); } void onMediaRemoved() { anycubicTFT.onSDCardStateChange(false); }
void onPlayTone(const uint16_t frequency, const uint16_t duration) { void onPlayTone(const uint16_t frequency, const uint16_t duration) {
TERN_(SPEAKER, ::tone(BEEPER_PIN, frequency, duration)); TERN_(SPEAKER, ::tone(BEEPER_PIN, frequency, duration));
} }
void onPrintTimerStarted() { AnycubicTFT.OnPrintTimerStarted(); } void onPrintTimerStarted() { anycubicTFT.onPrintTimerStarted(); }
void onPrintTimerPaused() { AnycubicTFT.OnPrintTimerPaused(); } void onPrintTimerPaused() { anycubicTFT.onPrintTimerPaused(); }
void onPrintTimerStopped() { AnycubicTFT.OnPrintTimerStopped(); } void onPrintTimerStopped() { anycubicTFT.onPrintTimerStopped(); }
void onFilamentRunout(const extruder_t extruder) { AnycubicTFT.OnFilamentRunout(); } void onFilamentRunout(const extruder_t extruder) { anycubicTFT.onFilamentRunout(); }
void onUserConfirmRequired(const char * const msg) { AnycubicTFT.OnUserConfirmRequired(msg); } void onUserConfirmRequired(const char * const msg) { anycubicTFT.onUserConfirmRequired(msg); }
void onStatusChanged(const char * const msg) {} void onStatusChanged(const char * const msg) {}
void onHomingStart() {} void onHomingStart() {}

View File

@@ -24,6 +24,8 @@
#if ENABLED(ANYCUBIC_LCD_I3MEGA) #if ENABLED(ANYCUBIC_LCD_I3MEGA)
//#define ANYCUBIC_LCD_DEBUG //#define ANYCUBIC_LCD_DEBUG
#define DEBUG_OUT ANYCUBIC_LCD_DEBUG
#include "../../../core/debug_out.h"
#include "anycubic_i3mega_lcd.h" #include "anycubic_i3mega_lcd.h"
#include "../ui_api.h" #include "../ui_api.h"
@@ -40,13 +42,8 @@
#define SEND_PGM_VAL(x,y) (send_P(PSTR(x)), sendLine(i16tostr3rj(y))) #define SEND_PGM_VAL(x,y) (send_P(PSTR(x)), sendLine(i16tostr3rj(y)))
#define SEND(x) send(x) #define SEND(x) send(x)
#define SENDLINE(x) sendLine(x) #define SENDLINE(x) sendLine(x)
#if ENABLED(ANYCUBIC_LCD_DEBUG) #define SENDLINE_DBG_PGM(x,y) do{ sendLine_P(PSTR(x)); DEBUG_ECHOLNPGM(y); }while(0)
#define SENDLINE_DBG_PGM(x,y) do{ sendLine_P(PSTR(x)); SERIAL_ECHOLNPGM(y); }while(0) #define SENDLINE_DBG_PGM_VAL(x,y,z) do{ sendLine_P(PSTR(x)); DEBUG_ECHOLNPGM(y, z); }while(0)
#define SENDLINE_DBG_PGM_VAL(x,y,z) do{ sendLine_P(PSTR(x)); SERIAL_ECHOLNPGM(y, z); }while(0)
#else
#define SENDLINE_DBG_PGM(x,y) sendLine_P(PSTR(x))
#define SENDLINE_DBG_PGM_VAL(x,y,z) sendLine_P(PSTR(x))
#endif
// Append ".gcode" to filename, if requested. Used for some DGUS-clone displays with built-in filter. // Append ".gcode" to filename, if requested. Used for some DGUS-clone displays with built-in filter.
// Filenames are limited to 26 characters, so the actual name for the FILENAME can be 20 characters at most. // Filenames are limited to 26 characters, so the actual name for the FILENAME can be 20 characters at most.
@@ -54,21 +51,20 @@
#define SPECIAL_MENU_FILENAME(A) A TERN_(ANYCUBIC_LCD_GCODE_EXT, ".gcode") #define SPECIAL_MENU_FILENAME(A) A TERN_(ANYCUBIC_LCD_GCODE_EXT, ".gcode")
#define SPECIAL_MENU_ALTNAME(A, B) TERN(ANYCUBIC_LCD_GCODE_EXT, A ".gcode", B) #define SPECIAL_MENU_ALTNAME(A, B) TERN(ANYCUBIC_LCD_GCODE_EXT, A ".gcode", B)
AnycubicTFTClass AnycubicTFT; AnycubicTFTClass anycubicTFT;
char AnycubicTFTClass::TFTcmdbuffer[TFTBUFSIZE][TFT_MAX_CMD_SIZE]; char AnycubicTFTClass::tftCommands[TFTBUFSIZE][TFT_MAX_CMD_SIZE];
int AnycubicTFTClass::TFTbuflen = 0, int AnycubicTFTClass::tftBufLen = 0,
AnycubicTFTClass::TFTbufindr = 0, AnycubicTFTClass::tftBufIndR = 0,
AnycubicTFTClass::TFTbufindw = 0; AnycubicTFTClass::tftBufIndW = 0;
char AnycubicTFTClass::serial3_char; char AnycubicTFTClass::serial3_char;
int AnycubicTFTClass::serial3_count = 0; char* AnycubicTFTClass::tftStrchrPtr;
char* AnycubicTFTClass::TFTstrchr_pointer; uint8_t AnycubicTFTClass::specialMenu = false;
uint8_t AnycubicTFTClass::SpecialMenu = false;
AnycubicMediaPrintState AnycubicTFTClass::mediaPrintingState = AMPRINTSTATE_NOT_PRINTING; AnycubicMediaPrintState AnycubicTFTClass::mediaPrintingState = AMPRINTSTATE_NOT_PRINTING;
AnycubicMediaPauseState AnycubicTFTClass::mediaPauseState = AMPAUSESTATE_NOT_PAUSED; AnycubicMediaPauseState AnycubicTFTClass::mediaPauseState = AMPAUSESTATE_NOT_PAUSED;
char AnycubicTFTClass::SelectedDirectory[30]; char AnycubicTFTClass::selectedDirectory[30];
char AnycubicTFTClass::SelectedFile[FILENAME_LENGTH]; char AnycubicTFTClass::selectedFile[FILENAME_LENGTH];
// Serial helpers // Serial helpers
static void sendNewLine() { LCD_SERIAL.write('\r'); LCD_SERIAL.write('\n'); } static void sendNewLine() { LCD_SERIAL.write('\r'); LCD_SERIAL.write('\n'); }
@@ -84,7 +80,7 @@ using namespace ExtUI;
AnycubicTFTClass::AnycubicTFTClass() {} AnycubicTFTClass::AnycubicTFTClass() {}
void AnycubicTFTClass::OnSetup() { void AnycubicTFTClass::onSetup() {
#ifndef LCD_BAUDRATE #ifndef LCD_BAUDRATE
#define LCD_BAUDRATE 115200 #define LCD_BAUDRATE 115200
#endif #endif
@@ -94,9 +90,6 @@ void AnycubicTFTClass::OnSetup() {
delay_ms(10); delay_ms(10);
// Init the state of the key pins running on the TFT // Init the state of the key pins running on the TFT
#if BOTH(HAS_MEDIA, HAS_SD_DETECT)
SET_INPUT_PULLUP(SD_DETECT_PIN);
#endif
#if ENABLED(FILAMENT_RUNOUT_SENSOR) #if ENABLED(FILAMENT_RUNOUT_SENSOR)
SET_INPUT_PULLUP(FIL_RUNOUT1_PIN); SET_INPUT_PULLUP(FIL_RUNOUT1_PIN);
#endif #endif
@@ -104,30 +97,26 @@ void AnycubicTFTClass::OnSetup() {
mediaPrintingState = AMPRINTSTATE_NOT_PRINTING; mediaPrintingState = AMPRINTSTATE_NOT_PRINTING;
mediaPauseState = AMPAUSESTATE_NOT_PAUSED; mediaPauseState = AMPAUSESTATE_NOT_PAUSED;
// DoSDCardStateCheck(); // doSDCardStateCheck();
SENDLINE_DBG_PGM("J12", "TFT Serial Debug: Ready... J12"); // J12 Ready SENDLINE_DBG_PGM("J12", "TFT Serial Debug: Ready... J12"); // J12 Ready
delay_ms(10); delay_ms(10);
DoFilamentRunoutCheck(); doFilamentRunoutCheck();
SelectedFile[0] = 0; selectedFile[0] = 0;
#if ENABLED(STARTUP_CHIME) #if ENABLED(STARTUP_CHIME)
injectCommands(F("M300 P250 S554\nM300 P250 S554\nM300 P250 S740\nM300 P250 S554\nM300 P250 S740\nM300 P250 S554\nM300 P500 S831")); injectCommands(F("M300 P250 S554\nM300 P250 S554\nM300 P250 S740\nM300 P250 S554\nM300 P250 S740\nM300 P250 S554\nM300 P500 S831"));
#endif #endif
#if ENABLED(ANYCUBIC_LCD_DEBUG) DEBUG_ECHOLNPGM("TFT Serial Debug: Finished startup");
SERIAL_ECHOLNPGM("TFT Serial Debug: Finished startup");
#endif
} }
void AnycubicTFTClass::OnCommandScan() { void AnycubicTFTClass::onCommandScan() {
static millis_t nextStopCheck = 0; // used to slow the stopped print check down to reasonable times static millis_t nextStopCheck = 0; // used to slow the stopped print check down to reasonable times
const millis_t ms = millis(); const millis_t ms = millis();
if (ELAPSED(ms, nextStopCheck)) { if (ELAPSED(ms, nextStopCheck)) {
nextStopCheck = ms + 1000UL; nextStopCheck = ms + 1000UL;
if (mediaPrintingState == AMPRINTSTATE_STOP_REQUESTED && IsNozzleHomed()) { if (mediaPrintingState == AMPRINTSTATE_STOP_REQUESTED && isNozzleHomed()) {
#if ENABLED(ANYCUBIC_LCD_DEBUG) DEBUG_ECHOLNPGM("TFT Serial Debug: Finished stopping print, releasing motors ...");
SERIAL_ECHOLNPGM("TFT Serial Debug: Finished stopping print, releasing motors ...");
#endif
mediaPrintingState = AMPRINTSTATE_NOT_PRINTING; mediaPrintingState = AMPRINTSTATE_NOT_PRINTING;
mediaPauseState = AMPAUSESTATE_NOT_PAUSED; mediaPauseState = AMPAUSESTATE_NOT_PAUSED;
injectCommands(F("M84\nM27")); // disable stepper motors and force report of SD status injectCommands(F("M84\nM27")); // disable stepper motors and force report of SD status
@@ -137,44 +126,36 @@ void AnycubicTFTClass::OnCommandScan() {
} }
} }
if (TFTbuflen < (TFTBUFSIZE - 1)) if (tftBufLen < (TFTBUFSIZE) - 1)
GetCommandFromTFT(); getCommandFromTFT();
if (TFTbuflen) { if (tftBufLen) {
TFTbuflen = (TFTbuflen - 1); --tftBufLen;
TFTbufindr = (TFTbufindr + 1) % TFTBUFSIZE; tftBufIndR = (tftBufIndR + 1) % (TFTBUFSIZE);
} }
} }
void AnycubicTFTClass::OnKillTFT() { void AnycubicTFTClass::onKillTFT() {
SENDLINE_DBG_PGM("J11", "TFT Serial Debug: Kill command... J11"); SENDLINE_DBG_PGM("J11", "TFT Serial Debug: Kill command... J11");
} }
void AnycubicTFTClass::OnSDCardStateChange(bool isInserted) { void AnycubicTFTClass::onSDCardStateChange(bool isInserted) {
#if ENABLED(ANYCUBIC_LCD_DEBUG) DEBUG_ECHOLNPGM("TFT Serial Debug: onSDCardStateChange event triggered...", isInserted);
SERIAL_ECHOLNPGM("TFT Serial Debug: OnSDCardStateChange event triggered...", isInserted); doSDCardStateCheck();
#endif
DoSDCardStateCheck();
} }
void AnycubicTFTClass::OnSDCardError() { void AnycubicTFTClass::onSDCardError() {
#if ENABLED(ANYCUBIC_LCD_DEBUG) DEBUG_ECHOLNPGM("TFT Serial Debug: onSDCardError event triggered...");
SERIAL_ECHOLNPGM("TFT Serial Debug: OnSDCardError event triggered...");
#endif
SENDLINE_DBG_PGM("J21", "TFT Serial Debug: On SD Card Error ... J21"); SENDLINE_DBG_PGM("J21", "TFT Serial Debug: On SD Card Error ... J21");
} }
void AnycubicTFTClass::OnFilamentRunout() { void AnycubicTFTClass::onFilamentRunout() {
#if ENABLED(ANYCUBIC_LCD_DEBUG) DEBUG_ECHOLNPGM("TFT Serial Debug: onFilamentRunout triggered...");
SERIAL_ECHOLNPGM("TFT Serial Debug: FilamentRunout triggered..."); doFilamentRunoutCheck();
#endif
DoFilamentRunoutCheck();
} }
void AnycubicTFTClass::OnUserConfirmRequired(const char * const msg) { void AnycubicTFTClass::onUserConfirmRequired(const char * const msg) {
#if ENABLED(ANYCUBIC_LCD_DEBUG) DEBUG_ECHOLNPGM("TFT Serial Debug: onUserConfirmRequired triggered... ", msg);
SERIAL_ECHOLNPGM("TFT Serial Debug: OnUserConfirmRequired triggered... ", msg);
#endif
#if HAS_MEDIA #if HAS_MEDIA
/** /**
@@ -225,190 +206,188 @@ void AnycubicTFTClass::OnUserConfirmRequired(const char * const msg) {
#endif #endif
} }
float AnycubicTFTClass::CodeValue() { float AnycubicTFTClass::codeValue() {
return (strtod(&TFTcmdbuffer[TFTbufindr][TFTstrchr_pointer - TFTcmdbuffer[TFTbufindr] + 1], nullptr)); return (strtod(&tftCommands[tftBufIndR][tftStrchrPtr - tftCommands[tftBufIndR] + 1], nullptr));
} }
bool AnycubicTFTClass::CodeSeen(char code) { bool AnycubicTFTClass::codeSeen(char code) {
TFTstrchr_pointer = strchr(TFTcmdbuffer[TFTbufindr], code); tftStrchrPtr = strchr(tftCommands[tftBufIndR], code);
return !!TFTstrchr_pointer; // Return True if a character was found return !!tftStrchrPtr; // Return True if a character was found
} }
bool AnycubicTFTClass::IsNozzleHomed() { bool AnycubicTFTClass::isNozzleHomed() {
const float xPosition = getAxisPosition_mm((axis_t) X); const float xPosition = getAxisPosition_mm((axis_t) X);
const float yPosition = getAxisPosition_mm((axis_t) Y); const float yPosition = getAxisPosition_mm((axis_t) Y);
return WITHIN(xPosition, X_MIN_POS - 0.1, X_MIN_POS + 0.1) && return WITHIN(xPosition, X_MIN_POS - 0.1, X_MIN_POS + 0.1) &&
WITHIN(yPosition, Y_MIN_POS - 0.1, Y_MIN_POS + 0.1); WITHIN(yPosition, Y_MIN_POS - 0.1, Y_MIN_POS + 0.1);
} }
void AnycubicTFTClass::HandleSpecialMenu() { void AnycubicTFTClass::handleSpecialMenu() {
/** /**
* NOTE: that the file selection command actual lowercases the entire selected file/foldername, so charracter comparisons need to be lowercase. * NOTE: that the file selection command actual lowercases the entire selected file/foldername, so charracter comparisons need to be lowercase.
*/ */
if (SelectedDirectory[0] == '<') { if (selectedDirectory[0] != '<') {
switch (SelectedDirectory[1]) { DEBUG_ECHOLNPGM("TFT Serial Debug: Attempted to handleSpecialMenu on non-special menu... ", selectedDirectory);
case 'e': // "<exit>"
SpecialMenu = false;
return; return;
break; }
switch (selectedDirectory[1]) {
default: break;
case 'e': specialMenu = false; return; // "<exit>"
#if ENABLED(PROBE_MANUALLY) #if ENABLED(PROBE_MANUALLY)
case '0': case '0':
switch (SelectedDirectory[2]) { switch (selectedDirectory[2]) {
default: break;
case '1': // "<01ZUp0.1>" case '1': // "<01ZUp0.1>"
SERIAL_ECHOLNPGM("Special Menu: Z Up 0.1"); SERIAL_ECHOLNPGM("Special Menu: ", F("Z Up 0.1"));
injectCommands(F("G91\nG1 Z+0.1\nG90")); injectCommands(F("G91\nG1 Z+0.1\nG90"));
break; break;
case '2': // "<02ZUp0.02>" case '2': // "<02ZUp0.02>"
SERIAL_ECHOLNPGM("Special Menu: Z Up 0.02"); SERIAL_ECHOLNPGM("Special Menu: ", F("Z Up 0.02"));
injectCommands(F("G91\nG1 Z+0.02\nG90")); injectCommands(F("G91\nG1 Z+0.02\nG90"));
break; break;
case '3': // "<03ZDn0.02>" case '3': // "<03ZDn0.02>"
SERIAL_ECHOLNPGM("Special Menu: Z Down 0.02"); SERIAL_ECHOLNPGM("Special Menu: ", F("Z Down 0.02"));
injectCommands(F("G91\nG1 Z-0.02\nG90")); injectCommands(F("G91\nG1 Z-0.02\nG90"));
break; break;
case '4': // "<04ZDn0.1>" case '4': // "<04ZDn0.1>"
SERIAL_ECHOLNPGM("Special Menu: Z Down 0.1"); SERIAL_ECHOLNPGM("Special Menu: ", F("Z Down 0.1"));
injectCommands(F("G91\nG1 Z-0.1\nG90")); injectCommands(F("G91\nG1 Z-0.1\nG90"));
break; break;
case '5': // "<05PrehtBed>" case '5': // "<05PrehtBed>"
SERIAL_ECHOLNPGM("Special Menu: Preheat Bed"); SERIAL_ECHOLNPGM("Special Menu: ", F("Preheat Bed"));
injectCommands(F("M140 S65")); injectCommands(F("M140 S65"));
break; break;
case '6': // "<06SMeshLvl>" case '6': // "<06SMeshLvl>"
SERIAL_ECHOLNPGM("Special Menu: Start Mesh Leveling"); SERIAL_ECHOLNPGM("Special Menu: ", F("Start Mesh Leveling"));
injectCommands(F("G29S1")); injectCommands(F("G29S1"));
break; break;
case '7': // "<07MeshNPnt>" case '7': // "<07MeshNPnt>"
SERIAL_ECHOLNPGM("Special Menu: Next Mesh Point"); SERIAL_ECHOLNPGM("Special Menu: ", F("Next Mesh Point"));
injectCommands(F("G29S2")); injectCommands(F("G29S2"));
break; break;
case '8': // "<08HtEndPID>" case '8': // "<08HtEndPID>"
SERIAL_ECHOLNPGM("Special Menu: Auto Tune Hotend PID"); SERIAL_ECHOLNPGM("Special Menu: ", F("Auto Tune Hotend PID"));
// need to dwell for half a second to give the fan a chance to start before the pid tuning starts // need to dwell for half a second to give the fan a chance to start before the pid tuning starts
injectCommands(F("M106 S204\nG4 P500\nM303 E0 S215 C15 U1")); injectCommands(F("M106 S204\nG4 P500\nM303 E0 S215 C15 U1"));
break; break;
case '9': // "<09HtBedPID>" case '9': // "<09HtBedPID>"
SERIAL_ECHOLNPGM("Special Menu: Auto Tune Hotbed Pid"); SERIAL_ECHOLNPGM("Special Menu: ", F("Auto Tune Hotbed Pid"));
injectCommands(F("M303 E-1 S65 C6 U1")); injectCommands(F("M303 E-1 S65 C6 U1"));
break; break;
default:
break;
} }
break; break;
case '1': case '1':
switch (SelectedDirectory[2]) { switch (selectedDirectory[2]) {
default: break;
case '0': // "<10FWDeflts>" case '0': // "<10FWDeflts>"
SERIAL_ECHOLNPGM("Special Menu: Load FW Defaults"); SERIAL_ECHOLNPGM("Special Menu: ", F("Load FW Defaults"));
injectCommands(F("M502\nM300 P105 S1661\nM300 P210 S1108")); injectCommands(F("M502\nM300 P105 S1661\nM300 P210 S1108"));
break; break;
case '1': // "<11SvEEPROM>" case '1': // "<11SvEEPROM>"
SERIAL_ECHOLNPGM("Special Menu: Save EEPROM"); SERIAL_ECHOLNPGM("Special Menu: ", F("Save EEPROM"));
injectCommands(F("M500\nM300 P105 S1108\nM300 P210 S1661")); injectCommands(F("M500\nM300 P105 S1108\nM300 P210 S1661"));
break; break;
default:
break;
} }
break; break;
#else // if ENABLED(PROBE_MANUALLY)
#else // !PROBE_MANUALLY
case '0': case '0':
switch (SelectedDirectory[2]) { switch (selectedDirectory[2]) {
default: break;
case '1': // "<01PrehtBed>" case '1': // "<01PrehtBed>"
SERIAL_ECHOLNPGM("Special Menu: Preheat Bed"); SERIAL_ECHOLNPGM("Special Menu: ", F("Preheat Bed"));
injectCommands(F("M140 S65")); injectCommands(F("M140 S65"));
break; break;
case '2': // "<02ABL>" case '2': // "<02ABL>"
SERIAL_ECHOLNPGM("Special Menu: Auto Bed Leveling"); SERIAL_ECHOLNPGM("Special Menu: ", F("Auto Bed Leveling"));
injectCommands(F("G29N")); injectCommands(F("G29N"));
break; break;
case '3': // "<03HtendPID>" case '3': // "<03HtendPID>"
SERIAL_ECHOLNPGM("Special Menu: Auto Tune Hotend PID"); SERIAL_ECHOLNPGM("Special Menu: ", F("Auto Tune Hotend PID"));
// need to dwell for half a second to give the fan a chance to start before the pid tuning starts // need to dwell for half a second to give the fan a chance to start before the pid tuning starts
injectCommands(F("M106 S204\nG4 P500\nM303 E0 S215 C15 U1")); injectCommands(F("M106 S204\nG4 P500\nM303 E0 S215 C15 U1"));
break; break;
case '4': // "<04HtbedPID>" case '4': // "<04HtbedPID>"
SERIAL_ECHOLNPGM("Special Menu: Auto Tune Hotbed Pid"); SERIAL_ECHOLNPGM("Special Menu: ", F("Auto Tune Hotbed Pid"));
injectCommands(F("M303 E-1 S65 C6 U1")); injectCommands(F("M303 E-1 S65 C6 U1"));
break; break;
case '5': // "<05FWDeflts>" case '5': // "<05FWDeflts>"
SERIAL_ECHOLNPGM("Special Menu: Load FW Defaults"); SERIAL_ECHOLNPGM("Special Menu: ", F("Load FW Defaults"));
injectCommands(F("M502\nM300 P105 S1661\nM300 P210 S1108")); injectCommands(F("M502\nM300 P105 S1661\nM300 P210 S1108"));
break; break;
case '6': // "<06SvEEPROM>" case '6': // "<06SvEEPROM>"
SERIAL_ECHOLNPGM("Special Menu: Save EEPROM"); SERIAL_ECHOLNPGM("Special Menu: ", F("Save EEPROM"));
injectCommands(F("M500\nM300 P105 S1108\nM300 P210 S1661")); injectCommands(F("M500\nM300 P105 S1108\nM300 P210 S1661"));
break; break;
case '7': // <07SendM108> case '7': // <07SendM108>
SERIAL_ECHOLNPGM("Special Menu: Send User Confirmation"); SERIAL_ECHOLNPGM("Special Menu: ", F("Send User Confirmation"));
injectCommands(F("M108")); injectCommands(F("M108"));
break; break;
default:
break;
} }
break; break;
#endif // PROBE_MANUALLY
default: #endif // !PROBE_MANUALLY
break;
}
#if ENABLED(ANYCUBIC_LCD_DEBUG)
}
else {
SERIAL_ECHOPGM("TFT Serial Debug: Attempted to HandleSpecialMenu on non-special menu... ");
SERIAL_ECHOLN(SelectedDirectory);
#endif
}
} }
void AnycubicTFTClass::RenderCurrentFileList() { }
void AnycubicTFTClass::renderCurrentFileList() {
#if HAS_MEDIA #if HAS_MEDIA
uint16_t selectedNumber = 0; uint16_t selectedNumber = 0;
SelectedDirectory[0] = 0; selectedDirectory[0] = 0;
SelectedFile[0] = 0; selectedFile[0] = 0;
FileList currentFileList; FileList currentFileList;
SENDLINE_PGM("FN "); // Filelist start SENDLINE_PGM("FN "); // Filelist start
if (!isMediaInserted() && !SpecialMenu) { if (!isMediaInserted() && !specialMenu) {
SENDLINE_DBG_PGM("J02", "TFT Serial Debug: No SD Card mounted to render Current File List... J02"); SENDLINE_DBG_PGM("J02", "TFT Serial Debug: No SD Card mounted to render Current File List... J02");
SENDLINE_PGM("<SPECI~1.GCO"); SENDLINE_PGM("<SPECI~1.GCO");
SENDLINE_PGM(SPECIAL_MENU_FILENAME("<Special Menu>")); SENDLINE_PGM(SPECIAL_MENU_FILENAME("<Special Menu>"));
} }
else { else {
if (CodeSeen('S')) if (codeSeen('S'))
selectedNumber = CodeValue(); selectedNumber = codeValue();
if (SpecialMenu) if (specialMenu)
RenderSpecialMenu(selectedNumber); renderSpecialMenu(selectedNumber);
else if (selectedNumber <= currentFileList.count()) else if (selectedNumber <= currentFileList.count())
RenderCurrentFolder(selectedNumber); renderCurrentFolder(selectedNumber);
} }
SENDLINE_PGM("END"); // Filelist stop SENDLINE_PGM("END"); // Filelist stop
#endif // HAS_MEDIA #endif // HAS_MEDIA
} }
void AnycubicTFTClass::RenderSpecialMenu(uint16_t selectedNumber) { void AnycubicTFTClass::renderSpecialMenu(uint16_t selectedNumber) {
switch (selectedNumber) { switch (selectedNumber) {
default: break;
#if ENABLED(PROBE_MANUALLY) #if ENABLED(PROBE_MANUALLY)
case 0: // First Page case 0: // First Page
SENDLINE_PGM("<01ZUP~1.GCO"); SENDLINE_PGM("<01ZUP~1.GCO");
@@ -442,7 +421,9 @@ void AnycubicTFTClass::RenderSpecialMenu(uint16_t selectedNumber) {
SENDLINE_PGM("<EXIT_~1.GCO"); SENDLINE_PGM("<EXIT_~1.GCO");
SENDLINE_PGM(SPECIAL_MENU_FILENAME("<Exit>")); SENDLINE_PGM(SPECIAL_MENU_FILENAME("<Exit>"));
break; break;
#else
#else // !PROBE_MANUALLY
case 0: // First Page case 0: // First Page
SENDLINE_PGM("<01PRE~1.GCO"); SENDLINE_PGM("<01PRE~1.GCO");
SENDLINE_PGM(SPECIAL_MENU_FILENAME("<Preheat Bed>")); SENDLINE_PGM(SPECIAL_MENU_FILENAME("<Preheat Bed>"));
@@ -465,25 +446,16 @@ void AnycubicTFTClass::RenderSpecialMenu(uint16_t selectedNumber) {
SENDLINE_PGM(SPECIAL_MENU_FILENAME("<Exit>")); SENDLINE_PGM(SPECIAL_MENU_FILENAME("<Exit>"));
break; break;
#endif // PROBE_MANUALLY #endif // !PROBE_MANUALLY
default:
break;
} }
} }
void AnycubicTFTClass::RenderCurrentFolder(uint16_t selectedNumber) { void AnycubicTFTClass::renderCurrentFolder(uint16_t selectedNumber) {
FileList currentFileList; FileList currentFileList;
uint16_t cnt = selectedNumber; const uint16_t dir_files = currentFileList.count(),
uint16_t max_files; max_files = (dir_files - selectedNumber) < 4 ? dir_files : selectedNumber + 3;
uint16_t dir_files = currentFileList.count();
if ((dir_files - selectedNumber) < 4) for (uint16_t cnt = selectedNumber; cnt <= max_files; cnt++) {
max_files = dir_files;
else
max_files = selectedNumber + 3;
for (cnt = selectedNumber; cnt <= max_files; cnt++) {
if (cnt == 0) { // Special Entry if (cnt == 0) { // Special Entry
if (currentFileList.isAtRootDir()) { if (currentFileList.isAtRootDir()) {
SENDLINE_PGM("<SPECI~1.GCO"); SENDLINE_PGM("<SPECI~1.GCO");
@@ -497,9 +469,7 @@ void AnycubicTFTClass::RenderCurrentFolder(uint16_t selectedNumber) {
else { else {
currentFileList.seek(cnt - 1, false); currentFileList.seek(cnt - 1, false);
#if ENABLED(ANYCUBIC_LCD_DEBUG) DEBUG_ECHOLN(currentFileList.filename());
SERIAL_ECHOLN(currentFileList.filename());
#endif
if (currentFileList.isDir()) { if (currentFileList.isDir()) {
SEND_PGM("/"); SEND_PGM("/");
SENDLINE(currentFileList.shortFilename()); SENDLINE(currentFileList.shortFilename());
@@ -515,15 +485,14 @@ void AnycubicTFTClass::RenderCurrentFolder(uint16_t selectedNumber) {
} }
} }
void AnycubicTFTClass::OnPrintTimerStarted() { void AnycubicTFTClass::onPrintTimerStarted() {
#if HAS_MEDIA #if HAS_MEDIA
if (mediaPrintingState == AMPRINTSTATE_PRINTING) if (mediaPrintingState == AMPRINTSTATE_PRINTING)
SENDLINE_DBG_PGM("J04", "TFT Serial Debug: Starting SD Print... J04"); // J04 Starting Print SENDLINE_DBG_PGM("J04", "TFT Serial Debug: Starting SD Print... J04"); // J04 Starting Print
#endif #endif
} }
void AnycubicTFTClass::OnPrintTimerPaused() { void AnycubicTFTClass::onPrintTimerPaused() {
#if HAS_MEDIA #if HAS_MEDIA
if (isPrintingFromMedia()) { if (isPrintingFromMedia()) {
mediaPrintingState = AMPRINTSTATE_PAUSED; mediaPrintingState = AMPRINTSTATE_PAUSED;
@@ -532,7 +501,7 @@ void AnycubicTFTClass::OnPrintTimerPaused() {
#endif #endif
} }
void AnycubicTFTClass::OnPrintTimerStopped() { void AnycubicTFTClass::onPrintTimerStopped() {
#if HAS_MEDIA #if HAS_MEDIA
if (mediaPrintingState == AMPRINTSTATE_PRINTING) { if (mediaPrintingState == AMPRINTSTATE_PRINTING) {
mediaPrintingState = AMPRINTSTATE_NOT_PRINTING; mediaPrintingState = AMPRINTSTATE_NOT_PRINTING;
@@ -545,29 +514,29 @@ void AnycubicTFTClass::OnPrintTimerStopped() {
#define ROUND(val) int((val)+0.5f) #define ROUND(val) int((val)+0.5f)
void AnycubicTFTClass::GetCommandFromTFT() { void AnycubicTFTClass::getCommandFromTFT() {
static int serial_count = 0;
char *starpos = nullptr; char *starpos = nullptr;
while (LCD_SERIAL.available() > 0 && TFTbuflen < TFTBUFSIZE) { while (LCD_SERIAL.available() > 0 && tftBufLen < (TFTBUFSIZE)) {
serial3_char = LCD_SERIAL.read(); char c = LCD_SERIAL.read();
if (serial3_char == '\n' || if (c != '\n' && c != '\r' && c != ':' && serial_count < (TFT_MAX_CMD_SIZE - 1)) {
serial3_char == '\r' || tftCommands[tftBufIndW][serial_count++] = c;
serial3_char == ':' || continue;
serial3_count >= (TFT_MAX_CMD_SIZE - 1) }
) {
if (!serial3_count) return; // if empty line if (!serial_count) return; // if empty line
TFTcmdbuffer[TFTbufindw][serial3_count] = 0; // terminate string tftCommands[tftBufIndW][serial_count] = 0; // terminate string
if ((strchr(TFTcmdbuffer[TFTbufindw], 'A') != nullptr)) { if ((strchr(tftCommands[tftBufIndW], 'A') != nullptr)) {
int16_t a_command; int16_t a_command;
TFTstrchr_pointer = strchr(TFTcmdbuffer[TFTbufindw], 'A'); tftStrchrPtr = strchr(tftCommands[tftBufIndW], 'A');
a_command = ((int)((strtod(&TFTcmdbuffer[TFTbufindw][TFTstrchr_pointer - TFTcmdbuffer[TFTbufindw] + 1], nullptr)))); a_command = ((int)((strtod(&tftCommands[tftBufIndW][tftStrchrPtr - tftCommands[tftBufIndW] + 1], nullptr))));
#if ENABLED(ANYCUBIC_LCD_DEBUG) if (a_command > 7 && a_command != 20) { // No debugging of status polls, please!
if ((a_command > 7) && (a_command != 20)) // No debugging of status polls, please! DEBUG_ECHOLNPGM("TFT Serial Command: ", tftCommands[tftBufIndW]);
SERIAL_ECHOLNPGM("TFT Serial Command: ", TFTcmdbuffer[TFTbufindw]); }
#endif
switch (a_command) { switch (a_command) {
case 0: { // A0 GET HOTEND TEMP case 0: { // A0 GET HOTEND TEMP
@@ -638,27 +607,24 @@ void AnycubicTFTClass::GetCommandFromTFT() {
case 8: // A8 GET SD LIST case 8: // A8 GET SD LIST
#if HAS_MEDIA #if HAS_MEDIA
SelectedFile[0] = 0; selectedFile[0] = 0;
RenderCurrentFileList(); renderCurrentFileList();
#endif #endif
break; break;
case 9: // A9 pause sd print case 9: // A9 pause sd print
#if HAS_MEDIA TERN_(HAS_MEDIA, if (isPrintingFromMedia()) pausePrint());
if (isPrintingFromMedia())
PausePrint();
#endif
break; break;
case 10: // A10 resume sd print case 10: // A10 resume sd print
#if HAS_MEDIA #if HAS_MEDIA
if (isPrintingFromMediaPaused()) if (isPrintingFromMediaPaused())
ResumePrint(); resumePrint();
#endif #endif
break; break;
case 11: // A11 STOP SD PRINT case 11: // A11 STOP SD PRINT
TERN_(HAS_MEDIA, StopPrint()); TERN_(HAS_MEDIA, stopPrint());
break; break;
case 12: // A12 kill case 12: // A12 kill
@@ -668,27 +634,27 @@ void AnycubicTFTClass::GetCommandFromTFT() {
case 13: // A13 SELECTION FILE case 13: // A13 SELECTION FILE
#if HAS_MEDIA #if HAS_MEDIA
if (isMediaInserted()) { if (isMediaInserted()) {
starpos = (strchr(TFTstrchr_pointer + 4, '*')); starpos = (strchr(tftStrchrPtr + 4, '*'));
if (TFTstrchr_pointer[4] == '/') { if (tftStrchrPtr[4] == '/') {
strcpy(SelectedDirectory, TFTstrchr_pointer + 5); strcpy(selectedDirectory, tftStrchrPtr + 5);
SelectedFile[0] = 0; selectedFile[0] = 0;
SENDLINE_DBG_PGM("J21", "TFT Serial Debug: Clear file selection... J21 "); // J21 Not File Selected SENDLINE_DBG_PGM("J21", "TFT Serial Debug: Clear file selection... J21 "); // J21 Not File Selected
SENDLINE_PGM(""); SENDLINE_PGM("");
} }
else if (TFTstrchr_pointer[4] == '<') { else if (tftStrchrPtr[4] == '<') {
strcpy(SelectedDirectory, TFTstrchr_pointer + 4); strcpy(selectedDirectory, tftStrchrPtr + 4);
SpecialMenu = true; specialMenu = true;
SelectedFile[0] = 0; selectedFile[0] = 0;
SENDLINE_DBG_PGM("J21", "TFT Serial Debug: Clear file selection... J21 "); // J21 Not File Selected SENDLINE_DBG_PGM("J21", "TFT Serial Debug: Clear file selection... J21 "); // J21 Not File Selected
SENDLINE_PGM(""); SENDLINE_PGM("");
} }
else { else {
SelectedDirectory[0] = 0; selectedDirectory[0] = 0;
if (starpos) *(starpos - 1) = '\0'; if (starpos) *(starpos - 1) = '\0';
strcpy(SelectedFile, TFTstrchr_pointer + 4); strcpy(selectedFile, tftStrchrPtr + 4);
SENDLINE_DBG_PGM_VAL("J20", "TFT Serial Debug: File Selected... J20 ", SelectedFile); // J20 File Selected SENDLINE_DBG_PGM_VAL("J20", "TFT Serial Debug: File Selected... J20 ", selectedFile); // J20 File Selected
} }
} }
#endif #endif
@@ -696,8 +662,8 @@ void AnycubicTFTClass::GetCommandFromTFT() {
case 14: // A14 START PRINTING case 14: // A14 START PRINTING
#if HAS_MEDIA #if HAS_MEDIA
if (!isPrinting() && strlen(SelectedFile) > 0) if (!isPrinting() && strlen(selectedFile) > 0)
StartPrint(); startPrint();
#endif #endif
break; break;
@@ -707,14 +673,14 @@ void AnycubicTFTClass::GetCommandFromTFT() {
case 16: { // A16 set hotend temp case 16: { // A16 set hotend temp
uint16_t tempvalue; uint16_t tempvalue;
if (CodeSeen('S')) { if (codeSeen('S')) {
tempvalue = constrain(CodeValue(), 0, 275); tempvalue = constrain(codeValue(), 0, 275);
setTargetTemp_celsius(tempvalue, (extruder_t)E0); setTargetTemp_celsius(tempvalue, (extruder_t)E0);
} }
else if (CodeSeen('C') && !isPrinting()) { else if (codeSeen('C') && !isPrinting()) {
if (getAxisPosition_mm(Z) < 10) if (getAxisPosition_mm(Z) < 10)
injectCommands(F("G1 Z10")); // RASE Z AXIS injectCommands(F("G1 Z10")); // RASE Z AXIS
tempvalue = constrain(CodeValue(), 0, 275); tempvalue = constrain(codeValue(), 0, 275);
setTargetTemp_celsius(tempvalue, (extruder_t)E0); setTargetTemp_celsius(tempvalue, (extruder_t)E0);
} }
} }
@@ -722,8 +688,8 @@ void AnycubicTFTClass::GetCommandFromTFT() {
case 17: { // A17 set heated bed temp case 17: { // A17 set heated bed temp
uint16_t tempbed; uint16_t tempbed;
if (CodeSeen('S')) { if (codeSeen('S')) {
tempbed = constrain(CodeValue(), 0, 100); tempbed = constrain(codeValue(), 0, 100);
setTargetTemp_celsius(tempbed, (heater_t)BED); setTargetTemp_celsius(tempbed, (heater_t)BED);
} }
} }
@@ -731,8 +697,8 @@ void AnycubicTFTClass::GetCommandFromTFT() {
case 18: { // A18 set fan speed case 18: { // A18 set fan speed
float fanPercent; float fanPercent;
if (CodeSeen('S')) { if (codeSeen('S')) {
fanPercent = CodeValue(); fanPercent = codeValue();
fanPercent = constrain(fanPercent, 0, 100); fanPercent = constrain(fanPercent, 0, 100);
setTargetFan_percent(fanPercent, FAN0); setTargetFan_percent(fanPercent, FAN0);
} }
@@ -754,23 +720,23 @@ void AnycubicTFTClass::GetCommandFromTFT() {
break; break;
case 20: // A20 read printing speed case 20: // A20 read printing speed
if (CodeSeen('S')) if (codeSeen('S'))
feedrate_percentage = constrain(CodeValue(), 40, 999); feedrate_percentage = constrain(codeValue(), 40, 999);
else else
SEND_PGM_VAL("A20V ", feedrate_percentage); SEND_PGM_VAL("A20V ", feedrate_percentage);
break; break;
case 21: // A21 all home case 21: // A21 all home
if (!isPrinting() && !isPrintingFromMediaPaused()) { if (!isPrinting() && !isPrintingFromMediaPaused()) {
if (CodeSeen('X') || CodeSeen('Y') || CodeSeen('Z')) { if (codeSeen('X') || codeSeen('Y') || codeSeen('Z')) {
if (CodeSeen('X')) if (codeSeen('X'))
injectCommands(F("G28X")); injectCommands(F("G28X"));
if (CodeSeen('Y')) if (codeSeen('Y'))
injectCommands(F("G28Y")); injectCommands(F("G28Y"));
if (CodeSeen('Z')) if (codeSeen('Z'))
injectCommands(F("G28Z")); injectCommands(F("G28Z"));
} }
else if (CodeSeen('C')) { else if (codeSeen('C')) {
injectCommands_P(G28_STR); injectCommands_P(G28_STR);
} }
} }
@@ -784,11 +750,11 @@ void AnycubicTFTClass::GetCommandFromTFT() {
char fullCommandStr[38]; char fullCommandStr[38];
commandStr[0] = 0; // empty string commandStr[0] = 0; // empty string
if (CodeSeen('F')) // Set feedrate if (codeSeen('F')) // Set feedrate
movespeed = CodeValue(); movespeed = codeValue();
if (CodeSeen('X')) { // Move in X direction if (codeSeen('X')) { // Move in X direction
coorvalue = CodeValue(); coorvalue = codeValue();
if ((coorvalue <= 0.2) && coorvalue > 0) if ((coorvalue <= 0.2) && coorvalue > 0)
sprintf_P(commandStr, PSTR("G1 X0.1F%i"), movespeed); sprintf_P(commandStr, PSTR("G1 X0.1F%i"), movespeed);
else if ((coorvalue <= -0.1) && coorvalue > -1) else if ((coorvalue <= -0.1) && coorvalue > -1)
@@ -796,8 +762,8 @@ void AnycubicTFTClass::GetCommandFromTFT() {
else else
sprintf_P(commandStr, PSTR("G1 X%iF%i"), int(coorvalue), movespeed); sprintf_P(commandStr, PSTR("G1 X%iF%i"), int(coorvalue), movespeed);
} }
else if (CodeSeen('Y')) { // Move in Y direction else if (codeSeen('Y')) { // Move in Y direction
coorvalue = CodeValue(); coorvalue = codeValue();
if ((coorvalue <= 0.2) && coorvalue > 0) if ((coorvalue <= 0.2) && coorvalue > 0)
sprintf_P(commandStr, PSTR("G1 Y0.1F%i"), movespeed); sprintf_P(commandStr, PSTR("G1 Y0.1F%i"), movespeed);
else if ((coorvalue <= -0.1) && coorvalue > -1) else if ((coorvalue <= -0.1) && coorvalue > -1)
@@ -805,8 +771,8 @@ void AnycubicTFTClass::GetCommandFromTFT() {
else else
sprintf_P(commandStr, PSTR("G1 Y%iF%i"), int(coorvalue), movespeed); sprintf_P(commandStr, PSTR("G1 Y%iF%i"), int(coorvalue), movespeed);
} }
else if (CodeSeen('Z')) { // Move in Z direction else if (codeSeen('Z')) { // Move in Z direction
coorvalue = CodeValue(); coorvalue = codeValue();
if ((coorvalue <= 0.2) && coorvalue > 0) if ((coorvalue <= 0.2) && coorvalue > 0)
sprintf_P(commandStr, PSTR("G1 Z0.1F%i"), movespeed); sprintf_P(commandStr, PSTR("G1 Z0.1F%i"), movespeed);
else if ((coorvalue <= -0.1) && coorvalue > -1) else if ((coorvalue <= -0.1) && coorvalue > -1)
@@ -814,8 +780,8 @@ void AnycubicTFTClass::GetCommandFromTFT() {
else else
sprintf_P(commandStr, PSTR("G1 Z%iF%i"), int(coorvalue), movespeed); sprintf_P(commandStr, PSTR("G1 Z%iF%i"), int(coorvalue), movespeed);
} }
else if (CodeSeen('E')) { // Extrude else if (codeSeen('E')) { // Extrude
coorvalue = CodeValue(); coorvalue = codeValue();
if ((coorvalue <= 0.2) && coorvalue > 0) if ((coorvalue <= 0.2) && coorvalue > 0)
sprintf_P(commandStr, PSTR("G1 E0.1F%i"), movespeed); sprintf_P(commandStr, PSTR("G1 E0.1F%i"), movespeed);
else if ((coorvalue <= -0.1) && coorvalue > -1) else if ((coorvalue <= -0.1) && coorvalue > -1)
@@ -826,10 +792,8 @@ void AnycubicTFTClass::GetCommandFromTFT() {
if (strlen(commandStr) > 0) { if (strlen(commandStr) > 0) {
sprintf_P(fullCommandStr, PSTR("G91\n%s\nG90"), commandStr); sprintf_P(fullCommandStr, PSTR("G91\n%s\nG90"), commandStr);
#if ENABLED(ANYCUBIC_LCD_DEBUG) DEBUG_ECHOPGM("TFT Serial Debug: A22 Move final request with gcode... ");
SERIAL_ECHOPGM("TFT Serial Debug: A22 Move final request with gcode... "); DEBUG_ECHOLN(fullCommandStr);
SERIAL_ECHOLN(fullCommandStr);
#endif
injectCommands(fullCommandStr); injectCommands(fullCommandStr);
} }
} }
@@ -870,16 +834,16 @@ void AnycubicTFTClass::GetCommandFromTFT() {
case 26: // A26 refresh SD case 26: // A26 refresh SD
#if HAS_MEDIA #if HAS_MEDIA
if (isMediaInserted()) { if (isMediaInserted()) {
if (strlen(SelectedDirectory) > 0) { if (strlen(selectedDirectory) > 0) {
FileList currentFileList; FileList currentFileList;
if ((SelectedDirectory[0] == '.') && (SelectedDirectory[1] == '.')) { if ((selectedDirectory[0] == '.') && (selectedDirectory[1] == '.')) {
currentFileList.upDir(); currentFileList.upDir();
} }
else { else {
if (SelectedDirectory[0] == '<') if (selectedDirectory[0] == '<')
HandleSpecialMenu(); handleSpecialMenu();
else else
currentFileList.changeDir(SelectedDirectory); currentFileList.changeDir(selectedDirectory);
} }
} }
} }
@@ -887,7 +851,7 @@ void AnycubicTFTClass::GetCommandFromTFT() {
SENDLINE_DBG_PGM("J02", "TFT Serial Debug: No SD Card mounted to refresh SD A26... J02"); SENDLINE_DBG_PGM("J02", "TFT Serial Debug: No SD Card mounted to refresh SD A26... J02");
} }
SelectedDirectory[0] = 0; selectedDirectory[0] = 0;
#endif #endif
break; break;
@@ -896,9 +860,9 @@ void AnycubicTFTClass::GetCommandFromTFT() {
#endif #endif
case 28: // A28 filament test case 28: // A28 filament test
if (CodeSeen('O')) if (codeSeen('O'))
NOOP; NOOP;
else if (CodeSeen('C')) else if (codeSeen('C'))
NOOP; NOOP;
SENDLINE_PGM(""); SENDLINE_PGM("");
break; break;
@@ -913,17 +877,14 @@ void AnycubicTFTClass::GetCommandFromTFT() {
} }
} }
TFTbufindw = (TFTbufindw + 1) % TFTBUFSIZE; tftBufIndW = (tftBufIndW + 1) % (TFTBUFSIZE);
TFTbuflen += 1; tftBufLen++;
serial3_count = 0; // clear buffer serial_count = 0; // clear buffer
}
else { } // while
TFTcmdbuffer[TFTbufindw][serial3_count++] = serial3_char;
}
}
} }
void AnycubicTFTClass::DoSDCardStateCheck() { void AnycubicTFTClass::doSDCardStateCheck() {
#if BOTH(HAS_MEDIA, HAS_SD_DETECT) #if BOTH(HAS_MEDIA, HAS_SD_DETECT)
bool isInserted = isMediaInserted(); bool isInserted = isMediaInserted();
if (isInserted) if (isInserted)
@@ -934,7 +895,7 @@ void AnycubicTFTClass::DoSDCardStateCheck() {
#endif #endif
} }
void AnycubicTFTClass::DoFilamentRunoutCheck() { void AnycubicTFTClass::doFilamentRunoutCheck() {
#if ENABLED(FILAMENT_RUNOUT_SENSOR) #if ENABLED(FILAMENT_RUNOUT_SENSOR)
// NOTE: getFilamentRunoutState() only returns the runout state if the job is printing // NOTE: getFilamentRunoutState() only returns the runout state if the job is printing
// we want to actually check the status of the pin here, regardless of printstate // we want to actually check the status of the pin here, regardless of printstate
@@ -953,23 +914,18 @@ void AnycubicTFTClass::DoFilamentRunoutCheck() {
#endif // FILAMENT_RUNOUT_SENSOR #endif // FILAMENT_RUNOUT_SENSOR
} }
void AnycubicTFTClass::StartPrint() { void AnycubicTFTClass::startPrint() {
#if HAS_MEDIA #if HAS_MEDIA
if (!isPrinting() && strlen(SelectedFile) > 0) { if (!isPrinting() && strlen(selectedFile) > 0) {
#if ENABLED(ANYCUBIC_LCD_DEBUG) DEBUG_ECHOLNPGM("TFT Serial Debug: About to print file ... ", isPrinting(), " ", selectedFile);
SERIAL_ECHOPGM("TFT Serial Debug: About to print file ... ");
SERIAL_ECHO(isPrinting());
SERIAL_ECHOPGM(" ");
SERIAL_ECHOLN(SelectedFile);
#endif
mediaPrintingState = AMPRINTSTATE_PRINTING; mediaPrintingState = AMPRINTSTATE_PRINTING;
mediaPauseState = AMPAUSESTATE_NOT_PAUSED; mediaPauseState = AMPAUSESTATE_NOT_PAUSED;
printFile(SelectedFile); printFile(selectedFile);
} }
#endif // SDUPPORT #endif // SDUPPORT
} }
void AnycubicTFTClass::PausePrint() { void AnycubicTFTClass::pausePrint() {
#if HAS_MEDIA #if HAS_MEDIA
if (isPrintingFromMedia() && mediaPrintingState != AMPRINTSTATE_STOP_REQUESTED && mediaPauseState == AMPAUSESTATE_NOT_PAUSED) { if (isPrintingFromMedia() && mediaPrintingState != AMPRINTSTATE_STOP_REQUESTED && mediaPauseState == AMPAUSESTATE_NOT_PAUSED) {
mediaPrintingState = AMPRINTSTATE_PAUSE_REQUESTED; mediaPrintingState = AMPRINTSTATE_PAUSE_REQUESTED;
@@ -983,16 +939,14 @@ void AnycubicTFTClass::PausePrint() {
#endif #endif
} }
void AnycubicTFTClass::ResumePrint() { void AnycubicTFTClass::resumePrint() {
#if HAS_MEDIA #if HAS_MEDIA
#if ENABLED(FILAMENT_RUNOUT_SENSOR) #if ENABLED(FILAMENT_RUNOUT_SENSOR)
if (READ(FIL_RUNOUT1_PIN)) { if (READ(FIL_RUNOUT1_PIN)) {
#if ENABLED(ANYCUBIC_LCD_DEBUG) DEBUG_ECHOLNPGM("TFT Serial Debug: Resume Print with filament sensor still tripped... ");
SERIAL_ECHOLNPGM("TFT Serial Debug: Resume Print with filament sensor still tripped... ");
#endif
// trigger the user message box // trigger the user message box
DoFilamentRunoutCheck(); doFilamentRunoutCheck();
// re-enable the continue button // re-enable the continue button
SENDLINE_DBG_PGM("J18", "TFT Serial Debug: Resume Print with filament sensor still tripped... J18"); SENDLINE_DBG_PGM("J18", "TFT Serial Debug: Resume Print with filament sensor still tripped... J18");
@@ -1019,7 +973,7 @@ void AnycubicTFTClass::ResumePrint() {
#endif #endif
} }
void AnycubicTFTClass::StopPrint() { void AnycubicTFTClass::stopPrint() {
#if HAS_MEDIA #if HAS_MEDIA
mediaPrintingState = AMPRINTSTATE_STOP_REQUESTED; mediaPrintingState = AMPRINTSTATE_STOP_REQUESTED;
mediaPauseState = AMPAUSESTATE_NOT_PAUSED; mediaPauseState = AMPAUSESTATE_NOT_PAUSED;

View File

@@ -48,48 +48,45 @@ enum AnycubicMediaPauseState {
class AnycubicTFTClass { class AnycubicTFTClass {
public: public:
AnycubicTFTClass(); AnycubicTFTClass();
static void OnSetup(); static void onSetup();
static void OnCommandScan(); static void onCommandScan();
static void OnKillTFT(); static void onKillTFT();
static void OnSDCardStateChange(bool); static void onSDCardStateChange(bool);
static void OnSDCardError(); static void onSDCardError();
static void OnFilamentRunout(); static void onFilamentRunout();
static void OnUserConfirmRequired(const char *); static void onUserConfirmRequired(const char *);
static void OnPrintTimerStarted(); static void onPrintTimerStarted();
static void OnPrintTimerPaused(); static void onPrintTimerPaused();
static void OnPrintTimerStopped(); static void onPrintTimerStopped();
private: private:
static char TFTcmdbuffer[TFTBUFSIZE][TFT_MAX_CMD_SIZE]; static char tftCommands[TFTBUFSIZE][TFT_MAX_CMD_SIZE];
static int TFTbuflen, TFTbufindr, TFTbufindw; static int tftBufLen, tftBufIndR, tftBufIndW;
static char serial3_char; static char *tftStrchrPtr;
static int serial3_count; static uint8_t specialMenu;
static char *TFTstrchr_pointer;
static uint8_t SpecialMenu;
static AnycubicMediaPrintState mediaPrintingState; static AnycubicMediaPrintState mediaPrintingState;
static AnycubicMediaPauseState mediaPauseState; static AnycubicMediaPauseState mediaPauseState;
static float CodeValue(); static float codeValue();
static bool CodeSeen(char); static bool codeSeen(char);
static bool IsNozzleHomed(); static bool isNozzleHomed();
static void RenderCurrentFileList(); static void renderCurrentFileList();
static void RenderSpecialMenu(uint16_t); static void renderSpecialMenu(uint16_t);
static void RenderCurrentFolder(uint16_t); static void renderCurrentFolder(uint16_t);
static void GetCommandFromTFT(); static void getCommandFromTFT();
static void CheckSDCardChange(); static void checkSDCardChange();
static void CheckPauseState(); static void checkPauseState();
static void CheckPrintCompletion(); static void handleSpecialMenu();
static void HandleSpecialMenu(); static void doSDCardStateCheck();
static void DoSDCardStateCheck(); static void doFilamentRunoutCheck();
static void DoFilamentRunoutCheck(); static void startPrint();
static void StartPrint(); static void pausePrint();
static void PausePrint(); static void resumePrint();
static void ResumePrint(); static void stopPrint();
static void StopPrint();
static char SelectedDirectory[30]; static char selectedDirectory[30];
static char SelectedFile[FILENAME_LENGTH]; static char selectedFile[FILENAME_LENGTH];
}; };
extern AnycubicTFTClass AnycubicTFT; extern AnycubicTFTClass anycubicTFT;
extern const char G28_STR[]; extern const char G28_STR[];

View File

@@ -40,8 +40,8 @@ using namespace ExtUI;
namespace Anycubic { namespace Anycubic {
FileList FileNavigator::filelist; // Instance of the Marlin file API FileList FileNavigator::filelist; // ExtUI file API
char FileNavigator::currentfoldername[MAX_PATH_LEN + 1]; // Current folder path char FileNavigator::currentDirPath[MAX_PATH_LEN + 1]; // Current folder path
uint16_t FileNavigator::lastindex; uint16_t FileNavigator::lastindex;
uint8_t FileNavigator::folderdepth; uint8_t FileNavigator::folderdepth;
uint16_t FileNavigator::currentindex; // override the panel request uint16_t FileNavigator::currentindex; // override the panel request
@@ -51,7 +51,7 @@ namespace Anycubic {
FileNavigator::FileNavigator() { reset(); } FileNavigator::FileNavigator() { reset(); }
void FileNavigator::reset() { void FileNavigator::reset() {
currentfoldername[0] = '\0'; currentDirPath[0] = '\0';
folderdepth = 0; folderdepth = 0;
currentindex = 0; currentindex = 0;
lastindex = 0; lastindex = 0;
@@ -94,7 +94,7 @@ namespace Anycubic {
DgusTFT::SendTxtToTFT(filelist.longFilename(), TXT_FILE_0 + file_num*0x30); DgusTFT::SendTxtToTFT(filelist.longFilename(), TXT_FILE_0 + file_num*0x30);
#if ACDEBUG(AC_FILE) #if ACDEBUG(AC_FILE)
SERIAL_ECHOLNPGM("seek: ", _seek, " '", filelist.longFilename(), "' '", currentfoldername, "", filelist.shortFilename(), "'\n"); SERIAL_ECHOLNPGM("seek: ", _seek, " '", filelist.longFilename(), "' '", currentDirPath, "", filelist.shortFilename(), "'\n");
#endif #endif
} }
else { else {
@@ -120,11 +120,11 @@ namespace Anycubic {
void FileNavigator::changeDIR(char *folder) { void FileNavigator::changeDIR(char *folder) {
#if ACDEBUG(AC_FILE) #if ACDEBUG(AC_FILE)
SERIAL_ECHOLNPGM("currentfolder: ", currentfoldername, " New: ", folder); SERIAL_ECHOLNPGM("currentfolder: ", currentDirPath, " New: ", folder);
#endif #endif
if (folderdepth >= MAX_FOLDER_DEPTH) return; // limit the folder depth if (folderdepth >= MAX_FOLDER_DEPTH) return; // limit the folder depth
strcat(currentfoldername, folder); strcat(currentDirPath, folder);
strcat(currentfoldername, "/"); strcat(currentDirPath, "/");
filelist.changeDir(folder); filelist.changeDir(folder);
refresh(); refresh();
folderdepth++; folderdepth++;
@@ -138,22 +138,22 @@ namespace Anycubic {
currentindex = 0; currentindex = 0;
// Remove the last child folder from the stored path // Remove the last child folder from the stored path
if (folderdepth == 0) { if (folderdepth == 0) {
currentfoldername[0] = '\0'; currentDirPath[0] = '\0';
reset(); reset();
} }
else { else {
char *pos = nullptr; char *pos = nullptr;
for (uint8_t f = 0; f < folderdepth; f++) for (uint8_t f = 0; f < folderdepth; f++)
pos = strchr(currentfoldername, '/'); pos = strchr(currentDirPath, '/');
*(pos + 1) = '\0'; *(pos + 1) = '\0';
} }
#if ACDEBUG(AC_FILE) #if ACDEBUG(AC_FILE)
SERIAL_ECHOLNPGM("depth: ", folderdepth, " currentfoldername: ", currentfoldername); SERIAL_ECHOLNPGM("depth: ", folderdepth, " currentDirPath: ", currentDirPath);
#endif #endif
} }
char* FileNavigator::getCurrentFolderName() { return currentfoldername; } char* FileNavigator::getCurrentDirPath() { return currentDirPath; }
uint16_t FileNavigator::getFileNum() { return filelist.count(); } uint16_t FileNavigator::getFileNum() { return filelist.count(); }
} }

View File

@@ -43,13 +43,13 @@ namespace Anycubic {
static void changeDIR(char *); static void changeDIR(char *);
static void sendFile(); static void sendFile();
static void refresh(); static void refresh();
static char* getCurrentFolderName(); static char* getCurrentDirPath();
static uint16_t getFileNum(); static uint16_t getFileNum();
private: private:
static uint16_t lastindex; static uint16_t lastindex;
static uint16_t currentindex; static uint16_t currentindex;
static uint8_t folderdepth; static uint8_t folderdepth;
static char currentfoldername[MAX_PATH_LEN + 1]; static char currentDirPath[MAX_PATH_LEN + 1];
}; };
extern FileNavigator filenavigator; extern FileNavigator filenavigator;

View File

@@ -111,10 +111,10 @@ namespace Anycubic {
uint8_t pop_up_index_saved; uint8_t pop_up_index_saved;
uint32_t key_value_saved; uint32_t key_value_saved;
void DEBUG_PRINT_PAUSED_STATE(FSTR_P const msg, paused_state_t state); void DEBUG_PRINT_PAUSED_STATE(const paused_state_t state, FSTR_P const msg=nullptr);
void DEBUG_PRINT_PRINTER_STATE(FSTR_P const msg, printer_state_t state); void DEBUG_PRINT_PRINTER_STATE(const printer_state_t state, FSTR_P const msg=nullptr);
void DEBUG_PRINT_TIMER_EVENT(FSTR_P const msg, timer_event_t event); void DEBUG_PRINT_TIMER_EVENT(const timer_event_t event, FSTR_P const msg=nullptr);
void DEBUG_PRINT_MEDIA_EVENT(FSTR_P const msg, media_event_t event); void DEBUG_PRINT_MEDIA_EVENT(const media_event_t event, FSTR_P const msg=nullptr);
DgusTFT Dgus; DgusTFT Dgus;
@@ -127,9 +127,9 @@ namespace Anycubic {
feedrate_back = -1; feedrate_back = -1;
} }
void DgusTFT::Startup() { void DgusTFT::startup() {
#if ACDEBUG(AC_MARLIN) #if ACDEBUG(AC_MARLIN)
DEBUG_ECHOLNPGM("DgusTFT::Startup()"); DEBUG_ECHOLNPGM("DgusTFT::startup()");
#endif #endif
selectedfile[0] = '\0'; selectedfile[0] = '\0';
panel_command[0] = '\0'; panel_command[0] = '\0';
@@ -148,16 +148,16 @@ namespace Anycubic {
TFTSer.begin(115200); TFTSer.begin(115200);
// Signal Board has reset // Signal Board has reset
SendtoTFTLN(AC_msg_main_board_has_reset); tftSendLn(AC_msg_main_board_has_reset);
// Enable levelling and Disable end stops during print // Enable levelling and Disable end stops during print
// as Z home places nozzle above the bed so we need to allow it past the end stops // as Z home places nozzle above the bed so we need to allow it past the end stops
injectCommands(AC_cmnd_enable_leveling); injectCommands(AC_cmnd_enable_leveling);
#if ACDEBUGLEVEL #if ACDEBUGLEVEL
DEBUG_ECHOLNPGM("Startup AC Debug Level ", ACDEBUGLEVEL); DEBUG_ECHOLNPGM("startup AC Debug Level ", ACDEBUGLEVEL);
#endif #endif
SendtoTFTLN(AC_msg_ready); tftSendLn(AC_msg_ready);
} }
void DgusTFT::ParamInit() { void DgusTFT::ParamInit() {
@@ -188,15 +188,15 @@ namespace Anycubic {
RequestValueFromTFT(0x14); // get page ID RequestValueFromTFT(0x14); // get page ID
} }
void DgusTFT::IdleLoop() { void DgusTFT::idleLoop() {
if (ReadTFTCommand()) { if (readTFTCommand()) {
ProcessPanelRequest(); processPanelRequest();
command_len = 0; command_len = 0;
} }
#if ACDEBUG(AC_MARLIN) #if ACDEBUG(AC_MARLIN)
if (key_value) { if (key_value) {
DEBUG_ECHOLNPGM("IdleLoop page: ", page_index_now); DEBUG_ECHOLNPGM("idleLoop page: ", page_index_now);
DEBUG_ECHOLNPGM("key: ", key_value); DEBUG_ECHOLNPGM("key: ", key_value);
} }
#endif #endif
@@ -266,7 +266,7 @@ namespace Anycubic {
pop_up_manager(); pop_up_manager();
key_value = 0; key_value = 0;
CheckHeaters(); checkHeaters();
} }
uint8_t FSHlength(FSTR_P FSHinput) { uint8_t FSHlength(FSTR_P FSHinput) {
@@ -276,7 +276,7 @@ namespace Anycubic {
return stringLength; return stringLength;
} }
void DgusTFT::PrinterKilled(FSTR_P error_p, FSTR_P component_p) { void DgusTFT::printerKilled(FSTR_P error_p, FSTR_P component_p) {
// copy string in FLASH to RAM for strcmp_P // copy string in FLASH to RAM for strcmp_P
@@ -288,9 +288,9 @@ namespace Anycubic {
char component[FSHlength(component_p) + 1]; char component[FSHlength(component_p) + 1];
memcpy_P(component, component_p, textLength + 1); // +1 for the null terminator memcpy_P(component, component_p, textLength + 1); // +1 for the null terminator
SendtoTFTLN(AC_msg_kill_lcd); tftSendLn(AC_msg_kill_lcd);
#if ACDEBUG(AC_MARLIN) #if ACDEBUG(AC_MARLIN)
DEBUG_ECHOLNPGM("PrinterKilled()\nerror: ", error, "\ncomponent: ", component); DEBUG_ECHOLNPGM("printerKilled()\nerror: ", error, "\ncomponent: ", component);
#endif #endif
if (strcmp_P(error, PSTR("Heating Failed")) == 0) { if (strcmp_P(error, PSTR("Heating Failed")) == 0) {
@@ -364,9 +364,9 @@ namespace Anycubic {
SendColorToTFT(color, TXT_DESCRIPT_0 + 0x30 * (index - 1)); SendColorToTFT(color, TXT_DESCRIPT_0 + 0x30 * (index - 1));
} }
void DgusTFT::MediaEvent(media_event_t event) { void DgusTFT::mediaEvent(media_event_t event) {
#if ACDEBUG(AC_MARLIN) #if ACDEBUG(AC_MARLIN)
DEBUG_PRINT_MEDIA_EVENT(F("ProcessMediaStatus() "), event); DEBUG_PRINT_MEDIA_EVENT(event);
#endif #endif
switch (event) { switch (event) {
case AC_media_inserted: case AC_media_inserted:
@@ -379,12 +379,12 @@ namespace Anycubic {
lcd_txtbox_index = 0; lcd_txtbox_index = 0;
} }
SendFileList(lcd_txtbox_index); sendFileList(lcd_txtbox_index);
break; break;
case AC_media_removed: case AC_media_removed:
SendtoTFTLN(AC_msg_sd_card_removed); tftSendLn(AC_msg_sd_card_removed);
filenavigator.reset(); filenavigator.reset();
@@ -394,33 +394,33 @@ namespace Anycubic {
lcd_txtbox_index = 0; lcd_txtbox_index = 0;
} }
SendFileList(lcd_txtbox_index); sendFileList(lcd_txtbox_index);
break; break;
case AC_media_error: case AC_media_error:
SendtoTFTLN(AC_msg_no_sd_card); tftSendLn(AC_msg_no_sd_card);
break; break;
} }
} }
void DgusTFT::TimerEvent(timer_event_t event) { void DgusTFT::timerEvent(timer_event_t event) {
#if ACDEBUG(AC_MARLIN) #if ACDEBUG(AC_MARLIN)
DEBUG_PRINT_TIMER_EVENT(F("TimerEvent() "), event); DEBUG_PRINT_TIMER_EVENT(event);
DEBUG_PRINT_PRINTER_STATE(F("Printer State: "), printer_state); DEBUG_PRINT_PRINTER_STATE(printer_state);
#endif #endif
switch (event) { switch (event) {
case AC_timer_started: case AC_timer_started:
setSoftEndstopState(false); // disable endstops to print setSoftEndstopState(false); // disable endstops to print
printer_state = AC_printer_printing; printer_state = AC_printer_printing;
SendtoTFTLN(AC_msg_print_from_sd_card); tftSendLn(AC_msg_print_from_sd_card);
break; break;
case AC_timer_paused: case AC_timer_paused:
//printer_state = AC_printer_paused; //printer_state = AC_printer_paused;
//pause_state = AC_paused_idle; //pause_state = AC_paused_idle;
SendtoTFTLN(AC_msg_paused); tftSendLn(AC_msg_paused);
break; break;
case AC_timer_stopped: case AC_timer_stopped:
@@ -438,7 +438,7 @@ namespace Anycubic {
sprintf(str_buf + strlen(str_buf), "%s M", utostr3(time % 60)); sprintf(str_buf + strlen(str_buf), "%s M", utostr3(time % 60));
SendTxtToTFT(str_buf, TXT_FINISH_TIME); SendTxtToTFT(str_buf, TXT_FINISH_TIME);
ChangePageOfTFT(PAGE_PRINT_FINISH); ChangePageOfTFT(PAGE_PRINT_FINISH);
SendtoTFTLN(AC_msg_print_complete); tftSendLn(AC_msg_print_complete);
pop_up_index = 100; pop_up_index = 100;
} }
} }
@@ -449,12 +449,12 @@ namespace Anycubic {
#if ENABLED(FILAMENT_RUNOUT_SENSOR) #if ENABLED(FILAMENT_RUNOUT_SENSOR)
void DgusTFT::FilamentRunout() { void DgusTFT::filamentRunout() {
#if ACDEBUG(AC_MARLIN) #if ACDEBUG(AC_MARLIN)
DEBUG_PRINT_PRINTER_STATE(F("FilamentRunout() printer_state "), printer_state); DEBUG_PRINT_PRINTER_STATE(printer_state, F("filamentRunout() "));
// 1 Signal filament out // 1 Signal filament out
SendtoTFTLN(isPrintingFromMedia() ? AC_msg_filament_out_alert : AC_msg_filament_out_block); tftSendLn(isPrintingFromMedia() ? AC_msg_filament_out_alert : AC_msg_filament_out_block);
//printer_state = AC_printer_filament_out; //printer_state = AC_printer_filament_out;
DEBUG_ECHOLNPGM("getFilamentRunoutState: ", getFilamentRunoutState()); DEBUG_ECHOLNPGM("getFilamentRunoutState: ", getFilamentRunoutState());
@@ -477,13 +477,13 @@ namespace Anycubic {
#endif // FILAMENT_RUNOUT_SENSOR #endif // FILAMENT_RUNOUT_SENSOR
void DgusTFT::ConfirmationRequest(const char * const msg) { void DgusTFT::confirmationRequest(const char * const msg) {
// M108 continue // M108 continue
#if ACDEBUG(AC_MARLIN) #if ACDEBUG(AC_MARLIN)
DEBUG_ECHOLNPGM("HomingComplete, line: ", __LINE__); DEBUG_ECHOLNPGM("HomingComplete, line: ", __LINE__);
DEBUG_ECHOLNPGM("ConfirmationRequest() ", msg); DEBUG_ECHOLNPGM("confirmationRequest() ", msg);
DEBUG_PRINT_PRINTER_STATE(F("printer_state: " ), printer_state); DEBUG_PRINT_PRINTER_STATE(printer_state);
DEBUG_PRINT_PAUSED_STATE(F("pause_state: "), pause_state); DEBUG_PRINT_PAUSED_STATE(pause_state);
#endif #endif
switch (printer_state) { switch (printer_state) {
@@ -504,7 +504,7 @@ namespace Anycubic {
// Heater timout, send acknowledgement // Heater timout, send acknowledgement
if (strcmp_P(msg, MARLIN_msg_heater_timeout) == 0) { if (strcmp_P(msg, MARLIN_msg_heater_timeout) == 0) {
pause_state = AC_paused_heater_timed_out; pause_state = AC_paused_heater_timed_out;
SendtoTFTLN(AC_msg_paused); // enable continue button tftSendLn(AC_msg_paused); // enable continue button
PlayTune(HeaterTimeout); PlayTune(HeaterTimeout);
} }
// Reheat finished, send acknowledgement // Reheat finished, send acknowledgement
@@ -517,12 +517,12 @@ namespace Anycubic {
if (pause_state != AC_paused_filament_lack) if (pause_state != AC_paused_filament_lack)
pause_state = AC_paused_idle; pause_state = AC_paused_idle;
SendtoTFTLN(AC_msg_paused); // enable continue button tftSendLn(AC_msg_paused); // enable continue button
} }
// Filament Purging, send acknowledgement enter run mode // Filament Purging, send acknowledgement enter run mode
else if (strcmp_P(msg, MARLIN_msg_filament_purging) == 0) { else if (strcmp_P(msg, MARLIN_msg_filament_purging) == 0) {
pause_state = AC_paused_purging_filament; pause_state = AC_paused_purging_filament;
SendtoTFTLN(AC_msg_paused); // enable continue button tftSendLn(AC_msg_paused); // enable continue button
} }
else if (strcmp_P(msg, MARLIN_msg_nozzle_parked) == 0) { else if (strcmp_P(msg, MARLIN_msg_nozzle_parked) == 0) {
#if ACDEBUG(AC_MARLIN) #if ACDEBUG(AC_MARLIN)
@@ -540,11 +540,11 @@ namespace Anycubic {
} }
} }
void DgusTFT::StatusChange(const char * const msg) { void DgusTFT::statusChange(const char * const msg) {
#if ACDEBUG(AC_MARLIN) #if ACDEBUG(AC_MARLIN)
DEBUG_ECHOLNPGM("StatusChange() ", msg); DEBUG_ECHOLNPGM("statusChange() ", msg);
DEBUG_PRINT_PRINTER_STATE(F("printer_state: "), printer_state); DEBUG_PRINT_PRINTER_STATE(printer_state);
DEBUG_PRINT_PAUSED_STATE(F("pause_state: "), pause_state); DEBUG_PRINT_PAUSED_STATE(pause_state);
#endif #endif
bool msg_matched = false; bool msg_matched = false;
@@ -579,7 +579,7 @@ namespace Anycubic {
PlayTune(BeepBeepBeeep); PlayTune(BeepBeepBeeep);
injectCommands(F("G1 Z50 F500")); injectCommands(F("G1 Z50 F500"));
ChangePageOfTFT(PAGE_CHS_ABNORMAL_LEVELING_SENSOR); ChangePageOfTFT(PAGE_CHS_ABNORMAL_LEVELING_SENSOR);
SendtoTFTLN(AC_msg_probing_complete); tftSendLn(AC_msg_probing_complete);
printer_state = AC_printer_idle; printer_state = AC_printer_idle;
msg_matched = true; msg_matched = true;
} }
@@ -595,7 +595,7 @@ namespace Anycubic {
case AC_printer_printing: case AC_printer_printing:
if (strcmp_P(msg, MARLIN_msg_reheating) == 0) { if (strcmp_P(msg, MARLIN_msg_reheating) == 0) {
SendtoTFTLN(AC_msg_paused); // enable continue button tftSendLn(AC_msg_paused); // enable continue button
ChangePageOfTFT(PAGE_STATUS2); ChangePageOfTFT(PAGE_STATUS2);
msg_matched = true; msg_matched = true;
} }
@@ -652,14 +652,14 @@ namespace Anycubic {
if (!msg_matched) { if (!msg_matched) {
#if HAS_HOTEND #if HAS_HOTEND
if (strcmp_P(msg, MARLIN_msg_extruder_heating) == 0) { if (strcmp_P(msg, MARLIN_msg_extruder_heating) == 0) {
SendtoTFTLN(AC_msg_nozzle_heating); tftSendLn(AC_msg_nozzle_heating);
hotend_state = AC_heater_temp_set; hotend_state = AC_heater_temp_set;
return; return;
} }
#endif #endif
#if HAS_HEATED_BED #if HAS_HEATED_BED
if (strcmp_P(msg, MARLIN_msg_bed_heating) == 0) { if (strcmp_P(msg, MARLIN_msg_bed_heating) == 0) {
SendtoTFTLN(AC_msg_bed_heating); tftSendLn(AC_msg_bed_heating);
hotbed_state = AC_heater_temp_set; hotbed_state = AC_heater_temp_set;
} }
#endif #endif
@@ -675,7 +675,7 @@ namespace Anycubic {
LOOP_L_N(i, COUNT(data)) TFTSer.write(data[i]); LOOP_L_N(i, COUNT(data)) TFTSer.write(data[i]);
} }
void DgusTFT::PowerLossRecovery() { void DgusTFT::powerLossRecovery() {
printer_state = AC_printer_resuming_from_power_outage; // Play tune to notify user we can recover. printer_state = AC_printer_resuming_from_power_outage; // Play tune to notify user we can recover.
} }
@@ -699,7 +699,7 @@ namespace Anycubic {
ChangePageOfTFT(page_index_last); ChangePageOfTFT(page_index_last);
} }
void DgusTFT::SendtoTFT(FSTR_P const fstr/*=nullptr*/) { // A helper to print PROGMEM string to the panel void DgusTFT::tftSend(FSTR_P const fstr/*=nullptr*/) { // A helper to print PROGMEM string to the panel
#if ACDEBUG(AC_SOME) #if ACDEBUG(AC_SOME)
DEBUG_ECHOF(fstr); DEBUG_ECHOF(fstr);
#endif #endif
@@ -707,12 +707,12 @@ namespace Anycubic {
while (const char c = pgm_read_byte(str++)) TFTSer.write(c); while (const char c = pgm_read_byte(str++)) TFTSer.write(c);
} }
void DgusTFT::SendtoTFTLN(FSTR_P const fstr/*=nullptr*/) { void DgusTFT::tftSendLn(FSTR_P const fstr/*=nullptr*/) {
if (fstr) { if (fstr) {
#if ACDEBUG(AC_SOME) #if ACDEBUG(AC_SOME)
DEBUG_ECHOPGM("> "); DEBUG_ECHOPGM("> ");
#endif #endif
SendtoTFT(fstr); tftSend(fstr);
#if ACDEBUG(AC_SOME) #if ACDEBUG(AC_SOME)
SERIAL_EOL(); SERIAL_EOL();
#endif #endif
@@ -804,7 +804,7 @@ namespace Anycubic {
LOOP_L_N(i, 10) TFTSer.write(data[i]); LOOP_L_N(i, 10) TFTSer.write(data[i]);
} }
bool DgusTFT::ReadTFTCommand() { bool DgusTFT::readTFTCommand() {
static uint8_t length = 0, cnt = 0, tft_receive_steps = 0; static uint8_t length = 0, cnt = 0, tft_receive_steps = 0;
uint8_t data; uint8_t data;
@@ -858,7 +858,7 @@ namespace Anycubic {
#if 0 #if 0
{ {
//SERIAL_ECHOLNPGM("ReadTFTCommand: ", millis()); //SERIAL_ECHOLNPGM("readTFTCommand: ", millis());
//return -1; //return -1;
bool command_ready = false; bool command_ready = false;
@@ -888,7 +888,7 @@ namespace Anycubic {
uint8_t req = atoi(&panel_command[1]); uint8_t req = atoi(&panel_command[1]);
if (req > 7 && req != 20) { if (req > 7 && req != 20) {
DEBUG_ECHOLNPGM("> ", panel_command); DEBUG_ECHOLNPGM("> ", panel_command);
DEBUG_PRINT_PRINTER_STATE(F("printer_state: "), printer_state); DEBUG_PRINT_PRINTER_STATE(printer_state);
} }
#endif #endif
} }
@@ -902,7 +902,7 @@ namespace Anycubic {
return -1; return -1;
} }
void DgusTFT::CheckHeaters() { void DgusTFT::checkHeaters() {
static uint32_t time_last = 0; static uint32_t time_last = 0;
if (PENDING(millis(), time_last)) return; if (PENDING(millis(), time_last)) return;
time_last = millis() + 500; time_last = millis() + 500;
@@ -916,7 +916,7 @@ namespace Anycubic {
if (!WITHIN(temp, HEATER_0_MINTEMP, HEATER_0_MAXTEMP)) { if (!WITHIN(temp, HEATER_0_MINTEMP, HEATER_0_MAXTEMP)) {
faultE0Duration++; faultE0Duration++;
if (faultE0Duration >= AC_HEATER_FAULT_VALIDATION_TIME) { if (faultE0Duration >= AC_HEATER_FAULT_VALIDATION_TIME) {
SendtoTFTLN(AC_msg_nozzle_temp_abnormal); tftSendLn(AC_msg_nozzle_temp_abnormal);
#if ACDEBUG(AC_MARLIN) #if ACDEBUG(AC_MARLIN)
DEBUG_ECHOLNPGM("Extruder temp abnormal! : ", temp); DEBUG_ECHOLNPGM("Extruder temp abnormal! : ", temp);
#endif #endif
@@ -931,7 +931,7 @@ namespace Anycubic {
if (!WITHIN(temp, BED_MINTEMP, BED_MAXTEMP)) { if (!WITHIN(temp, BED_MINTEMP, BED_MAXTEMP)) {
faultBedDuration++; faultBedDuration++;
if (faultBedDuration >= AC_HEATER_FAULT_VALIDATION_TIME) { if (faultBedDuration >= AC_HEATER_FAULT_VALIDATION_TIME) {
SendtoTFTLN(AC_msg_bed_temp_abnormal); tftSendLn(AC_msg_bed_temp_abnormal);
#if ACDEBUG(AC_MARLIN) #if ACDEBUG(AC_MARLIN)
DEBUG_ECHOLNPGM("Bed temp abnormal! : ", temp); DEBUG_ECHOLNPGM("Bed temp abnormal! : ", temp);
#endif #endif
@@ -944,7 +944,7 @@ namespace Anycubic {
// Update panel with hotend heater status // Update panel with hotend heater status
if (hotend_state != AC_heater_temp_reached) { if (hotend_state != AC_heater_temp_reached) {
if (WITHIN(getActualTemp_celsius(E0) - getTargetTemp_celsius(E0), -1, 1)) { if (WITHIN(getActualTemp_celsius(E0) - getTargetTemp_celsius(E0), -1, 1)) {
SendtoTFTLN(AC_msg_nozzle_heating_done); tftSendLn(AC_msg_nozzle_heating_done);
hotend_state = AC_heater_temp_reached; hotend_state = AC_heater_temp_reached;
} }
} }
@@ -952,22 +952,22 @@ namespace Anycubic {
// Update panel with bed heater status // Update panel with bed heater status
if (hotbed_state != AC_heater_temp_reached) { if (hotbed_state != AC_heater_temp_reached) {
if (WITHIN(getActualTemp_celsius(BED) - getTargetTemp_celsius(BED), -0.5, 0.5)) { if (WITHIN(getActualTemp_celsius(BED) - getTargetTemp_celsius(BED), -0.5, 0.5)) {
SendtoTFTLN(AC_msg_bed_heating_done); tftSendLn(AC_msg_bed_heating_done);
hotbed_state = AC_heater_temp_reached; hotbed_state = AC_heater_temp_reached;
} }
} }
#endif #endif
} }
void DgusTFT::SendFileList(int8_t startindex) { void DgusTFT::sendFileList(int8_t startindex) {
// Respond to panel request for 4 files starting at index // Respond to panel request for 4 files starting at index
#if ACDEBUG(AC_INFO) #if ACDEBUG(AC_INFO)
DEBUG_ECHOLNPGM("## SendFileList ## ", startindex); DEBUG_ECHOLNPGM("## sendFileList ## ", startindex);
#endif #endif
filenavigator.getFiles(startindex); filenavigator.getFiles(startindex);
} }
void DgusTFT::SelectFile() { void DgusTFT::selectFile() {
strncpy(selectedfile, panel_command + 4, command_len - 4); strncpy(selectedfile, panel_command + 4, command_len - 4);
selectedfile[command_len - 5] = '\0'; selectedfile[command_len - 5] = '\0';
#if ACDEBUG(AC_FILE) #if ACDEBUG(AC_FILE)
@@ -975,22 +975,22 @@ namespace Anycubic {
#endif #endif
switch (selectedfile[0]) { switch (selectedfile[0]) {
case '/': // Valid file selected case '/': // Valid file selected
SendtoTFTLN(AC_msg_sd_file_open_success); tftSendLn(AC_msg_sd_file_open_success);
break; break;
case '<': // .. (go up folder level) case '<': // .. (go up folder level)
filenavigator.upDIR(); filenavigator.upDIR();
SendtoTFTLN(AC_msg_sd_file_open_failed); tftSendLn(AC_msg_sd_file_open_failed);
SendFileList(0); sendFileList(0);
break; break;
default: // enter sub folder default: // enter sub folder
filenavigator.changeDIR(selectedfile); filenavigator.changeDIR(selectedfile);
SendtoTFTLN(AC_msg_sd_file_open_failed); tftSendLn(AC_msg_sd_file_open_failed);
SendFileList(0); sendFileList(0);
break; break;
} }
} }
void DgusTFT::ProcessPanelRequest() { void DgusTFT::processPanelRequest() {
uint16_t control_index = 0; uint16_t control_index = 0;
uint32_t control_value; uint32_t control_value;
uint16_t temp; uint16_t temp;
@@ -1080,7 +1080,7 @@ namespace Anycubic {
} }
else if (control_value == 0x010000) { // startup first gif else if (control_value == 0x010000) { // startup first gif
// Startup tunes are defined in Tunes.h // startup tunes are defined in Tunes.h
PlayTune(Anycubic_PowerOn); // takes 3500 ms PlayTune(Anycubic_PowerOn); // takes 3500 ms
} }
} }
@@ -1112,15 +1112,15 @@ namespace Anycubic {
int8_t req = atoi(&panel_command[1]); int8_t req = atoi(&panel_command[1]);
// Information requests A0 - A8 and A33 // Information requests A0 - A8 and A33
if (req <= 8 || req == 33) PanelInfo(req); if (req <= 8 || req == 33) panelInfo(req);
// Simple Actions A9 - A28 // Simple Actions A9 - A28
else if (req <= 28) PanelAction(req); else if (req <= 28) panelAction(req);
// Process Initiation // Process Initiation
else if (req <= 34) PanelProcess(req); else if (req <= 34) panelProcess(req);
else SendtoTFTLN(); else tftSendLn();
} }
#endif #endif
@@ -1187,7 +1187,7 @@ namespace Anycubic {
lcd_txtbox_index = 0; lcd_txtbox_index = 0;
} }
ChangePageOfTFT(PAGE_FILE); ChangePageOfTFT(PAGE_FILE);
SendFileList(0); sendFileList(0);
} break; } break;
case 2: { // tool case 2: { // tool
@@ -1249,7 +1249,7 @@ namespace Anycubic {
set_descript_color(COLOR_BLUE); set_descript_color(COLOR_BLUE);
lcd_txtbox_index = 0; lcd_txtbox_index = 0;
SendFileList(lcd_txtbox_page * 5); sendFileList(lcd_txtbox_page * 5);
} }
break; break;
@@ -1260,7 +1260,7 @@ namespace Anycubic {
set_descript_color(COLOR_BLUE); set_descript_color(COLOR_BLUE);
lcd_txtbox_index = 0; lcd_txtbox_index = 0;
SendFileList(lcd_txtbox_page * 5); sendFileList(lcd_txtbox_page * 5);
} }
break; break;
@@ -1274,12 +1274,12 @@ namespace Anycubic {
set_descript_color(COLOR_BLUE); set_descript_color(COLOR_BLUE);
lcd_txtbox_index = 0; lcd_txtbox_index = 0;
} }
SendFileList(lcd_txtbox_index); sendFileList(lcd_txtbox_index);
break; break;
case 5: // resume of outage(last power off) case 5: // resume of outage(last power off)
#if ACDEBUG(AC_MARLIN) #if ACDEBUG(AC_MARLIN)
DEBUG_PRINT_PRINTER_STATE(F("printer_state: "), printer_state); DEBUG_PRINT_PRINTER_STATE(printer_state);
#endif #endif
if (lcd_txtbox_index > 0 && lcd_txtbox_index < 6) { // 1~5 if (lcd_txtbox_index > 0 && lcd_txtbox_index < 6) { // 1~5
@@ -1398,8 +1398,8 @@ namespace Anycubic {
case 2: // resume print case 2: // resume print
#if ACDEBUG(AC_MARLIN) #if ACDEBUG(AC_MARLIN)
DEBUG_PRINT_PRINTER_STATE(F("printer_state: "), printer_state); DEBUG_PRINT_PRINTER_STATE(printer_state);
DEBUG_PRINT_PAUSED_STATE(F("pause_state :"), pause_state); DEBUG_PRINT_PAUSED_STATE(pause_state);
#endif #endif
if ( pause_state == AC_paused_idle if ( pause_state == AC_paused_idle
|| pause_state == AC_paused_filament_lack || pause_state == AC_paused_filament_lack
@@ -2418,8 +2418,8 @@ namespace Anycubic {
case 1: // return case 1: // return
#if ACDEBUG(AC_MARLIN) #if ACDEBUG(AC_MARLIN)
DEBUG_PRINT_PRINTER_STATE(F("printer_state: "), printer_state); DEBUG_PRINT_PRINTER_STATE(printer_state);
DEBUG_PRINT_PAUSED_STATE(F("pause_state: "), pause_state); DEBUG_PRINT_PAUSED_STATE(pause_state);
#endif #endif
if (AC_printer_printing == printer_state) if (AC_printer_printing == printer_state)
ChangePageOfTFT(PAGE_STATUS2); // show pause ChangePageOfTFT(PAGE_STATUS2); // show pause
@@ -3179,6 +3179,7 @@ namespace Anycubic {
break; break;
case 15: // filament lack case 15: // filament lack
case 23:
if (page_index_now != PAGE_FILAMENT_LACK) if (page_index_now != PAGE_FILAMENT_LACK)
ChangePageOfTFT(PAGE_FILAMENT_LACK); ChangePageOfTFT(PAGE_FILAMENT_LACK);
pop_up_index = 100; pop_up_index = 100;
@@ -3194,12 +3195,6 @@ namespace Anycubic {
pop_up_index = 100; pop_up_index = 100;
break; break;
case 23: //
if (page_index_now != PAGE_FILAMENT_LACK)
ChangePageOfTFT(PAGE_FILAMENT_LACK);
pop_up_index = 100;
break;
case 24: { // case 24: { //
uint32_t time = getProgress_seconds_elapsed() / 60; uint32_t time = getProgress_seconds_elapsed() / 60;
char str_buf[20]; char str_buf[20];
@@ -3207,7 +3202,7 @@ namespace Anycubic {
sprintf(str_buf + strlen(str_buf), "%s M", utostr3(time % 60)); sprintf(str_buf + strlen(str_buf), "%s M", utostr3(time % 60));
SendTxtToTFT(str_buf, TXT_FINISH_TIME); SendTxtToTFT(str_buf, TXT_FINISH_TIME);
ChangePageOfTFT(PAGE_PRINT_FINISH); ChangePageOfTFT(PAGE_PRINT_FINISH);
//SendtoTFTLN(AC_msg_print_complete); // no idea why this causes a compile error //tftSendLn(AC_msg_print_complete); // no idea why this causes a compile error
pop_up_index = 100; pop_up_index = 100;
} break; } break;
@@ -3218,84 +3213,56 @@ namespace Anycubic {
} }
} }
void DEBUG_PRINT_PAUSED_STATE(FSTR_P const msg, paused_state_t state) { void DEBUG_PRINT_PAUSED_STATE(const paused_state_t state, FSTR_P const msg/*=nullptr*/) {
DEBUG_ECHOPGM(msg, state); if (msg) DEBUG_ECHOF(msg);
DEBUG_ECHOPGM("Paused state: ", state, " ");
switch (state) { switch (state) {
case AC_paused_heater_timed_out: case AC_paused_heater_timed_out: DEBUG_ECHOPGM("AC_paused_heater_timed_out"); break;
DEBUG_ECHOLNPGM(" AC_paused_heater_timed_out"); case AC_paused_filament_lack: DEBUG_ECHOPGM("AC_paused_filament_lack"); break;
break; case AC_paused_purging_filament: DEBUG_ECHOPGM("AC_paused_purging_filament"); break;
case AC_paused_filament_lack: case AC_paused_idle: DEBUG_ECHOPGM("AC_paused_idle"); break;
DEBUG_ECHOLNPGM(" AC_paused_filament_lack");
break;
case AC_paused_purging_filament:
DEBUG_ECHOLNPGM(" AC_paused_purging_filament");
break;
case AC_paused_idle:
DEBUG_ECHOLNPGM(" AC_paused_idle");
break;
} }
DEBUG_EOL();
} }
// routines to make the debug outputs human readable // Human-readable debugging
void DEBUG_PRINT_PRINTER_STATE(FSTR_P const msg, printer_state_t state) { void DEBUG_PRINT_PRINTER_STATE(const printer_state_t state, FSTR_P const msg/*=nullptr*/) {
DEBUG_ECHOPGM(msg, state); if (msg) DEBUG_ECHOF(msg);
DEBUG_ECHOPGM("Printer State: ", state, " ");
switch (state) { switch (state) {
case AC_printer_idle: case AC_printer_idle: DEBUG_ECHOPGM("AC_printer_idle"); break;
DEBUG_ECHOLNPGM(" AC_printer_idle"); case AC_printer_probing: DEBUG_ECHOPGM("AC_printer_probing"); break;
break; case AC_printer_printing: DEBUG_ECHOPGM("AC_printer_printing"); break;
case AC_printer_probing: case AC_printer_pausing: DEBUG_ECHOPGM("AC_printer_pausing"); break;
DEBUG_ECHOLNPGM(" AC_printer_probing"); case AC_printer_paused: DEBUG_ECHOPGM("AC_printer_paused"); break;
break; case AC_printer_stopping: DEBUG_ECHOPGM("AC_printer_stopping"); break;
case AC_printer_printing: case AC_printer_stopping_from_media_remove: DEBUG_ECHOPGM("AC_printer_stopping_from_media_remove"); break;
DEBUG_ECHOLNPGM(" AC_printer_printing"); case AC_printer_resuming_from_power_outage: DEBUG_ECHOPGM("AC_printer_resuming_from_power_outage"); break;
break;
case AC_printer_pausing:
DEBUG_ECHOLNPGM(" AC_printer_pausing");
break;
case AC_printer_paused:
DEBUG_ECHOLNPGM(" AC_printer_paused");
break;
case AC_printer_stopping:
DEBUG_ECHOLNPGM(" AC_printer_stopping");
break;
case AC_printer_stopping_from_media_remove:
DEBUG_ECHOLNPGM(" AC_printer_stopping_from_media_remove");
break;
case AC_printer_resuming_from_power_outage:
DEBUG_ECHOLNPGM(" AC_printer_resuming_from_power_outage");
break;
} }
DEBUG_EOL();
} }
void DEBUG_PRINT_TIMER_EVENT(FSTR_P const msg, timer_event_t event) { void DEBUG_PRINT_TIMER_EVENT(const timer_event_t event, FSTR_P const msg/*=nullptr*/) {
DEBUG_ECHOPGM(msg, event); if (msg) DEBUG_ECHOPGM(msg, event);
DEBUG_ECHOPGM("timerEvent() ", event, " ");
switch (event) { switch (event) {
case AC_timer_started: case AC_timer_started: DEBUG_ECHOPGM("AC_timer_started"); break;
DEBUG_ECHOLNPGM(" AC_timer_started"); case AC_timer_paused: DEBUG_ECHOPGM("AC_timer_paused"); break;
break; case AC_timer_stopped: DEBUG_ECHOPGM("AC_timer_stopped"); break;
case AC_timer_paused:
DEBUG_ECHOLNPGM(" AC_timer_paused");
break;
case AC_timer_stopped:
DEBUG_ECHOLNPGM(" AC_timer_stopped");
break;
} }
DEBUG_EOL();
} }
void DEBUG_PRINT_MEDIA_EVENT(FSTR_P const msg, media_event_t event) { void DEBUG_PRINT_MEDIA_EVENT(const media_event_t event, FSTR_P const msg/*=nullptr*/) {
DEBUG_ECHOPGM(msg, event); if (msg) DEBUG_ECHOPGM(msg, event);
DEBUG_ECHOPGM("ProcessMediaStatus() ", event, " ");
switch (event) { switch (event) {
case AC_media_inserted: case AC_media_inserted: DEBUG_ECHOPGM("AC_media_inserted"); break;
DEBUG_ECHOLNPGM(" AC_media_inserted"); case AC_media_removed: DEBUG_ECHOPGM("AC_media_removed"); break;
break; case AC_media_error: DEBUG_ECHOPGM("AC_media_error"); break;
case AC_media_removed:
DEBUG_ECHOLNPGM(" AC_media_removed");
break;
case AC_media_error:
DEBUG_ECHOLNPGM(" AC_media_error");
break;
} }
DEBUG_EOL();
} }
} // namespace } // namespace

View File

@@ -356,17 +356,17 @@ namespace Anycubic {
static lcd_info_t lcd_info, lcd_info_back; static lcd_info_t lcd_info, lcd_info_back;
static uint16_t page_index_now; static uint16_t page_index_now;
static void Startup(); static void startup();
static void ParamInit(); static void ParamInit();
static void IdleLoop(); static void idleLoop();
static void PrinterKilled(FSTR_P,FSTR_P); static void printerKilled(FSTR_P,FSTR_P);
static void MediaEvent(media_event_t); static void mediaEvent(media_event_t);
static void TimerEvent(timer_event_t); static void timerEvent(timer_event_t);
static void FilamentRunout(); static void filamentRunout();
static void ConfirmationRequest(const char * const); static void confirmationRequest(const char * const);
static void StatusChange(const char * const); static void statusChange(const char * const);
static void PowerLoss(); static void PowerLoss();
static void PowerLossRecovery(); static void powerLossRecovery();
static void HomingStart(); static void HomingStart();
static void HomingComplete(); static void HomingComplete();
@@ -450,17 +450,17 @@ namespace Anycubic {
static void pop_up_manager(); static void pop_up_manager();
static void SendtoTFT(FSTR_P const=nullptr); static void tftSend(FSTR_P const=nullptr);
static void SendtoTFTLN(FSTR_P const=nullptr); static void tftSendLn(FSTR_P const=nullptr);
static bool ReadTFTCommand(); static bool readTFTCommand();
static int8_t Findcmndpos(const char *, const char); static int8_t Findcmndpos(const char *, const char);
static void CheckHeaters(); static void checkHeaters();
static void SendFileList(int8_t); static void sendFileList(int8_t);
static void SelectFile(); static void selectFile();
static void ProcessPanelRequest(); static void processPanelRequest();
static void PanelInfo(uint8_t); static void panelInfo(uint8_t);
static void PanelAction(uint8_t); static void panelAction(uint8_t);
static void PanelProcess(uint8_t); static void panelProcess(uint8_t);
static void SendValueToTFT(const uint16_t value, const uint16_t address); static void SendValueToTFT(const uint16_t value, const uint16_t address);
static void RequestValueFromTFT(const uint16_t address); static void RequestValueFromTFT(const uint16_t address);

View File

@@ -37,17 +37,17 @@ using namespace Anycubic;
namespace ExtUI { namespace ExtUI {
void onStartup() { Dgus.Startup(); } void onStartup() { Dgus.startup(); }
void onIdle() { Dgus.IdleLoop(); } void onIdle() { Dgus.idleLoop(); }
void onPrinterKilled(FSTR_P const error, FSTR_P const component) { void onPrinterKilled(FSTR_P const error, FSTR_P const component) {
Dgus.PrinterKilled(error, component); Dgus.printerKilled(error, component);
} }
void onMediaInserted() { Dgus.MediaEvent(AC_media_inserted); } void onMediaInserted() { Dgus.mediaEvent(AC_media_inserted); }
void onMediaError() { Dgus.MediaEvent(AC_media_error); } void onMediaError() { Dgus.mediaEvent(AC_media_error); }
void onMediaRemoved() { Dgus.MediaEvent(AC_media_removed); } void onMediaRemoved() { Dgus.mediaEvent(AC_media_removed); }
void onPlayTone(const uint16_t frequency, const uint16_t duration) { void onPlayTone(const uint16_t frequency, const uint16_t duration) {
#if ENABLED(SPEAKER) #if ENABLED(SPEAKER)
@@ -55,15 +55,15 @@ namespace ExtUI {
#endif #endif
} }
void onPrintTimerStarted() { Dgus.TimerEvent(AC_timer_started); } void onPrintTimerStarted() { Dgus.timerEvent(AC_timer_started); }
void onPrintTimerPaused() { Dgus.TimerEvent(AC_timer_paused); } void onPrintTimerPaused() { Dgus.timerEvent(AC_timer_paused); }
void onPrintTimerStopped() { Dgus.TimerEvent(AC_timer_stopped); } void onPrintTimerStopped() { Dgus.timerEvent(AC_timer_stopped); }
void onPrintDone() {} void onPrintDone() {}
void onFilamentRunout(const extruder_t) { Dgus.FilamentRunout(); } void onFilamentRunout(const extruder_t) { Dgus.filamentRunout(); }
void onUserConfirmRequired(const char * const msg) { Dgus.ConfirmationRequest(msg); } void onUserConfirmRequired(const char * const msg) { Dgus.confirmationRequest(msg); }
void onStatusChanged(const char * const msg) { Dgus.StatusChange(msg); } void onStatusChanged(const char * const msg) { Dgus.statusChange(msg); }
void onHomingStart() { Dgus.HomingStart(); } void onHomingStart() { Dgus.HomingStart(); }
void onHomingDone() { Dgus.HomingComplete(); } void onHomingDone() { Dgus.HomingComplete(); }
@@ -129,7 +129,7 @@ namespace ExtUI {
// Called when power-loss state is detected // Called when power-loss state is detected
void onPowerLoss() { /* handled internally */ } void onPowerLoss() { /* handled internally */ }
// Called on resume from power-loss // Called on resume from power-loss
void onPowerLossResume() { Dgus.PowerLossRecovery(); } void onPowerLossResume() { Dgus.powerLossRecovery(); }
#endif #endif
#if HAS_PID_HEATING #if HAS_PID_HEATING

View File

@@ -220,7 +220,7 @@ void DGUSDisplay::ProcessRx() {
} }
} }
size_t DGUSDisplay::GetFreeTxBuffer() { return SERIAL_GET_TX_BUFFER_FREE(); } size_t DGUSDisplay::GetFreeTxBuffer() { return LCD_SERIAL_TX_BUFFER_FREE(); }
void DGUSDisplay::WriteHeader(uint16_t adr, uint8_t cmd, uint8_t payloadlen) { void DGUSDisplay::WriteHeader(uint16_t adr, uint8_t cmd, uint8_t payloadlen) {
LCD_SERIAL.write(DGUS_HEADER1); LCD_SERIAL.write(DGUS_HEADER1);

View File

@@ -157,7 +157,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
} }
#endif #endif
char axiscode; char axiscode;
uint16_t speed = manual_feedrate_mm_m[X_AXIS]; // Default feedrate for manual moves uint16_t speed = manual_feedrate_mm_m.x; // Default feedrate for manual moves
switch (var.VP) { switch (var.VP) {
default: return; default: return;
@@ -172,7 +172,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
#if HAS_Y_AXIS #if HAS_Y_AXIS
case VP_MOVE_Y: case VP_MOVE_Y:
axiscode = 'Y'; axiscode = 'Y';
speed = manual_feedrate_mm_m[Y_AXIS]; speed = manual_feedrate_mm_m.y;
if (!ExtUI::canMove(ExtUI::axis_t::Y)) goto cannotmove; if (!ExtUI::canMove(ExtUI::axis_t::Y)) goto cannotmove;
break; break;
#endif #endif
@@ -180,7 +180,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
#if HAS_Z_AXIS #if HAS_Z_AXIS
case VP_MOVE_Z: case VP_MOVE_Z:
axiscode = 'Z'; axiscode = 'Z';
speed = manual_feedrate_mm_m[Z_AXIS]; speed = manual_feedrate_mm_m.z;
if (!ExtUI::canMove(ExtUI::axis_t::Z)) goto cannotmove; if (!ExtUI::canMove(ExtUI::axis_t::Z)) goto cannotmove;
break; break;
#endif #endif

View File

@@ -157,7 +157,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
} }
#endif #endif
char axiscode; char axiscode;
uint16_t speed = manual_feedrate_mm_m[X_AXIS]; // Default feedrate for manual moves uint16_t speed = manual_feedrate_mm_m.x; // Default feedrate for manual moves
switch (var.VP) { switch (var.VP) {
default: return; default: return;
@@ -172,7 +172,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
#if HAS_Y_AXIS #if HAS_Y_AXIS
case VP_MOVE_Y: case VP_MOVE_Y:
axiscode = 'Y'; axiscode = 'Y';
speed = manual_feedrate_mm_m[Y_AXIS]; speed = manual_feedrate_mm_m.y;
if (!ExtUI::canMove(ExtUI::axis_t::Y)) goto cannotmove; if (!ExtUI::canMove(ExtUI::axis_t::Y)) goto cannotmove;
break; break;
#endif #endif
@@ -180,7 +180,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
#if HAS_Z_AXIS #if HAS_Z_AXIS
case VP_MOVE_Z: case VP_MOVE_Z:
axiscode = 'Z'; axiscode = 'Z';
speed = manual_feedrate_mm_m[Z_AXIS]; speed = manual_feedrate_mm_m.z;
if (!ExtUI::canMove(ExtUI::axis_t::Z)) goto cannotmove; if (!ExtUI::canMove(ExtUI::axis_t::Z)) goto cannotmove;
break; break;
#endif #endif

View File

@@ -739,7 +739,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
return; return;
char axiscode; char axiscode;
uint16_t speed = manual_feedrate_mm_m[X_AXIS]; // Default feedrate for manual moves uint16_t speed = manual_feedrate_mm_m.x; // Default feedrate for manual moves
switch (var.VP) { // switch X Y Z or Home switch (var.VP) { // switch X Y Z or Home
default: return; default: return;
@@ -753,7 +753,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
#if HAS_Y_AXIS #if HAS_Y_AXIS
case VP_MOVE_Y: case VP_MOVE_Y:
axiscode = 'Y'; axiscode = 'Y';
speed = manual_feedrate_mm_m[Y_AXIS]; speed = manual_feedrate_mm_m.y;
if (!ExtUI::canMove(ExtUI::axis_t::Y)) goto cannotmove; if (!ExtUI::canMove(ExtUI::axis_t::Y)) goto cannotmove;
break; break;
#endif #endif
@@ -761,7 +761,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
#if HAS_Z_AXIS #if HAS_Z_AXIS
case VP_MOVE_Z: case VP_MOVE_Z:
axiscode = 'Z'; axiscode = 'Z';
speed = manual_feedrate_mm_m[Z_AXIS]; speed = manual_feedrate_mm_m.z;
if (!ExtUI::canMove(ExtUI::axis_t::Z)) goto cannotmove; if (!ExtUI::canMove(ExtUI::axis_t::Z)) goto cannotmove;
break; break;
#endif #endif

View File

@@ -157,7 +157,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
} }
#endif #endif
char axiscode; char axiscode;
uint16_t speed = manual_feedrate_mm_m[X_AXIS]; // Default feedrate for manual moves uint16_t speed = manual_feedrate_mm_m.x; // Default feedrate for manual moves
switch (var.VP) { switch (var.VP) {
default: return; default: return;
@@ -172,7 +172,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
#if HAS_Y_AXIS #if HAS_Y_AXIS
case VP_MOVE_Y: case VP_MOVE_Y:
axiscode = 'Y'; axiscode = 'Y';
speed = manual_feedrate_mm_m[Y_AXIS]; speed = manual_feedrate_mm_m.y;
if (!ExtUI::canMove(ExtUI::axis_t::Y)) goto cannotmove; if (!ExtUI::canMove(ExtUI::axis_t::Y)) goto cannotmove;
break; break;
#endif #endif
@@ -180,7 +180,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) {
#if HAS_Z_AXIS #if HAS_Z_AXIS
case VP_MOVE_Z: case VP_MOVE_Z:
axiscode = 'Z'; axiscode = 'Z';
speed = manual_feedrate_mm_m[Z_AXIS]; speed = manual_feedrate_mm_m.z;
if (!ExtUI::canMove(ExtUI::axis_t::Z)) goto cannotmove; if (!ExtUI::canMove(ExtUI::axis_t::Z)) goto cannotmove;
break; break;
#endif #endif

View File

@@ -111,7 +111,7 @@ void DGUSRxHandler::ScreenChange(DGUS_VP &vp, void *data_ptr) {
dgus_screen_handler.TriggerFullUpdate(); dgus_screen_handler.TriggerFullUpdate();
} }
void DGUSRxHandler::SelectFile(DGUS_VP &vp, void *data_ptr) { void DGUSRxHandler::selectFile(DGUS_VP &vp, void *data_ptr) {
UNUSED(vp); UNUSED(vp);
const uint8_t index = ((uint8_t*)data_ptr)[1]; const uint8_t index = ((uint8_t*)data_ptr)[1];

View File

@@ -30,7 +30,7 @@ namespace DGUSRxHandler {
#if HAS_MEDIA #if HAS_MEDIA
void Scroll(DGUS_VP &, void *); void Scroll(DGUS_VP &, void *);
void SelectFile(DGUS_VP &, void *); void selectFile(DGUS_VP &, void *);
void PrintFile(DGUS_VP &, void *); void PrintFile(DGUS_VP &, void *);
#endif #endif

View File

@@ -148,7 +148,7 @@ void DGUSScreenHandler::Loop() {
dgus_display.Loop(); dgus_display.Loop();
} }
void DGUSScreenHandler::PrinterKilled(FSTR_P const error, FSTR_P const component) { void DGUSScreenHandler::printerKilled(FSTR_P const error, FSTR_P const component) {
SetMessageLine(error, 1); SetMessageLine(error, 1);
SetMessageLine(component, 2); SetMessageLine(component, 2);
SetMessageLinePGM(NUL_STR, 3); SetMessageLinePGM(NUL_STR, 3);
@@ -271,7 +271,7 @@ void DGUSScreenHandler::PrintTimerStopped() {
TriggerScreenChange(DGUS_Screen::PRINT_FINISHED); TriggerScreenChange(DGUS_Screen::PRINT_FINISHED);
} }
void DGUSScreenHandler::FilamentRunout(const ExtUI::extruder_t extruder) { void DGUSScreenHandler::filamentRunout(const ExtUI::extruder_t extruder) {
char buffer[21]; char buffer[21];
snprintf_P(buffer, sizeof(buffer), GET_TEXT(DGUS_MSG_FILAMENT_RUNOUT), extruder); snprintf_P(buffer, sizeof(buffer), GET_TEXT(DGUS_MSG_FILAMENT_RUNOUT), extruder);

View File

@@ -37,7 +37,7 @@ public:
static void Ready(); static void Ready();
static void Loop(); static void Loop();
static void PrinterKilled(FSTR_P const error, FSTR_P const component); static void printerKilled(FSTR_P const error, FSTR_P const component);
static void UserConfirmRequired(const char * const msg); static void UserConfirmRequired(const char * const msg);
static void SettingsReset(); static void SettingsReset();
static void StoreSettings(char *buff); static void StoreSettings(char *buff);
@@ -50,7 +50,7 @@ public:
static void PrintTimerStarted(); static void PrintTimerStarted();
static void PrintTimerPaused(); static void PrintTimerPaused();
static void PrintTimerStopped(); static void PrintTimerStopped();
static void FilamentRunout(const ExtUI::extruder_t extruder); static void filamentRunout(const ExtUI::extruder_t extruder);
#if HAS_MEDIA #if HAS_MEDIA
/// Marlin informed us that a new SD has been inserted. /// Marlin informed us that a new SD has been inserted.

View File

@@ -81,7 +81,7 @@ const struct DGUS_VP vp_list[] PROGMEM = {
VP_HELPER_RX(DGUS_Addr::SCREENCHANGE_Printing, &DGUSRxHandler::ScreenChange), VP_HELPER_RX(DGUS_Addr::SCREENCHANGE_Printing, &DGUSRxHandler::ScreenChange),
#if HAS_MEDIA #if HAS_MEDIA
VP_HELPER_RX(DGUS_Addr::SD_SelectFile, &DGUSRxHandler::SelectFile), VP_HELPER_RX(DGUS_Addr::SD_SelectFile, &DGUSRxHandler::selectFile),
VP_HELPER_RX(DGUS_Addr::SD_Scroll, &DGUSRxHandler::Scroll), VP_HELPER_RX(DGUS_Addr::SD_Scroll, &DGUSRxHandler::Scroll),
VP_HELPER_RX_NODATA(DGUS_Addr::SD_Print, &DGUSRxHandler::PrintFile), VP_HELPER_RX_NODATA(DGUS_Addr::SD_Print, &DGUSRxHandler::PrintFile),
#endif #endif

View File

@@ -47,7 +47,7 @@ namespace ExtUI {
} }
void onPrinterKilled(FSTR_P const error, FSTR_P const component) { void onPrinterKilled(FSTR_P const error, FSTR_P const component) {
dgus_screen_handler.PrinterKilled(error, component); dgus_screen_handler.printerKilled(error, component);
} }
void onMediaInserted() { TERN_(HAS_MEDIA, dgus_screen_handler.SDCardInserted()); } void onMediaInserted() { TERN_(HAS_MEDIA, dgus_screen_handler.SDCardInserted()); }
@@ -71,7 +71,7 @@ namespace ExtUI {
} }
void onFilamentRunout(const extruder_t extruder) { void onFilamentRunout(const extruder_t extruder) {
dgus_screen_handler.FilamentRunout(extruder); dgus_screen_handler.filamentRunout(extruder);
} }
void onUserConfirmRequired(const char * const msg) { void onUserConfirmRequired(const char * const msg) {

View File

@@ -33,13 +33,13 @@
#if DGUS_LCD_UI_IA_CREALITY #if DGUS_LCD_UI_IA_CREALITY
#include "ia_creality_extui.h" #include "ia_creality_rts.h"
#include "FileNavigator.h" #include "FileNavigator.h"
using namespace ExtUI; #include <WString.h>
FileList FileNavigator::filelist; // Instance of the Marlin file API ExtUI::FileList FileNavigator::filelist; // ExtUI file API
char FileNavigator::currentfoldername[MAX_PATH_LEN]; // Current folder path char FileNavigator::currentDirPath[MAX_PATH_LEN]; // Current folder path
uint16_t FileNavigator::lastindex; uint16_t FileNavigator::lastindex;
uint8_t FileNavigator::folderdepth; uint8_t FileNavigator::folderdepth;
uint16_t FileNavigator::currentindex; // override the panel request uint16_t FileNavigator::currentindex; // override the panel request
@@ -49,7 +49,7 @@ FileNavigator filenavigator;
FileNavigator::FileNavigator() { reset(); } FileNavigator::FileNavigator() { reset(); }
void FileNavigator::reset() { void FileNavigator::reset() {
currentfoldername[0] = '\0'; currentDirPath[0] = '\0';
folderdepth = 0; folderdepth = 0;
currentindex = 0; currentindex = 0;
lastindex = 0; lastindex = 0;
@@ -136,7 +136,7 @@ void FileNavigator::getFiles(uint16_t index) {
rts.sendData((uint8_t)0, FilenameIcon + (fcnt+1)); rts.sendData((uint8_t)0, FilenameIcon + (fcnt+1));
rts.sendData((unsigned long)0xFFFF, (FilenameNature + ((1+fcnt) * 16))); // white rts.sendData((unsigned long)0xFFFF, (FilenameNature + ((1+fcnt) * 16))); // white
} }
SERIAL_ECHOLNPGM("-", seek, " '", filelist.filename(), "' '", currentfoldername, "", filelist.shortFilename(), "'\n"); SERIAL_ECHOLNPGM("-", seek, " '", filelist.filename(), "' '", currentDirPath, "", filelist.shortFilename(), "'\n");
fcnt++; fcnt++;
} }
} }
@@ -144,8 +144,8 @@ void FileNavigator::getFiles(uint16_t index) {
void FileNavigator::changeDIR(char *folder) { void FileNavigator::changeDIR(char *folder) {
if (folderdepth >= MAX_FOLDER_DEPTH) return; // limit the folder depth if (folderdepth >= MAX_FOLDER_DEPTH) return; // limit the folder depth
strcat(currentfoldername, folder); strcat(currentDirPath, folder);
strcat(currentfoldername, "/"); strcat(currentDirPath, "/");
filelist.changeDir(folder); filelist.changeDir(folder);
refresh(); refresh();
folderdepth++; folderdepth++;
@@ -159,17 +159,17 @@ void FileNavigator::upDIR() {
currentindex = 0; currentindex = 0;
// Remove the last child folder from the stored path // Remove the last child folder from the stored path
if (folderdepth == 0) { if (folderdepth == 0) {
currentfoldername[0] = '\0'; currentDirPath[0] = '\0';
reset(); reset();
} }
else { else {
char *pos = nullptr; char *pos = nullptr;
for (uint8_t f = 0; f < folderdepth; f++) for (uint8_t f = 0; f < folderdepth; f++)
pos = strchr(currentfoldername, '/'); pos = strchr(currentDirPath, '/');
pos[1] = '\0'; pos[1] = '\0';
} }
} }
char* FileNavigator::getCurrentFolderName() { return currentfoldername; } char* FileNavigator::getCurrentDirPath() { return currentDirPath; }
#endif // DGUS_LCD_UI_IA_CREALITY #endif // DGUS_LCD_UI_IA_CREALITY

View File

@@ -30,13 +30,12 @@
* Written by Insanity Automation * Written by Insanity Automation
* ***************************************/ * ***************************************/
#include "../ui_api.h"
#define MAX_FOLDER_DEPTH 4 // Limit folder depth TFT has a limit for the file path #define MAX_FOLDER_DEPTH 4 // Limit folder depth TFT has a limit for the file path
#define MAX_CMND_LEN 16 * MAX_FOLDER_DEPTH // Maximum Length for a Panel command
#define MAX_PATH_LEN 16 * MAX_FOLDER_DEPTH // Maximum number of characters in a SD file path #define MAX_PATH_LEN 16 * MAX_FOLDER_DEPTH // Maximum number of characters in a SD file path
#define DISPLAY_FILES 4 #define DISPLAY_FILES 4
using namespace ExtUI;
class FileNavigator { class FileNavigator {
public: public:
FileNavigator(); FileNavigator();
@@ -45,15 +44,15 @@ class FileNavigator {
static void upDIR(); static void upDIR();
static void changeDIR(char *); static void changeDIR(char *);
static void refresh(); static void refresh();
static char* getCurrentFolderName(); static char* getCurrentDirPath();
static uint8_t folderdepth; static uint8_t folderdepth;
static uint16_t currentindex; static uint16_t currentindex;
static bool getIndexisDir(uint16_t); static bool getIndexisDir(uint16_t);
const char *getIndexName(uint16_t); const char *getIndexName(uint16_t);
static uint16_t maxFiles(); static uint16_t maxFiles();
private: private:
static FileList filelist; static ExtUI::FileList filelist;
static char currentfoldername[MAX_PATH_LEN]; static char currentDirPath[MAX_PATH_LEN];
static uint16_t lastindex; static uint16_t lastindex;
}; };

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -22,18 +22,18 @@
#pragma once #pragma once
/* **************************************** /* ****************************************
* lcd/extui/ia_creality/ia_creality_extui.h * lcd/extui/ia_creality/ia_creality_rts.h
* **************************************** * ****************************************
* Extensible_UI implementation for Creality DWIN * Extensible_UI implementation for Creality DWIN
* 10SPro, Max, CRX, and others * 10SPro, Max, CRX, and others
* Based original Creality release, ported to ExtUI for Marlin 2.0 * Based original Creality release
* Written by Insanity Automation, sponsored by Tiny Machines 3D * Written by Insanity Automation, sponsored by Tiny Machines 3D
* *
* ***************************************/ * ***************************************/
#include "../ui_api.h" #include "../../../inc/MarlinConfig.h"
#include <string.h> #include <WString.h>
/*********************************/ /*********************************/
#define FHONE (0x5A) #define FHONE (0x5A)
@@ -211,7 +211,7 @@ struct creality_dwin_settings_t {
bool display_sound; bool display_sound;
int8_t screen_rotation; int8_t screen_rotation;
int16_t display_volume; int16_t display_volume;
uint8_t standby_screen_brightness; uint8_t standby_brightness;
uint8_t screen_brightness; uint8_t screen_brightness;
int16_t standby_time_seconds; int16_t standby_time_seconds;
}; };
@@ -297,3 +297,19 @@ void RTS_Update();
#else #else
#define MEASURING_GCODE MAIN_MENU_ITEM_1_GCODE #define MEASURING_GCODE MAIN_MENU_ITEM_1_GCODE
#endif #endif
// Data shared by RTS and ExtUI
extern uint16_t fileIndex;
extern uint8_t recordcount;
extern uint8_t startprogress;
extern char waitway;
extern char printerStatusKey[2]; // [0] = 0:ready [1] = 0:keep temperature, 1:heating, 2:cooling, 3:printing
extern bool show_status;
extern bool tpShowStatus; // true: opening time/percentage, false: closing time/percentage
extern uint8_t lastPauseMsgState;
extern creality_dwin_settings_t dwin_settings;
extern bool no_reentry;
#if HAS_PID_HEATING
extern uint16_t pid_hotendAutoTemp;
extern uint16_t pid_bedAutoTemp;
#endif

View File

@@ -137,7 +137,6 @@ void tft_lvgl_init() {
#if ENABLED(USB_FLASH_DRIVE_SUPPORT) #if ENABLED(USB_FLASH_DRIVE_SUPPORT)
uint16_t usb_flash_loop = 1000; uint16_t usb_flash_loop = 1000;
#if ENABLED(MULTI_VOLUME) && !HAS_SD_HOST_DRIVE #if ENABLED(MULTI_VOLUME) && !HAS_SD_HOST_DRIVE
SET_INPUT_PULLUP(SD_DETECT_PIN);
if (IS_SD_INSERTED()) if (IS_SD_INSERTED())
card.changeMedia(&card.media_driver_sdcard); card.changeMedia(&card.media_driver_sdcard);
else else

View File

@@ -39,8 +39,8 @@ using namespace ExtUI;
#define DEBUG_OUT NEXDEBUGLEVEL #define DEBUG_OUT NEXDEBUGLEVEL
#include "../../../core/debug_out.h" #include "../../../core/debug_out.h"
FileList FileNavigator::filelist; // Instance of the Marlin file API FileList FileNavigator::filelist; // ExtUI file API
char FileNavigator::currentfoldername[MAX_PATH_LEN]; // Current folder path char FileNavigator::currentDirPath[MAX_PATH_LEN]; // Current folder path
uint16_t FileNavigator::lastindex; uint16_t FileNavigator::lastindex;
uint8_t FileNavigator::folderdepth; uint8_t FileNavigator::folderdepth;
uint16_t FileNavigator::currentindex; // override the panel request uint16_t FileNavigator::currentindex; // override the panel request
@@ -50,7 +50,7 @@ FileNavigator filenavigator;
FileNavigator::FileNavigator() { reset(); } FileNavigator::FileNavigator() { reset(); }
void FileNavigator::reset() { void FileNavigator::reset() {
currentfoldername[0] = '\0'; currentDirPath[0] = '\0';
folderdepth = 0; folderdepth = 0;
currentindex = 0; currentindex = 0;
lastindex = 0; lastindex = 0;
@@ -83,51 +83,51 @@ void FileNavigator::getFiles(uint16_t index) {
#endif #endif
if (currentindex == 0 && folderdepth > 0) { // Add a link to go up a folder if (currentindex == 0 && folderdepth > 0) { // Add a link to go up a folder
nextion.SendtoTFT(F("vis p0,1")); nextion.tftSend(F("vis p0,1"));
nextion.SendtoTFT(F("\xFF\xFF\xFF")); nextion.tftSend(F("\xFF\xFF\xFF"));
SEND_VAL("tmpUP", "0"); SEND_VAL("tmpUP", "0");
files--; files--;
} }
else { else {
nextion.SendtoTFT(F("vis p0,0")); nextion.tftSend(F("vis p0,0"));
nextion.SendtoTFT(F("\xFF\xFF\xFF")); nextion.tftSend(F("\xFF\xFF\xFF"));
} }
for (uint16_t seek = currentindex; seek < currentindex + files; seek++) { for (uint16_t seek = currentindex; seek < currentindex + files; seek++) {
if (filelist.seek(seek)) { if (filelist.seek(seek)) {
nextion.SendtoTFT(F("s")); nextion.tftSend(F("s"));
LCD_SERIAL.print(fcnt); LCD_SERIAL.print(fcnt);
nextion.SendtoTFT(F(".txt=\"")); nextion.tftSend(F(".txt=\""));
if (filelist.isDir()) { if (filelist.isDir()) {
LCD_SERIAL.print(filelist.shortFilename()); LCD_SERIAL.print(filelist.shortFilename());
nextion.SendtoTFT(F("/\"")); nextion.tftSend(F("/\""));
nextion.SendtoTFT(F("\xFF\xFF\xFF")); nextion.tftSend(F("\xFF\xFF\xFF"));
nextion.SendtoTFT(F("l")); nextion.tftSend(F("l"));
LCD_SERIAL.print(fcnt); LCD_SERIAL.print(fcnt);
nextion.SendtoTFT(F(".txt=\"")); nextion.tftSend(F(".txt=\""));
LCD_SERIAL.print(filelist.filename()); LCD_SERIAL.print(filelist.filename());
nextion.SendtoTFT(F("\"")); nextion.tftSend(F("\""));
nextion.SendtoTFT(F("\xFF\xFF\xFF")); nextion.tftSend(F("\xFF\xFF\xFF"));
SEND_PCO2("l", fcnt, "1055"); SEND_PCO2("l", fcnt, "1055");
} }
else { else {
LCD_SERIAL.print(currentfoldername); LCD_SERIAL.print(currentDirPath);
LCD_SERIAL.print(filelist.shortFilename()); LCD_SERIAL.print(filelist.shortFilename());
nextion.SendtoTFT(F("\"")); nextion.tftSend(F("\""));
nextion.SendtoTFT(F("\xFF\xFF\xFF")); nextion.tftSend(F("\xFF\xFF\xFF"));
nextion.SendtoTFT(F("l")); nextion.tftSend(F("l"));
LCD_SERIAL.print(fcnt); LCD_SERIAL.print(fcnt);
nextion.SendtoTFT(F(".txt=\"")); nextion.tftSend(F(".txt=\""));
LCD_SERIAL.print(filelist.longFilename()); LCD_SERIAL.print(filelist.longFilename());
nextion.SendtoTFT(F("\"")); nextion.tftSend(F("\""));
nextion.SendtoTFT(F("\xFF\xFF\xFF")); nextion.tftSend(F("\xFF\xFF\xFF"));
} }
fcnt++; fcnt++;
fseek = seek; fseek = seek;
#if NEXDEBUG(AC_FILE) #if NEXDEBUG(AC_FILE)
DEBUG_ECHOLNPGM("-", seek, " '", filelist.longFilename(), "' '", currentfoldername, "", filelist.shortFilename(), "'\n"); DEBUG_ECHOLNPGM("-", seek, " '", filelist.longFilename(), "' '", currentDirPath, "", filelist.shortFilename(), "'\n");
#endif #endif
} }
} }
@@ -137,11 +137,11 @@ void FileNavigator::getFiles(uint16_t index) {
void FileNavigator::changeDIR(char *folder) { void FileNavigator::changeDIR(char *folder) {
#if NEXDEBUG(AC_FILE) #if NEXDEBUG(AC_FILE)
DEBUG_ECHOLNPGM("currentfolder: ", currentfoldername, " New: ", folder); DEBUG_ECHOLNPGM("currentfolder: ", currentDirPath, " New: ", folder);
#endif #endif
if (folderdepth >= MAX_FOLDER_DEPTH) return; // limit the folder depth if (folderdepth >= MAX_FOLDER_DEPTH) return; // limit the folder depth
strcat(currentfoldername, folder); strcat(currentDirPath, folder);
strcat(currentfoldername, "/"); strcat(currentDirPath, "/");
filelist.changeDir(folder); filelist.changeDir(folder);
refresh(); refresh();
folderdepth++; folderdepth++;
@@ -155,20 +155,20 @@ void FileNavigator::upDIR() {
currentindex = 0; currentindex = 0;
// Remove the last child folder from the stored path // Remove the last child folder from the stored path
if (folderdepth == 0) { if (folderdepth == 0) {
currentfoldername[0] = '\0'; currentDirPath[0] = '\0';
reset(); reset();
} }
else { else {
char *pos = nullptr; char *pos = nullptr;
for (uint8_t f = 0; f < folderdepth; f++) for (uint8_t f = 0; f < folderdepth; f++)
pos = strchr(currentfoldername, '/'); pos = strchr(currentDirPath, '/');
pos[1] = '\0'; pos[1] = '\0';
} }
#if NEXDEBUG(AC_FILE) #if NEXDEBUG(AC_FILE)
DEBUG_ECHOLNPGM("depth: ", folderdepth, " currentfoldername: ", currentfoldername); DEBUG_ECHOLNPGM("depth: ", folderdepth, " currentDirPath: ", currentDirPath);
#endif #endif
} }
char* FileNavigator::getCurrentFolderName() { return currentfoldername; } char* FileNavigator::getCurrentDirPath() { return currentDirPath; }
#endif // NEXTION_TFT #endif // NEXTION_TFT

View File

@@ -41,10 +41,10 @@ class FileNavigator {
static void upDIR(); static void upDIR();
static void changeDIR(char *); static void changeDIR(char *);
static void refresh(); static void refresh();
static char* getCurrentFolderName(); static char* getCurrentDirPath();
private: private:
static FileList filelist; static FileList filelist;
static char currentfoldername[MAX_PATH_LEN]; static char currentDirPath[MAX_PATH_LEN];
static uint16_t lastindex; static uint16_t lastindex;
static uint8_t folderdepth; static uint8_t folderdepth;
static uint16_t currentindex; static uint16_t currentindex;

View File

@@ -35,9 +35,9 @@
namespace ExtUI { namespace ExtUI {
void onStartup() { nextion.Startup(); } void onStartup() { nextion.startup(); }
void onIdle() { nextion.IdleLoop(); } void onIdle() { nextion.idleLoop(); }
void onPrinterKilled(FSTR_P const error, FSTR_P const component) { nextion.PrinterKilled(error, component); } void onPrinterKilled(FSTR_P const error, FSTR_P const component) { nextion.printerKilled(error, component); }
void onMediaInserted() {} void onMediaInserted() {}
void onMediaError() {} void onMediaError() {}
void onMediaRemoved() {} void onMediaRemoved() {}
@@ -46,8 +46,8 @@ namespace ExtUI {
void onPrintTimerPaused() {} void onPrintTimerPaused() {}
void onPrintTimerStopped() {} void onPrintTimerStopped() {}
void onFilamentRunout(const extruder_t) {} void onFilamentRunout(const extruder_t) {}
void onUserConfirmRequired(const char * const msg) { nextion.ConfirmationRequest(msg); } void onUserConfirmRequired(const char * const msg) { nextion.confirmationRequest(msg); }
void onStatusChanged(const char * const msg) { nextion.StatusChange(msg); } void onStatusChanged(const char * const msg) { nextion.statusChange(msg); }
void onHomingStart() {} void onHomingStart() {}
void onHomingDone() {} void onHomingDone() {}
@@ -117,7 +117,7 @@ namespace ExtUI {
#if HAS_PID_HEATING #if HAS_PID_HEATING
void onPidTuning(const result_t rst) { void onPidTuning(const result_t rst) {
// Called for temperature PID tuning result // Called for temperature PID tuning result
nextion.PanelInfo(37); nextion.panelInfo(37);
} }
#endif #endif

View File

@@ -53,7 +53,7 @@ NextionTFT nextion;
NextionTFT::NextionTFT() {} NextionTFT::NextionTFT() {}
void NextionTFT::Startup() { void NextionTFT::startup() {
selectedfile[0] = '\0'; selectedfile[0] = '\0';
nextion_command[0] = '\0'; nextion_command[0] = '\0';
command_len = 0; command_len = 0;
@@ -76,15 +76,15 @@ void NextionTFT::Startup() {
DEBUG_ECHOLNPGM("Nextion Debug Level ", NEXDEBUGLEVEL); DEBUG_ECHOLNPGM("Nextion Debug Level ", NEXDEBUGLEVEL);
} }
void NextionTFT::IdleLoop() { void NextionTFT::idleLoop() {
if (ReadTFTCommand()) { if (readTFTCommand()) {
ProcessPanelRequest(); processPanelRequest();
command_len = 0; command_len = 0;
} }
UpdateOnChange(); UpdateOnChange();
} }
void NextionTFT::PrinterKilled(FSTR_P const error, FSTR_P const component) { void NextionTFT::printerKilled(FSTR_P const error, FSTR_P const component) {
SEND_TXT_END("page error"); SEND_TXT_END("page error");
SEND_TXT_F("t3", F("Error")); SEND_TXT_F("t3", F("Error"));
SEND_TXT_F("t4", component); SEND_TXT_F("t4", component);
@@ -96,21 +96,21 @@ void NextionTFT::PrintFinished() {
SEND_TXT_END("page printfinished"); SEND_TXT_END("page printfinished");
} }
void NextionTFT::ConfirmationRequest(const char * const msg) { void NextionTFT::confirmationRequest(const char * const msg) {
SEND_VALasTXT("tmppage.M117", msg); SEND_VALasTXT("tmppage.M117", msg);
#if NEXDEBUG(N_MARLIN) #if NEXDEBUG(N_MARLIN)
DEBUG_ECHOLNPGM("ConfirmationRequest() ", msg, " printer_state:", printer_state); DEBUG_ECHOLNPGM("confirmationRequest() ", msg, " printer_state:", printer_state);
#endif #endif
} }
void NextionTFT::StatusChange(const char * const msg) { void NextionTFT::statusChange(const char * const msg) {
#if NEXDEBUG(N_MARLIN) #if NEXDEBUG(N_MARLIN)
DEBUG_ECHOLNPGM("StatusChange() ", msg, "\nprinter_state:", printer_state); DEBUG_ECHOLNPGM("statusChange() ", msg, "\nprinter_state:", printer_state);
#endif #endif
SEND_VALasTXT("tmppage.M117", msg); SEND_VALasTXT("tmppage.M117", msg);
} }
void NextionTFT::SendtoTFT(FSTR_P const fstr/*=nullptr*/) { // A helper to print PROGMEM string to the panel void NextionTFT::tftSend(FSTR_P const fstr/*=nullptr*/) { // A helper to print PROGMEM string to the panel
#if NEXDEBUG(N_SOME) #if NEXDEBUG(N_SOME)
DEBUG_ECHOF(fstr); DEBUG_ECHOF(fstr);
#endif #endif
@@ -118,7 +118,7 @@ void NextionTFT::SendtoTFT(FSTR_P const fstr/*=nullptr*/) { // A helper to print
while (const char c = pgm_read_byte(str++)) LCD_SERIAL.write(c); while (const char c = pgm_read_byte(str++)) LCD_SERIAL.write(c);
} }
bool NextionTFT::ReadTFTCommand() { bool NextionTFT::readTFTCommand() {
bool command_ready = false; bool command_ready = false;
while ((LCD_SERIAL.available() > 0) && (command_len < MAX_CMND_LEN)) { while ((LCD_SERIAL.available() > 0) && (command_len < MAX_CMND_LEN)) {
nextion_command[command_len] = LCD_SERIAL.read(); nextion_command[command_len] = LCD_SERIAL.read();
@@ -149,15 +149,15 @@ bool NextionTFT::ReadTFTCommand() {
return command_ready; return command_ready;
} }
void NextionTFT::SendFileList(int8_t startindex) { void NextionTFT::sendFileList(int8_t startindex) {
// respond to panel request for 7 files starting at index // respond to panel request for 7 files starting at index
#if NEXDEBUG(N_INFO) #if NEXDEBUG(N_INFO)
DEBUG_ECHOLNPGM("## SendFileList ## ", startindex); DEBUG_ECHOLNPGM("## sendFileList ## ", startindex);
#endif #endif
filenavigator.getFiles(startindex); filenavigator.getFiles(startindex);
} }
void NextionTFT::SelectFile() { void NextionTFT::selectFile() {
strncpy(selectedfile, nextion_command + 4, command_len - 4); strncpy(selectedfile, nextion_command + 4, command_len - 4);
selectedfile[command_len - 5] = '\0'; selectedfile[command_len - 5] = '\0';
#if NEXDEBUG(N_FILE) #if NEXDEBUG(N_FILE)
@@ -169,11 +169,11 @@ void NextionTFT::SelectFile() {
break; break;
case '<': // .. (go up folder level) case '<': // .. (go up folder level)
filenavigator.upDIR(); filenavigator.upDIR();
SendFileList(0); sendFileList(0);
break; break;
default: // enter sub folder default: // enter sub folder
filenavigator.changeDIR(selectedfile); filenavigator.changeDIR(selectedfile);
SendFileList(0); sendFileList(0);
break; break;
} }
} }
@@ -188,24 +188,24 @@ void NextionTFT::_format_time(char *outstr, uint32_t time) {
sprintf_P(outstr, PSTR("%02d:%02ds"), min, sec); sprintf_P(outstr, PSTR("%02d:%02ds"), min, sec);
} }
void NextionTFT::ProcessPanelRequest() { void NextionTFT::processPanelRequest() {
// Break these up into logical blocks as its easier to navigate than one huge switch case! // Break these up into logical blocks as its easier to navigate than one huge switch case!
if (nextion_command[0] == 'X') { if (nextion_command[0] == 'X') {
int8_t req = atoi(&nextion_command[1]); int8_t req = atoi(&nextion_command[1]);
// Information requests // Information requests
if (req <= 49) if (req <= 49)
PanelInfo(req); panelInfo(req);
// Simple Actions // Simple Actions
else if (req >= 50) else if (req >= 50)
PanelAction(req); panelAction(req);
} }
} }
#define SEND_NA(A) SEND_TXT(A, "n/a") #define SEND_NA(A) SEND_TXT(A, "n/a")
void NextionTFT::PanelInfo(uint8_t req) { void NextionTFT::panelInfo(uint8_t req) {
switch (req) { switch (req) {
case 0: break; case 0: break;
@@ -216,7 +216,7 @@ void NextionTFT::PanelInfo(uint8_t req) {
//SEND_TXT("tmppage.M117", msg_no_sd_card); //SEND_TXT("tmppage.M117", msg_no_sd_card);
} }
else if (nextion_command[3] == 'S') else if (nextion_command[3] == 'S')
SendFileList(atoi(&nextion_command[4])); sendFileList(atoi(&nextion_command[4]));
} }
break; break;
@@ -488,7 +488,7 @@ void NextionTFT::PanelInfo(uint8_t req) {
} }
} }
void NextionTFT::PanelAction(uint8_t req) { void NextionTFT::panelAction(uint8_t req) {
switch (req) { switch (req) {
case 50: // Pause SD print case 50: // Pause SD print
@@ -512,7 +512,7 @@ void NextionTFT::PanelAction(uint8_t req) {
break; break;
case 54: // A13 Select file case 54: // A13 Select file
SelectFile(); selectFile();
break; break;
case 65: // Cool Down case 65: // Cool Down

View File

@@ -40,23 +40,23 @@ class NextionTFT {
public: public:
NextionTFT(); NextionTFT();
static void Startup(); static void startup();
static void IdleLoop(); static void idleLoop();
static void PrinterKilled(FSTR_P const, FSTR_P const); static void printerKilled(FSTR_P const, FSTR_P const);
static void ConfirmationRequest(const char * const); static void confirmationRequest(const char * const);
static void StatusChange(const char * const); static void statusChange(const char * const);
static void SendtoTFT(FSTR_P const=nullptr); static void tftSend(FSTR_P const=nullptr);
//static void SendtoTFTLN(FSTR_P const=nullptr); //static void tftSendLn(FSTR_P const=nullptr);
static void UpdateOnChange(); static void UpdateOnChange();
static void PrintFinished(); static void PrintFinished();
static void PanelInfo(uint8_t); static void panelInfo(uint8_t);
private: private:
static bool ReadTFTCommand(); static bool readTFTCommand();
static void SendFileList(int8_t); static void sendFileList(int8_t);
static void SelectFile(); static void selectFile();
static void ProcessPanelRequest(); static void processPanelRequest();
static void PanelAction(uint8_t); static void panelAction(uint8_t);
static void _format_time(char *, uint32_t); static void _format_time(char *, uint32_t);
}; };

View File

@@ -54,10 +54,10 @@
// TFT panel commands // TFT panel commands
#define msg_welcome MACHINE_NAME " Ready." #define msg_welcome MACHINE_NAME " Ready."
#define SEND_TEMP(x,y,t,z) (nextion.SendtoTFT(F(x)), nextion.SendtoTFT(F(".txt=\"")), LCD_SERIAL.print(y), nextion.SendtoTFT(F(t)), LCD_SERIAL.print(z), nextion.SendtoTFT(F("\"\xFF\xFF\xFF"))) #define SEND_TEMP(x,y,t,z) (nextion.tftSend(F(x)), nextion.tftSend(F(".txt=\"")), LCD_SERIAL.print(y), nextion.tftSend(F(t)), LCD_SERIAL.print(z), nextion.tftSend(F("\"\xFF\xFF\xFF")))
#define SEND_VAL(x,y) (nextion.SendtoTFT(F(x)), nextion.SendtoTFT(F(".val=")), LCD_SERIAL.print(y), nextion.SendtoTFT(F("\xFF\xFF\xFF"))) #define SEND_VAL(x,y) (nextion.tftSend(F(x)), nextion.tftSend(F(".val=")), LCD_SERIAL.print(y), nextion.tftSend(F("\xFF\xFF\xFF")))
#define SEND_TXT(x,y) (nextion.SendtoTFT(F(x)), nextion.SendtoTFT(F(".txt=\"")), nextion.SendtoTFT(F(y)), nextion.SendtoTFT(F("\"\xFF\xFF\xFF"))) #define SEND_TXT(x,y) (nextion.tftSend(F(x)), nextion.tftSend(F(".txt=\"")), nextion.tftSend(F(y)), nextion.tftSend(F("\"\xFF\xFF\xFF")))
#define SEND_TXT_F(x,y) (nextion.SendtoTFT(F(x)), nextion.SendtoTFT(F(".txt=\"")), nextion.SendtoTFT(y), nextion.SendtoTFT(F("\"\xFF\xFF\xFF"))) #define SEND_TXT_F(x,y) (nextion.tftSend(F(x)), nextion.tftSend(F(".txt=\"")), nextion.tftSend(y), nextion.tftSend(F("\"\xFF\xFF\xFF")))
#define SEND_VALasTXT(x,y) (nextion.SendtoTFT(F(x)), nextion.SendtoTFT(F(".txt=\"")), LCD_SERIAL.print(y), nextion.SendtoTFT(F("\"\xFF\xFF\xFF"))) #define SEND_VALasTXT(x,y) (nextion.tftSend(F(x)), nextion.tftSend(F(".txt=\"")), LCD_SERIAL.print(y), nextion.tftSend(F("\"\xFF\xFF\xFF")))
#define SEND_TXT_END(x) (nextion.SendtoTFT(F(x)), nextion.SendtoTFT(F("\xFF\xFF\xFF"))) #define SEND_TXT_END(x) (nextion.tftSend(F(x)), nextion.tftSend(F("\xFF\xFF\xFF")))
#define SEND_PCO2(x,y,z) (nextion.SendtoTFT(F(x)), LCD_SERIAL.print(y), nextion.SendtoTFT(F(".pco=")), nextion.SendtoTFT(F(z)), nextion.SendtoTFT(F("\xFF\xFF\xFF"))) #define SEND_PCO2(x,y,z) (nextion.tftSend(F(x)), LCD_SERIAL.print(y), nextion.tftSend(F(".pco=")), nextion.tftSend(F(z)), nextion.tftSend(F("\xFF\xFF\xFF")))

View File

@@ -748,9 +748,9 @@ namespace Language_en {
LSTR MSG_MMU2_EJECT_FILAMENT = _UxGT("MMU Eject"); LSTR MSG_MMU2_EJECT_FILAMENT = _UxGT("MMU Eject");
LSTR MSG_MMU2_EJECT_FILAMENT_N = _UxGT("MMU Eject ~"); LSTR MSG_MMU2_EJECT_FILAMENT_N = _UxGT("MMU Eject ~");
LSTR MSG_MMU2_UNLOAD_FILAMENT = _UxGT("MMU Unload"); LSTR MSG_MMU2_UNLOAD_FILAMENT = _UxGT("MMU Unload");
LSTR MSG_MMU2_LOADING_FILAMENT = _UxGT("Loading Fil. %i..."); LSTR MSG_MMU2_LOADING_FILAMENT = _UxGT("Filament %i Load...");
LSTR MSG_MMU2_EJECTING_FILAMENT = _UxGT("Ejecting Fil. ..."); LSTR MSG_MMU2_EJECTING_FILAMENT = _UxGT("Filament Eject...");
LSTR MSG_MMU2_UNLOADING_FILAMENT = _UxGT("Unloading Fil...."); LSTR MSG_MMU2_UNLOADING_FILAMENT = _UxGT("Filament Unload...");
LSTR MSG_MMU2_ALL = _UxGT("All"); LSTR MSG_MMU2_ALL = _UxGT("All");
LSTR MSG_MMU2_FILAMENT_N = _UxGT("Filament ~"); LSTR MSG_MMU2_FILAMENT_N = _UxGT("Filament ~");
LSTR MSG_MMU2_RESET = _UxGT("Reset MMU"); LSTR MSG_MMU2_RESET = _UxGT("Reset MMU");