1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-26 21:36:21 +00:00

🎨 Minor code cleanup

This commit is contained in:
Scott Lahteine 2023-06-25 01:31:07 -05:00
parent a256e47b9c
commit f281fb473d
5 changed files with 27 additions and 40 deletions

View File

@ -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();

View File

@ -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) {
if (mydata.repeat_tag == 0)
cmd.colors(normal_btn).enabled(false);
} else {
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);
@ -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;
@ -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
@ -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

View File

@ -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;
}
@ -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();
}
}

View File

@ -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;
@ -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);
@ -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);

View File

@ -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
@ -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
@ -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