Browse Source

🎨 Misc. 'else' cleanup

Scott Lahteine 2 years ago
parent
commit
7e5d5330d6

+ 2
- 2
Marlin/src/HAL/STM32/tft/tft_ltdc.cpp View File

@@ -372,9 +372,9 @@ void TFT_LTDC::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Cou
372 372
     if (MemoryIncrease == DMA_PINC_ENABLE) {
373 373
       DrawImage(x_min, y_cur, x_min + width, y_cur + height, Data);
374 374
       Data += width * height;
375
-    } else {
376
-      DrawRect(x_min, y_cur, x_min + width, y_cur + height, *Data);
377 375
     }
376
+    else
377
+      DrawRect(x_min, y_cur, x_min + width, y_cur + height, *Data);
378 378
     y_cur += height;
379 379
   }
380 380
 

+ 10
- 9
Marlin/src/feature/direct_stepping.cpp View File

@@ -143,14 +143,16 @@ namespace DirectStepping {
143 143
           // special case for 8-bit, check if rolled back to 0
144 144
           if (Cfg::DIRECTIONAL || !write_page_size) { // full 256 bytes
145 145
             if (write_byte_idx) return true;
146
-          } else {
147
-            if (write_byte_idx < write_page_size) return true;
148 146
           }
149
-        } else if (Cfg::DIRECTIONAL) {
150
-          if (write_byte_idx != Cfg::PAGE_SIZE) return true;
151
-        } else {
152
-          if (write_byte_idx < write_page_size) return true;
147
+          else if (write_byte_idx < write_page_size)
148
+            return true;
149
+        }
150
+        else if (Cfg::DIRECTIONAL) {
151
+          if (write_byte_idx != Cfg::PAGE_SIZE)
152
+            return true;
153 153
         }
154
+        else if (write_byte_idx < write_page_size)
155
+          return true;
154 156
 
155 157
         state = State::CHECKSUM;
156 158
         return true;
@@ -161,11 +163,10 @@ namespace DirectStepping {
161 163
         return true;
162 164
       }
163 165
       case State::UNFAIL:
164
-        if (c == 0) {
166
+        if (c == 0)
165 167
           set_page_state(write_page_idx, PageState::FREE);
166
-        } else {
168
+        else
167 169
           fatal_error = true;
168
-        }
169 170
         state = State::MONITOR;
170 171
         return true;
171 172
     }

+ 2
- 2
Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/change_filament_screen.cpp View File

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

+ 6
- 5
Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/files_screen.cpp View File

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

+ 28
- 25
Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.cpp View File

@@ -53,42 +53,45 @@ void WifiSerial::init(PinName _rx, PinName _tx) {
53 53
 WifiSerial::WifiSerial(void *peripheral) {
54 54
   // If PIN_SERIALy_RX is not defined assume half-duplex
55 55
   _serial.pin_rx = NC;
56
+  if (false) {
57
+    // for else if / else below...
58
+  }
56 59
   // If Serial is defined in variant set
57 60
   // the Rx/Tx pins for com port if defined
58 61
   #if defined(Serial) && defined(PIN_SERIAL_TX)
59
-    if ((void *)this == (void *)&Serial) {
62
+    else if ((void *)this == (void *)&Serial) {
60 63
       #ifdef PIN_SERIAL_RX
61 64
         setRx(PIN_SERIAL_RX);
62 65
       #endif
63 66
       setTx(PIN_SERIAL_TX);
64
-    } else
67
+    }
65 68
   #endif
66 69
   #if defined(PIN_SERIAL1_TX) && defined(USART1_BASE)
67
-    if (peripheral == USART1) {
70
+    else if (peripheral == USART1) {
68 71
       #ifdef PIN_SERIAL1_RX
69 72
         setRx(PIN_SERIAL1_RX);
70 73
       #endif
71 74
       setTx(PIN_SERIAL1_TX);
72
-    } else
75
+    }
73 76
   #endif
74 77
   #if defined(PIN_SERIAL2_TX) && defined(USART2_BASE)
75
-    if (peripheral == USART2) {
78
+    else if (peripheral == USART2) {
76 79
       #ifdef PIN_SERIAL2_RX
77 80
         setRx(PIN_SERIAL2_RX);
78 81
       #endif
79 82
       setTx(PIN_SERIAL2_TX);
80
-    } else
83
+    }
81 84
   #endif
82 85
   #if defined(PIN_SERIAL3_TX) && defined(USART3_BASE)
83
-    if (peripheral == USART3) {
86
+    else if (peripheral == USART3) {
84 87
       #ifdef PIN_SERIAL3_RX
85 88
         setRx(PIN_SERIAL3_RX);
86 89
       #endif
87 90
       setTx(PIN_SERIAL3_TX);
88
-    } else
91
+    }
89 92
   #endif
90 93
   #ifdef PIN_SERIAL4_TX
91
-    if (false
94
+    else if (false
92 95
       #ifdef USART4_BASE
93 96
         || peripheral == USART4
94 97
       #elif defined(UART4_BASE)
@@ -99,10 +102,10 @@ WifiSerial::WifiSerial(void *peripheral) {
99 102
         setRx(PIN_SERIAL4_RX);
100 103
       #endif
101 104
       setTx(PIN_SERIAL4_TX);
102
-    } else
105
+    }
103 106
   #endif
104 107
   #ifdef PIN_SERIAL5_TX
105
-    if (false
108
+    else if (false
106 109
       #ifdef USART5_BASE
107 110
         || peripheral == USART5
108 111
       #elif defined(UART5_BASE)
@@ -113,18 +116,18 @@ WifiSerial::WifiSerial(void *peripheral) {
113 116
         setRx(PIN_SERIAL5_RX);
114 117
       #endif
115 118
       setTx(PIN_SERIAL5_TX);
116
-    } else
119
+    }
117 120
   #endif
118 121
   #if defined(PIN_SERIAL6_TX) && defined(USART6_BASE)
119
-    if (peripheral == USART6) {
122
+    else if (peripheral == USART6) {
120 123
       #ifdef PIN_SERIAL6_RX
121 124
         setRx(PIN_SERIAL6_RX);
122 125
       #endif
123 126
         setTx(PIN_SERIAL6_TX);
124
-    } else
127
+    }
125 128
   #endif
126 129
   #ifdef PIN_SERIAL7_TX
127
-    if (false
130
+    else if (false
128 131
       #ifdef USART7_BASE
129 132
         || peripheral == USART7
130 133
       #elif defined(UART7_BASE)
@@ -135,10 +138,10 @@ WifiSerial::WifiSerial(void *peripheral) {
135 138
         setRx(PIN_SERIAL7_RX);
136 139
       #endif
137 140
       setTx(PIN_SERIAL7_TX);
138
-    } else
141
+    }
139 142
   #endif
140 143
   #ifdef PIN_SERIAL8_TX
141
-    if (false
144
+    else if (false
142 145
       #ifdef USART8_BASE
143 146
         || peripheral == USART8
144 147
       #elif defined(UART8_BASE)
@@ -149,18 +152,18 @@ WifiSerial::WifiSerial(void *peripheral) {
149 152
         setRx(PIN_SERIAL8_RX);
150 153
       #endif
151 154
       setTx(PIN_SERIAL8_TX);
152
-    } else
155
+    }
153 156
   #endif
154 157
   #if defined(PIN_SERIAL9_TX) && defined(UART9_BASE)
155
-    if (peripheral == UART9) {
158
+    else if (peripheral == UART9) {
156 159
       #ifdef PIN_SERIAL9_RX
157 160
         setRx(PIN_SERIAL9_RX);
158 161
       #endif
159 162
       setTx(PIN_SERIAL9_TX);
160
-    } else
163
+    }
161 164
   #endif
162 165
   #ifdef PIN_SERIAL10_TX
163
-    if (false
166
+    else if (false
164 167
       #ifdef USART10_BASE
165 168
         || peripheral == USART10
166 169
       #elif defined(UART10_BASE)
@@ -171,18 +174,18 @@ WifiSerial::WifiSerial(void *peripheral) {
171 174
         setRx(PIN_SERIAL10_RX);
172 175
       #endif
173 176
       setTx(PIN_SERIAL10_TX);
174
-    } else
177
+    }
175 178
   #endif
176 179
   #if defined(PIN_SERIALLP1_TX) && defined(LPUART1_BASE)
177
-    if (peripheral == LPUART1) {
180
+    else if (peripheral == LPUART1) {
178 181
       #ifdef PIN_SERIALLP1_RX
179 182
         setRx(PIN_SERIALLP1_RX);
180 183
       #endif
181 184
       setTx(PIN_SERIALLP1_TX);
182
-    } else
185
+    }
183 186
   #endif
184 187
   // else get the pins of the first peripheral occurrence in PinMap
185
-  {
188
+  else {
186 189
     _serial.pin_rx = pinmap_pin(peripheral, PinMap_UART_RX);
187 190
     _serial.pin_tx = pinmap_pin(peripheral, PinMap_UART_TX);
188 191
   }

Loading…
Cancel
Save