|
@ -43,22 +43,22 @@ |
|
|
|
|
|
|
|
|
namespace Anycubic { |
|
|
namespace Anycubic { |
|
|
|
|
|
|
|
|
printer_state_t ChironTFT::printer_state; |
|
|
printer_state_t ChironTFT::printer_state; |
|
|
paused_state_t ChironTFT::pause_state; |
|
|
paused_state_t ChironTFT::pause_state; |
|
|
heater_state_t ChironTFT::hotend_state; |
|
|
heater_state_t ChironTFT::hotend_state; |
|
|
heater_state_t ChironTFT::hotbed_state; |
|
|
heater_state_t ChironTFT::hotbed_state; |
|
|
xy_uint8_t ChironTFT::selectedmeshpoint; |
|
|
xy_uint8_t ChironTFT::selectedmeshpoint; |
|
|
char ChironTFT::selectedfile[MAX_PATH_LEN]; |
|
|
char ChironTFT::selectedfile[MAX_PATH_LEN]; |
|
|
char ChironTFT::panel_command[MAX_CMND_LEN]; |
|
|
char ChironTFT::panel_command[MAX_CMND_LEN]; |
|
|
uint8_t ChironTFT::command_len; |
|
|
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; |
|
|
|
|
|
|
|
|
ChironTFT Chiron; |
|
|
ChironTFT Chiron; |
|
|
|
|
|
|
|
|
ChironTFT::ChironTFT(){} |
|
|
ChironTFT::ChironTFT(){} |
|
|
|
|
|
|
|
|
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; |
|
@ -99,24 +99,24 @@ namespace Anycubic { |
|
|
SERIAL_ECHOLNPAIR("AC Debug Level ", ACDEBUGLEVEL); |
|
|
SERIAL_ECHOLNPAIR("AC Debug Level ", ACDEBUGLEVEL); |
|
|
#endif |
|
|
#endif |
|
|
SendtoTFTLN(AC_msg_ready); |
|
|
SendtoTFTLN(AC_msg_ready); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void ChironTFT::IdleLoop() { |
|
|
void ChironTFT::IdleLoop() { |
|
|
if (ReadTFTCommand()) { |
|
|
if (ReadTFTCommand()) { |
|
|
ProcessPanelRequest(); |
|
|
ProcessPanelRequest(); |
|
|
command_len = 0; |
|
|
command_len = 0; |
|
|
} |
|
|
} |
|
|
CheckHeaters(); |
|
|
CheckHeaters(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void ChironTFT::PrinterKilled(PGM_P error,PGM_P component) { |
|
|
void ChironTFT::PrinterKilled(PGM_P error,PGM_P component) { |
|
|
SendtoTFTLN(AC_msg_kill_lcd); |
|
|
SendtoTFTLN(AC_msg_kill_lcd); |
|
|
#if ACDEBUG(AC_MARLIN) |
|
|
#if ACDEBUG(AC_MARLIN) |
|
|
SERIAL_ECHOLNPAIR("PrinterKilled()\nerror: ", error , "\ncomponent: ", component); |
|
|
SERIAL_ECHOLNPAIR("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_ECHOLNPAIR("ProcessMediaStatus() ", event); |
|
|
SERIAL_ECHOLNPAIR("ProcessMediaStatus() ", event); |
|
|
#endif |
|
|
#endif |
|
@ -133,9 +133,9 @@ namespace Anycubic { |
|
|
SendtoTFTLN(AC_msg_no_sd_card); |
|
|
SendtoTFTLN(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_ECHOLNPAIR("TimerEvent() ", event); |
|
|
SERIAL_ECHOLNPAIR("TimerEvent() ", event); |
|
|
SERIAL_ECHOLNPAIR("Printer State: ", printer_state); |
|
|
SERIAL_ECHOLNPAIR("Printer State: ", printer_state); |
|
@ -163,9 +163,9 @@ namespace Anycubic { |
|
|
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_ECHOLNPAIR("FilamentRunout() printer_state ", printer_state); |
|
|
SERIAL_ECHOLNPAIR("FilamentRunout() printer_state ", printer_state); |
|
|
#endif |
|
|
#endif |
|
@ -173,9 +173,9 @@ namespace Anycubic { |
|
|
SendtoTFTLN(isPrintingFromMedia() ? AC_msg_filament_out_alert : AC_msg_filament_out_block); |
|
|
SendtoTFTLN(isPrintingFromMedia() ? AC_msg_filament_out_alert : AC_msg_filament_out_block); |
|
|
//printer_state = AC_printer_filament_out;
|
|
|
//printer_state = AC_printer_filament_out;
|
|
|
PlayTune(BEEPER_PIN, FilamentOut, 1); |
|
|
PlayTune(BEEPER_PIN, FilamentOut, 1); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
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_ECHOLNPAIR("ConfirmationRequest() ", msg, " printer_state:", printer_state); |
|
|
SERIAL_ECHOLNPAIR("ConfirmationRequest() ", msg, " printer_state:", printer_state); |
|
@ -211,9 +211,9 @@ namespace Anycubic { |
|
|
default: |
|
|
default: |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void ChironTFT::StatusChange(const char * const msg) { |
|
|
void ChironTFT::StatusChange(const char * const msg) { |
|
|
#if ACDEBUG(AC_MARLIN) |
|
|
#if ACDEBUG(AC_MARLIN) |
|
|
SERIAL_ECHOLNPAIR("StatusChange() ", msg); |
|
|
SERIAL_ECHOLNPAIR("StatusChange() ", msg); |
|
|
SERIAL_ECHOLNPAIR("printer_state:", printer_state); |
|
|
SERIAL_ECHOLNPAIR("printer_state:", printer_state); |
|
@ -279,23 +279,23 @@ namespace Anycubic { |
|
|
hotbed_state = AC_heater_temp_set; |
|
|
hotbed_state = AC_heater_temp_set; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
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.
|
|
|
PlayTune(BEEPER_PIN, SOS, 1); |
|
|
PlayTune(BEEPER_PIN, SOS, 1); |
|
|
SERIAL_ECHOLNPGM("Resuming from power outage..."); |
|
|
SERIAL_ECHOLNPGM("Resuming from power outage..."); |
|
|
SERIAL_ECHOLNPGM("Select SD file then press resume"); |
|
|
SERIAL_ECHOLNPGM("Select SD file then press resume"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void ChironTFT::SendtoTFT(PGM_P str) { // A helper to print PROGMEM string to the panel
|
|
|
void ChironTFT::SendtoTFT(PGM_P str) { // A helper to print PROGMEM string to the panel
|
|
|
#if ACDEBUG(AC_SOME) |
|
|
#if ACDEBUG(AC_SOME) |
|
|
SERIAL_ECHOPGM_P(str); |
|
|
SERIAL_ECHOPGM_P(str); |
|
|
#endif |
|
|
#endif |
|
|
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(PGM_P str = nullptr) { |
|
|
void ChironTFT::SendtoTFTLN(PGM_P str = nullptr) { |
|
|
if (str) { |
|
|
if (str) { |
|
|
#if ACDEBUG(AC_SOME) |
|
|
#if ACDEBUG(AC_SOME) |
|
|
SERIAL_ECHOPGM("> "); |
|
|
SERIAL_ECHOPGM("> "); |
|
@ -306,9 +306,9 @@ namespace Anycubic { |
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
|
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(); |
|
@ -334,15 +334,15 @@ namespace Anycubic { |
|
|
#endif |
|
|
#endif |
|
|
} |
|
|
} |
|
|
return command_ready; |
|
|
return command_ready; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int8_t ChironTFT::Findcmndpos(const char * buff, char q) { |
|
|
int8_t ChironTFT::Findcmndpos(const char * buff, char q) { |
|
|
int8_t pos = 0; |
|
|
int8_t pos = 0; |
|
|
do { if (buff[pos] == q) return pos; } while (++pos < MAX_CMND_LEN); |
|
|
do { if (buff[pos] == q) return pos; } while (++pos < MAX_CMND_LEN); |
|
|
return -1; |
|
|
return -1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void ChironTFT::CheckHeaters() { |
|
|
void ChironTFT::CheckHeaters() { |
|
|
uint8_t faultDuration = 0; |
|
|
uint8_t faultDuration = 0; |
|
|
float temp = 0; |
|
|
float temp = 0; |
|
|
|
|
|
|
|
@ -388,9 +388,9 @@ namespace Anycubic { |
|
|
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_ECHOLNPAIR("## SendFileList ## ", startindex); |
|
|
SERIAL_ECHOLNPAIR("## SendFileList ## ", startindex); |
|
@ -398,9 +398,9 @@ namespace Anycubic { |
|
|
SendtoTFTLN(PSTR("FN ")); |
|
|
SendtoTFTLN(PSTR("FN ")); |
|
|
filenavigator.getFiles(startindex); |
|
|
filenavigator.getFiles(startindex); |
|
|
SendtoTFTLN(PSTR("END")); |
|
|
SendtoTFTLN(PSTR("END")); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void ChironTFT::SelectFile() { |
|
|
void ChironTFT::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) |
|
@ -422,14 +422,14 @@ namespace Anycubic { |
|
|
SendFileList( 0 ); |
|
|
SendFileList( 0 ); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void ChironTFT::InjectCommandandWait(PGM_P cmd) { |
|
|
void ChironTFT::InjectCommandandWait(PGM_P cmd) { |
|
|
//injectCommands_P(cmnd); queue.enqueue_now_P(cmd);
|
|
|
//injectCommands_P(cmnd); queue.enqueue_now_P(cmd);
|
|
|
//SERIAL_ECHOLN(PSTR("Inject>"));
|
|
|
//SERIAL_ECHOLN(PSTR("Inject>"));
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
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 req = atoi(&panel_command[1]); |
|
|
int8_t req = atoi(&panel_command[1]); |
|
|
|
|
|
|
|
@ -443,9 +443,9 @@ namespace Anycubic { |
|
|
else if (req <= 34) PanelProcess(req); |
|
|
else if (req <= 34) PanelProcess(req); |
|
|
|
|
|
|
|
|
else SendtoTFTLN(); |
|
|
else SendtoTFTLN(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
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
|
|
@ -516,9 +516,9 @@ namespace Anycubic { |
|
|
SendtoTFTLN(PSTR(SHORT_BUILD_VERSION)); |
|
|
SendtoTFTLN(PSTR(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()) { |
|
@ -703,9 +703,9 @@ namespace Anycubic { |
|
|
SendtoTFTLN(); |
|
|
SendtoTFTLN(); |
|
|
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; |
|
@ -832,8 +832,8 @@ namespace Anycubic { |
|
|
setAxisPosition_mm(currZpos+constrain(Zshift,-0.05,0.05),Z); |
|
|
setAxisPosition_mm(currZpos+constrain(Zshift,-0.05,0.05),Z); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} break; |
|
|
} |
|
|
} // end switch
|
|
|
} |
|
|
} break; |
|
|
} break; |
|
|
|
|
|
|
|
|
case 32: { // A32 clean leveling beep flag
|
|
|
case 32: { // A32 clean leveling beep flag
|
|
@ -843,7 +843,7 @@ namespace Anycubic { |
|
|
//TFTSer.println();
|
|
|
//TFTSer.println();
|
|
|
} break; |
|
|
} break; |
|
|
|
|
|
|
|
|
// A33 firmware info request seet 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
|
|
@ -879,7 +879,7 @@ namespace Anycubic { |
|
|
} |
|
|
} |
|
|
} break; |
|
|
} break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} // Anycubic
|
|
|
} // Anycubic
|
|
|
|
|
|
|
|
|