Skip to content

Commit

Permalink
Corner Leveling Marlin Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kisslorand committed Oct 6, 2023
1 parent 7d638de commit 206934b
Show file tree
Hide file tree
Showing 13 changed files with 163 additions and 212 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ the following options must be enabled in Marlin firmware.
`AUTO_REPORT_TEMPERATURES` (in Configuration_adv.h)<br>
`AUTO_REPORT_POSITION` (in Configuration_adv.h)<br>
`EXTENDED_CAPABILITIES_REPORT` (in Configuration_adv.h)<br>
`M115_GEOMETRY_REPORT` (in Configuration_adv.h)<br>
`MIN/MAX_SOFTWARE_ENDSTOPS` (in Configuration.h)<br>
`M114_DETAIL` (in Configuration_adv.h)<br>
`REPORT_FAN_CHANGE` (in Configuration_adv.h)<br>

Expand Down
4 changes: 2 additions & 2 deletions TFT/src/User/API/LevelingControl.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ float probedZ = 0.0f; // last Z offset measured by probe

int16_t setCoordValue(AXIS axis, ALIGN_POSITION align)
{
return ((align == LEFT || align == BOTTOM) ? infoSettings.machine_size_min[axis] + infoSettings.level_edge
: infoSettings.machine_size_max[axis] - infoSettings.level_edge) - infoParameters.HomeOffset[axis];
return ((align == LEFT || align == BOTTOM) ? infoSettings.level_edge
: infoSettings.bed_size[axis] - infoSettings.level_edge);
}

void levelingGetPointCoords(LEVELING_POINT_COORDS coords)
Expand Down
9 changes: 7 additions & 2 deletions TFT/src/User/API/Settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,13 @@ void initSettings(void)

for (int i = 0; i < AXIS_NUM; i++) // x, y, z
{
infoSettings.machine_size_min[i] = default_size_min[i];
infoSettings.machine_size_max[i] = default_size_max[i];
infoSettings.endstop_min[i] = default_size_min[i];
infoSettings.endstop_max[i] = default_size_max[i];
}

for (int i = 0; i < AXIS_NUM - 1; i++) // x, y
{
infoSettings.bed_size[i] = default_size_max[i];
}

for (int i = 0; i < SPEED_COUNT; i++)
Expand Down
9 changes: 5 additions & 4 deletions TFT/src/User/API/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ extern "C" {
// Config version support (format YYYYMMDD)
// change if new elements/keywords are added/removed/changed in the Configuration.h
// this number should match CONFIG_VERSION in Configuration.h
#define CONFIG_SUPPPORT 20230821
#define CONFIG_SUPPPORT 20231001

#define FONT_FLASH_SIGN 20230821 // (YYYYMMDD) change if fonts require updating
#define CONFIG_FLASH_SIGN 20230821 // (YYYYMMDD) change if any keyword(s) in config.ini is added or removed
#define CONFIG_FLASH_SIGN 20231001 // (YYYYMMDD) change if any keyword(s) in config.ini is added or removed
#define LANGUAGE_FLASH_SIGN 20230821 // (YYYYMMDD) change if any keyword(s) in language pack is added or removed
#define ICON_FLASH_SIGN 20230821 // (YYYYMMDD) change if any icon(s) is added or removed

Expand Down Expand Up @@ -222,8 +222,9 @@ typedef struct
uint16_t max_temp[MAX_HEATER_COUNT]; // hotends + bed + chamber
uint16_t min_ext_temp;
uint8_t fan_max[MAX_FAN_COUNT];
int16_t machine_size_min[AXIS_NUM]; // X, Y, Z
int16_t machine_size_max[AXIS_NUM]; // X, Y, Z
int16_t endstop_min[AXIS_NUM]; // X, Y, Z
int16_t endstop_max[AXIS_NUM]; // X, Y, Z
uint16_t bed_size[AXIS_NUM - 1]; // X, Y
uint16_t xy_speed[SPEED_COUNT];
uint16_t z_speed[SPEED_COUNT];
uint16_t ext_speed[SPEED_COUNT];
Expand Down
20 changes: 12 additions & 8 deletions TFT/src/User/API/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -774,18 +774,22 @@ void parseConfigKey(uint16_t index)
if (key_seen("CtI:")) SET_VALID_INT_VALUE(infoSettings.fan_max[7], MIN_FAN_SPEED, MAX_FAN_SPEED);
break;

case C_INDEX_SIZE_MIN:
if (key_seen("X")) SET_VALID_INT_VALUE(infoSettings.machine_size_min[X_AXIS], MIN_SIZE_LIMIT, MAX_SIZE_LIMIT);
if (key_seen("Y")) SET_VALID_INT_VALUE(infoSettings.machine_size_min[Y_AXIS], MIN_SIZE_LIMIT, MAX_SIZE_LIMIT);
if (key_seen("Z")) SET_VALID_INT_VALUE(infoSettings.machine_size_min[Z_AXIS], MIN_SIZE_LIMIT, MAX_SIZE_LIMIT);
case C_INDEX_ENDSTOP_MIN:
if (key_seen("X")) SET_VALID_INT_VALUE(infoSettings.endstop_min[X_AXIS], MIN_SIZE_LIMIT, MAX_SIZE_LIMIT);
if (key_seen("Y")) SET_VALID_INT_VALUE(infoSettings.endstop_min[Y_AXIS], MIN_SIZE_LIMIT, MAX_SIZE_LIMIT);
if (key_seen("Z")) SET_VALID_INT_VALUE(infoSettings.endstop_min[Z_AXIS], MIN_SIZE_LIMIT, MAX_SIZE_LIMIT);
break;

case C_INDEX_SIZE_MAX:
if (key_seen("X")) SET_VALID_INT_VALUE(infoSettings.machine_size_max[X_AXIS], MIN_SIZE_LIMIT, MAX_SIZE_LIMIT);
if (key_seen("Y")) SET_VALID_INT_VALUE(infoSettings.machine_size_max[Y_AXIS], MIN_SIZE_LIMIT, MAX_SIZE_LIMIT);
if (key_seen("Z")) SET_VALID_INT_VALUE(infoSettings.machine_size_max[Z_AXIS], MIN_SIZE_LIMIT, MAX_SIZE_LIMIT);
case C_INDEX_ENDSTOP_MAX:
if (key_seen("X")) SET_VALID_INT_VALUE(infoSettings.endstop_max[X_AXIS], MIN_SIZE_LIMIT, MAX_SIZE_LIMIT);
if (key_seen("Y")) SET_VALID_INT_VALUE(infoSettings.endstop_max[Y_AXIS], MIN_SIZE_LIMIT, MAX_SIZE_LIMIT);
if (key_seen("Z")) SET_VALID_INT_VALUE(infoSettings.endstop_max[Z_AXIS], MIN_SIZE_LIMIT, MAX_SIZE_LIMIT);
break;

case C_INDEX_BED_SIZE:
if (key_seen("X")) SET_VALID_INT_VALUE(infoSettings.bed_size[X_AXIS], 0, MAX_SIZE_LIMIT);
if (key_seen("Y")) SET_VALID_INT_VALUE(infoSettings.bed_size[Y_AXIS], 0, MAX_SIZE_LIMIT);

case C_INDEX_XY_SPEED:
if (key_seen("S")) SET_VALID_INT_VALUE(infoSettings.xy_speed[0], MIN_SPEED_LIMIT, MAX_SPEED_LIMIT);
if (key_seen("N")) SET_VALID_INT_VALUE(infoSettings.xy_speed[1], MIN_SPEED_LIMIT, MAX_SPEED_LIMIT);
Expand Down
5 changes: 3 additions & 2 deletions TFT/src/User/API/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ extern "C" {
#define CONFIG_MAX_TEMP "max_temp:"
#define CONFIG_MIN_TEMP "min_temp:"
#define CONFIG_FAN_MAX "fan_max:"
#define CONFIG_SIZE_MIN "size_min:"
#define CONFIG_SIZE_MAX "size_max:"
#define CONFIG_ENDSTOP_MIN "pos_min:"
#define CONFIG_ENDSTOP_MAX "pos_max:"
#define CONFIG_BED_SIZE "bed_size:"
#define CONFIG_XY_SPEED "xy_speed:"
#define CONFIG_Z_SPEED "z_speed:"
#define CONFIG_EXT_SPEED "ext_speed:"
Expand Down
5 changes: 3 additions & 2 deletions TFT/src/User/API/config.inc
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ X_CONFIG (CONTROLLER_FAN)
X_CONFIG (MAX_TEMP)
X_CONFIG (MIN_TEMP)
X_CONFIG (FAN_MAX)
X_CONFIG (SIZE_MIN)
X_CONFIG (SIZE_MAX)
X_CONFIG (ENDSTOP_MIN)
X_CONFIG (ENDSTOP_MAX)
X_CONFIG (BED_SIZE)
X_CONFIG (XY_SPEED)
X_CONFIG (Z_SPEED)
X_CONFIG (EXT_SPEED)
Expand Down
60 changes: 35 additions & 25 deletions TFT/src/User/API/parseACK.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ void parseACK(void)
speedQuerySetWait(false);
}
// parse and store flow rate percentage
else if (ack_seen("Flow: "))
else if (ack_seen("Flow:"))
{
speedSetCurPercent(1, ack_value());
speedQuerySetWait(false);
Expand Down Expand Up @@ -784,22 +784,23 @@ void parseACK(void)
// Tuning parsed responses
//----------------------------------------

// parse and store build volume size
else if (ack_seen("work:"))
// parse and store soft endstops (M211)
else if (GET_BIT(infoMachineSettings.softwareEndstops, 1))
{
if (ack_continue_seen("min:"))
if (ack_seen("Min:"))
{
if (ack_continue_seen("x:")) infoSettings.machine_size_min[X_AXIS] = ack_value();
if (ack_continue_seen("y:")) infoSettings.machine_size_min[Y_AXIS] = ack_value();
if (ack_continue_seen("z:")) infoSettings.machine_size_min[Z_AXIS] = ack_value();
}
// check endstop minimum values
if (ack_continue_seen("X")) infoSettings.endstop_min[X_AXIS] = ack_value();
if (ack_continue_seen("Y")) infoSettings.endstop_min[Y_AXIS] = ack_value();
if (ack_continue_seen("Z")) infoSettings.endstop_min[Z_AXIS] = ack_value();

if (ack_continue_seen("max:"))
{
if (ack_continue_seen("x:")) infoSettings.machine_size_max[X_AXIS] = ack_value();
if (ack_continue_seen("y:")) infoSettings.machine_size_max[Y_AXIS] = ack_value();
if (ack_continue_seen("z:")) infoSettings.machine_size_max[Z_AXIS] = ack_value();
// check endstop maximum values
if (ack_continue_seen("X")) infoSettings.endstop_max[X_AXIS] = ack_value();
if (ack_continue_seen("Y")) infoSettings.endstop_max[Y_AXIS] = ack_value();
if (ack_continue_seen("Z")) infoSettings.endstop_max[Z_AXIS] = ack_value();
}

SET_BIT_OFF(infoMachineSettings.softwareEndstops, 1); // clear "M211 seen" flag
}
// parse M48, repeatability test
else if (ack_starts_with("Mean:"))
Expand All @@ -808,22 +809,22 @@ void parseACK(void)

sprintf(tmpMsg, "Mean: %0.5f", ack_value());

if (ack_continue_seen("Min: "))
if (ack_continue_seen("Min:"))
sprintf(&tmpMsg[strlen(tmpMsg)], "\nMin: %0.5f", ack_value());
if (ack_continue_seen("Max: "))
if (ack_continue_seen("Max:"))
sprintf(&tmpMsg[strlen(tmpMsg)], "\nMax: %0.5f", ack_value());
if (ack_continue_seen("Range: "))
if (ack_continue_seen("Range:"))
sprintf(&tmpMsg[strlen(tmpMsg)], "\nRange: %0.5f", ack_value());

popupReminder(DIALOG_TYPE_INFO, (uint8_t *)"Repeatability Test", (uint8_t *)tmpMsg);
}
// parse M48, standard deviation
else if (ack_seen("Standard Deviation: "))
else if (ack_seen("Standard Deviation:"))
{
char tmpMsg[100];
char * dialogMsg = (char *)getDialogMsgStr();

if (memcmp(dialogMsg, "Mean: ", 6) == 0)
if (memcmp(dialogMsg, "Mean:", 6) == 0)
{
levelingSetProbedPoint(-1, -1, ack_value()); // save probed Z value
sprintf(tmpMsg, "%s\nStandard Deviation: %0.5f", dialogMsg, ack_value());
Expand All @@ -835,10 +836,12 @@ void parseACK(void)
else if (ack_starts_with("M211") || ack_seen("Soft endstops"))
{
uint8_t curValue = infoMachineSettings.softwareEndstops;
infoMachineSettings.softwareEndstops = ack_continue_seen("ON");
SET_BIT_VALUE(infoMachineSettings.softwareEndstops, 0, ack_continue_seen("ON")); // set ON/Off bit

if (curValue != infoMachineSettings.softwareEndstops) // send a notification only if status is changed
addToast(DIALOG_TYPE_INFO, ack_cache);

SET_BIT_ON(infoMachineSettings.softwareEndstops, 1); // set "M211 seen" flag
}
// parse M303, PID autotune finished message
else if (ack_starts_with("PID Autotune finished"))
Expand Down Expand Up @@ -916,16 +919,23 @@ void parseACK(void)
mblUpdateStatus(true);
}
// parse G30, feedback to get the 4 corners Z value returned by Marlin for LevelCorner menu
else if (ack_seen("Bed X: "))
else if (ack_seen("Bed X:"))
{
float x = ack_value();
float y = 0;

if (ack_continue_seen("Y: "))
y = ack_value();
if (ack_continue_seen("Y:"))
{
float y = ack_value();

if (ack_continue_seen("Z: "))
levelingSetProbedPoint(x, y, ack_value()); // save probed Z value
if (ack_continue_seen("Z:"))
levelingSetProbedPoint(x, y, ack_value()); // save probed Z value
}
}
// parse G30 coordinate unreachable message
else if (ack_seen("Z Probe Past Bed"))
{
levelingSetProbedPoint(-1, -1, 0); // cancel waiting for coordinates
BUZZER_PLAY(SOUND_ERROR);
}
#if DELTA_PROBE_TYPE != 0
// parse and store Delta calibration settings
Expand Down
12 changes: 6 additions & 6 deletions TFT/src/User/Configuration.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef _CONFIGURATION_H_
#define _CONFIGURATION_H_

#define CONFIG_VERSION 20230821
#define CONFIG_VERSION 20231001

//====================================================================================================
//=============================== Settings Configurable On config.ini ================================
Expand Down Expand Up @@ -491,11 +491,11 @@
#define FAN_MAX {255, 255, 255, 255, 255, 255, 255, 255} // Default: {255, 255, 255, 255, 255, 255, 255, 255}

/**
* Machine Size / Build Area
* The TFT will auto-detect the machine size (min and max) in Marlin firmware (requires
* enabling "M115_GEOMETRY_REPORT" in Configuration_adv.h in Marlin firmware).
* Format: [size_min: X<minimum distance> Y<minimum distance> Z<minimum distance>]
* [size_max: X<maximum distance> Y<maximum distance> Z<maximum distance>]
* Motion limits
* This sets the minimum and maximum motion limits. The TFT can autodect it from an M211 respone.
* For this "MIN/MAX_SOFTWARE_ENDSTOPS" must be enabled in Marlin's "Configuration.h".
* Format: [pos_min: X<minimum coordinate> Y<minimum coordinate> Z<minimum coordinate>]
* [pos_max: X<maximum coordinate> Y<maximum coordinate> Z<maximum coordinate>]
* Unit: [distance in mm]
* Value range: [min: -2000, max: 2000]
*/
Expand Down
Loading

0 comments on commit 206934b

Please sign in to comment.