First partially working ABL implementation for Anycubic Chiron including EEPROM functions.

This commit is contained in:
Knutwurst
2021-04-13 23:04:49 +02:00
parent 1eed2a03dd
commit a6fc1cb0c5
4 changed files with 40 additions and 42 deletions

View File

@@ -56,6 +56,7 @@
#define KNUTWURST_SPECIAL_MENU_WO_SD #define KNUTWURST_SPECIAL_MENU_WO_SD
//#define ANYCUBIC_TFT_DEBUG //#define ANYCUBIC_TFT_DEBUG
//#define POWER_OUTAGE_TEST //#define POWER_OUTAGE_TEST
#define EXT_LEVEL_HIGH 0.1 #define EXT_LEVEL_HIGH 0.1
/* /*
@@ -87,9 +88,10 @@
* *
*/ */
#if ENABLED(KNUTWURST_CHIRON) #if ENABLED(KNUTWURST_CHIRON)
//#define KNUTWURST_TFT_LEVELING #define KNUTWURST_TFT_LEVELING
#endif #endif
/* /*
* 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

View File

@@ -35,6 +35,7 @@
#include "../module/motion.h" #include "../module/motion.h"
#include "../module/configuration_store.h" #include "../module/configuration_store.h"
#include "../sd/cardreader.h" #include "../sd/cardreader.h"
#include "../module/probe.h"
#ifdef ANYCUBIC_TOUCHSCREEN #ifdef ANYCUBIC_TOUCHSCREEN
@@ -47,9 +48,31 @@ 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;
// xyz_pos_t probe_offset; //configuration_store.cpp line 204
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 = probe.offset.z;
#else
SERIAL_ECHOPAIR("MEANL_L:", 0xaa);
zprobe_zoffset = Z_PROBE_OFFSET_FROM_EXTRUDER;
#endif
}
#endif #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;
@@ -58,6 +81,8 @@ int Temp_Buf_Bed_Temperature = 0;
unsigned char ResumingFlag = 0; unsigned char ResumingFlag = 0;
#endif #endif
void setup_OutageTestPin() void setup_OutageTestPin()
{ {
#ifdef POWER_OUTAGE_TEST #ifdef POWER_OUTAGE_TEST
@@ -1942,7 +1967,7 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
if(CodeSeen('S')) if(CodeSeen('S'))
{ {
float value = constrain(CodeValue(),-1.0,1.0); float value = constrain(CodeValue(),-1.0,1.0);
zprobe_zoffset += value; probe.offset.z += value;
for (x = 0; x < GRID_MAX_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 (y = 0; y < GRID_MAX_POINTS_Y; y++) z_values[x][y] += value;
} }
@@ -1950,20 +1975,20 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
refresh_bed_level(); refresh_bed_level();
HARDWARE_SERIAL_PROTOCOLPGM("A31V "); HARDWARE_SERIAL_PROTOCOLPGM("A31V ");
HARDWARE_SERIAL_PROTOCOL(ftostr32(zprobe_zoffset)); HARDWARE_SERIAL_PROTOCOL(ftostr32(probe.offset.z));
HARDWARE_SERIAL_ENTER(); HARDWARE_SERIAL_ENTER();
} }
if(CodeSeen('G')) if(CodeSeen('G'))
{ {
SAVE_zprobe_zoffset = zprobe_zoffset; SAVE_zprobe_zoffset = probe.offset.z;
HARDWARE_SERIAL_PROTOCOLPGM("A31V "); HARDWARE_SERIAL_PROTOCOLPGM("A31V ");
HARDWARE_SERIAL_PROTOCOL(ftostr32(SAVE_zprobe_zoffset)); HARDWARE_SERIAL_PROTOCOL(ftostr32(SAVE_zprobe_zoffset));
HARDWARE_SERIAL_ENTER(); HARDWARE_SERIAL_ENTER();
} }
if(CodeSeen('D')) if(CodeSeen('D'))
{ {
SAVE_zprobe_zoffset = zprobe_zoffset; SAVE_zprobe_zoffset = probe.offset.z;
settings.save(); settings.save();
set_bed_leveling_enabled(true); set_bed_leveling_enabled(true);
refresh_bed_level(); refresh_bed_level();
@@ -1995,22 +2020,16 @@ void AnycubicTouchscreenClass::GetCommandFromTFT()
if(CodeSeen('C')) if(CodeSeen('C'))
{ {
restore_z_values(); restore_z_values();
zprobe_zoffset = SAVE_zprobe_zoffset; probe.offset.z = SAVE_zprobe_zoffset;
set_bed_leveling_enabled(true); set_bed_leveling_enabled(true);
refresh_bed_level(); refresh_bed_level();
} }
#endif #endif
} }
break; break;
case 35: case 35: //RESET AUTOBED DATE //M1000
{
//RESET AUTOBED DATE //M1000
}
break; break;
case 36: case 36: // a36 M1001
{
// a36 M1001
}
break; break;
#endif #endif
@@ -2295,30 +2314,5 @@ 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

@@ -197,8 +197,10 @@ char *ftostr32(const float &);
#endif #endif
#if ENABLED(KNUTWURST_TFT_LEVELING) #if ENABLED(KNUTWURST_TFT_LEVELING)
// eeprom_index
extern int z_values_index; extern int z_values_index;
extern int z_values_size; extern int z_values_size;
// temp value which needs to be saved
extern float SAVE_zprobe_zoffset; extern float SAVE_zprobe_zoffset;
#endif #endif

View File

@@ -720,8 +720,8 @@ void MarlinSettings::postprocess() {
EEPROM_WRITE(bilinear_start); EEPROM_WRITE(bilinear_start);
#if ENABLED(KNUTWURST_TFT_LEVELING) #if ENABLED(KNUTWURST_TFT_LEVELING)
z_values_index = eeprom_index; int z_values_index = eeprom_index;
z_values_size = sizeof(z_values); int z_values_size = sizeof(z_values);
#endif #endif
#if ENABLED(AUTO_BED_LEVELING_BILINEAR) #if ENABLED(AUTO_BED_LEVELING_BILINEAR)