Skip to content

Commit

Permalink
🎨 Minor code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Jun 25, 2023
1 parent a256e47 commit f281fb4
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const char *FilesScreen::getSelectedFilename(bool shortName) {
}

void FilesScreen::drawSelectedFile() {
if(mydata.selected_tag == 0xFF) return;
if (mydata.selected_tag == 0xFF) return;
FileList files;
files.seek(getSelectedFileIndex(), true);
mydata.flags.is_dir = files.isDir();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,10 @@ void LoadChocolateScreen::draw_buttons(draw_mode_t what) {
cmd.tag(3).colors(mydata.repeat_tag == 6 ? action_btn : normal_btn).button(x, y, h, v, GET_TEXT_F(MSG_LOAD));

ui.bounds(POLY(load_screen_start_stop_btn), x, y, h, v);
if(mydata.repeat_tag == 0) {
cmd.colors(normal_btn).enabled(false);
} else {
cmd.colors(mydata.repeating ? action_btn : normal_btn).enabled(true);
}
if (mydata.repeat_tag == 0)
cmd.colors(normal_btn).enabled(false);
else
cmd.colors(mydata.repeating ? action_btn : normal_btn).enabled(true);
cmd.tag(4).button(x, y, h, v, GET_TEXT_F(MSG_START_STOP));

ui.bounds(POLY(load_screen_back_btn), x, y, h, v);
Expand Down Expand Up @@ -115,24 +114,16 @@ void LoadChocolateScreen::onRedraw(draw_mode_t what) {
}

bool LoadChocolateScreen::onTouchStart(uint8_t tag) {
if(tag != 4) {
mydata.repeating = false;
}
if (tag != 4) mydata.repeating = false;
return true;
}

bool LoadChocolateScreen::onTouchEnd(uint8_t tag) {
using namespace ExtUI;
switch (tag) {
case 2:
mydata.repeat_tag = 5;
break;
case 3:
mydata.repeat_tag = 6;
break;
case 4:
mydata.repeating = !mydata.repeating;
break;
case 2: mydata.repeat_tag = 5; break;
case 3: mydata.repeat_tag = 6; break;
case 4: mydata.repeating = !mydata.repeating; break;
case 1: GOTO_PREVIOUS(); break;
}
return true;
Expand All @@ -153,12 +144,8 @@ bool LoadChocolateScreen::onTouchHeld(uint8_t tag) {
#define UI_INCREMENT_AXIS(axis) UI_INCREMENT(AxisPosition_mm, axis);
#define UI_DECREMENT_AXIS(axis) UI_DECREMENT(AxisPosition_mm, axis);
switch (tag) {
case 5:
UI_INCREMENT_AXIS(E0);
break;
case 6:
UI_DECREMENT_AXIS(E0);
break;
case 5: UI_INCREMENT_AXIS(E0); break;
case 6: UI_DECREMENT_AXIS(E0); break;
default: return false;
}
#undef UI_DECREMENT_AXIS
Expand All @@ -170,10 +157,10 @@ void LoadChocolateScreen::onIdle() {
reset_menu_timeout();
if (mydata.repeating) onTouchHeld(mydata.repeat_tag);
if (refresh_timer.elapsed(STATUS_UPDATE_INTERVAL)) {
if (!EventLoop::is_touch_held())
onRefresh();
if (!EventLoop::is_touch_held()) onRefresh();
refresh_timer.start();
}
BaseScreen::onIdle();
}

#endif // COCOA_LOAD_CHOCOLATE_SCREEN
Original file line number Diff line number Diff line change
Expand Up @@ -271,22 +271,23 @@ void StatusScreen::draw_file(draw_mode_t what) {
if (what & FOREGROUND) {
cmd.cmd(COLOR_RGB(bg_text_enabled));

if(!isMediaInserted())
if (!isMediaInserted())
draw_text_with_ellipsis(cmd, TEXT_POS(x, y, w, h), F("No media present"), OPT_CENTERY, font_small);
else if(isFileSelected()) {
else if (isFileSelected()) {
FileList list;
draw_text_with_ellipsis(cmd, TEXT_POS(x, y, w, h), list.filename(), OPT_CENTERY, font_small);
} else
}
else
draw_text_with_ellipsis(cmd, TEXT_POS(x, y, w, h), F("No file selected"), OPT_CENTERY, font_small);
}
}

bool StatusScreen::isFileSelected() {
if(!isMediaInserted()) return false;
if (!isMediaInserted()) return false;
FileList list;
if(list.isDir()) return false;
if (list.isDir()) return false;
const char *filename = list.filename();
if(filename[0] == '\0') return false;
if (filename[0] == '\0') return false;
return true;
}

Expand Down Expand Up @@ -368,8 +369,7 @@ void StatusScreen::setStatusMessage(const char * const) {
void StatusScreen::onIdle() {
reset_menu_timeout();
if (refresh_timer.elapsed(STATUS_UPDATE_INTERVAL)) {
if (!EventLoop::is_touch_held())
onRefresh();
if (!EventLoop::is_touch_held()) onRefresh();
refresh_timer.start();
}
}
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/lcd/extui/ia_creality/ia_creality_rts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ void RTS::onIdle() {
break;

case 3:
//if(isPositionKnown() && (getActualTemp_celsius(BED) >= (getTargetTemp_celsius(BED)-1))) {
//if (isPositionKnown() && (getActualTemp_celsius(BED) >= (getTargetTemp_celsius(BED)-1))) {
rts.sendData(ExchangePageBase + 64, ExchangepageAddr);
waitway = 7;
//return;
Expand Down Expand Up @@ -1559,7 +1559,7 @@ void RTS::handleData() {
else if (recdat.data[0] == 2) { // Page Down
if ((fileIndex + DISPLAY_FILES) < (filenavigator.maxFiles() + (filenavigator.folderdepth != 0))) {
fileIndex = fileIndex + DISPLAY_FILES;
// if(filenavigator.folderdepth!=0 && fileIndex!=0) //Shift to acknowledge Return DIR button on first page
// if (filenavigator.folderdepth!=0 && fileIndex!=0) //Shift to acknowledge Return DIR button on first page
// filenavigator.getFiles(fileIndex-1);
// else
filenavigator.getFiles(fileIndex);
Expand All @@ -1569,7 +1569,7 @@ void RTS::handleData() {
else if (recdat.data[0] == 3) { // Page Up
if (fileIndex >= DISPLAY_FILES) {
fileIndex = fileIndex - DISPLAY_FILES;
// if(filenavigator.folderdepth!=0 && fileIndex!=0) //Shift to acknowledge Return DIR button on first page
// if (filenavigator.folderdepth!=0 && fileIndex!=0) //Shift to acknowledge Return DIR button on first page
// filenavigator.getFiles(filenavigator.currentindex-DISPLAY_FILES);
// else
filenavigator.getFiles(fileIndex);
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/module/stepper/trinamic.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ void reset_trinamic_drivers();
#define U_ENABLE_READ() stepperU.isEnabled()
#endif
#if AXIS_HAS_DEDGE(U)
#define U_STEP_WRITE(STATE) do{ if(STATE) TOGGLE(U_STEP_PIN); }while(0)
#define U_STEP_WRITE(STATE) do{ if (STATE) TOGGLE(U_STEP_PIN); }while(0)
#endif
#endif

Expand All @@ -308,7 +308,7 @@ void reset_trinamic_drivers();
#define V_ENABLE_READ() stepperV.isEnabled()
#endif
#if AXIS_HAS_DEDGE(V)
#define V_STEP_WRITE(STATE) do{ if(STATE) TOGGLE(V_STEP_PIN); }while(0)
#define V_STEP_WRITE(STATE) do{ if (STATE) TOGGLE(V_STEP_PIN); }while(0)
#endif
#endif

Expand All @@ -322,7 +322,7 @@ void reset_trinamic_drivers();
#define W_ENABLE_READ() stepperW.isEnabled()
#endif
#if AXIS_HAS_DEDGE(W)
#define W_STEP_WRITE(STATE) do{ if(STATE) TOGGLE(W_STEP_PIN); }while(0)
#define W_STEP_WRITE(STATE) do{ if (STATE) TOGGLE(W_STEP_PIN); }while(0)
#endif
#endif

Expand Down

1 comment on commit f281fb4

@rondlh
Copy link
Contributor

@rondlh rondlh commented on f281fb4 Jun 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of hits if you search for "if("

Please sign in to comment.