Browse Source

Clean up "else" and other spacing

Scott Lahteine 10 years ago
parent
commit
9bdab4f3a8

+ 2
- 1
Marlin/MarlinSerial.cpp View File

78
   if (useU2X) {
78
   if (useU2X) {
79
     M_UCSRxA = BIT(M_U2Xx);
79
     M_UCSRxA = BIT(M_U2Xx);
80
     baud_setting = (F_CPU / 4 / baud - 1) / 2;
80
     baud_setting = (F_CPU / 4 / baud - 1) / 2;
81
-  } else {
81
+  }
82
+  else {
82
     M_UCSRxA = 0;
83
     M_UCSRxA = 0;
83
     baud_setting = (F_CPU / 8 / baud - 1) / 2;
84
     baud_setting = (F_CPU / 8 / baud - 1) / 2;
84
   }
85
   }

+ 16
- 8
Marlin/Marlin_main.cpp View File

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

+ 4
- 2
Marlin/Sd2Card.cpp View File

192
     uint8_t c_size_mult = (csd.v1.c_size_mult_high << 1)
192
     uint8_t c_size_mult = (csd.v1.c_size_mult_high << 1)
193
                           | csd.v1.c_size_mult_low;
193
                           | csd.v1.c_size_mult_low;
194
     return (uint32_t)(c_size + 1) << (c_size_mult + read_bl_len - 7);
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
     uint32_t c_size = ((uint32_t)csd.v2.c_size_high << 16)
197
     uint32_t c_size = ((uint32_t)csd.v2.c_size_high << 16)
197
                       | (csd.v2.c_size_mid << 8) | csd.v2.c_size_low;
198
                       | (csd.v2.c_size_mid << 8) | csd.v2.c_size_low;
198
     return (c_size + 1) << 10;
199
     return (c_size + 1) << 10;
199
-  } else {
200
+  }
201
+  else {
200
     error(SD_CARD_ERROR_BAD_CSD);
202
     error(SD_CARD_ERROR_BAD_CSD);
201
     return 0;
203
     return 0;
202
   }
204
   }

+ 12
- 6
Marlin/Sd2PinMap.h View File

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

+ 2
- 0
Marlin/dogm_lcd_implementation.h View File

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

+ 6
- 6
Marlin/fastio.h View File

30
 
30
 
31
 #define _WRITE_C(IO, v)   do { if (v) { \
31
 #define _WRITE_C(IO, v)   do { if (v) { \
32
                                          CRITICAL_SECTION_START; \
32
                                          CRITICAL_SECTION_START; \
33
-                                         {DIO ##  IO ## _WPORT |= MASK(DIO ## IO ## _PIN); }\
33
+                                         {DIO ##  IO ## _WPORT |= MASK(DIO ## IO ## _PIN); } \
34
                                          CRITICAL_SECTION_END; \
34
                                          CRITICAL_SECTION_END; \
35
-                                       }\
36
-                                       else {\
35
+                                       } \
36
+                                       else { \
37
                                          CRITICAL_SECTION_START; \
37
                                          CRITICAL_SECTION_START; \
38
-                                         {DIO ##  IO ## _WPORT &= ~MASK(DIO ## IO ## _PIN); }\
38
+                                         {DIO ##  IO ## _WPORT &= ~MASK(DIO ## IO ## _PIN); } \
39
                                          CRITICAL_SECTION_END; \
39
                                          CRITICAL_SECTION_END; \
40
-                                       }\
41
-                                     }\
40
+                                       } \
41
+                                     } \
42
                                      while (0)
42
                                      while (0)
43
 
43
 
44
 #define _WRITE(IO, v)  do {  if (&(DIO ##  IO ## _RPORT) >= (uint8_t *)0x100) {_WRITE_C(IO, v); } else {_WRITE_NC(IO, v); }; } while (0)
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
           // Just starting up fan - run at full power.
439
           // Just starting up fan - run at full power.
440
           fan_kick_end = ms + FAN_KICKSTART_TIME;
440
           fan_kick_end = ms + FAN_KICKSTART_TIME;
441
           tail_fan_speed = 255;
441
           tail_fan_speed = 255;
442
-        } else if (fan_kick_end > ms)
442
+        }
443
+        else if (fan_kick_end > ms)
443
           // Fan still spinning up.
444
           // Fan still spinning up.
444
           tail_fan_speed = 255;
445
           tail_fan_speed = 255;
445
-        } else {
446
+        }
447
+        else {
446
           fan_kick_end = 0;
448
           fan_kick_end = 0;
447
         }
449
         }
448
     #endif //FAN_KICKSTART_TIME
450
     #endif //FAN_KICKSTART_TIME

+ 6
- 3
Marlin/qr_solve.cpp View File

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

+ 4
- 2
Marlin/stepper.cpp View File

139
       if (Z_HOME_DIR > 0) {\
139
       if (Z_HOME_DIR > 0) {\
140
         if (!(TEST(old_endstop_bits, Z_MAX) && (count_direction[Z_AXIS] > 0)) && !locked_z_motor) Z_STEP_WRITE(v); \
140
         if (!(TEST(old_endstop_bits, Z_MAX) && (count_direction[Z_AXIS] > 0)) && !locked_z_motor) Z_STEP_WRITE(v); \
141
         if (!(TEST(old_endstop_bits, Z2_MAX) && (count_direction[Z_AXIS] > 0)) && !locked_z2_motor) Z2_STEP_WRITE(v); \
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
         if (!(TEST(old_endstop_bits, Z_MIN) && (count_direction[Z_AXIS] < 0)) && !locked_z_motor) Z_STEP_WRITE(v); \
144
         if (!(TEST(old_endstop_bits, Z_MIN) && (count_direction[Z_AXIS] < 0)) && !locked_z_motor) Z_STEP_WRITE(v); \
144
         if (!(TEST(old_endstop_bits, Z2_MIN) && (count_direction[Z_AXIS] < 0)) && !locked_z2_motor) Z2_STEP_WRITE(v); \
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
       Z_STEP_WRITE(v); \
149
       Z_STEP_WRITE(v); \
148
       Z2_STEP_WRITE(v); \
150
       Z2_STEP_WRITE(v); \
149
     }
151
     }

+ 2
- 1
Marlin/temperature.cpp View File

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

+ 2
- 2
Marlin/ultralcd_implementation_hitachi_HD44780.h View File

716
       lcd.print(ftostr12ns(filament_width_meas));
716
       lcd.print(ftostr12ns(filament_width_meas));
717
       lcd_printPGM(PSTR(" V"));
717
       lcd_printPGM(PSTR(" V"));
718
       lcd.print(itostr3(100.0 * volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
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
   #endif // FILAMENT_LCD_DISPLAY
723
   #endif // FILAMENT_LCD_DISPLAY

+ 55
- 35
Marlin/utf_mapper.h View File

123
 #endif // SIMULATE_ROMFONT
123
 #endif // SIMULATE_ROMFONT
124
 
124
 
125
 #if ENABLED(MAPPER_NON)
125
 #if ENABLED(MAPPER_NON)
126
-  char charset_mapper(char c){
126
+
127
+  char charset_mapper(char c) {
127
     HARDWARE_CHAR_OUT( c );
128
     HARDWARE_CHAR_OUT( c );
128
     return 1;
129
     return 1;
129
   }
130
   }
131
+
130
 #elif ENABLED(MAPPER_C2C3)
132
 #elif ENABLED(MAPPER_C2C3)
131
   uint8_t utf_hi_char; // UTF-8 high part
133
   uint8_t utf_hi_char; // UTF-8 high part
132
   bool seen_c2 = false;
134
   bool seen_c2 = false;
138
         seen_c2 = true;
140
         seen_c2 = true;
139
         return 0;
141
         return 0;
140
       }
142
       }
141
-      else if (seen_c2){
143
+      else if (seen_c2) {
142
         d &= 0x3f;
144
         d &= 0x3f;
143
         #ifndef MAPPER_ONE_TO_ONE
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
         #else
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
         #endif
149
         #endif
148
       }
150
       }
149
       else {
151
       else {
150
-          HARDWARE_CHAR_OUT('?');
152
+        HARDWARE_CHAR_OUT('?');
151
       }
153
       }
152
     }
154
     }
153
     else {
155
     else {
156
     seen_c2 = false;
158
     seen_c2 = false;
157
     return 1;
159
     return 1;
158
   }
160
   }
161
+
159
 #elif ENABLED(MAPPER_D0D1_MOD)
162
 #elif ENABLED(MAPPER_D0D1_MOD)
160
   uint8_t utf_hi_char; // UTF-8 high part
163
   uint8_t utf_hi_char; // UTF-8 high part
161
   bool seen_d5 = false;
164
   bool seen_d5 = false;
162
-  char charset_mapper(char c){
165
+
166
+  char charset_mapper(char c) {
163
     // it is a Russian alphabet translation
167
     // it is a Russian alphabet translation
164
     // except 0401 --> 0xa2 = Ё, 0451 --> 0xb5 = ё
168
     // except 0401 --> 0xa2 = Ё, 0451 --> 0xb5 = ё
165
     uint8_t d = c;
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
         utf_hi_char = d - 0xd0;
172
         utf_hi_char = d - 0xd0;
169
         seen_d5 = true;
173
         seen_d5 = true;
170
         return 0;
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
         else {
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
       HARDWARE_CHAR_OUT((char) c );
193
       HARDWARE_CHAR_OUT((char) c );
186
     }
194
     }
187
     seen_d5 = false;
195
     seen_d5 = false;
188
     return 1;
196
     return 1;
189
   }
197
   }
198
+
190
 #elif ENABLED(MAPPER_D0D1)
199
 #elif ENABLED(MAPPER_D0D1)
191
   uint8_t utf_hi_char; // UTF-8 high part
200
   uint8_t utf_hi_char; // UTF-8 high part
192
   bool seen_d5 = false;
201
   bool seen_d5 = false;
193
   char charset_mapper(char c) {
202
   char charset_mapper(char c) {
194
     uint8_t d = c;
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
         utf_hi_char = d - 0xd0u;
206
         utf_hi_char = d - 0xd0u;
198
         seen_d5 = true;
207
         seen_d5 = true;
199
         return 0;
208
         return 0;
200
-      } else if (seen_d5) {
201
-          d &= 0x3fu;
209
+      }
210
+      else if (seen_d5) {
211
+        d &= 0x3fu;
202
         #ifndef MAPPER_ONE_TO_ONE
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
         #else
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
         #endif
216
         #endif
207
-      } else {
217
+      }
218
+      else {
208
         HARDWARE_CHAR_OUT('?');
219
         HARDWARE_CHAR_OUT('?');
209
       }
220
       }
210
-    } else {
221
+    }
222
+    else {
211
       HARDWARE_CHAR_OUT((char) c );
223
       HARDWARE_CHAR_OUT((char) c );
212
     }
224
     }
213
     seen_d5 = false;
225
     seen_d5 = false;
214
     return 1;
226
     return 1;
215
   }
227
   }
228
+
216
 #elif ENABLED(MAPPER_E382E383)
229
 #elif ENABLED(MAPPER_E382E383)
217
   uint8_t utf_hi_char; // UTF-8 high part
230
   uint8_t utf_hi_char; // UTF-8 high part
218
   bool seen_e3 = false;
231
   bool seen_e3 = false;
219
   bool seen_82_83 = false;
232
   bool seen_82_83 = false;
220
   char charset_mapper(char c){
233
   char charset_mapper(char c){
221
     uint8_t d = c;
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
         seen_e3 = true;
237
         seen_e3 = true;
225
         return 0;      // eat 0xe3
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
         utf_hi_char = d - 0x82;
241
         utf_hi_char = d - 0x82;
228
         seen_82_83 = true;
242
         seen_82_83 = true;
229
         return 0;
243
         return 0;
230
-      } else if ((seen_e3 == true) && (seen_82_83 == true)){
244
+      }
245
+      else if (seen_e3 && seen_82_83) {
231
         d &= 0x3f;
246
         d &= 0x3f;
232
         #ifndef MAPPER_ONE_TO_ONE
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
         #else
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
         #endif
251
         #endif
237
-      } else {
252
+      }
253
+      else {
238
         HARDWARE_CHAR_OUT((char) '?' );
254
         HARDWARE_CHAR_OUT((char) '?' );
239
       }
255
       }
240
-    } else {
256
+    }
257
+    else {
241
       HARDWARE_CHAR_OUT((char) c );
258
       HARDWARE_CHAR_OUT((char) c );
242
     }
259
     }
243
     seen_e3 = false;
260
     seen_e3 = false;
244
     seen_82_83 = false;
261
     seen_82_83 = false;
245
     return 1;
262
     return 1;
246
   }
263
   }
264
+
247
 #else
265
 #else
266
+
248
   #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.
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
 #endif // code mappers
269
 #endif // code mappers
250
 
270
 
251
 #endif // UTF_MAPPER_H
271
 #endif // UTF_MAPPER_H

Loading…
Cancel
Save