Complete rewrite of anycubic tft code structure + cleanup for upcoming Chiron BBL feature.

This commit is contained in:
Knutwurst
2021-02-18 18:18:38 +01:00
parent 72d48a5ef8
commit 7f56178d13
4 changed files with 1368 additions and 1327 deletions

View File

@@ -161,9 +161,9 @@
* PLEASE READ THE WARNING ABOVE! * PLEASE READ THE WARNING ABOVE!
* *
*/ */
#if ENABLED(KNUTWURST_CHIRON) //#if ENABLED(KNUTWURST_CHIRON)
//#define KNUTWURST_TFT_LEVELING //#define KNUTWURST_TFT_LEVELING
#endif //#endif
/******************************************************************************************* /*******************************************************************************************
** ** ** **

View File

@@ -31,6 +31,8 @@
#include "../module/planner.h" #include "../module/planner.h"
#include "../module/printcounter.h" #include "../module/printcounter.h"
#include "../module/temperature.h" #include "../module/temperature.h"
#include "../module/motion.h"
#include "../module/configuration_store.h"
#include "../sd/cardreader.h" #include "../sd/cardreader.h"
@@ -40,6 +42,12 @@
char _conv[8]; char _conv[8];
#if ENABLED(KNUTWURST_TFT_LEVELING)
int z_values_index;
int z_values_size;
float SAVE_zprobe_zoffset;
#endif
#if defined(POWER_OUTAGE_TEST) #if defined(POWER_OUTAGE_TEST)
int PowerInt = 6; int PowerInt = 6;
unsigned char PowerTestFlag = false; unsigned char PowerTestFlag = false;
@@ -94,7 +102,6 @@ char *ftostr32(const float &x)
_conv[6] = DIGIMOD(xx, 1); _conv[6] = DIGIMOD(xx, 1);
return &_conv[1]; return &_conv[1];
} }
#endif #endif
AnycubicTouchscreenClass::AnycubicTouchscreenClass() AnycubicTouchscreenClass::AnycubicTouchscreenClass()
@@ -151,7 +158,6 @@ setup_OutageTestPin();
} }
#if ENABLED(KNUTWURST_MEGA_P_LASER) #if ENABLED(KNUTWURST_MEGA_P_LASER)
PRINTER_STRUCT Laser_printer_st = {0}; PRINTER_STRUCT Laser_printer_st = {0};
BMP_HEAD st_bmp = {0}; BMP_HEAD st_bmp = {0};
@@ -910,6 +916,7 @@ void AnycubicTouchscreenClass::PrintList()
} }
} }
#endif #endif
#ifdef SDSUPPORT #ifdef SDSUPPORT
#if ENABLED(KNUTWURST_SPECIAL_MENU) #if ENABLED(KNUTWURST_SPECIAL_MENU)
else if (card.isMounted()) else if (card.isMounted())
@@ -1078,14 +1085,10 @@ void AnycubicTouchscreenClass::CheckHeaterError()
#ifdef ANYCUBIC_TFT_DEBUG #ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("TFT Serial Debug: Hotend temperature abnormal... J20"); SERIAL_ECHOLNPGM("TFT Serial Debug: Hotend temperature abnormal... J20");
#endif #endif
} } else {
else
{
HeaterCheckCount++; HeaterCheckCount++;
} }
} } else {
else
{
HeaterCheckCount = 0; HeaterCheckCount = 0;
} }
} }
@@ -1167,9 +1170,7 @@ void AnycubicTouchscreenClass::StateHandler()
if (FilamentTestStatus) if (FilamentTestStatus)
{ {
TFTstate = ANYCUBIC_TFT_STATE_SDPAUSE; TFTstate = ANYCUBIC_TFT_STATE_SDPAUSE;
} } else {
else
{
// Pause because of "out of filament" // Pause because of "out of filament"
TFTstate = ANYCUBIC_TFT_STATE_SDPAUSE_OOF; TFTstate = ANYCUBIC_TFT_STATE_SDPAUSE_OOF;
} }
@@ -1247,8 +1248,7 @@ void AnycubicTouchscreenClass::FilamentRunout()
#endif #endif
if (card.isPrinting()) if (card.isPrinting())
{ {
ai3m_pause_state = 3; ai3m_pause_state = 3; // set runout pause flag
; // set runout pause flag
#ifdef ANYCUBIC_TFT_DEBUG #ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOPAIR(" DEBUG: AI3M Pause State: ", ai3m_pause_state); SERIAL_ECHOPAIR(" DEBUG: AI3M Pause State: ", ai3m_pause_state);
SERIAL_EOL(); SERIAL_EOL();
@@ -1285,7 +1285,6 @@ static boolean TFTcomment_mode = false;
void AnycubicTouchscreenClass::GetCommandFromTFT() void AnycubicTouchscreenClass::GetCommandFromTFT()
{ {
char *starpos = NULL; char *starpos = NULL;
while( HardwareSerial.available() > 0 && TFTbuflen < TFTBUFSIZE) while( HardwareSerial.available() > 0 && TFTbuflen < TFTBUFSIZE)
{ {
@@ -1304,7 +1303,6 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
{ {
// -------- START ERROR CORRECTION ---------- // -------- START ERROR CORRECTION ----------
TFTcomment_mode = false; //for new command TFTcomment_mode = false; //for new command
if(strchr(TFTcmdbuffer[TFTbufindw], 'N') != NULL) if(strchr(TFTcmdbuffer[TFTbufindw], 'N') != NULL)
{ {
if(strchr(TFTcmdbuffer[TFTbufindw], '*') != NULL) if(strchr(TFTcmdbuffer[TFTbufindw], '*') != NULL)
@@ -1324,18 +1322,14 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
return; return;
} }
//if no errors, continue parsing //if no errors, continue parsing
} } else {
else
{
HARDWARE_SERIAL_ERROR_START; HARDWARE_SERIAL_ERROR_START;
HardwareSerial.flush(); HardwareSerial.flush();
serial3_count = 0; serial3_count = 0;
return; return;
} }
//if no errors, continue parsing //if no errors, continue parsing
} } else { // if we don't receive 'N' but still see '*'
else // if we don't receive 'N' but still see '*'
{
if((strchr(TFTcmdbuffer[TFTbufindw], '*') != NULL)) if((strchr(TFTcmdbuffer[TFTbufindw], '*') != NULL))
{ {
HARDWARE_SERIAL_ERROR_START; HARDWARE_SERIAL_ERROR_START;
@@ -1351,7 +1345,6 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
TFTstrchr_pointer = strchr(TFTcmdbuffer[TFTbufindw], 'A'); TFTstrchr_pointer = strchr(TFTcmdbuffer[TFTbufindw], 'A');
switch((int)((strtod(&TFTcmdbuffer[TFTbufindw][TFTstrchr_pointer - TFTcmdbuffer[TFTbufindw] + 1], NULL)))) switch((int)((strtod(&TFTcmdbuffer[TFTbufindw][TFTstrchr_pointer - TFTcmdbuffer[TFTbufindw] + 1], NULL))))
{ {
case 0: //A0 GET HOTEND TEMP case 0: //A0 GET HOTEND TEMP
HARDWARE_SERIAL_PROTOCOLPGM("A0V "); HARDWARE_SERIAL_PROTOCOLPGM("A0V ");
HARDWARE_SERIAL_PROTOCOL(itostr3(int(thermalManager.degHotend(0) + 0.5))); HARDWARE_SERIAL_PROTOCOL(itostr3(int(thermalManager.degHotend(0) + 0.5)));
@@ -1410,15 +1403,13 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
if (card.isMounted()) if (card.isMounted())
{ {
HARDWARE_SERIAL_PROTOCOL(itostr3(card.percentDone())); HARDWARE_SERIAL_PROTOCOL(itostr3(card.percentDone()));
} } else {
else
{
HARDWARE_SERIAL_PROTOCOLPGM("J02"); // J02 SD Card initilized HARDWARE_SERIAL_PROTOCOLPGM("J02"); // J02 SD Card initilized
} }
} } else {
else
HARDWARE_SERIAL_PROTOCOLPGM("A6V ---"); HARDWARE_SERIAL_PROTOCOLPGM("A6V ---");
HARDWARE_SERIAL_ENTER(); HARDWARE_SERIAL_ENTER();
}
#endif #endif
break; break;
case 7: //A7 GET PRINTING TIME case 7: //A7 GET PRINTING TIME
@@ -1434,19 +1425,15 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
HARDWARE_SERIAL_PROTOCOL(itostr2(time % 60)); HARDWARE_SERIAL_PROTOCOL(itostr2(time % 60));
HARDWARE_SERIAL_SPACE(); HARDWARE_SERIAL_SPACE();
HARDWARE_SERIAL_PROTOCOLPGM("M"); HARDWARE_SERIAL_PROTOCOLPGM("M");
} } else {
else
{
HARDWARE_SERIAL_SPACE(); HARDWARE_SERIAL_SPACE();
HARDWARE_SERIAL_PROTOCOLPGM("999:999"); HARDWARE_SERIAL_PROTOCOLPGM("999:999");
} }
HARDWARE_SERIAL_ENTER(); HARDWARE_SERIAL_ENTER();
break;
} }
break;
case 8: // A8 GET SD LIST case 8: // A8 GET SD LIST
#ifdef SDSUPPORT #ifdef SDSUPPORT
currentTouchscreenSelection[0] = 0; currentTouchscreenSelection[0] = 0;
#if DISABLED(KNUTWURST_SPECIAL_MENU_WO_SD) #if DISABLED(KNUTWURST_SPECIAL_MENU_WO_SD)
if (!IS_SD_INSERTED()) if (!IS_SD_INSERTED())
@@ -1466,7 +1453,6 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
HARDWARE_SERIAL_PROTOCOLPGM("END"); // Filelist stop HARDWARE_SERIAL_PROTOCOLPGM("END"); // Filelist stop
HARDWARE_SERIAL_ENTER(); HARDWARE_SERIAL_ENTER();
} }
#endif #endif
break; break;
case 9: // A9 pause sd print case 9: // A9 pause sd print
@@ -1476,9 +1462,7 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
PausePrint(); PausePrint();
HARDWARE_SERIAL_PROTOCOLPGM("J05");//j05 pausing HARDWARE_SERIAL_PROTOCOLPGM("J05");//j05 pausing
HARDWARE_SERIAL_ENTER(); HARDWARE_SERIAL_ENTER();
} } else {
else
{
ai3m_pause_state = 0; ai3m_pause_state = 0;
#ifdef ANYCUBIC_TFT_DEBUG #ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOPAIR(" DEBUG: AI3M Pause State: ", ai3m_pause_state); SERIAL_ECHOPAIR(" DEBUG: AI3M Pause State: ", ai3m_pause_state);
@@ -1510,9 +1494,7 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
if ((card.isPrinting()) || (TFTstate == ANYCUBIC_TFT_STATE_SDOUTAGE)) if ((card.isPrinting()) || (TFTstate == ANYCUBIC_TFT_STATE_SDOUTAGE))
{ {
StopPrint(); StopPrint();
} } else {
else
{
HARDWARE_SERIAL_PROTOCOLPGM("J16"); // J16 stop print HARDWARE_SERIAL_PROTOCOLPGM("J16"); // J16 stop print
HARDWARE_SERIAL_ENTER(); HARDWARE_SERIAL_ENTER();
TFTstate = ANYCUBIC_TFT_STATE_IDLE; TFTstate = ANYCUBIC_TFT_STATE_IDLE;
@@ -1532,11 +1514,9 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
if ((TFTstate != ANYCUBIC_TFT_STATE_SDOUTAGE)) if ((TFTstate != ANYCUBIC_TFT_STATE_SDOUTAGE))
{ {
starpos = (strchr(TFTstrchr_pointer + 4, '*')); starpos = (strchr(TFTstrchr_pointer + 4, '*'));
if (TFTstrchr_pointer[4] == '/') if (TFTstrchr_pointer[4] == '/')
{ {
strcpy(currentTouchscreenSelection, TFTstrchr_pointer + 5); strcpy(currentTouchscreenSelection, TFTstrchr_pointer + 5);
#ifdef ANYCUBIC_TFT_DEBUG #ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOPAIR(" TFT Serial Debug: currentTouchscreenSelection: ",currentTouchscreenSelection); SERIAL_ECHOPAIR(" TFT Serial Debug: currentTouchscreenSelection: ",currentTouchscreenSelection);
SERIAL_EOL(); SERIAL_EOL();
@@ -1545,9 +1525,7 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
else if (TFTstrchr_pointer[4] == '<') else if (TFTstrchr_pointer[4] == '<')
{ {
strcpy(currentTouchscreenSelection, TFTstrchr_pointer + 4); strcpy(currentTouchscreenSelection, TFTstrchr_pointer + 4);
} } else {
else
{
currentTouchscreenSelection[0] = 0; currentTouchscreenSelection[0] = 0;
#ifdef ANYCUBIC_TFT_DEBUG #ifdef ANYCUBIC_TFT_DEBUG
@@ -1564,9 +1542,7 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
#ifdef ANYCUBIC_TFT_DEBUG #ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("TFT Serial Debug: File open successful... J20"); SERIAL_ECHOLNPGM("TFT Serial Debug: File open successful... J20");
#endif #endif
} } else {
else
{
HARDWARE_SERIAL_PROTOCOLPGM("J21"); // J21 Open failed HARDWARE_SERIAL_PROTOCOLPGM("J21"); // J21 Open failed
HARDWARE_SERIAL_ENTER(); HARDWARE_SERIAL_ENTER();
#ifdef ANYCUBIC_TFT_DEBUG #ifdef ANYCUBIC_TFT_DEBUG
@@ -1623,7 +1599,9 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
else if ((CodeSeen('C')) && (!planner.movesplanned())) else if ((CodeSeen('C')) && (!planner.movesplanned()))
{ {
if ((current_position[Z_AXIS] < 10)) if ((current_position[Z_AXIS] < 10))
{
queue.inject_P(PSTR("G1 Z10")); //RASE Z AXIS queue.inject_P(PSTR("G1 Z10")); //RASE Z AXIS
}
tempvalue = constrain(CodeValue(), 0, 275); tempvalue = constrain(CodeValue(), 0, 275);
thermalManager.setTargetHotend(tempvalue, 0); thermalManager.setTargetHotend(tempvalue, 0);
} }
@@ -1646,9 +1624,9 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
temp = (CodeValue() * 255 / 100); temp = (CodeValue() * 255 / 100);
temp = constrain(temp, 0, 255); temp = constrain(temp, 0, 255);
thermalManager.set_fan_speed(0, temp); thermalManager.set_fan_speed(0, temp);
} } else {
else
thermalManager.set_fan_speed(0, 255); thermalManager.set_fan_speed(0, 255);
}
HARDWARE_SERIAL_ENTER(); HARDWARE_SERIAL_ENTER();
break; break;
case 19: // A19 stop stepper drivers case 19: // A19 stop stepper drivers
@@ -1668,9 +1646,7 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
if (CodeSeen('S')) if (CodeSeen('S'))
{ {
feedrate_percentage = constrain(CodeValue(), 40, 999); feedrate_percentage = constrain(CodeValue(), 40, 999);
} } else {
else
{
HARDWARE_SERIAL_PROTOCOLPGM("A20V "); HARDWARE_SERIAL_PROTOCOLPGM("A20V ");
HARDWARE_SERIAL_PROTOCOL(feedrate_percentage); HARDWARE_SERIAL_PROTOCOL(feedrate_percentage);
HARDWARE_SERIAL_ENTER(); HARDWARE_SERIAL_ENTER();
@@ -1781,6 +1757,7 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
{ {
if ((current_position[Z_AXIS] < 10)) if ((current_position[Z_AXIS] < 10))
queue.inject_P(PSTR("G1 Z10")); // RAISE Z AXIS queue.inject_P(PSTR("G1 Z10")); // RAISE Z AXIS
thermalManager.setTargetBed(KNUTWURST_PRHEAT_BED_PLA); thermalManager.setTargetBed(KNUTWURST_PRHEAT_BED_PLA);
thermalManager.setTargetHotend(KNUTWURST_PRHEAT_NOZZLE_PLA, 0); thermalManager.setTargetHotend(KNUTWURST_PRHEAT_NOZZLE_PLA, 0);
HARDWARE_SERIAL_SUCC_START; HARDWARE_SERIAL_SUCC_START;
@@ -1792,6 +1769,7 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
{ {
if ((current_position[Z_AXIS] < 10)) if ((current_position[Z_AXIS] < 10))
queue.inject_P(PSTR("G1 Z10")); //RAISE Z AXIS queue.inject_P(PSTR("G1 Z10")); //RAISE Z AXIS
thermalManager.setTargetBed(KNUTWURST_PRHEAT_BED_ABS); thermalManager.setTargetBed(KNUTWURST_PRHEAT_BED_ABS);
thermalManager.setTargetHotend(KNUTWURST_PRHEAT_NOZZLE_ABS, 0); thermalManager.setTargetHotend(KNUTWURST_PRHEAT_NOZZLE_ABS, 0);
HARDWARE_SERIAL_SUCC_START; HARDWARE_SERIAL_SUCC_START;
@@ -1819,9 +1797,7 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
if (currentTouchscreenSelection[0] == 0) if (currentTouchscreenSelection[0] == 0)
{ {
card.mount(); card.mount();
} } else {
else
{
if ((strcasestr(currentTouchscreenSelection, SM_DIR_UP_S) != NULL) if ((strcasestr(currentTouchscreenSelection, SM_DIR_UP_S) != NULL)
|| (strcasestr(currentTouchscreenSelection, SM_DIR_UP_L) != NULL)) || (strcasestr(currentTouchscreenSelection, SM_DIR_UP_L) != NULL))
{ {
@@ -1829,18 +1805,14 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
SERIAL_ECHOLNPGM("TFT Serial Debug: Directory UP (cd ..)"); SERIAL_ECHOLNPGM("TFT Serial Debug: Directory UP (cd ..)");
#endif #endif
card.cdup(); card.cdup();
} } else {
else
{
if (currentTouchscreenSelection[0] == '<') if (currentTouchscreenSelection[0] == '<')
{ {
#ifdef ANYCUBIC_TFT_DEBUG #ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("TFT Serial Debug: Enter Special Menu"); SERIAL_ECHOLNPGM("TFT Serial Debug: Enter Special Menu");
#endif #endif
HandleSpecialMenu(); HandleSpecialMenu();
} } else {
else
{
#ifdef ANYCUBIC_TFT_DEBUG #ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLNPGM("TFT Serial Debug: Not a menu. Must be a directory!"); SERIAL_ECHOLNPGM("TFT Serial Debug: Not a menu. Must be a directory!");
#endif #endif
@@ -1856,7 +1828,6 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
} }
} }
} }
currentTouchscreenSelection[0] = 0; currentTouchscreenSelection[0] = 0;
#endif #endif
break; break;
@@ -1873,6 +1844,7 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
} }
HARDWARE_SERIAL_ENTER(); HARDWARE_SERIAL_ENTER();
break; break;
case 33: // A33 get version info case 33: // A33 get version info
{ {
HARDWARE_SERIAL_PROTOCOLPGM("J33 "); HARDWARE_SERIAL_PROTOCOLPGM("J33 ");
@@ -1889,84 +1861,130 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
* Chiron printer. * Chiron printer.
*/ */
//#define KNUTWURST_TFT_LEVELING
//#define AUTO_BED_LEVELING_BILINEAR //#define AUTO_BED_LEVELING_BILINEAR
#if ENABLED(KNUTWURST_TFT_LEVELING) #if ENABLED(KNUTWURST_TFT_LEVELING)
#ifdef AUTO_BED_LEVELING_BILINEAR
case 29: // A29 bed grid read case 29: // A29 bed grid read
{ {
unsigned char temp_x=0,temp_y=0; #ifdef AUTO_BED_LEVELING_BILINEAR
if(CodeSeen('X'))temp_x=CodeValue(); if(CodeSeen('X')) x = CodeValue();
if(CodeSeen('Y'))temp_y=CodeValue(); if(CodeSeen('Y')) y = CodeValue();
float Zvalue=bed_level_grid[temp_x][temp_y]; float Zvalue = z_values[x][y];
Zvalue = Zvalue * 100; Zvalue = Zvalue * 100;
refresh_bed_level();
set_bed_leveling_enabled(true);
if(!!card.isPrinting() && sdcardstartprintingflag == 0)
{
if (!all_axes_known())
{
queue.enqueue_now_P(PSTR("G28"));
} else {
destination[Z_AXIS] = (float)(5.0);
prepare_line_to_destination();
feedrate_mm_s = MMM_TO_MMS(3600.0f);
destination[X_AXIS] = _GET_MESH_X(x);
destination[Y_AXIS] = _GET_MESH_Y(y);
prepare_line_to_destination();
destination[Z_AXIS] = (float)(EXT_LEVEL_HIGH);
prepare_line_to_destination();
report_current_position();
}
}
HARDWARE_SERIAL_PROTOCOLPGM("A29V "); HARDWARE_SERIAL_PROTOCOLPGM("A29V ");
HARDWARE_SERIAL_PROTOCOL(Zvalue); HARDWARE_SERIAL_PROTOCOL(ftostr32(Zvalue)); // or better HARDWARE_SERIAL_PROTOCOLLN?
HARDWARE_SERIAL_ENTER(); HARDWARE_SERIAL_ENTER();
#endif
} }
break; break;
case 30: // A30 auto leveling
case 30://a30 auto leveling #ifdef AUTO_BED_LEVELING_BILINEAR
{ if( (planner.movesplanned()) || (!card.isPrinting()) ) {
if((planner.movesplanned())||(card.sdprinting))
{
HARDWARE_SERIAL_PROTOCOLPGM("J24"); // forbid auto leveling HARDWARE_SERIAL_PROTOCOLPGM("J24"); // forbid auto leveling
HARDWARE_SERIAL_ENTER(); HARDWARE_SERIAL_ENTER();
} else {
HARDWARE_SERIAL_PROTOCOLPGM("J26"); // start auto leveling
HARDWARE_SERIAL_ENTER();
} }
if(CodeSeen('S') ) if(CodeSeen('S') ) {
{ queue.enqueue_now_P(PSTR("G28\nG29"));
Manual_Leveling=0x55;
enqueue_and_echo_commands_P(PSTR("G28\nG29"));
}
} }
#else
HARDWARE_SERIAL_PROTOCOLPGM("J24\r\n")); // forbid auto leveling
#endif
break; break;
case 31: //a31 zoffset set get or save case 31: // A31 zoffset set get or save
{ #ifdef AUTO_BED_LEVELING_BILINEAR
if(Manual_Leveling==0xaa)break;
if(CodeSeen('S')) if(CodeSeen('S'))
{ {
float value = constrain(CodeValue(),-1.0,1.0); float value = constrain(CodeValue(),-1.0,1.0);
NEW_zprobe_zoffset+=value; zprobe_zoffset += value;
for (uint8_t x = 0; x < ABL_GRID_POINTS_X; x++) for (x = 0; x < GRID_MAX_POINTS_X; x++) {
{ for (y = 0; y < GRID_MAX_POINTS_Y; y++) z_values[x][y] += value;
for (uint8_t y = 0; y < ABL_GRID_POINTS_Y; y++)
bed_level_grid[x][y] += value;
} }
set_bed_leveling_enabled(true);
refresh_bed_level();
HARDWARE_SERIAL_PROTOCOLPGM("A31V "); HARDWARE_SERIAL_PROTOCOLPGM("A31V ");
HARDWARE_SERIAL_PROTOCOL(NEW_zprobe_zoffset); write_to_lcd_f(zprobe_zoffset);
HARDWARE_SERIAL_ENTER();
} }
if(CodeSeen('G')) {HARDWARE_SERIAL_PROTOCOLPGM("A31V ");HARDWARE_SERIAL_PROTOCOL(NEW_zprobe_zoffset); HARDWARE_SERIAL_ENTER(); }
if(CodeSeen('D')) SaveAutoBedGridData();
if(CodeSeen('G'))
{
SAVE_zprobe_zoffset = zprobe_zoffset;
HARDWARE_SERIAL_PROTOCOLPGM("A31V ");
write_to_lcd_f(SAVE_zprobe_zoffset);
}
if(CodeSeen('D'))
{
SAVE_zprobe_zoffset = zprobe_zoffset;
settings.save();
set_bed_leveling_enabled(true);
refresh_bed_level();
} }
HARDWARE_SERIAL_ENTER(); HARDWARE_SERIAL_ENTER();
break;
#endif #endif
break;
case 32: //a32 clean leveling beep flag case 32: //a32 clean leveling beep flag
// { break;
// PointTestFlag=0;
// }
#ifdef AUTO_BED_LEVELING_BILINEAR
case 34: //a34 bed grid write case 34: //a34 bed grid write
{ {
uint8_t x_array=0,y_array=0,result=0; #ifdef AUTO_BED_LEVELING_BILINEAR
if(Manual_Leveling==0xaa) break; if(CodeSeen('X')) x = constrain(CodeValue(),0,GRID_MAX_POINTS_X);
if(CodeSeen('X')) x_array=constrain(CodeValue(),0,ABL_GRID_POINTS_X); if(CodeSeen('Y')) y = constrain(CodeValue(),0,GRID_MAX_POINTS_Y);
if(CodeSeen('Y')) y_array=constrain(CodeValue(),0,ABL_GRID_POINTS_Y); if(CodeSeen('V'))
if(CodeSeen('V')) {float i=constrain(CodeValue()/100,-10,10); bed_level_grid[x_array][y_array] = i;} {
if(CodeSeen('S')) SaveAutoBedGridData(); //z_values[x][y] = (float)constrain(CodeValue()/100,-10,10);
if(CodeSeen('C')) ReadAutoBedGridData(); // if click return(didn't choose save),needs restore bed grid data. float new_z_value = (float)constrain(CodeValue()/100,-10,10);
z_values[x][y] = new_z_value;
set_bed_leveling_enabled(true);
refresh_bed_level();
}
if(CodeSeen('S'))
{
refresh_bed_level();
set_bed_leveling_enabled(true);
settings.save();
}
if(CodeSeen('C'))
{
restore_z_values();
zprobe_zoffset = SAVE_zprobe_zoffset;
set_bed_leveling_enabled(true);
refresh_bed_level();
}
#endif
} }
break; break;
case 35:
case 35:{ //RESET AUTOBED DATE //M1000 { //RESET AUTOBED DATE //M1000
/*
float temp; float temp;
if(code_seen('S')) temp=code_value_float(); if(code_seen('S')) temp=code_value_float();
else temp=-3.5; else temp=-3.5;
@@ -1986,12 +2004,12 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
SaveAutoBedGridData(); SaveAutoBedGridData();
SERIAL_ECHOPGM("Done, Manual Leveling was actived!"); SERIAL_ECHOPGM("Done, Manual Leveling was actived!");
HARDWARE_SERIAL_ENTER(); HARDWARE_SERIAL_ENTER();
*/
} }
break; break;
case 36:// a36 M1001 case 36:// a36 M1001
{ { /*
if((planner.movesplanned())||(card.sdprinting)) //forbit auto leveling when the printer is moving if((planner.movesplanned())||(!card.isPrinting())) //forbit auto leveling when the printer is moving
{ {
HARDWARE_SERIAL_PROTOCOLPGM("J24");// forbid auto leveling HARDWARE_SERIAL_PROTOCOLPGM("J24");// forbid auto leveling
HARDWARE_SERIAL_ENTER(); HARDWARE_SERIAL_ENTER();
@@ -2024,25 +2042,22 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
HARDWARE_SERIAL_PROTOCOLPGM("J26");//start auto leveling HARDWARE_SERIAL_PROTOCOLPGM("J26");//start auto leveling
HARDWARE_SERIAL_ENTER(); HARDWARE_SERIAL_ENTER();
HARDWARE_SERIAL_PROTOCOLLN("J26"); HARDWARE_SERIAL_PROTOCOLLN("J26");
*/
} }
break; break;
#endif #endif
#endif
#if ENABLED(KNUTWURST_MEGA_P_LASER) #if ENABLED(KNUTWURST_MEGA_P_LASER)
case 34:// Continuous printing case 34:// Continuous printing
{ {
en_continue = 1 ;} en_continue = 1 ;
}
break; break;
case 35:// Continuous printing case 35:// Continuous printing
{ {
en_continue = 0 ;} en_continue = 0 ;
}
break; break;
case 36://A36 case 36://A36
if(CodeSeen('S')) if(CodeSeen('S'))
{ {
@@ -2052,7 +2067,6 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
Laser_printer_st.pic_vector = 1; Laser_printer_st.pic_vector = 1;
else else
Laser_printer_st.pic_vector = 0; Laser_printer_st.pic_vector = 0;
} }
case 37: case 37:
if(CodeSeen('S'))//X if(CodeSeen('S'))//X
@@ -2064,7 +2078,6 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
else if(coorvalue == 1) else if(coorvalue == 1)
Laser_printer_st.pic_x_mirror = 1; //x Laser_printer_st.pic_x_mirror = 1; //x
} }
break; break;
case 38: case 38:
if(CodeSeen('S'))//A38 if(CodeSeen('S'))//A38
@@ -2073,9 +2086,7 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
coorvalue=CodeValueInt(); coorvalue=CodeValueInt();
Laser_printer_st.pic_laser_time = coorvalue; Laser_printer_st.pic_laser_time = coorvalue;
} }
break; break;
case 39: case 39:
if(CodeSeen('S'))//A39 if(CodeSeen('S'))//A39
{ {
@@ -2084,9 +2095,7 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
Laser_printer_st.laser_height = coorvalue; Laser_printer_st.laser_height = coorvalue;
HARDWARE_SERIAL_PROTOCOL("laser_height = "); HARDWARE_SERIAL_PROTOCOL("laser_height = ");
HARDWARE_SERIAL_PROTOCOLLN(Laser_printer_st.laser_height); HARDWARE_SERIAL_PROTOCOLLN(Laser_printer_st.laser_height);
} }
break; break;
case 40: case 40:
if(CodeSeen('S'))//A40 if(CodeSeen('S'))//A40
@@ -2095,19 +2104,17 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
coorvalue=CodeValue(); coorvalue=CodeValue();
Laser_printer_st.pic_pixel_distance = coorvalue; Laser_printer_st.pic_pixel_distance = coorvalue;
} }
break; break;
case 41: case 41:
if(CodeSeen('S'))// if(CodeSeen('S'))
{ {
float coorvalue; float coorvalue;
coorvalue=CodeValue(); coorvalue=CodeValue();
Laser_printer_st.x_offset = coorvalue; Laser_printer_st.x_offset = coorvalue;
} }
break; break;
case 42: case 42:
if(CodeSeen('S'))// if(CodeSeen('S'))
{ {
float coorvalue; float coorvalue;
coorvalue=CodeValue(); coorvalue=CodeValue();
@@ -2123,66 +2130,63 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
if(coorvalue == 0) if(coorvalue == 0)
Laser_printer_st.pic_y_mirror = 0; Laser_printer_st.pic_y_mirror = 0;
else if(coorvalue == 1) else if(coorvalue == 1)
Laser_printer_st.pic_y_mirror = 1; // Laser_printer_st.pic_y_mirror = 1;
} }
break; break;
case 44: case 44:
send_laser_param();// send_laser_param();//
break; break;
case 49:// A49 case 49:// A49
{ {
laser_on_off = 0; laser_on_off = 0;
WRITE(HEATER_0_PIN, 0); WRITE(HEATER_0_PIN, 0);
} }
break; break;
case 50:// A50 case 50:// A50
{ {
if( laser_on_off == 0) if( laser_on_off == 0)
{
laser_on_off = 1; laser_on_off = 1;
else } else {
{ laser_on_off = 0; laser_on_off = 0;
WRITE(HEATER_0_PIN, 0); WRITE(HEATER_0_PIN, 0);
} }
} }
break; break;
case 51: case 51:
{ {
if(CodeSeen('H')) if(CodeSeen('H'))
{ {
enqueue_and_echo_commands_P(PSTR("G1 Z5 F500")); queue.enqueue_now_P(PSTR("G1 Z5 F500"));
enqueue_and_echo_commands_P(PSTR("G1 X30 Y30 F5000")); queue.enqueue_now_P(PSTR("G1 X30 Y30 F5000"));
enqueue_and_echo_commands_P(PSTR("G1 Z0.15 F300")); queue.enqueue_now_P(PSTR("G1 Z0.15 F300"));
} }
else if(CodeSeen('I')) else if(CodeSeen('I'))
{ {
enqueue_and_echo_commands_P(PSTR("G1 Z5 F500")); queue.enqueue_now_P(PSTR("G1 Z5 F500"));
enqueue_and_echo_commands_P(PSTR("G1 X190 Y30 F5000")); queue.enqueue_now_P(PSTR("G1 X190 Y30 F5000"));
enqueue_and_echo_commands_P(PSTR("G1 Z0.15 F300")); queue.enqueue_now_P(PSTR("G1 Z0.15 F300"));
} }
else if(CodeSeen('J')) else if(CodeSeen('J'))
{ {
enqueue_and_echo_commands_P(PSTR("G1 Z5 F500")); queue.enqueue_now_P(PSTR("G1 Z5 F500"));
enqueue_and_echo_commands_P(PSTR("G1 X190 Y190 F5000")); queue.enqueue_now_P(PSTR("G1 X190 Y190 F5000"));
enqueue_and_echo_commands_P(PSTR("G1 Z0.15 F300")); queue.enqueue_now_P(PSTR("G1 Z0.15 F300"));
} }
else if(CodeSeen('K')) else if(CodeSeen('K'))
{ {
enqueue_and_echo_commands_P(PSTR("G1 Z5 F500")); queue.enqueue_now_P(PSTR("G1 Z5 F500"));
enqueue_and_echo_commands_P(PSTR("G1 X30 Y190 F5000")); queue.enqueue_now_P(PSTR("G1 X30 Y190 F5000"));
enqueue_and_echo_commands_P(PSTR("G1 Z0.15 F300")); queue.enqueue_now_P(PSTR("G1 Z0.15 F300"));
} }
else if(CodeSeen('L')) else if(CodeSeen('L'))
{ {
enqueue_and_echo_commands_P(PSTR("G1 X100 Y100 Z50 F5000")); queue.enqueue_now_P(PSTR("G1 X100 Y100 Z50 F5000"));
} }
} }
break; break;
#endif #endif
default: default:
break; break;
} }
@@ -2213,23 +2217,23 @@ void prepare_laser_print()
if(laser_print_steps == 0) if(laser_print_steps == 0)
{ {
cvalue[0]= 0; cvalue[0]= 0;
while (planner.blocks_queued());//<2F>ȴ<EFBFBD><C8B4>˶<EFBFBD>ֹͣ while (planner.blocks_queued());
enqueue_and_echo_commands_P(PSTR("G28"));//<2F>ȹ<EFBFBD><C8B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD><CBB6><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6>߶<EFBFBD> queue.enqueue_now_P(PSTR("G28"));
sprintf_P(cvalue,PSTR("G1 Z%i F500"),(int)Laser_printer_st.laser_height); sprintf_P(cvalue,PSTR("G1 Z%i F500"),(int)Laser_printer_st.laser_height);
SERIAL_PROTOCOLLN(cvalue); SERIAL_PROTOCOLLN(cvalue);
enqueue_and_echo_command_now(cvalue);//<2F>˶<EFBFBD><CBB6><EFBFBD><EFBFBD>ƶ<EFBFBD><C6B6>߶<EFBFBD> enqueue_and_echo_command_now(cvalue);
laser_print_steps =1; laser_print_steps =1;
times = 120000; times = 120000;
} }
else if(laser_print_steps==1) else if(laser_print_steps==1)
{ {
if(planner.blocks_queued())return;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD>?<3F>򷵻<EFBFBD> if(planner.blocks_queued())return;
laser_print_steps =2; laser_print_steps =2;
} }
else if(laser_print_steps==2) else if(laser_print_steps==2)
{ {
Laset_print_picture( );//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>? Laset_print_picture( );
laser_print_steps=0; laser_print_steps=0;
card.printingHasFinished(); card.printingHasFinished();
card.checkautostart(true); card.checkautostart(true);
@@ -2324,5 +2328,30 @@ void PowerKill()
#endif #endif
} }
#if ENABLED(KNUTWURST_TFT_LEVELING)
void restore_z_values() {
uint16_t size = z_values_size;
int pos = z_values_index;
uint8_t* value = (uint8_t*)&z_values;
do {
uint8_t c = eeprom_read_byte((unsigned char*)pos);
*value = c;
pos++;
value++;
} while (--size);
}
void setupMyZoffset() {
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
SERIAL_ECHOPAIR("MEANL_L:", 0x55);
SAVE_zprobe_zoffset = zprobe_zoffset;
#else
SERIAL_ECHOPAIR("MEANL_L:", 0xaa);
zprobe_zoffset = Z_PROBE_OFFSET_FROM_EXTRUDER;
#endif
}
#endif
AnycubicTouchscreenClass AnycubicTouchscreen; AnycubicTouchscreenClass AnycubicTouchscreen;
#endif #endif

View File

@@ -287,6 +287,12 @@ private:
int FilamentRunoutCounter = 0; int FilamentRunoutCounter = 0;
#endif #endif
#if ENABLED(KNUTWURST_TFT_LEVELING)
extern int z_values_index;
extern int z_values_size;
extern float SAVE_zprobe_zoffset;
#endif
#if ENABLED(KNUTWURST_MEGA_P_LASER) #if ENABLED(KNUTWURST_MEGA_P_LASER)

View File

@@ -51,6 +51,7 @@
#include "stepper.h" #include "stepper.h"
#include "temperature.h" #include "temperature.h"
#include "../lcd/ultralcd.h" #include "../lcd/ultralcd.h"
#include "../lcd/anycubic_touchscreen.h"
#include "../core/language.h" #include "../core/language.h"
#include "../libs/vector_3.h" // for matrix_3x3 #include "../libs/vector_3.h" // for matrix_3x3
#include "../gcode/gcode.h" #include "../gcode/gcode.h"
@@ -718,6 +719,11 @@ void MarlinSettings::postprocess() {
EEPROM_WRITE(bilinear_grid_spacing); EEPROM_WRITE(bilinear_grid_spacing);
EEPROM_WRITE(bilinear_start); EEPROM_WRITE(bilinear_start);
#if ENABLED(KNUTWURST_TFT_LEVELING)
z_values_index = eeprom_index;
z_values_size = sizeof(z_values);
#endif
#if ENABLED(AUTO_BED_LEVELING_BILINEAR) #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
EEPROM_WRITE(z_values); // 9-256 floats EEPROM_WRITE(z_values); // 9-256 floats
#else #else