Browse Source

Clean up "else" and other spacing

Scott Lahteine 8 years ago
parent
commit
9bdab4f3a8

+ 2
- 1
Marlin/MarlinSerial.cpp View File

@@ -78,7 +78,8 @@ void MarlinSerial::begin(long baud) {
78 78
   if (useU2X) {
79 79
     M_UCSRxA = BIT(M_U2Xx);
80 80
     baud_setting = (F_CPU / 4 / baud - 1) / 2;
81
-  } else {
81
+  }
82
+  else {
82 83
     M_UCSRxA = 0;
83 84
     baud_setting = (F_CPU / 8 / baud - 1) / 2;
84 85
   }

+ 16
- 8
Marlin/Marlin_main.cpp View File

@@ -1688,7 +1688,8 @@ static void setup_for_endstop_move() {
1688 1688
       if (a < b) {
1689 1689
         if (b < c) median = b;
1690 1690
         if (c < a) median = a;
1691
-      } else {  // b <= a
1691
+      }
1692
+      else {  // b <= a
1692 1693
         if (c < b) median = b;
1693 1694
         if (a < c) median = a;
1694 1695
       }
@@ -1783,7 +1784,8 @@ static void setup_for_endstop_move() {
1783 1784
       #endif
1784 1785
       do_blocking_move_to_x(X_MAX_POS + SLED_DOCKING_OFFSET + offset - 1);  // Dock sled a bit closer to ensure proper capturing
1785 1786
       digitalWrite(SLED_PIN, LOW); // turn off magnet
1786
-    } else {
1787
+    }
1788
+    else {
1787 1789
       float z_loc = current_position[Z_AXIS];
1788 1790
       if (z_loc < Z_RAISE_BEFORE_PROBING + 5) z_loc = Z_RAISE_BEFORE_PROBING;
1789 1791
       do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset, current_position[Y_AXIS], z_loc); // this also updates current_position
@@ -2696,7 +2698,8 @@ inline void gcode_G28() {
2696 2698
             SERIAL_PROTOCOLPGM("X out of range (1-" STRINGIFY(MESH_NUM_X_POINTS) ").\n");
2697 2699
             return;
2698 2700
           }
2699
-        } else {
2701
+        }
2702
+        else {
2700 2703
           SERIAL_PROTOCOLPGM("X not entered.\n");
2701 2704
           return;
2702 2705
         }
@@ -2706,7 +2709,8 @@ inline void gcode_G28() {
2706 2709
             SERIAL_PROTOCOLPGM("Y out of range (1-" STRINGIFY(MESH_NUM_Y_POINTS) ").\n");
2707 2710
             return;
2708 2711
           }
2709
-        } else {
2712
+        }
2713
+        else {
2710 2714
           SERIAL_PROTOCOLPGM("Y not entered.\n");
2711 2715
           return;
2712 2716
         }
@@ -6381,25 +6385,29 @@ void mesh_plan_buffer_line(float x, float y, float z, const float e, float feed_
6381 6385
     ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
6382 6386
     ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
6383 6387
     x_splits ^= BIT(ix);
6384
-  } else if (ix < pix && (x_splits) & BIT(pix)) {
6388
+  }
6389
+  else if (ix < pix && (x_splits) & BIT(pix)) {
6385 6390
     nx = mbl.get_x(pix);
6386 6391
     normalized_dist = (nx - current_position[X_AXIS]) / (x - current_position[X_AXIS]);
6387 6392
     ny = current_position[Y_AXIS] + (y - current_position[Y_AXIS]) * normalized_dist;
6388 6393
     ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
6389 6394
     x_splits ^= BIT(pix);
6390
-  } else if (iy > piy && (y_splits) & BIT(iy)) {
6395
+  }
6396
+  else if (iy > piy && (y_splits) & BIT(iy)) {
6391 6397
     ny = mbl.get_y(iy);
6392 6398
     normalized_dist = (ny - current_position[Y_AXIS]) / (y - current_position[Y_AXIS]);
6393 6399
     nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
6394 6400
     ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
6395 6401
     y_splits ^= BIT(iy);
6396
-  } else if (iy < piy && (y_splits) & BIT(piy)) {
6402
+  }
6403
+  else if (iy < piy && (y_splits) & BIT(piy)) {
6397 6404
     ny = mbl.get_y(piy);
6398 6405
     normalized_dist = (ny - current_position[Y_AXIS]) / (y - current_position[Y_AXIS]);
6399 6406
     nx = current_position[X_AXIS] + (x - current_position[X_AXIS]) * normalized_dist;
6400 6407
     ne = current_position[E_AXIS] + (e - current_position[E_AXIS]) * normalized_dist;
6401 6408
     y_splits ^= BIT(piy);
6402
-  } else {
6409
+  }
6410
+  else {
6403 6411
     // Already split on a border
6404 6412
     plan_buffer_line(x, y, z, e, feed_rate, extruder);
6405 6413
     set_current_to_destination();

+ 4
- 2
Marlin/Sd2Card.cpp View File

@@ -192,11 +192,13 @@ uint32_t Sd2Card::cardSize() {
192 192
     uint8_t c_size_mult = (csd.v1.c_size_mult_high << 1)
193 193
                           | csd.v1.c_size_mult_low;
194 194
     return (uint32_t)(c_size + 1) << (c_size_mult + read_bl_len - 7);
195
-  } else if (csd.v2.csd_ver == 1) {
195
+  }
196
+  else if (csd.v2.csd_ver == 1) {
196 197
     uint32_t c_size = ((uint32_t)csd.v2.c_size_high << 16)
197 198
                       | (csd.v2.c_size_mid << 8) | csd.v2.c_size_low;
198 199
     return (c_size + 1) << 10;
199
-  } else {
200
+  }
201
+  else {
200 202
     error(SD_CARD_ERROR_BAD_CSD);
201 203
     return 0;
202 204
   }

+ 12
- 6
Marlin/Sd2PinMap.h View File

@@ -396,7 +396,8 @@ static inline __attribute__((always_inline))
396 396
   bool getPinMode(uint8_t pin) {
397 397
   if (__builtin_constant_p(pin) && pin < digitalPinCount) {
398 398
     return (*digitalPinMap[pin].ddr >> digitalPinMap[pin].bit) & 1;
399
-  } else {
399
+  }
400
+  else {
400 401
     return badPinNumber();
401 402
   }
402 403
 }
@@ -405,10 +406,12 @@ static inline __attribute__((always_inline))
405 406
   if (__builtin_constant_p(pin) && pin < digitalPinCount) {
406 407
     if (mode) {
407 408
       *digitalPinMap[pin].ddr |= BIT(digitalPinMap[pin].bit);
408
-    } else {
409
+    }
410
+    else {
409 411
       *digitalPinMap[pin].ddr &= ~BIT(digitalPinMap[pin].bit);
410 412
     }
411
-  } else {
413
+  }
414
+  else {
412 415
     badPinNumber();
413 416
   }
414 417
 }
@@ -416,7 +419,8 @@ static inline __attribute__((always_inline))
416 419
   bool fastDigitalRead(uint8_t pin) {
417 420
   if (__builtin_constant_p(pin) && pin < digitalPinCount) {
418 421
     return (*digitalPinMap[pin].pin >> digitalPinMap[pin].bit) & 1;
419
-  } else {
422
+  }
423
+  else {
420 424
     return badPinNumber();
421 425
   }
422 426
 }
@@ -425,10 +429,12 @@ static inline __attribute__((always_inline))
425 429
   if (__builtin_constant_p(pin) && pin < digitalPinCount) {
426 430
     if (value) {
427 431
       *digitalPinMap[pin].port |= BIT(digitalPinMap[pin].bit);
428
-    } else {
432
+    }
433
+    else {
429 434
       *digitalPinMap[pin].port &= ~BIT(digitalPinMap[pin].bit);
430 435
     }
431
-  } else {
436
+  }
437
+  else {
432 438
     badPinNumber();
433 439
   }
434 440
 }

+ 2
- 0
Marlin/dogm_lcd_implementation.h View File

@@ -206,9 +206,11 @@ static void lcd_implementation_init() {
206 206
     pinMode(LCD_PIN_RESET, OUTPUT);
207 207
     digitalWrite(LCD_PIN_RESET, HIGH);
208 208
   #endif
209
+
209 210
   #if DISABLED(MINIPANEL) // setContrast not working for Mini Panel
210 211
     u8g.setContrast(lcd_contrast);
211 212
   #endif
213
+
212 214
   // FIXME: remove this workaround
213 215
   // Uncomment this if you have the first generation (V1.10) of STBs board
214 216
   // pinMode(17, OUTPUT); // Enable LCD backlight

+ 6
- 6
Marlin/fastio.h View File

@@ -30,15 +30,15 @@
30 30
 
31 31
 #define _WRITE_C(IO, v)   do { if (v) { \
32 32
                                          CRITICAL_SECTION_START; \
33
-                                         {DIO ##  IO ## _WPORT |= MASK(DIO ## IO ## _PIN); }\
33
+                                         {DIO ##  IO ## _WPORT |= MASK(DIO ## IO ## _PIN); } \
34 34
                                          CRITICAL_SECTION_END; \
35
-                                       }\
36
-                                       else {\
35
+                                       } \
36
+                                       else { \
37 37
                                          CRITICAL_SECTION_START; \
38
-                                         {DIO ##  IO ## _WPORT &= ~MASK(DIO ## IO ## _PIN); }\
38
+                                         {DIO ##  IO ## _WPORT &= ~MASK(DIO ## IO ## _PIN); } \
39 39
                                          CRITICAL_SECTION_END; \
40
-                                       }\
41
-                                     }\
40
+                                       } \
41
+                                     } \
42 42
                                      while (0)
43 43
 
44 44
 #define _WRITE(IO, v)  do {  if (&(DIO ##  IO ## _RPORT) >= (uint8_t *)0x100) {_WRITE_C(IO, v); } else {_WRITE_NC(IO, v); }; } while (0)

+ 4
- 2
Marlin/planner.cpp View File

@@ -439,10 +439,12 @@ void check_axes_activity() {
439 439
           // Just starting up fan - run at full power.
440 440
           fan_kick_end = ms + FAN_KICKSTART_TIME;
441 441
           tail_fan_speed = 255;
442
-        } else if (fan_kick_end > ms)
442
+        }
443
+        else if (fan_kick_end > ms)
443 444
           // Fan still spinning up.
444 445
           tail_fan_speed = 255;
445
-        } else {
446
+        }
447
+        else {
446 448
           fan_kick_end = 0;
447 449
         }
448 450
     #endif //FAN_KICKSTART_TIME

+ 6
- 3
Marlin/qr_solve.cpp View File

@@ -494,7 +494,8 @@ double dnrm2(int n, double x[], int incx)
494 494
         if (scale < absxi) {
495 495
           ssq = 1.0 + ssq * (scale / absxi) * (scale / absxi);
496 496
           scale = absxi;
497
-        } else
497
+        }
498
+        else
498 499
           ssq = ssq + (absxi / scale) * (absxi / scale);
499 500
       }
500 501
       ix += incx;
@@ -1404,7 +1405,8 @@ void dscal(int n, double sa, double x[], int incx)
1404 1405
       x[i + 3] = sa * x[i + 3];
1405 1406
       x[i + 4] = sa * x[i + 4];
1406 1407
     }
1407
-  } else {
1408
+  }
1409
+  else {
1408 1410
     if (0 <= incx)
1409 1411
       ix = 0;
1410 1412
     else
@@ -1486,7 +1488,6 @@ void dswap(int n, double x[], int incx, double y[], int incy)
1486 1488
       x[i + 2] = y[i + 2];
1487 1489
       y[i + 2] = temp;
1488 1490
     }
1489
-  } else {
1490 1491
     if (0 <= incx)
1491 1492
       ix = 0;
1492 1493
     else
@@ -1495,6 +1496,8 @@ void dswap(int n, double x[], int incx, double y[], int incy)
1495 1496
       iy = 0;
1496 1497
     else
1497 1498
       iy = (- n + 1) * incy;
1499
+  }
1500
+  else {
1498 1501
     for (i = 0; i < n; i++) {
1499 1502
       temp = x[ix];
1500 1503
       x[ix] = y[iy];

+ 4
- 2
Marlin/stepper.cpp View File

@@ -139,11 +139,13 @@ volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 };
139 139
       if (Z_HOME_DIR > 0) {\
140 140
         if (!(TEST(old_endstop_bits, Z_MAX) && (count_direction[Z_AXIS] > 0)) && !locked_z_motor) Z_STEP_WRITE(v); \
141 141
         if (!(TEST(old_endstop_bits, Z2_MAX) && (count_direction[Z_AXIS] > 0)) && !locked_z2_motor) Z2_STEP_WRITE(v); \
142
-      } else {\
142
+      } \
143
+      else { \
143 144
         if (!(TEST(old_endstop_bits, Z_MIN) && (count_direction[Z_AXIS] < 0)) && !locked_z_motor) Z_STEP_WRITE(v); \
144 145
         if (!(TEST(old_endstop_bits, Z2_MIN) && (count_direction[Z_AXIS] < 0)) && !locked_z2_motor) Z2_STEP_WRITE(v); \
145 146
       } \
146
-    } else { \
147
+    } \
148
+    else { \
147 149
       Z_STEP_WRITE(v); \
148 150
       Z2_STEP_WRITE(v); \
149 151
     }

+ 2
- 1
Marlin/temperature.cpp View File

@@ -511,7 +511,8 @@ float get_pid_output(int e) {
511 511
             if (e_position > last_position[e]) {
512 512
               lpq[lpq_ptr++] = e_position - last_position[e];
513 513
               last_position[e] = e_position;
514
-            } else {
514
+            }
515
+            else {
515 516
               lpq[lpq_ptr++] = 0;
516 517
             }
517 518
             if (lpq_ptr >= lpq_len) lpq_ptr = 0;

+ 2
- 2
Marlin/ultralcd_implementation_hitachi_HD44780.h View File

@@ -716,8 +716,8 @@ static void lcd_implementation_status_screen() {
716 716
       lcd.print(ftostr12ns(filament_width_meas));
717 717
       lcd_printPGM(PSTR(" V"));
718 718
       lcd.print(itostr3(100.0 * volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
719
-  	  lcd.print('%');
720
-  	  return;
719
+      lcd.print('%');
720
+      return;
721 721
     }
722 722
 
723 723
   #endif // FILAMENT_LCD_DISPLAY

+ 55
- 35
Marlin/utf_mapper.h View File

@@ -123,10 +123,12 @@
123 123
 #endif // SIMULATE_ROMFONT
124 124
 
125 125
 #if ENABLED(MAPPER_NON)
126
-  char charset_mapper(char c){
126
+
127
+  char charset_mapper(char c) {
127 128
     HARDWARE_CHAR_OUT( c );
128 129
     return 1;
129 130
   }
131
+
130 132
 #elif ENABLED(MAPPER_C2C3)
131 133
   uint8_t utf_hi_char; // UTF-8 high part
132 134
   bool seen_c2 = false;
@@ -138,16 +140,16 @@
138 140
         seen_c2 = true;
139 141
         return 0;
140 142
       }
141
-      else if (seen_c2){
143
+      else if (seen_c2) {
142 144
         d &= 0x3f;
143 145
         #ifndef MAPPER_ONE_TO_ONE
144
-          HARDWARE_CHAR_OUT( (char) pgm_read_byte_near( utf_recode + d + ( utf_hi_char << 6 ) - 0x20 ) );
146
+          HARDWARE_CHAR_OUT((char)pgm_read_byte_near(utf_recode + d + (utf_hi_char << 6) - 0x20));
145 147
         #else
146
-          HARDWARE_CHAR_OUT( (char) (0x80 + ( utf_hi_char << 6 ) + d) ) ;
148
+          HARDWARE_CHAR_OUT((char)(0x80 + (utf_hi_char << 6) + d)) ;
147 149
         #endif
148 150
       }
149 151
       else {
150
-          HARDWARE_CHAR_OUT('?');
152
+        HARDWARE_CHAR_OUT('?');
151 153
       }
152 154
     }
153 155
     else {
@@ -156,96 +158,114 @@
156 158
     seen_c2 = false;
157 159
     return 1;
158 160
   }
161
+
159 162
 #elif ENABLED(MAPPER_D0D1_MOD)
160 163
   uint8_t utf_hi_char; // UTF-8 high part
161 164
   bool seen_d5 = false;
162
-  char charset_mapper(char c){
165
+
166
+  char charset_mapper(char c) {
163 167
     // it is a Russian alphabet translation
164 168
     // except 0401 --> 0xa2 = Ё, 0451 --> 0xb5 = ё
165 169
     uint8_t d = c;
166
-    if ( d >= 0x80 ) { // UTF-8 handling
167
-      if ((d >= 0xd0) && (!seen_d5)) {
170
+    if (d >= 0x80) { // UTF-8 handling
171
+      if (d >= 0xd0 && !seen_d5) {
168 172
         utf_hi_char = d - 0xd0;
169 173
         seen_d5 = true;
170 174
         return 0;
171
-      } else if (seen_d5) {
172
-          d &= 0x3f;
173
-          if ( !utf_hi_char && ( d == 1 )) {
174
-            HARDWARE_CHAR_OUT((char) 0xa2 ); // Ё
175
-        } else if ((utf_hi_char == 1) && (d == 0x11)) {
176
-            HARDWARE_CHAR_OUT((char) 0xb5 ); // ё
177
-          } else {
178
-            HARDWARE_CHAR_OUT((char) pgm_read_byte_near( utf_recode + d + ( utf_hi_char << 6 ) - 0x10 ) );
179
-          }
175
+      }
176
+      else if (seen_d5) {
177
+        d &= 0x3f;
178
+        if (!utf_hi_char && d == 1) {
179
+          HARDWARE_CHAR_OUT((char) 0xa2); // Ё
180
+        }
181
+        else if (utf_hi_char == 1 && d == 0x11) {
182
+          HARDWARE_CHAR_OUT((char)0xb5); // ё
180 183
         }
181 184
         else {
182
-          HARDWARE_CHAR_OUT('?');
185
+          HARDWARE_CHAR_OUT((char)pgm_read_byte_near(utf_recode + d + (utf_hi_char << 6) - 0x10));
183 186
         }
184
-    } else {
187
+      }
188
+      else {
189
+        HARDWARE_CHAR_OUT('?');
190
+      }
191
+    }
192
+    else {
185 193
       HARDWARE_CHAR_OUT((char) c );
186 194
     }
187 195
     seen_d5 = false;
188 196
     return 1;
189 197
   }
198
+
190 199
 #elif ENABLED(MAPPER_D0D1)
191 200
   uint8_t utf_hi_char; // UTF-8 high part
192 201
   bool seen_d5 = false;
193 202
   char charset_mapper(char c) {
194 203
     uint8_t d = c;
195
-    if ( d >= 0x80u ) { // UTF-8 handling
196
-      if ((d >= 0xd0u) && (!seen_d5)) {
204
+    if (d >= 0x80u) { // UTF-8 handling
205
+      if (d >= 0xd0u && !seen_d5) {
197 206
         utf_hi_char = d - 0xd0u;
198 207
         seen_d5 = true;
199 208
         return 0;
200
-      } else if (seen_d5) {
201
-          d &= 0x3fu;
209
+      }
210
+      else if (seen_d5) {
211
+        d &= 0x3fu;
202 212
         #ifndef MAPPER_ONE_TO_ONE
203
-          HARDWARE_CHAR_OUT( (char) pgm_read_byte_near( utf_recode + d + ( utf_hi_char << 6 ) - 0x20 ) );
213
+          HARDWARE_CHAR_OUT((char)pgm_read_byte_near(utf_recode + d + (utf_hi_char << 6) - 0x20));
204 214
         #else
205
-          HARDWARE_CHAR_OUT( (char) (0xa0u + ( utf_hi_char << 6 ) + d ) ) ;
215
+          HARDWARE_CHAR_OUT((char)(0xa0u + (utf_hi_char << 6) + d)) ;
206 216
         #endif
207
-      } else {
217
+      }
218
+      else {
208 219
         HARDWARE_CHAR_OUT('?');
209 220
       }
210
-    } else {
221
+    }
222
+    else {
211 223
       HARDWARE_CHAR_OUT((char) c );
212 224
     }
213 225
     seen_d5 = false;
214 226
     return 1;
215 227
   }
228
+
216 229
 #elif ENABLED(MAPPER_E382E383)
217 230
   uint8_t utf_hi_char; // UTF-8 high part
218 231
   bool seen_e3 = false;
219 232
   bool seen_82_83 = false;
220 233
   char charset_mapper(char c){
221 234
     uint8_t d = c;
222
-    if ( d >= 0x80 ) { // UTF-8 handling
223
-      if ( (d == 0xe3) && (seen_e3 == false)) {
235
+    if (d >= 0x80) { // UTF-8 handling
236
+      if (d == 0xe3 && !seen_e3) {
224 237
         seen_e3 = true;
225 238
         return 0;      // eat 0xe3
226
-      } else if ( (d >= 0x82) && (seen_e3 == true) && (seen_82_83 == false)) {
239
+      }
240
+      else if (d >= 0x82 && seen_e3 && !seen_82_83) {
227 241
         utf_hi_char = d - 0x82;
228 242
         seen_82_83 = true;
229 243
         return 0;
230
-      } else if ((seen_e3 == true) && (seen_82_83 == true)){
244
+      }
245
+      else if (seen_e3 && seen_82_83) {
231 246
         d &= 0x3f;
232 247
         #ifndef MAPPER_ONE_TO_ONE
233
-          HARDWARE_CHAR_OUT( (char) pgm_read_byte_near( utf_recode + d + ( utf_hi_char << 6 ) - 0x20 ) );
248
+          HARDWARE_CHAR_OUT((char)pgm_read_byte_near(utf_recode + d + (utf_hi_char << 6) - 0x20));
234 249
         #else
235
-          HARDWARE_CHAR_OUT( (char) (0x80 + ( utf_hi_char << 6 ) + d ) ) ;
250
+          HARDWARE_CHAR_OUT((char)(0x80 + (utf_hi_char << 6) + d)) ;
236 251
         #endif
237
-      } else {
252
+      }
253
+      else {
238 254
         HARDWARE_CHAR_OUT((char) '?' );
239 255
       }
240
-    } else {
256
+    }
257
+    else {
241 258
       HARDWARE_CHAR_OUT((char) c );
242 259
     }
243 260
     seen_e3 = false;
244 261
     seen_82_83 = false;
245 262
     return 1;
246 263
   }
264
+
247 265
 #else
266
+
248 267
   #error "You have to define one of the DISPLAY_INPUT_CODE_MAPPERs in your language_xx.h file" // should not occur because (en) will set.
268
+
249 269
 #endif // code mappers
250 270
 
251 271
 #endif // UTF_MAPPER_H

Loading…
Cancel
Save