Skip to content

Commit

Permalink
Some comments formatting, removed == true, == false
Browse files Browse the repository at this point in the history
"if (a == true)" is the same as "if (a)"
"if (a == false)" is the same as "if (!a)"
Some small comment formatting fixes
Small optimization
  • Loading branch information
rondlh committed Dec 12, 2024
1 parent 3698c62 commit 2febd02
Show file tree
Hide file tree
Showing 42 changed files with 127 additions and 133 deletions.
2 changes: 1 addition & 1 deletion TFT/src/User/API/HW_Init.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void HW_Init(void)
LCD_Enc_InitActiveSignal();
#endif

if (readIsTSCExist() == false) // read settings parameter
if (!readIsTSCExist()) // read settings parameter
{
LCD_RefreshDirection(infoSettings.rotated_ui);
TS_Calibrate();
Expand Down
2 changes: 1 addition & 1 deletion TFT/src/User/API/Language/utf8_decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ uint16_t GUI_StrPixelWidth_label(int16_t index)
{
uint8_t tempstr[MAX_LANG_LABEL_LENGTH];

if (loadLabelText((uint8_t *)tempstr, index) == false)
if (!loadLabelText((uint8_t *)tempstr, index))
return 0;

return GUI_StrPixelWidth_str(tempstr);
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 @@ -72,7 +72,7 @@ void levelingMoveToPoint(LEVELING_POINT point)

levelingGetPointCoords(coords);

if (coordinateIsKnown() == false)
if (!coordinateIsKnown())
storeCmd("G28\n");

storeCmd("G0 Z%.3f F%d\n", infoSettings.level_z_raise, infoSettings.level_feedrate[FEEDRATE_Z]);
Expand All @@ -86,7 +86,7 @@ void levelingProbePoint(LEVELING_POINT point)

levelingGetPointCoords(coords);

if (coordinateIsKnown() == false)
if (!coordinateIsKnown())
probeHeightHomeAndRaise(); // home and raise nozzle

if (infoSettings.touchmi_sensor != 0)
Expand Down
2 changes: 1 addition & 1 deletion TFT/src/User/API/Mainboard_AckHandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ void parseAck(void)
// TFT to printer connection handling
//----------------------------------------

if (infoHost.connected == false)
if (!infoHost.connected)
{
// parse error information even though not connected to printer
if (ack_seen(magic_error))
Expand Down
12 changes: 6 additions & 6 deletions TFT/src/User/API/Mainboard_CmdHandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ static bool openRemoteTFT(bool writingMode)
if (!writingMode) // if reading mode
{
// mount FS and open the file (infoFile.source and infoFile.path are used)
if (mountFS() == true && f_open(&file, infoFile.path, FA_OPEN_EXISTING | FA_READ) == FR_OK)
if (mountFS() && f_open(&file, infoFile.path, FA_OPEN_EXISTING | FA_READ) == FR_OK)
{
char buf[10];

Expand All @@ -436,7 +436,7 @@ static bool openRemoteTFT(bool writingMode)
else // if writing mode
{
// mount FS and open the file (infoFile.source and infoFile.path are used)
if (mountFS() == true && f_open(&file, infoFile.path, FA_OPEN_ALWAYS | FA_WRITE) == FR_OK)
if (mountFS() && f_open(&file, infoFile.path, FA_OPEN_ALWAYS | FA_WRITE) == FR_OK)
{
Serial_Forward(cmd_port_index, "Writing to file: ");
Serial_Forward(cmd_port_index, infoFile.path);
Expand Down Expand Up @@ -700,7 +700,7 @@ void sendQueueCmd(void)
Serial_Forward(cmd_port_index, "Begin file list\n");

// then mount FS and scan for files (infoFile.source and infoFile.path are used)
if (mountFS() == true && scanPrintFiles() == true)
if (mountFS() && scanPrintFiles())
{
for (uint16_t i = 0; i < infoFile.fileCount; i++)
{
Expand Down Expand Up @@ -857,7 +857,7 @@ void sendQueueCmd(void)
if (initRemoteTFT()) // examples: "M30 SD:/test/cap2.gcode\n", "M30 S /test/cap2.gcode\n"
{
// then mount FS and delete the file (infoFile.source and infoFile.path are used)
if (mountFS() == true && f_unlink(infoFile.path) == FR_OK)
if (mountFS() && f_unlink(infoFile.path) == FR_OK)
Serial_Forward(cmd_port_index, "File deleted: ");
else
Serial_Forward(cmd_port_index, "Deletion failed, File: ");
Expand Down Expand Up @@ -912,7 +912,7 @@ void sendQueueCmd(void)
msgText = parseM118(rawMsg, &hasE, &hasA);

// format: <E prefix> + <A prefix> + <text> + "\n"
snprintf(msg, CMD_MAX_SIZE, "%s%s%s\n", (hasE == true) ? "echo:" : "", (hasA == true) ? "//" : "", msgText);
snprintf(msg, CMD_MAX_SIZE, "%s%s%s\n", hasE ? "echo:" : "", hasA ? "//" : "", msgText);

int32_t fwdPort = cmd_seen('P') ? cmd_value() : SUP_PORTS;

Expand Down Expand Up @@ -1570,7 +1570,7 @@ void sendQueueCmd(void)
// - if TFT is connected, update tx slots and tx count
// - if TFT is not connected, consider the command as an out of band message
//
if (sendCmd(false, avoid_terminal) == true && infoHost.connected == true)
if (sendCmd(false, avoid_terminal) && infoHost.connected)
{
// decrease the number of available tx slots and increase the pending commands tx count
//
Expand Down
8 changes: 4 additions & 4 deletions TFT/src/User/API/Notification.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void drawToast(bool redraw)
if (!redraw)
curToastDisplay = (curToastDisplay + 1) % TOAST_MSG_COUNT;

if (toastlist[curToastDisplay].isNew == true || redraw)
if (toastlist[curToastDisplay].isNew || redraw)
{
// set toast notification running status
_toastRunning = true;
Expand Down Expand Up @@ -110,7 +110,7 @@ static inline bool toastAvailable(void)
{
for (int i = 0; i < TOAST_MSG_COUNT; i++)
{
if (toastlist[i].isNew == true)
if (toastlist[i].isNew)
return true;
}

Expand All @@ -121,14 +121,14 @@ static inline bool toastAvailable(void)
void loopToast(void)
{
// if no new toast is available or it is not yet expired on screen or in case a full screen menu is displayed, do nothing
if (_toastAvailable == false || ((OS_GetTimeMs() - nextToastTime) < SEC_TO_MS(TOAST_DURATION)) || getMenuType() == MENU_TYPE_FULLSCREEN)
if (!_toastAvailable || ((OS_GetTimeMs() - nextToastTime) < SEC_TO_MS(TOAST_DURATION)) || getMenuType() == MENU_TYPE_FULLSCREEN)
return;

if (toastAvailable())
{
drawToast(false);
}
else if (_toastRunning == true)
else if (_toastRunning)
{
_toastRunning = false;
_toastAvailable = false;
Expand Down
2 changes: 1 addition & 1 deletion TFT/src/User/API/PowerFailed.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ bool powerFailedInitRestore(void)
mustStoreCmd("G92 E%.5f\nG1 F%d\n", infoBreakPoint.axis[E_AXIS], infoBreakPoint.feedrate);
mustStoreCmd(infoBreakPoint.relative ? "G91\n" : "G90\n");

if (infoBreakPoint.relative_e == false)
if (!infoBreakPoint.relative_e)
mustStoreCmd("M82\n");
}

Expand Down
20 changes: 10 additions & 10 deletions TFT/src/User/API/Printing.c
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ bool pausePrint(bool isPause, PAUSE_TYPE pauseType)
{
case FS_TFT_SD:
case FS_TFT_USB:
if (isPause == true && pauseType == PAUSE_M0)
if (isPause && pauseType == PAUSE_M0)
TASK_LOOP_WHILE(isNotEmptyCmdQueue()); // wait for the communication to be clean

static COORDINATE tmp;
Expand All @@ -632,8 +632,8 @@ bool pausePrint(bool isPause, PAUSE_TYPE pauseType)
{
coordinateGetAll(&tmp);

if (isCoorRelative == true) mustStoreCmd("G90\n");
if (isExtrudeRelative == true) mustStoreCmd("M82\n");
if (isCoorRelative) mustStoreCmd("G90\n");
if (isExtrudeRelative) mustStoreCmd("M82\n");

if (heatGetCurrentTemp(heatGetCurrentHotend()) > infoSettings.min_ext_temp)
{
Expand All @@ -648,8 +648,8 @@ bool pausePrint(bool isPause, PAUSE_TYPE pauseType)
infoSettings.pause_feedrate[FEEDRATE_XY]);
}

if (isCoorRelative == true) mustStoreCmd("G91\n");
if (isExtrudeRelative == true) mustStoreCmd("M83\n");
if (isCoorRelative) mustStoreCmd("G91\n");
if (isExtrudeRelative) mustStoreCmd("M83\n");
}

// store pause type only on pause
Expand All @@ -663,10 +663,10 @@ bool pausePrint(bool isPause, PAUSE_TYPE pauseType)
}
else if (pauseType == PAUSE_NORMAL) // send command only for pause originated from TFT
{
if (isCoorRelative == true) mustStoreCmd("G90\n");
if (isExtrudeRelative == true) mustStoreCmd("M82\n");
if (isCoorRelative) mustStoreCmd("G90\n");
if (isExtrudeRelative) mustStoreCmd("M82\n");

if (extrusionDuringPause == true) // check if extrusion done during Print -> Pause
if (extrusionDuringPause) // check if extrusion done during Print -> Pause
{ // no purge
extrusionDuringPause = false;
}
Expand All @@ -685,8 +685,8 @@ bool pausePrint(bool isPause, PAUSE_TYPE pauseType)
mustStoreCmd("G92 E%.5f\n", tmp.axis[E_AXIS]);
mustStoreCmd("G1 F%d\n", tmp.feedrate);

if (isCoorRelative == true) mustStoreCmd("G91\n");
if (isExtrudeRelative == true) mustStoreCmd("M83\n");
if (isCoorRelative) mustStoreCmd("G91\n");
if (isExtrudeRelative) mustStoreCmd("M83\n");
}
}
break;
Expand Down
2 changes: 1 addition & 1 deletion TFT/src/User/API/Printing.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extern "C" {

#ifdef RAPID_SERIAL_COMM
#define RAPID_SERIAL_LOOP() loopBackEnd()
#define RAPID_PRINTING_COMM() if (isPrinting() == true && infoSettings.serial_always_on != 1) {loopBackEnd();}
#define RAPID_PRINTING_COMM() if (isPrinting() && infoSettings.serial_always_on != 1) {loopBackEnd();}
#else
#define RAPID_SERIAL_LOOP()
#define RAPID_PRINTING_COMM()
Expand Down
2 changes: 1 addition & 1 deletion TFT/src/User/API/SpeedControl.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void loopCheckSpeed(void)
if ((OS_GetTimeMs() - lastUpdateTime) < SPEED_REFRESH_TIME) // avoid rapid fire, clogging the queue
return;

lastUpdateTime = OS_GetTimeMs(); // extend next check time
lastUpdateTime = OS_GetTimeMs(); // extend next check time

for (uint8_t i = 0; i < SPEED_NUM; i++)
{
Expand Down
10 changes: 5 additions & 5 deletions TFT/src/User/API/Temperature.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void heatSetTargetTemp(uint8_t index, const int16_t temp, const TEMP_SOURCE temp
break;

case FROM_CMD:
if (GET_BIT(heat_feedback_waiting, index) == false)
if (!GET_BIT(heat_feedback_waiting, index))
{
heater.T[index].target = temp;
SET_BIT_ON(heat_feedback_waiting, index);
Expand Down Expand Up @@ -113,14 +113,14 @@ void heatCoolDown(void)

bool heatGetIsWaiting(const uint8_t index)
{
return (heater.T[index].waiting == true);
return (heater.T[index].waiting);
}

bool heatHasWaiting(void)
{
for (uint8_t i = 0; i < MAX_HEATER_COUNT; i++)
{
if (heater.T[i].waiting == true)
if (heater.T[i].waiting)
return true;
}

Expand All @@ -136,9 +136,9 @@ void heatSetIsWaiting(uint8_t index, const bool isWaiting)

heater.T[index].waiting = isWaiting;

if (isWaiting == true) // wait heating now, query more frequently
if (isWaiting) // wait heating now, query more frequently
heatSetUpdateSeconds(TEMPERATURE_QUERY_FAST_SECONDS);
else if (heatHasWaiting() == false)
else if (!heatHasWaiting())
heatSetUpdateSeconds(TEMPERATURE_QUERY_SLOW_SECONDS);
}

Expand Down
10 changes: 5 additions & 5 deletions TFT/src/User/API/Touch_Screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ uint16_t TS_KeyValue(uint8_t totalRect, const GUI_RECT * menuRect)
if ((x >= menuRect[i].x0) && (x <= menuRect[i].x1) && (y >= menuRect[i].y0) && (y <= menuRect[i].y1))
{
#ifdef BUZZER_PIN
if (TS_Sound == true)
if (TS_Sound)
BUZZER_PLAY(SOUND_KEYPRESS);
#endif

Expand All @@ -106,21 +106,21 @@ uint16_t KEY_GetValue(uint8_t totalRect, const GUI_RECT * menuRect)
{
if (firstPress)
{
key_num = TS_KeyValue(totalRect, menuRect); // store the pressed key number
key_num = TS_KeyValue(totalRect, menuRect); // store the pressed key number
firstPress = false;

if (TS_ReDrawIcon)
TS_ReDrawIcon(key_num, 1);
}
}
else // not pressed
else // not pressed
{
if (!firstPress) // not pressed anymore
if (!firstPress) // not pressed anymore
{
if (TS_ReDrawIcon)
TS_ReDrawIcon(key_num, 0);

key_return = key_num; // return stored key number
key_return = key_num; // return stored key number
key_num = IDLE_TOUCH;
firstPress = true;

Expand Down
18 changes: 9 additions & 9 deletions TFT/src/User/API/UI/GUI.c
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ void _GUI_DispLabel(int16_t x, int16_t y, uint16_t index)
{
uint8_t tempstr[MAX_LANG_LABEL_LENGTH];

if (loadLabelText(tempstr, index) == false)
if (!loadLabelText(tempstr, index))
return;

_GUI_DispString(x, y, tempstr);
Expand All @@ -949,7 +949,7 @@ const uint8_t * _GUI_DispLenLabel(int16_t x, int16_t y, uint16_t index, uint16_t
{
uint8_t tempstr[MAX_LANG_LABEL_LENGTH];

if (loadLabelText(tempstr, index) == false)
if (!loadLabelText(tempstr, index))
return NULL;

return _GUI_DispLenString(x, y, tempstr, pixelWidth, truncate);
Expand All @@ -959,7 +959,7 @@ void _GUI_DispLabelRight(int16_t x, int16_t y, uint16_t index)
{
uint8_t tempstr[MAX_LANG_LABEL_LENGTH];

if (loadLabelText(tempstr, index) == false)
if (!loadLabelText(tempstr, index))
return;

_GUI_DispStringRight(x, y, tempstr);
Expand All @@ -969,7 +969,7 @@ void _GUI_DispLabelCenter(int16_t x, int16_t y, uint16_t index)
{
uint8_t tempstr[MAX_LANG_LABEL_LENGTH];

if (loadLabelText(tempstr, index) == false)
if (!loadLabelText(tempstr, index))
return;

_GUI_DispStringCenter(x, y, tempstr);
Expand All @@ -979,7 +979,7 @@ void _GUI_DispLabelInRect(int16_t sx, int16_t sy, int16_t ex, int16_t ey, uint16
{
uint8_t tempstr[MAX_LANG_LABEL_LENGTH];

if (loadLabelText(tempstr, index) == false)
if (!loadLabelText(tempstr, index))
return;

_GUI_DispStringInRect(sx, sy, ex, ey, tempstr);
Expand All @@ -989,7 +989,7 @@ void _GUI_DispLabelInPrect(const GUI_RECT * rect, uint16_t index)
{
uint8_t tempstr[MAX_LANG_LABEL_LENGTH];

if (loadLabelText(tempstr, index) == false)
if (!loadLabelText(tempstr, index))
return;

_GUI_DispStringInPrect(rect, tempstr);
Expand All @@ -999,7 +999,7 @@ void _GUI_DispLabelInRectEOL(int16_t sx, int16_t sy, int16_t ex, int16_t ey, uin
{
uint8_t tempstr[MAX_LANG_LABEL_LENGTH];

if (loadLabelText(tempstr, index) == false)
if (!loadLabelText(tempstr, index))
return;

_GUI_DispStringInRectEOL(sx, sy, ex, ey, tempstr);
Expand All @@ -1009,7 +1009,7 @@ void _GUI_DispLabelInPrectEOL(const GUI_RECT * rect, uint16_t index)
{
uint8_t tempstr[MAX_LANG_LABEL_LENGTH];

if (loadLabelText(tempstr, index) == false)
if (!loadLabelText(tempstr, index))
return;

_GUI_DispStringInPrectEOL(rect, tempstr);
Expand All @@ -1019,7 +1019,7 @@ void _GUI_DispLabelOnIcon(uint16_t iconIndex, GUI_POINT iconPoint, GUI_POINT tex
{
uint8_t tempstr[MAX_LANG_LABEL_LENGTH];

if (loadLabelText(tempstr, index) == false)
if (!loadLabelText(tempstr, index))
return;

_GUI_DispStringOnIcon(iconIndex, iconPoint, textPos, tempstr);
Expand Down
Loading

0 comments on commit 2febd02

Please sign in to comment.