Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into MeshEditor-speed-…
Browse files Browse the repository at this point in the history
…mods
  • Loading branch information
kisslorand committed May 17, 2023
2 parents 3f4c9e4 + 9a7553c commit 5301b95
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 30 deletions.
42 changes: 20 additions & 22 deletions TFT/src/User/Menu/MeshEditor.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ const GUI_RECT meshAreaRect[ME_AREA_NUM] = {
#endif
};

const char *const meshKeyString[ME_KEY_NUM] = {
const char * const meshKeyString[ME_KEY_NUM] = {
"\u08A7", // SAVE
"\u0894", // OK
"\u08A5", // RESET
Expand Down Expand Up @@ -358,7 +358,7 @@ void meshSaveCallback(void)
else if (infoMachineSettings.leveling != BL_DISABLED)
saveEepromSettings();

if (meshData != NULL)
if (meshData != NULL) // if data have not been released (e.g. data are released when mesh editor menu is forced to exit)
memcpy(meshData->oriData, meshData->curData, sizeof(meshData->oriData)); // sync mesh data
}

Expand Down Expand Up @@ -399,12 +399,16 @@ static void meshUpdateIndex(MESH_KEY_VALUES key_num)
meshData->index = meshData->row * meshData->colsNum + meshData->col;
}

static void meshSetValue(const float newMeshData)
static bool meshSetValue(const float newMeshData)
{
const uint16_t curIndex = meshData->index;
if (meshData->curData[meshData->index] != newMeshData)
{
mustStoreCmd("M421 I%d J%d Z%.3f\n", (meshData->rowsNum - 1) - meshData->row, newMeshData); // (meshData->rowsNum - 1) - meshData->row -> real row in eeprom
meshData->curData[meshData->index] = newMeshData;
return true;
}

mustStoreCmd("M421 I%d J%d Z%.3f\n", (meshData->rowsNum - 1) - meshData->row, newMeshData); // (meshData->rowsNum - 1) - meshData->row -> real row in eeprom
meshData->curData[curIndex] = newMeshData;
return false;
}

static void meshUpdateValueMinMax(void)
Expand Down Expand Up @@ -620,14 +624,14 @@ bool meshIsWaitingData(void)
return true;
}

static uint16_t meshParseDataRow(char *dataRow, float *dataGrid, const uint16_t maxCount)
static uint16_t meshParseDataRow(char * dataRow, float * dataGrid, const uint16_t maxCount)
{
if (meshData->parsedRows < meshData->rowsToSkip)
return 0;

uint16_t count;
char *curPtr;
char *nextPtr;
char * curPtr;
char * nextPtr;
float value;

count = 0;
Expand Down Expand Up @@ -671,7 +675,7 @@ static void processGridData(void)
}
}

void meshUpdateData(char *dataRow)
void meshUpdateData(char * dataRow)
{
bool failed = false;

Expand Down Expand Up @@ -804,25 +808,18 @@ void menuMeshEditor(void)

case ME_KEY_EDIT:
{
float newMeshData = 0.0f;

if (coordinateIsKnown() == false)
probeHeightHome(); // home, disable ABL and raise nozzle

newMeshData = menuMeshTuner(meshData->col, (meshData->rowsNum - 1) - meshData->row, meshData->curData[curIndex]); // (meshData->rowsNum - 1) - meshData->row -> real row in eeprom

if (meshData->curData[curIndex] != newMeshData)
meshSetValue(newMeshData);
meshSetValue(menuMeshTuner(meshData->col, (meshData->rowsNum - 1) - meshData->row, meshData->curData[curIndex])); // (meshData->rowsNum - 1) - meshData->row -> real row in eeprom

meshDrawMenu();
}
break;

case ME_KEY_RESET:
if (meshData->curData[curIndex] != meshData->oriData[curIndex])
if (meshSetValue(meshData->oriData[curIndex]))
{
meshSetValue(meshData->oriData[curIndex]);

meshDrawGrid();
meshDrawInfo(true);
}
Expand All @@ -833,9 +830,7 @@ void menuMeshEditor(void)
break;

case ME_KEY_SAVE:
case ME_KEY_OK:
if (memcmp(meshData->oriData, meshData->curData, sizeof(meshData->oriData)))
meshSave(); // save mesh changes to eeprom (if eeprom exists)
meshSave(); // save mesh changes to eeprom (if eeprom exists)
break;

default:
Expand All @@ -844,6 +839,9 @@ void menuMeshEditor(void)

if (key_num == ME_KEY_OK)
{
if (memcmp(meshData->oriData, meshData->curData, sizeof(meshData->oriData)))
meshSave(); // save mesh changes to eeprom (if eeprom exists)

meshDeallocData();
CLOSE_MENU();
}
Expand Down
8 changes: 0 additions & 8 deletions TFT/src/User/my_misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,6 @@ bool validateChecksum(char *str);

const char *parseM118(char *str, bool *hasE, bool *hasA);

// call processes from the argument and than loopProcess() while condition is true
// tasks from argument must be separated by ";" ("TASK_LOOP_WHILE(condition, task1(); task2(); ...))
#define TASK_LOOP_WHILE(condition, ...) \
while(condition) \
{ \
__VA_ARGS__; \
loopProcess(); \
}
#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit 5301b95

Please # to comment.