@ -40,6 +40,7 @@
# include "../../../../sd/cardreader.h"
# include "../../../../sd/cardreader.h"
# include "../../../../libs/numtostr.h"
# include "../../../../libs/numtostr.h"
# include "../../../../MarlinCore.h"
# include "../../../../MarlinCore.h"
namespace Anycubic {
namespace Anycubic {
printer_state_t ChironTFT : : printer_state ;
printer_state_t ChironTFT : : printer_state ;
@ -87,7 +88,7 @@ namespace Anycubic {
// 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_P ( AC_cmnd_enable_levelling ) ; //M211 S0\n"));
injectCommands_P ( AC_cmnd_enable_levelling ) ;
// Startup tunes are defined in Tunes.h
// Startup tunes are defined in Tunes.h
//PlayTune(BEEPER_PIN, Anycubic_PowerOn, 1);
//PlayTune(BEEPER_PIN, Anycubic_PowerOn, 1);
@ -179,7 +180,7 @@ namespace Anycubic {
# 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
SendtoTFTLN ( AC_msg_paused ) ; // enable continue button
printer_state = AC_printer_paused ;
printer_state = AC_printer_paused ;
}
}
@ -221,7 +222,8 @@ namespace Anycubic {
switch ( printer_state ) {
switch ( printer_state ) {
case AC_printer_probing : {
case AC_printer_probing : {
// If probing completes ok save the mesh and park
// If probing completes ok save the mesh and park
if ( strcmp_P ( msg , MARLIN_msg_ready ) = = 0 ) {
// Ignore the custom machine name
if ( strcmp_P ( msg + strlen ( CUSTOM_MACHINE_NAME ) , MARLIN_msg_ready ) = = 0 ) {
injectCommands_P ( PSTR ( " M500 \n G27 " ) ) ;
injectCommands_P ( PSTR ( " M500 \n G27 " ) ) ;
SendtoTFTLN ( AC_msg_probing_complete ) ;
SendtoTFTLN ( AC_msg_probing_complete ) ;
printer_state = AC_printer_idle ;
printer_state = AC_printer_idle ;
@ -306,7 +308,7 @@ namespace Anycubic {
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 ( ) ;
if ( panel_command [ command_len ] = = ' \n ' ) {
if ( panel_command [ command_len ] = = ' \n ' ) {
command_ready = true ;
command_ready = true ;
@ -333,26 +335,18 @@ namespace Anycubic {
}
}
int8_t ChironTFT : : Findcmndpos ( const char * buff , char q ) {
int8_t ChironTFT : : Findcmndpos ( const char * buff , char q ) {
bool found = false ;
int8_t pos = 0 ;
int8_t pos = 0 ;
do {
do { if ( buff [ pos ] = = q ) return pos ; } while ( + + pos < MAX_CMND_LEN ) ;
if ( buff [ pos ] = = q ) {
found = true ;
break ;
}
pos + + ;
} while ( pos < MAX_CMND_LEN ) ;
if ( found ) return pos ;
return - 1 ;
return - 1 ;
}
}
void ChironTFT : : CheckHeaters ( ) {
void ChironTFT : : CheckHeaters ( ) {
uint8_t faultDuration = 0 ; float temp = 0 ;
uint8_t faultDuration = 0 ;
float temp = 0 ;
// if the hotend temp is abnormal, confirm state before signalling panel
// if the hotend temp is abnormal, confirm state before signalling panel
temp = getActualTemp_celsius ( E0 ) ;
temp = getActualTemp_celsius ( E0 ) ;
if ( ( temp < = HEATER_0_MINTEMP ) | | ( temp > = HEATER_0_MAXTEMP ) ) {
while ( ! WITHIN ( temp , HEATER_0_MINTEMP , HEATER_0_MAXTEMP ) ) {
do {
faultDuration + + ;
faultDuration + + ;
if ( faultDuration > = AC_HEATER_FAULT_VALIDATION_TIME ) {
if ( faultDuration > = AC_HEATER_FAULT_VALIDATION_TIME ) {
SendtoTFTLN ( AC_msg_nozzle_temp_abnormal ) ;
SendtoTFTLN ( AC_msg_nozzle_temp_abnormal ) ;
@ -361,14 +355,12 @@ namespace Anycubic {
}
}
delay_ms ( 500 ) ;
delay_ms ( 500 ) ;
temp = getActualTemp_celsius ( E0 ) ;
temp = getActualTemp_celsius ( E0 ) ;
} while ( ( temp < = HEATER_0_MINTEMP ) | | ( temp > = HEATER_0_MAXTEMP ) ) ;
}
}
// i f the hotbed temp is abnormal, confirm state before signal ling panel
// I f the hotbed temp is abnormal, confirm state before signaling panel
faultDuration = 0 ;
faultDuration = 0 ;
temp = getActualTemp_celsius ( BED ) ;
temp = getActualTemp_celsius ( BED ) ;
if ( ( temp < = BED_MINTEMP ) | | ( temp > = BED_MAXTEMP ) ) {
while ( ! WITHIN ( temp , BED_MINTEMP , BED_MAXTEMP ) ) {
do {
faultDuration + + ;
faultDuration + + ;
if ( faultDuration > = AC_HEATER_FAULT_VALIDATION_TIME ) {
if ( faultDuration > = AC_HEATER_FAULT_VALIDATION_TIME ) {
SendtoTFTLN ( AC_msg_nozzle_temp_abnormal ) ;
SendtoTFTLN ( AC_msg_nozzle_temp_abnormal ) ;
@ -377,7 +369,6 @@ namespace Anycubic {
}
}
delay_ms ( 500 ) ;
delay_ms ( 500 ) ;
temp = getActualTemp_celsius ( E0 ) ;
temp = getActualTemp_celsius ( E0 ) ;
} while ( ( temp < = BED_MINTEMP ) | | ( temp > = BED_MAXTEMP ) ) ;
}
}
// Update panel with hotend heater status
// Update panel with hotend heater status
@ -398,7 +389,7 @@ namespace Anycubic {
}
}
void ChironTFT : : SendFileList ( int8_t startindex ) {
void ChironTFT : : SendFileList ( int8_t startindex ) {
// r espond to panel request for 4 files starting at index
// R espond 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 ) ;
# endif
# endif
@ -493,7 +484,6 @@ namespace Anycubic {
if ( isPrintingFromMedia ( ) ) {
if ( isPrintingFromMedia ( ) ) {
SendtoTFT ( PSTR ( " A6V " ) ) ;
SendtoTFT ( PSTR ( " A6V " ) ) ;
TFTSer . println ( ui8tostr2 ( getProgress_percent ( ) ) ) ;
TFTSer . println ( ui8tostr2 ( getProgress_percent ( ) ) ) ;
}
}
else
else
SendtoTFTLN ( PSTR ( " A6V --- " ) ) ;
SendtoTFTLN ( PSTR ( " A6V --- " ) ) ;
@ -552,7 +542,7 @@ namespace Anycubic {
}
}
else {
else {
if ( printer_state = = AC_printer_resuming_from_power_outage )
if ( printer_state = = AC_printer_resuming_from_power_outage )
injectCommands_P ( PSTR ( " M1000 C \n " ) ) ; // Cancel recovery
injectCommands_P ( PSTR ( " M1000 C " ) ) ; // Cancel recovery
SendtoTFTLN ( AC_msg_stop ) ;
SendtoTFTLN ( AC_msg_stop ) ;
printer_state = AC_printer_idle ;
printer_state = AC_printer_idle ;
}
}
@ -569,7 +559,7 @@ namespace Anycubic {
case 14 : { // A14 Start Printing
case 14 : { // A14 Start Printing
// Allows printer to restart the job if we dont want to recover
// Allows printer to restart the job if we dont want to recover
if ( printer_state = = AC_printer_resuming_from_power_outage ) {
if ( printer_state = = AC_printer_resuming_from_power_outage ) {
injectCommands_P ( PSTR ( " M1000 C \n " ) ) ; // Cancel recovery
injectCommands_P ( PSTR ( " M1000 C " ) ) ; // Cancel recovery
printer_state = AC_printer_idle ;
printer_state = AC_printer_idle ;
}
}
# if ACDebugLevel >= 1
# if ACDebugLevel >= 1
@ -587,8 +577,7 @@ namespace Anycubic {
if ( printer_state = = AC_printer_resuming_from_power_outage )
if ( printer_state = = AC_printer_resuming_from_power_outage )
// Need to home here to restore the Z position
// Need to home here to restore the Z position
injectCommands_P ( AC_cmnd_power_loss_recovery ) ;
injectCommands_P ( AC_cmnd_power_loss_recovery ) ;
injectCommands_P ( PSTR ( " M1000 " ) ) ; // home and start recovery
injectCommands_P ( PSTR ( " M1000 \n " ) ) ; // home and start recovery
break ;
break ;
case 16 : { // A16 Set HotEnd temp A17 S170
case 16 : { // A16 Set HotEnd temp A17 S170
@ -631,10 +620,10 @@ namespace Anycubic {
case 21 : // A21 Home Axis A21 X
case 21 : // A21 Home Axis A21 X
if ( ! isPrinting ( ) ) {
if ( ! isPrinting ( ) ) {
switch ( ( char ) panel_command [ 4 ] ) {
switch ( ( char ) panel_command [ 4 ] ) {
case ' X ' : injectCommands_P ( PSTR ( " G28 X \n " ) ) ; break ;
case ' X ' : injectCommands_P ( PSTR ( " G28 X " ) ) ; break ;
case ' Y ' : injectCommands_P ( PSTR ( " G28 Y \n " ) ) ; break ;
case ' Y ' : injectCommands_P ( PSTR ( " G28 Y " ) ) ; break ;
case ' Z ' : injectCommands_P ( PSTR ( " G28 Z \n " ) ) ; break ;
case ' Z ' : injectCommands_P ( PSTR ( " G28 Z " ) ) ; break ;
case ' C ' : injectCommands_P ( PSTR ( " G28 \n " ) ) ; break ;
case ' C ' : injectCommands_P ( PSTR ( " G28 " ) ) ; break ;
}
}
}
}
break ;
break ;
@ -729,7 +718,7 @@ namespace Anycubic {
// If the same meshpoint is selected twice in a row, move the head to that ready for adjustment
// If the same meshpoint is selected twice in a row, move the head to that ready for adjustment
if ( ( selectedmeshpoint . x = = pos . x ) & & ( selectedmeshpoint . y = = pos . y ) ) {
if ( ( selectedmeshpoint . x = = pos . x ) & & ( selectedmeshpoint . y = = pos . y ) ) {
if ( ! isPositionKnown ( ) )
if ( ! isPositionKnown ( ) )
injectCommands_P ( PSTR ( " G28 \n " ) ) ; // home
injectCommands_P ( PSTR ( " G28 " ) ) ; // home
if ( isPositionKnown ( ) ) {
if ( isPositionKnown ( ) ) {
# if ACDEBUG(AC_INFO)
# if ACDEBUG(AC_INFO)
@ -769,17 +758,15 @@ namespace Anycubic {
switch ( panel_command [ 3 ] ) {
switch ( panel_command [ 3 ] ) {
case ' C ' : // Restore and apply original offsets
case ' C ' : // Restore and apply original offsets
if ( ! isPrinting ( ) ) {
if ( ! isPrinting ( ) ) {
injectCommands_P ( PSTR ( " M501 \n M420 S1 \n " ) ) ;
injectCommands_P ( PSTR ( " M501 \n M420 S1 " ) ) ;
selectedmeshpoint . x = 99 ;
selectedmeshpoint . x = selectedmeshpoint . y = 99 ;
selectedmeshpoint . y = 99 ;
}
}
break ;
break ;
case ' D ' : // Save Z Offset tables and restore levelling state
case ' D ' : // Save Z Offset tables and restore levelling state
if ( ! isPrinting ( ) ) {
if ( ! isPrinting ( ) ) {
setAxisPosition_mm ( 1.0 , Z ) ;
setAxisPosition_mm ( 1.0 , Z ) ;
injectCommands_P ( PSTR ( " M500 \n " ) ) ;
injectCommands_P ( PSTR ( " M500 " ) ) ;
selectedmeshpoint . x = 99 ;
selectedmeshpoint . x = selectedmeshpoint . y = 99 ;
selectedmeshpoint . y = 99 ;
}
}
break ;
break ;
case ' G ' : // Get current offset
case ' G ' : // Get current offset
@ -790,8 +777,7 @@ namespace Anycubic {
TFTSer . println ( live_Zoffset ) ;
TFTSer . println ( live_Zoffset ) ;
else {
else {
TFTSer . println ( getZOffset_mm ( ) ) ;
TFTSer . println ( getZOffset_mm ( ) ) ;
selectedmeshpoint . x = 99 ;
selectedmeshpoint . x = selectedmeshpoint . y = 99 ;
selectedmeshpoint . y = 99 ;
}
}
break ;
break ;
case ' S ' : { // Set offset (adjusts all points by value)
case ' S ' : { // Set offset (adjusts all points by value)
@ -859,8 +845,7 @@ namespace Anycubic {
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
injectCommands_P ( PSTR ( " M501 \n M420 S1 " ) ) ;
injectCommands_P ( PSTR ( " M501 \n M420 S1 " ) ) ;
selectedmeshpoint . x = 99 ;
selectedmeshpoint . x = selectedmeshpoint . y = 99 ;
selectedmeshpoint . y = 99 ;
//printer_state = AC_printer_idle;
//printer_state = AC_printer_idle;
}
}
else {
else {
@ -876,9 +861,10 @@ namespace Anycubic {
# endif
# endif
// Update Meshpoint
// Update Meshpoint
setMeshPoint ( pos , newval ) ;
setMeshPoint ( pos , newval ) ;
if ( ( printer_state = = AC_printer_idle ) | | ( printer_state = = AC_printer_probing ) ) { //!isPrinting()) {
if ( printer_state = = AC_printer_idle | | printer_state = = AC_printer_probing /*!isPrinting()*/ ) {
// if we are at the current mesh point indicated on the panel Move Z pos +/- 0.05mm ( The panel changes the mesh value by +/- 0.05mm on each button press)
// if we are at the current mesh point indicated on the panel Move Z pos +/- 0.05mm
if ( ( selectedmeshpoint . x = = pos . x ) & & ( selectedmeshpoint . y = = pos . y ) ) {
// (The panel changes the mesh value by +/- 0.05mm on each button press)
if ( selectedmeshpoint . x = = pos . x & & selectedmeshpoint . y = = pos . y ) {
setSoftEndstopState ( false ) ;
setSoftEndstopState ( false ) ;
float currZpos = getAxisPosition_mm ( Z ) ;
float currZpos = getAxisPosition_mm ( Z ) ;
# if ACDEBUG(AC_INFO)
# if ACDEBUG(AC_INFO)