Some refactoring

This commit is contained in:
Knutwurst
2021-05-17 21:20:01 +02:00
parent 589ad64a97
commit 751e3c0f25
2 changed files with 29 additions and 19 deletions

View File

@@ -91,7 +91,7 @@
#define KNUTWURST_TFT_LEVELING #define KNUTWURST_TFT_LEVELING
#endif #endif
#define KNUTWURST_TFT_LEVELING
/* /*
* Here you can set the default preheat-Temperatures * Here you can set the default preheat-Temperatures
* which are set when you use the builtin preheat * which are set when you use the builtin preheat
@@ -1715,15 +1715,14 @@
// Probe along the Y axis, advancing X after each column // Probe along the Y axis, advancing X after each column
//#define PROBE_Y_FIRST //#define PROBE_Y_FIRST
/*
#if ENABLED(KNUTWURST_TFT_LEVELING) #if ENABLED(KNUTWURST_TFT_LEVELING)
#define MIN_PROBE_EDGE_LEFT MIN_PROBE_EDGE #define MIN_PROBE_EDGE_LEFT MIN_PROBE_EDGE
#define MIN_PROBE_EDGE_RIGHT (MIN_PROBE_EDGE_LEFT + 380) #define MIN_PROBE_EDGE_RIGHT (MIN_PROBE_EDGE_LEFT + 380)
#define MIN_PROBE_EDGE_FRONT (MIN_PROBE_EDGE + 9) #define MIN_PROBE_EDGE_FRONT (MIN_PROBE_EDGE + 9)
#define MIN_PROBE_EDGE_BACK (MIN_PROBE_EDGE_FRONT + 380) #define MIN_PROBE_EDGE_BACK (MIN_PROBE_EDGE_FRONT + 380)
#endif #endif
*/
#if ENABLED(AUTO_BED_LEVELING_BILINEAR) #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
// Beyond the probed grid, continue the implied tilt? // Beyond the probed grid, continue the implied tilt?

View File

@@ -47,7 +47,9 @@ char _conv[8];
int z_values_index; int z_values_index;
int z_values_size; int z_values_size;
float SAVE_zprobe_zoffset; float SAVE_zprobe_zoffset;
uint8_t x;
uint8_t y;
void restore_z_values() { void restore_z_values() {
uint16_t size = z_values_size; uint16_t size = z_values_size;
int pos = z_values_index; int pos = z_values_index;
@@ -1364,11 +1366,6 @@ static boolean TFTcomment_mode = false;
void AnycubicTouchscreenClass::GetCommandFromTFT() void AnycubicTouchscreenClass::GetCommandFromTFT()
{ {
char *starpos = NULL; char *starpos = NULL;
#if ENABLED(KNUTWURST_TFT_LEVELING)
uint8_t x;
uint8_t y;
#endif
while( HardwareSerial.available() > 0 && TFTbuflen < TFTBUFSIZE) while( HardwareSerial.available() > 0 && TFTbuflen < TFTBUFSIZE)
{ {
serial3_char = HardwareSerial.read(); serial3_char = HardwareSerial.read();
@@ -1902,8 +1899,16 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
#if ENABLED(KNUTWURST_TFT_LEVELING) #if ENABLED(KNUTWURST_TFT_LEVELING)
case 29: // A29 bed grid read case 29: // A29 bed grid read
{ {
if(CodeSeen('X')) x = CodeValue(); if(CodeSeen('X'))
if(CodeSeen('Y')) y = CodeValue(); {
x = CodeValue();
}
if(CodeSeen('Y'))
{
y = CodeValue();
}
float Zvalue = z_values[x][y]; float Zvalue = z_values[x][y];
Zvalue = Zvalue * 100; Zvalue = Zvalue * 100;
@@ -1949,8 +1954,8 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
queue.enqueue_now_P(PSTR("G28\nG29")); queue.enqueue_now_P(PSTR("G28\nG29"));
} }
break; break;
case 31: // A31 zoffset set get or save case 31: // A31 z-offset
if(CodeSeen('S')) if(CodeSeen('S')) // set
{ {
float value = constrain(CodeValue(),-1.0,1.0); float value = constrain(CodeValue(),-1.0,1.0);
probe.offset.z += value; probe.offset.z += value;
@@ -1965,7 +1970,7 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
HARDWARE_SERIAL_ENTER(); HARDWARE_SERIAL_ENTER();
} }
if(CodeSeen('G')) if(CodeSeen('G')) // get
{ {
SAVE_zprobe_zoffset = probe.offset.z; SAVE_zprobe_zoffset = probe.offset.z;
HARDWARE_SERIAL_PROTOCOLPGM("A31V "); HARDWARE_SERIAL_PROTOCOLPGM("A31V ");
@@ -1973,7 +1978,7 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
HARDWARE_SERIAL_ENTER(); HARDWARE_SERIAL_ENTER();
} }
if(CodeSeen('D')) if(CodeSeen('D')) // save
{ {
SAVE_zprobe_zoffset = probe.offset.z; SAVE_zprobe_zoffset = probe.offset.z;
settings.save(); settings.save();
@@ -1994,8 +1999,14 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
break; break;
case 34: //a34 bed grid write case 34: //a34 bed grid write
{ {
if(CodeSeen('X')) x = constrain(CodeValue(),0,GRID_MAX_POINTS_X); if(CodeSeen('X'))
if(CodeSeen('Y')) y = constrain(CodeValue(),0,GRID_MAX_POINTS_Y); {
x = constrain(CodeValue(),0,GRID_MAX_POINTS_X);
}
if(CodeSeen('Y'))
{
y = constrain(CodeValue(),0,GRID_MAX_POINTS_Y);
}
if(CodeSeen('V')) if(CodeSeen('V'))
{ {
//z_values[x][y] = (float)constrain(CodeValue()/100,-10,10); //z_values[x][y] = (float)constrain(CodeValue()/100,-10,10);
@@ -2022,7 +2033,7 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
case 35: //RESET AUTOBED DATE //M1000 case 35: //RESET AUTOBED DATE //M1000
initializeGrid(); initializeGrid();
break; break;
case 36: // A36 auto leveling (Old Anycubic TFT) case 36: // A36 auto leveling (New Anycubic TFT)
if( (planner.movesplanned()) || (card.isPrinting()) ) { if( (planner.movesplanned()) || (card.isPrinting()) ) {
HARDWARE_SERIAL_PROTOCOLPGM("J24"); // forbid auto leveling HARDWARE_SERIAL_PROTOCOLPGM("J24"); // forbid auto leveling
HARDWARE_SERIAL_ENTER(); HARDWARE_SERIAL_ENTER();