Skip to content

Commit

Permalink
Bug fixes on top of last merged PRs (#2768)
Browse files Browse the repository at this point in the history
  • Loading branch information
digant73 authored Apr 17, 2023
1 parent 6c86560 commit adeefb6
Show file tree
Hide file tree
Showing 18 changed files with 140 additions and 156 deletions.
2 changes: 1 addition & 1 deletion TFT/src/User/API/BabystepControl.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ static float babystep_value = BABYSTEP_DEFAULT_VALUE;
#define BABYSTEP_CMD_SMW "G43.2 Z%.2f\n"

// Set current babystep value
void babystepSetValue(const float value)
void babystepSetValue(float value)
{
babystep_value = value;
}
Expand Down
3 changes: 2 additions & 1 deletion TFT/src/User/API/HomeOffsetControl.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ float homeOffsetGetValue(void)
// Reset Z offset value to default value
float homeOffsetResetValue(void)
{
if (z_offset_value != HOME_Z_OFFSET_DEFAULT_VALUE) // if already default value, nothing to do
if (z_offset_value != HOME_Z_OFFSET_DEFAULT_VALUE) // if not default value
{
sendParameterCmd(P_HOME_OFFSET, AXIS_INDEX_Z, HOME_Z_OFFSET_DEFAULT_VALUE); // set Z home offset value
mustStoreCmd("G1 Z%.2f\n", z_offset_value - HOME_Z_OFFSET_DEFAULT_VALUE); // move nozzle

z_offset_value = HOME_Z_OFFSET_DEFAULT_VALUE;
}

Expand Down
6 changes: 3 additions & 3 deletions TFT/src/User/API/Notification.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void addToast(DIALOG_TYPE style, char * text)
LCD_WAKE();

TOAST t;
strxcpy(t.text, text, TOAST_MSG_LENGTH);
strncpy_no_pad(t.text, text, TOAST_MSG_LENGTH);
t.style = style;
t.isNew = true;
toastlist[nextToastIndex] = t;
Expand Down Expand Up @@ -146,8 +146,8 @@ void addNotification(DIALOG_TYPE style, char *title, char *text, bool ShowDialog

// store message
msglist[nextMsgIndex].style = style;
strxcpy(msglist[nextMsgIndex].text, text, MAX_MSG_LENGTH);
strxcpy(msglist[nextMsgIndex].title, title, MAX_MSG_TITLE_LENGTH);
strncpy_no_pad(msglist[nextMsgIndex].text, text, MAX_MSG_LENGTH);
strncpy_no_pad(msglist[nextMsgIndex].title, title, MAX_MSG_TITLE_LENGTH);

if (ShowDialog && MENU_IS_NOT(menuNotification))
popupReminder(style, (uint8_t *)title, (uint8_t *)msglist[nextMsgIndex].text);
Expand Down
3 changes: 2 additions & 1 deletion TFT/src/User/API/ProbeOffsetControl.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,11 @@ float probeOffsetGetValue(void)
// Reset Z offset value to default value
float probeOffsetResetValue(void)
{
if (z_offset_value != PROBE_Z_OFFSET_DEFAULT_VALUE) // if already default value, nothing to do
if (z_offset_value != PROBE_Z_OFFSET_DEFAULT_VALUE) // if not default value
{
sendParameterCmd(P_PROBE_OFFSET, AXIS_INDEX_Z, PROBE_Z_OFFSET_DEFAULT_VALUE); // set Z probe offset value
mustStoreCmd("G1 Z%.2f\n", PROBE_Z_OFFSET_DEFAULT_VALUE - z_offset_value); // move nozzle

z_offset_value = PROBE_Z_OFFSET_DEFAULT_VALUE;
}

Expand Down
10 changes: 5 additions & 5 deletions TFT/src/User/API/Vfs/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ bool addFile(bool isFile, const char * shortName, const char * longName)
if (sName == NULL) // in case of error, exit
return false;

strxcpy(sName, shortName, sNameLen); // copy to "sName" and set to NULL the flag for filename extension check, if any
strncpy_pad(sName, shortName, sNameLen); // copy to "sName" and set to NULL the flag for filename extension check, if any

//
// get long name, if any
Expand All @@ -237,7 +237,7 @@ bool addFile(bool isFile, const char * shortName, const char * longName)
return false;
}

strxcpy(lName, longName, lNameLen); // copy to "lName" and set to NULL the flag for filename extension check, if any
strncpy_pad(lName, longName, lNameLen); // copy to "lName" and set to NULL the flag for filename extension check, if any
}

//
Expand Down Expand Up @@ -357,9 +357,9 @@ bool getPrintTitle(char * buf, uint8_t len)
return false;
}

strxcpy(buf, getFS(), len); // set source and set the flag for filename extension check
strcat(buf, strPtr); // append filename
hideExtension(buf); // hide filename extension if filename extension feature is disabled
strncpy_pad(buf, getFS(), len); // set source and set the flag for filename extension check
strcat(buf, strPtr); // append filename
hideExtension(buf); // hide filename extension if filename extension feature is disabled

return true;
}
Expand Down
6 changes: 2 additions & 4 deletions TFT/src/User/API/Vfs/vfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,8 @@ bool addFile(bool isFile, const char * shortName, const char * longName); // ad
// called in Print.c
char * getFoldername(uint8_t index); // return the long folder name if exists, otherwise the short one
char * getFilename(uint8_t index); // return the long file name if exists, otherwise the short one
char * hideFilenameExtension(uint8_t index); // given the index, hide the extension of that file name and return a pointer to that file name
char * restoreFilenameExtension(uint8_t index); // given the index, restore the extension of that file name and return a pointer to that file name
char * hideExtension(char * filename); // hide the extension of the file name and return a pointer to that file name
char * restoreExtension(char * filename); // restore the extension of the file name and return a pointer to that file name
char * hideFilenameExtension(uint8_t index); // hide the extension of the file name and return a pointer to that file name
char * restoreFilenameExtension(uint8_t index); // restore the extension of the file name and return a pointer to that file name

// called in PrintingMenu.c
char * getPrintFilename(void); // get print filename according to print originator (remote or local to TFT)
Expand Down
7 changes: 4 additions & 3 deletions TFT/src/User/API/interfaceCmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ bool storeCmdFromUART(const CMD cmd, const SERIAL_PORT_INDEX portIndex)
return false;
}

strxcpy(cmdQueue.queue[cmdQueue.index_w].gcode, cmd, CMD_MAX_SIZE);
strncpy_no_pad(cmdQueue.queue[cmdQueue.index_w].gcode, cmd, CMD_MAX_SIZE);

cmdQueue.queue[cmdQueue.index_w].port_index = portIndex;
cmdQueue.index_w = (cmdQueue.index_w + 1) % CMD_QUEUE_SIZE;
Expand Down Expand Up @@ -852,7 +852,7 @@ void sendQueueCmd(void)
bool hasE, hasA;

// make a copy to work on
strxcpy(rawMsg, &cmd_ptr[cmd_base_index + 4], CMD_MAX_SIZE);
strncpy_no_pad(rawMsg, &cmd_ptr[cmd_base_index + 4], CMD_MAX_SIZE);

// retrieve message text and flags of M118 gcode
msgText = parseM118(rawMsg, &hasE, &hasA);
Expand Down Expand Up @@ -999,7 +999,7 @@ void sendQueueCmd(void)
const char * msgText;

// make a copy to work on
strxcpy(rawMsg, &cmd_ptr[cmd_base_index + 4], CMD_MAX_SIZE);
strncpy_no_pad(rawMsg, &cmd_ptr[cmd_base_index + 4], CMD_MAX_SIZE);

// retrieve message text
stripChecksum(rawMsg);
Expand Down Expand Up @@ -1404,6 +1404,7 @@ void sendQueueCmd(void)
case 28: // G28
coordinateSetKnown(true);
babystepSetValue(BABYSTEP_DEFAULT_VALUE); // reset babystep

if (infoMachineSettings.leveling != BL_DISABLED)
storeCmd("M420\n"); // check bed leveling state
break;
Expand Down
4 changes: 2 additions & 2 deletions TFT/src/User/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -1369,8 +1369,8 @@

/**
* Suppress/allow terminal cache during keyboard view
* - uncomment to disable terminal cache during keyboard view
* - comment it to enable terminal cache during keyboard view
* Uncomment to disable terminal cache during keyboard view.
* Comment to enable terminal cache during keyboard view.
*/
#define TERMINAL_KEYBOARD_VIEW_SUPPRESS_ACK // Default: uncommented (cache suppressed)

Expand Down
2 changes: 1 addition & 1 deletion TFT/src/User/Fatfs/myfatfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ bool f_remove_full_dir(const TCHAR* path)
char dirBuffer[BUFFER_SIZE];
FILINFO tmpInfo;

strxcpy(dirBuffer, path, BUFFER_SIZE);
strncpy_no_pad(dirBuffer, path, BUFFER_SIZE);
if (f_remove_node(dirBuffer, BUFFER_SIZE, &tmpInfo) == FR_OK)
{
return true;
Expand Down
7 changes: 4 additions & 3 deletions TFT/src/User/Menu/BedLeveling.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,10 @@ void menuBedLeveling(void)
break;

case KEY_ICON_3:
if (levelStateNew != UNDEFINED) storeCmd((levelStateNew == ENABLED) ?
(infoMachineSettings.firmwareType == FW_MARLIN ? "M420 S0\n" : "G29 S2\n") :
(infoMachineSettings.firmwareType == FW_MARLIN ? "M420 S1\n" : "G29 S1\n"));
if (levelStateNew != UNDEFINED)
storeCmd((levelStateNew == ENABLED) ?
(infoMachineSettings.firmwareType != FW_REPRAPFW ? "M420 S0\n" : "G29 S2\n") :
(infoMachineSettings.firmwareType != FW_REPRAPFW ? "M420 S1\n" : "G29 S1\n"));

break;

Expand Down
5 changes: 1 addition & 4 deletions TFT/src/User/Menu/MBL.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,7 @@ void mblNotifyError(bool isStarted)
{
LABELCHAR(tempMsg, LABEL_MBL);

if (isStarted)
sprintf(&tempMsg[strlen(tempMsg)], " %s", textSelect(LABEL_ON));
else
sprintf(&tempMsg[strlen(tempMsg)], " %s", textSelect(LABEL_OFF));
sprintf(&tempMsg[strlen(tempMsg)], " %s", isStarted ? textSelect(LABEL_ON) : textSelect(LABEL_OFF));

addToast(DIALOG_TYPE_ERROR, tempMsg);
}
Expand Down
67 changes: 34 additions & 33 deletions TFT/src/User/Menu/MeshEditor.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,29 @@ typedef struct
float oriData[MESH_GRID_SIZE]; // data grid of original Z height
float curData[MESH_GRID_SIZE]; // data grid of current Z height

uint16_t dataSize; // number of data present in the data grid
uint16_t colsNum; // number of points per X axis (number of columns in the data grid)
uint16_t rowsNum; // number of points per Y axis (number of rows in the data grid)

uint16_t index; // current index in the data grid
uint16_t col; // current column in the data grid
uint16_t row; // current row in the data grid

float valueMin; // minimum data value in the data grid
float valueMax; // maximum data value in the data grid
float valueDelta; // valueMax - valueMin

uint16_t rStart; // RGB red component for drawing the minimum data value in the data grid
uint16_t gStart; // RGB green component for drawing the minimum data value in the data grid
uint16_t bStart; // RGB blue component for drawing the minimum data value in the data grid
uint16_t rEnd; // RGB green component for drawing the maximum data value in the data grid
uint16_t gEnd; // RGB red component for drawing the maximum data value in the data grid
uint16_t bEnd; // RGB blue component for drawing the maximum data value in the data grid
int16_t rDelta; // rEnd - rStart
int16_t gDelta; // gEnd - gStart
int16_t bDelta; // bEnd - bStart

MESH_DATA_STATUS status; // current status of oriData/data
uint16_t dataSize; // number of data present in the data grid
uint16_t colsNum; // number of points per X axis (number of columns in the data grid)
uint16_t rowsNum; // number of points per Y axis (number of rows in the data grid)

uint16_t index; // current index in the data grid
uint16_t col; // current column in the data grid
uint16_t row; // current row in the data grid

float valueMin; // minimum data value in the data grid
float valueMax; // maximum data value in the data grid
float valueDelta; // valueMax - valueMin

uint16_t rStart; // RGB red component for drawing the minimum data value in the data grid
uint16_t gStart; // RGB green component for drawing the minimum data value in the data grid
uint16_t bStart; // RGB blue component for drawing the minimum data value in the data grid
uint16_t rEnd; // RGB green component for drawing the maximum data value in the data grid
uint16_t gEnd; // RGB red component for drawing the maximum data value in the data grid
uint16_t bEnd; // RGB blue component for drawing the maximum data value in the data grid
int16_t rDelta; // rEnd - rStart
int16_t gDelta; // gEnd - gStart
int16_t bDelta; // bEnd - bStart

MESH_DATA_STATUS status; // current status of oriData/curData
uint8_t parsedRows;

uint8_t colsToSkip;
Expand Down Expand Up @@ -239,11 +239,11 @@ const struct
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
// 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 @@ -275,7 +275,9 @@ void meshInitData(void)

static inline void meshAllocData(void)
{
if (meshData == NULL) // if data already exist (e.g. when the menu is reloaded), continue to use the existing data
// if data doesn't already exist (e.g. when the menu is loaded for the first time), initialize data.
// Otherwise, if data already exist (e.g. when the menu is reloaded), continue to use the existing data
if (meshData == NULL)
{
meshData = (MESH_DATA *) malloc(sizeof(MESH_DATA));
meshInitData();
Expand Down Expand Up @@ -393,7 +395,7 @@ static inline uint16_t meshGetRealRow(void)

static inline void meshSetValue(void)
{
storeCmd("M421 I%d J%d Z%.3f\n", meshData->col, meshGetRealRow(), meshData->oriData[meshData->index]);
storeCmd("M421 I%d J%d Z%.3f\n", meshData->col, meshGetRealRow(), meshData->curData[meshData->index]);
}

static inline void meshUpdateValueMinMax(void)
Expand Down Expand Up @@ -690,7 +692,6 @@ void meshUpdateData(char *dataRow)
return;
}


if (!failed)
{
uint16_t count;
Expand Down Expand Up @@ -815,11 +816,11 @@ void menuMeshEditor(void)

case ME_KEY_SAVE:
meshSave();
memcpy(meshData->curData, meshData->oriData, sizeof(meshData->oriData));
memcpy(meshData->oriData, meshData->curData, sizeof(meshData->curData));
break;

case ME_KEY_OK:
if (memcmp(meshData->curData, meshData->oriData, sizeof(meshData->oriData)))
if (memcmp(meshData->oriData, meshData->curData, sizeof(meshData->curData)))
meshSave();

meshDeallocData();
Expand Down
16 changes: 8 additions & 8 deletions TFT/src/User/Menu/Popup.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ void menuDialog(void)

void _setDialogTitleStr(uint8_t * str)
{
strxcpy((char *)popup_title, (char *)str, sizeof(popup_title));
strncpy_no_pad((char *)popup_title, (char *)str, sizeof(popup_title));
}

void _setDialogMsgStr(uint8_t * str)
{
strxcpy((char *)popup_msg, (char *)str, sizeof(popup_msg));
strncpy_no_pad((char *)popup_msg, (char *)str, sizeof(popup_msg));
}

uint8_t *getDialogMsgStr()
Expand All @@ -141,40 +141,40 @@ uint8_t *getDialogMsgStr()

void _setDialogOkTextStr(uint8_t * str)
{
strxcpy((char *)popup_ok, (char *)str, sizeof(popup_ok));
strncpy_no_pad((char *)popup_ok, (char *)str, sizeof(popup_ok));
}

void _setDialogCancelTextStr(uint8_t * str)
{
strxcpy((char *)popup_cancel, (char *)str, sizeof(popup_cancel));
strncpy_no_pad((char *)popup_cancel, (char *)str, sizeof(popup_cancel));
}

void _setDialogTitleLabel(int16_t index)
{
uint8_t tempstr[MAX_LANG_LABEL_LENGTH] = {0};
loadLabelText(tempstr, index);
strxcpy((char *)popup_title, (char *)tempstr, sizeof(popup_title));
strncpy_no_pad((char *)popup_title, (char *)tempstr, sizeof(popup_title));
}

void _setDialogMsgLabel(int16_t index)
{
uint8_t tempstr[MAX_LANG_LABEL_LENGTH] = {0};
loadLabelText(tempstr, index);
strxcpy((char *)popup_msg, (char *)tempstr, sizeof(popup_msg));
strncpy_no_pad((char *)popup_msg, (char *)tempstr, sizeof(popup_msg));
}

void _setDialogOkTextLabel(int16_t index)
{
uint8_t tempstr[MAX_LANG_LABEL_LENGTH] = {0};
loadLabelText(tempstr, index);
strxcpy((char *)popup_ok, (char *)tempstr, sizeof(popup_ok));
strncpy_no_pad((char *)popup_ok, (char *)tempstr, sizeof(popup_ok));
}

void _setDialogCancelTextLabel(int16_t index)
{
uint8_t tempstr[MAX_LANG_LABEL_LENGTH] = {0};
loadLabelText(tempstr, index);
strxcpy((char *)popup_cancel, (char *)tempstr, sizeof(popup_cancel));
strncpy_no_pad((char *)popup_cancel, (char *)tempstr, sizeof(popup_cancel));
}

/**
Expand Down
15 changes: 3 additions & 12 deletions TFT/src/User/Menu/PrintingMenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,21 +122,12 @@ static void setLayerNumberTxt(char * layer_number_txt)
}
}

// set print title according to print originator (remote or local to TFT)
static void setPrintTitle(void)
{
char * fileName = getPrintFilename();

hideExtension(fileName); // hide filename extension if filename extension feature is disabled
snprintf(title, MAX_TITLE_LEN, "%s%s", getFS(), fileName);
restoreExtension(fileName); // restore filename extension if filename extension feature is disabled
}

// initialize printing info before opening Printing menu
static void initMenuPrinting(void)
{
setPrintTitle(); // set print title according to print originator (remote or local to TFT)
clearInfoFile(); // as last, clear and free memory for file list
getPrintTitle(title, MAX_TITLE_LEN); // get print title according to print originator (remote or local to TFT)
clearInfoFile(); // as last, clear and free memory for file list

progDisplayType = infoSettings.prog_disp_type;

// layer number can be parsed only when TFT reads directly the G-code file
Expand Down
Loading

0 comments on commit adeefb6

Please sign in to comment.