Skip to content

Commit

Permalink
Corner leveling and language bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
kisslorand committed Jun 5, 2023
1 parent 8a08dce commit 75646cb
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 36 deletions.
2 changes: 1 addition & 1 deletion TFT/src/User/API/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extern "C" {

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

#define FONT_CHECK_SIGN (FONT_FLASH_SIGN + WORD_UNICODE_ADDR + FLASH_SIGN_ADDR)
Expand Down
6 changes: 6 additions & 0 deletions TFT/src/User/API/parseACK.c
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,12 @@ void parseACK(void)
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
else if (ack_seen("Calibration OK"))
Expand Down
8 changes: 6 additions & 2 deletions TFT/src/User/Menu/LevelCorner.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void refreshValue(MENUITEMS * levelItems, uint8_t index)
menuDrawIconText(&levelItems->items[valIconIndex[index]], valIconIndex[index]);
}

void checkRefreshValue(MENUITEMS * levelItems)
bool checkRefreshValue(MENUITEMS * levelItems)
{
LEVELING_POINT levelingPoint = levelingGetProbedPoint();

Expand All @@ -47,7 +47,11 @@ void checkRefreshValue(MENUITEMS * levelItems)
refreshValue(levelItems, levelingPoint);

levelingResetProbedPoint(); // reset to check for new updates

return true;
}

return false;
}

// show M48 on icon
Expand Down Expand Up @@ -169,7 +173,7 @@ void menuLevelCorner(void)
levelingProbePoint(i);

// following loop needed to guarantee the value for each point beeing probed is updated at least one time on the menu
TASK_LOOP_WHILE(isNotEmptyCmdQueue(), checkRefreshValue(&levelCornerItems))
TASK_LOOP_WHILE(!checkRefreshValue(&levelCornerItems))
}

break;
Expand Down
53 changes: 20 additions & 33 deletions TFT/src/User/Menu/MeshEditor.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,9 @@

#define MESH_MAX_RETRIEVE_ATTEMPTS 20 // maximum number of attempts to retrieve the data format from Marlin FW
#define MESH_LINE_EDGE_DISTANCE 4
#define MESH_EEPROM_ROW (meshData->rowsNum - 1) - meshData->row

// data structures
typedef struct
{
const uint8_t colsToSkip;
const uint8_t rowsToSkip;
const bool rowsInverted;
const char * const echoMsg;
} MESH_DATA_FORMAT;

typedef enum
{
ME_DATA_IDLE = 0,
Expand Down Expand Up @@ -240,12 +233,18 @@ const char * const meshKeyString[ME_KEY_NUM] = {
"\u02C5", // DOWN
};

const MESH_DATA_FORMAT meshDataFormat[] = {
// columns to skip, rows to skip, rows inverted, bed leveling data type
{ 1, 4, true, "Mesh Bed Level data:"}, // MBL
{ 0, 2, false, "Bed Topography Report for CSV:"}, // UBL
{ 1, 2, true, "Bilinear Leveling Grid:"}, // ABL Bilinear
{ 0, 1, true, "Bed Level Correction Matrix:"}, // ABL Linear or 3-Point
const struct
{
const uint8_t colsToSkip;
const uint8_t rowsToSkip;
const bool rowsInverted;
const char *const echoMsg;
} meshDataFormat[] = {
/* columns to skip, rows to skip, rows inverted, bed leveling data type */
{ 1 , 4 , true , "Mesh Bed Level data:" }, // MBL
{ 0 , 2 , false , "Bed Topography Report for CSV:"}, // UBL
{ 1 , 2 , true , "Bilinear Leveling Grid:" }, // ABL Bilinear
{ 0 , 1 , true , "Bed Level Correction Matrix:" }, // ABL Linear or 3-Point
};

const char * meshErrorMsg[] = {"Invalid mesh"}; // list of possible error responses to "M420 V1 T1" command
Expand Down Expand Up @@ -400,21 +399,13 @@ static inline void meshUpdateIndex(const MESH_KEY_VALUES key_num)
meshData->index = meshData->row * meshData->colsNum + meshData->col;
}

uint16_t meshGetJ(void)
{
// J index (independent by data format) to be used by G42 (mesh tuner menu) and M421 (meshSetValue() function).
// Bed's top left point -> J = max row index
// Bed's bottom left point -> J = 0
return (meshData->rowsNum - 1) - meshData->row;
}

bool meshSetValue(const float value)
{
if (meshData->curData[meshData->index] != value) // if mesh value is changed
{
meshData->curData[meshData->index] = value; // set new mesh value

mustStoreCmd("M421 I%d J%d Z%.3f\n", meshData->col, meshGetJ(), value); // send new mesh value
mustStoreCmd("M421 I%d J%d Z%.3f\n", meshData->col, MESH_EEPROM_ROW, value); // send new mesh value

return true;
}
Expand All @@ -424,18 +415,14 @@ bool meshSetValue(const float value)

static inline void meshUpdateValueMinMax(void)
{
float value;

meshData->valueMin = meshData->valueMax = meshData->curData[0]; // init initial min/max values

for (uint16_t i = 0; i < meshData->dataSize; i++)
{
value = meshData->curData[i];

if (value < meshData->valueMin)
meshData->valueMin = value;
else if (value > meshData->valueMax)
meshData->valueMax = value;
if (meshData->curData[i] < meshData->valueMin)
meshData->valueMin = meshData->curData[i];
else if (meshData->curData[i] > meshData->valueMax)
meshData->valueMax = meshData->curData[i];
}

meshData->valueDelta = meshData->valueMax - meshData->valueMin;
Expand Down Expand Up @@ -727,7 +714,7 @@ void meshUpdateData(char * dataRow)

if (meshData->status == ME_DATA_EMPTY) // if data grid is empty, parse the data row and set the data grid columns number
{
count = meshParseDataRow(dataRow, &(meshData->oriData[0]), MESH_GRID_MAX_POINTS_X);
count = meshParseDataRow(dataRow, meshData->oriData, MESH_GRID_MAX_POINTS_X);

if (count > 0) // if number of columns in the parsed data row is at least 1, set the data grid columns number
{
Expand Down Expand Up @@ -830,7 +817,7 @@ void menuMeshEditor(void)
probeHeightHome(); // home, disable ABL and raise nozzle

// call mesh tuner menu and set current mesh value, if changed
meshSetValue(menuMeshTuner(meshData->col, meshGetJ(), meshData->curData[curIndex]));
meshSetValue(menuMeshTuner(meshData->col, MESH_EEPROM_ROW, meshData->curData[curIndex]));

meshDrawMenu();
break;
Expand Down

0 comments on commit 75646cb

Please sign in to comment.