Browse Source

🎨 Misc. 'else' cleanup

FB4S_WIFI
Scott Lahteine 2 years ago
parent
commit
9534c6e903
  1. 4
      Marlin/src/HAL/STM32/tft/tft_ltdc.cpp
  2. 19
      Marlin/src/feature/direct_stepping.cpp
  3. 4
      Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/change_filament_screen.cpp
  4. 11
      Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/files_screen.cpp
  5. 53
      Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.cpp

4
Marlin/src/HAL/STM32/tft/tft_ltdc.cpp

@ -372,9 +372,9 @@ void TFT_LTDC::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Cou
if (MemoryIncrease == DMA_PINC_ENABLE) {
DrawImage(x_min, y_cur, x_min + width, y_cur + height, Data);
Data += width * height;
} else {
DrawRect(x_min, y_cur, x_min + width, y_cur + height, *Data);
}
else
DrawRect(x_min, y_cur, x_min + width, y_cur + height, *Data);
y_cur += height;
}

19
Marlin/src/feature/direct_stepping.cpp

@ -143,14 +143,16 @@ namespace DirectStepping {
// special case for 8-bit, check if rolled back to 0
if (Cfg::DIRECTIONAL || !write_page_size) { // full 256 bytes
if (write_byte_idx) return true;
} else {
if (write_byte_idx < write_page_size) return true;
}
} else if (Cfg::DIRECTIONAL) {
if (write_byte_idx != Cfg::PAGE_SIZE) return true;
} else {
if (write_byte_idx < write_page_size) return true;
else if (write_byte_idx < write_page_size)
return true;
}
else if (Cfg::DIRECTIONAL) {
if (write_byte_idx != Cfg::PAGE_SIZE)
return true;
}
else if (write_byte_idx < write_page_size)
return true;
state = State::CHECKSUM;
return true;
@ -161,11 +163,10 @@ namespace DirectStepping {
return true;
}
case State::UNFAIL:
if (c == 0) {
if (c == 0)
set_page_state(write_page_idx, PageState::FREE);
} else {
else
fatal_error = true;
}
state = State::MONITOR;
return true;
}

4
Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/change_filament_screen.cpp

@ -171,9 +171,9 @@ void ChangeFilamentScreen::onRedraw(draw_mode_t what) {
const bool t_ok = getActualTemp_celsius(e) > getSoftenTemp() - 10;
if (mydata.t_tag && !t_ok) {
if (mydata.t_tag && !t_ok)
cmd.text(HEATING_LBL_POS, GET_TEXT_F(MSG_HEATING));
} else if (getActualTemp_celsius(e) > 100) {
else if (getActualTemp_celsius(e) > 100) {
cmd.cmd(COLOR_RGB(0xFF0000))
.text(CAUTION_LBL_POS, GET_TEXT_F(MSG_CAUTION))
.colors(normal_btn)

11
Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/files_screen.cpp

@ -111,16 +111,17 @@ void FilesScreen::drawFileButton(int x, int y, int w, int h, const char *filenam
cmd.cmd(COLOR_RGB(is_highlighted ? fg_action : bg_color));
cmd.font(font_medium).rectangle(bx, by, bw, bh);
cmd.cmd(COLOR_RGB(is_highlighted ? normal_btn.rgb : bg_text_enabled));
#if ENABLED(SCROLL_LONG_FILENAMES)
if (is_highlighted) {
if (TERN0(SCROLL_LONG_FILENAMES, is_highlighted)) {
#if ENABLED(SCROLL_LONG_FILENAMES)
cmd.cmd(SAVE_CONTEXT());
cmd.cmd(SCISSOR_XY(x,y));
cmd.cmd(SCISSOR_SIZE(w,h));
cmd.cmd(MACRO(0));
cmd.text(bx, by, bw, bh, filename, OPT_CENTERY | OPT_NOFIT);
} else
#endif
draw_text_with_ellipsis(cmd, bx,by, bw - (is_dir ? 20 : 0), bh, filename, OPT_CENTERY, font_medium);
#endif
}
else
draw_text_with_ellipsis(cmd, bx,by, bw - (is_dir ? 20 : 0), bh, filename, OPT_CENTERY, font_medium);
if (is_dir && !is_highlighted) cmd.text(bx, by, bw, bh, F("> "), OPT_CENTERY | OPT_RIGHTX);
#if ENABLED(SCROLL_LONG_FILENAMES)
if (is_highlighted) cmd.cmd(RESTORE_CONTEXT());

53
Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.cpp

@ -53,42 +53,45 @@ void WifiSerial::init(PinName _rx, PinName _tx) {
WifiSerial::WifiSerial(void *peripheral) {
// If PIN_SERIALy_RX is not defined assume half-duplex
_serial.pin_rx = NC;
if (false) {
// for else if / else below...
}
// If Serial is defined in variant set
// the Rx/Tx pins for com port if defined
#if defined(Serial) && defined(PIN_SERIAL_TX)
if ((void *)this == (void *)&Serial) {
else if ((void *)this == (void *)&Serial) {
#ifdef PIN_SERIAL_RX
setRx(PIN_SERIAL_RX);
#endif
setTx(PIN_SERIAL_TX);
} else
}
#endif
#if defined(PIN_SERIAL1_TX) && defined(USART1_BASE)
if (peripheral == USART1) {
else if (peripheral == USART1) {
#ifdef PIN_SERIAL1_RX
setRx(PIN_SERIAL1_RX);
#endif
setTx(PIN_SERIAL1_TX);
} else
}
#endif
#if defined(PIN_SERIAL2_TX) && defined(USART2_BASE)
if (peripheral == USART2) {
else if (peripheral == USART2) {
#ifdef PIN_SERIAL2_RX
setRx(PIN_SERIAL2_RX);
#endif
setTx(PIN_SERIAL2_TX);
} else
}
#endif
#if defined(PIN_SERIAL3_TX) && defined(USART3_BASE)
if (peripheral == USART3) {
else if (peripheral == USART3) {
#ifdef PIN_SERIAL3_RX
setRx(PIN_SERIAL3_RX);
#endif
setTx(PIN_SERIAL3_TX);
} else
}
#endif
#ifdef PIN_SERIAL4_TX
if (false
else if (false
#ifdef USART4_BASE
|| peripheral == USART4
#elif defined(UART4_BASE)
@ -99,10 +102,10 @@ WifiSerial::WifiSerial(void *peripheral) {
setRx(PIN_SERIAL4_RX);
#endif
setTx(PIN_SERIAL4_TX);
} else
}
#endif
#ifdef PIN_SERIAL5_TX
if (false
else if (false
#ifdef USART5_BASE
|| peripheral == USART5
#elif defined(UART5_BASE)
@ -113,18 +116,18 @@ WifiSerial::WifiSerial(void *peripheral) {
setRx(PIN_SERIAL5_RX);
#endif
setTx(PIN_SERIAL5_TX);
} else
}
#endif
#if defined(PIN_SERIAL6_TX) && defined(USART6_BASE)
if (peripheral == USART6) {
else if (peripheral == USART6) {
#ifdef PIN_SERIAL6_RX
setRx(PIN_SERIAL6_RX);
#endif
setTx(PIN_SERIAL6_TX);
} else
}
#endif
#ifdef PIN_SERIAL7_TX
if (false
else if (false
#ifdef USART7_BASE
|| peripheral == USART7
#elif defined(UART7_BASE)
@ -135,10 +138,10 @@ WifiSerial::WifiSerial(void *peripheral) {
setRx(PIN_SERIAL7_RX);
#endif
setTx(PIN_SERIAL7_TX);
} else
}
#endif
#ifdef PIN_SERIAL8_TX
if (false
else if (false
#ifdef USART8_BASE
|| peripheral == USART8
#elif defined(UART8_BASE)
@ -149,18 +152,18 @@ WifiSerial::WifiSerial(void *peripheral) {
setRx(PIN_SERIAL8_RX);
#endif
setTx(PIN_SERIAL8_TX);
} else
}
#endif
#if defined(PIN_SERIAL9_TX) && defined(UART9_BASE)
if (peripheral == UART9) {
else if (peripheral == UART9) {
#ifdef PIN_SERIAL9_RX
setRx(PIN_SERIAL9_RX);
#endif
setTx(PIN_SERIAL9_TX);
} else
}
#endif
#ifdef PIN_SERIAL10_TX
if (false
else if (false
#ifdef USART10_BASE
|| peripheral == USART10
#elif defined(UART10_BASE)
@ -171,18 +174,18 @@ WifiSerial::WifiSerial(void *peripheral) {
setRx(PIN_SERIAL10_RX);
#endif
setTx(PIN_SERIAL10_TX);
} else
}
#endif
#if defined(PIN_SERIALLP1_TX) && defined(LPUART1_BASE)
if (peripheral == LPUART1) {
else if (peripheral == LPUART1) {
#ifdef PIN_SERIALLP1_RX
setRx(PIN_SERIALLP1_RX);
#endif
setTx(PIN_SERIALLP1_TX);
} else
}
#endif
// else get the pins of the first peripheral occurrence in PinMap
{
else {
_serial.pin_rx = pinmap_pin(peripheral, PinMap_UART_RX);
_serial.pin_tx = pinmap_pin(peripheral, PinMap_UART_TX);
}

Loading…
Cancel
Save