Explorar el Código

Spacing, const, comments

Scott Lahteine hace 8 años
padre
commit
efc198f952

+ 1
- 1
Marlin/Conditionals_LCD.h Ver fichero

@@ -243,7 +243,7 @@
243 243
     /* Custom characters defined in the first 8 characters of the LCD */
244 244
     #define LCD_BEDTEMP_CHAR     0x00  // Print only as a char. This will have 'unexpected' results when used in a string!
245 245
     #define LCD_DEGREE_CHAR      0x01
246
-    #define LCD_STR_THERMOMETER "\x02" // Too many places use preprocessor string concatination to change this to a char right now.
246
+    #define LCD_STR_THERMOMETER "\x02" // Still used with string concatenation
247 247
     #define LCD_UPLEVEL_CHAR     0x03
248 248
     #define LCD_REFRESH_CHAR     0x04
249 249
     #define LCD_STR_FOLDER      "\x05"

+ 5
- 7
Marlin/Configuration_adv.h Ver fichero

@@ -225,13 +225,11 @@
225 225
  */
226 226
 //#define CASE_LIGHT_ENABLE
227 227
 #if ENABLED(CASE_LIGHT_ENABLE)
228
-  #define CASE_LIGHT_PIN 4          // can be defined here or in the pins_XXX.h file for your board
229
-                                    //  pins_XXX.h file overrides this one
230
-  #define INVERT_CASE_LIGHT false             // set to true if case light is ON when pin is at 0
231
-  #define CASE_LIGHT_DEFAULT_ON true          // set default power up state to on or off
232
-  #define CASE_LIGHT_DEFAULT_BRIGHTNESS 105   // set power up brightness 0-255 ( only used if on PWM
233
-                                              // and if CASE_LIGHT_DEFAULT is set to on
234
-  //#define MENU_ITEM_CASE_LIGHT              // Uncomment to have a Case Light entry in main menu
228
+  //#define CASE_LIGHT_PIN 4                  // Override the default pin if needed
229
+  #define INVERT_CASE_LIGHT false             // Set true if Case Light is ON when pin is LOW
230
+  #define CASE_LIGHT_DEFAULT_ON true          // Set default power-up state on
231
+  #define CASE_LIGHT_DEFAULT_BRIGHTNESS 105   // Set default power-up brightness (0-255, requires PWM pin)
232
+  //#define MENU_ITEM_CASE_LIGHT              // Add a Case Light option to the LCD main menu
235 233
 #endif
236 234
 
237 235
 //===========================================================================

+ 31
- 57
Marlin/Marlin_main.cpp Ver fichero

@@ -458,7 +458,7 @@ volatile bool wait_for_heatup = true;
458 458
   volatile bool wait_for_user = false;
459 459
 #endif
460 460
 
461
-const char axis_codes[XYZE] = {'X', 'Y', 'Z', 'E'};
461
+const char axis_codes[XYZE] = { 'X', 'Y', 'Z', 'E' };
462 462
 
463 463
 // Number of characters read in the current line of serial input
464 464
 static int serial_count = 0;
@@ -1394,7 +1394,7 @@ bool get_target_extruder_from_command(int code) {
1394 1394
  *
1395 1395
  * Callers must sync the planner position after calling this!
1396 1396
  */
1397
-static void set_axis_is_at_home(AxisEnum axis) {
1397
+static void set_axis_is_at_home(const AxisEnum axis) {
1398 1398
   #if ENABLED(DEBUG_LEVELING_FEATURE)
1399 1399
     if (DEBUGGING(LEVELING)) {
1400 1400
       SERIAL_ECHOPAIR(">>> set_axis_is_at_home(", axis_codes[axis]);
@@ -1496,7 +1496,7 @@ static void set_axis_is_at_home(AxisEnum axis) {
1496 1496
 /**
1497 1497
  * Some planner shorthand inline functions
1498 1498
  */
1499
-inline float get_homing_bump_feedrate(AxisEnum axis) {
1499
+inline float get_homing_bump_feedrate(const AxisEnum axis) {
1500 1500
   int constexpr homing_bump_divisor[] = HOMING_BUMP_DIVISOR;
1501 1501
   int hbd = homing_bump_divisor[axis];
1502 1502
   if (hbd < 1) {
@@ -1507,20 +1507,19 @@ inline float get_homing_bump_feedrate(AxisEnum axis) {
1507 1507
   return homing_feedrate_mm_s[axis] / hbd;
1508 1508
 }
1509 1509
 
1510
-//
1511
-// line_to_current_position
1512
-// Move the planner to the current position from wherever it last moved
1513
-// (or from wherever it has been told it is located).
1514
-//
1510
+/**
1511
+ * Move the planner to the current position from wherever it last moved
1512
+ * (or from wherever it has been told it is located).
1513
+ */
1515 1514
 inline void line_to_current_position() {
1516 1515
   planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate_mm_s, active_extruder);
1517 1516
 }
1518 1517
 
1519
-//
1520
-// line_to_destination
1521
-// Move the planner, not necessarily synced with current_position
1522
-//
1523
-inline void line_to_destination(float fr_mm_s) {
1518
+/**
1519
+ * Move the planner to the position stored in the destination array, which is
1520
+ * used by G0/G1/G2/G3/G5 and many other functions to set a destination.
1521
+ */
1522
+inline void line_to_destination(const float fr_mm_s) {
1524 1523
   planner.buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], fr_mm_s, active_extruder);
1525 1524
 }
1526 1525
 inline void line_to_destination() { line_to_destination(feedrate_mm_s); }
@@ -2751,7 +2750,7 @@ static void clean_up_after_endstop_or_probe_move() {
2751 2750
 /**
2752 2751
  * Home an individual linear axis
2753 2752
  */
2754
-static void do_homing_move(const AxisEnum axis, float distance, float fr_mm_s=0.0) {
2753
+static void do_homing_move(const AxisEnum axis, const float distance, const float fr_mm_s=0.0) {
2755 2754
 
2756 2755
   #if ENABLED(DEBUG_LEVELING_FEATURE)
2757 2756
     if (DEBUGGING(LEVELING)) {
@@ -4907,7 +4906,7 @@ void home_all_axes() { gcode_G28(true); }
4907 4906
         if ( NEAR(current_position[X_AXIS], xProbe - (X_PROBE_OFFSET_FROM_EXTRUDER))
4908 4907
           && NEAR(current_position[Y_AXIS], yProbe - (Y_PROBE_OFFSET_FROM_EXTRUDER))
4909 4908
         ) {
4910
-          float simple_z = current_position[Z_AXIS] - measured_z;
4909
+          const float simple_z = current_position[Z_AXIS] - measured_z;
4911 4910
           #if ENABLED(DEBUG_LEVELING_FEATURE)
4912 4911
             if (DEBUGGING(LEVELING)) {
4913 4912
               SERIAL_ECHOPAIR("Z from Probe:", simple_z);
@@ -7667,45 +7666,32 @@ void report_current_position() {
7667 7666
 
7668 7667
 #ifdef M114_DETAIL
7669 7668
 
7670
-  static const char axis_char[XYZE] = {'X','Y','Z','E'};
7671
-
7672
-  void report_xyze(const float pos[XYZE], uint8_t n = 4, uint8_t precision = 3) {
7669
+  void report_xyze(const float pos[XYZE], const uint8_t n = 4, const uint8_t precision = 3) {
7673 7670
     char str[12];
7674
-    for(uint8_t i=0; i<n; i++) {
7671
+    for (uint8_t i = 0; i < n; i++) {
7675 7672
       SERIAL_CHAR(' ');
7676
-      SERIAL_CHAR(axis_char[i]);
7673
+      SERIAL_CHAR(axis_codes[i]);
7677 7674
       SERIAL_CHAR(':');
7678
-      SERIAL_PROTOCOL(dtostrf(pos[i],8,precision,str));
7675
+      SERIAL_PROTOCOL(dtostrf(pos[i], 8, precision, str));
7679 7676
     }
7680 7677
     SERIAL_EOL;
7681 7678
   }
7682 7679
 
7683
-  inline void report_xyz(const float pos[XYZ]) {
7684
-    report_xyze(pos,3);
7685
-  }
7680
+  inline void report_xyz(const float pos[XYZ]) { report_xyze(pos, 3); }
7686 7681
 
7687 7682
   void report_current_position_detail() {
7688 7683
 
7689 7684
     stepper.synchronize();
7690 7685
 
7691
-    SERIAL_EOL;
7692
-    SERIAL_PROTOCOLPGM("Logical:");
7686
+    SERIAL_PROTOCOLPGM("\nLogical:");
7693 7687
     report_xyze(current_position);
7694 7688
 
7695 7689
     SERIAL_PROTOCOLPGM("Raw:    ");
7696
-    const float raw[XYZ] = {
7697
-      RAW_X_POSITION(current_position[X_AXIS]),
7698
-      RAW_Y_POSITION(current_position[Y_AXIS]),
7699
-      RAW_Z_POSITION(current_position[Z_AXIS])
7700
-    };
7690
+    const float raw[XYZ] = { RAW_X_POSITION(current_position[X_AXIS]), RAW_Y_POSITION(current_position[Y_AXIS]), RAW_Z_POSITION(current_position[Z_AXIS]) };
7701 7691
     report_xyz(raw);
7702 7692
 
7703 7693
     SERIAL_PROTOCOLPGM("Leveled:");
7704
-    float leveled[XYZ] = {
7705
-      current_position[X_AXIS],
7706
-      current_position[Y_AXIS],
7707
-      current_position[Z_AXIS]
7708
-    };
7694
+    float leveled[XYZ] = { current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] };
7709 7695
     planner.apply_leveling(leveled);
7710 7696
     report_xyz(leveled);
7711 7697
 
@@ -7725,13 +7711,8 @@ void report_current_position() {
7725 7711
     #endif
7726 7712
 
7727 7713
     SERIAL_PROTOCOLPGM("Stepper:");
7728
-    const float step_count[XYZE] = {
7729
-      (float)stepper.position(X_AXIS),
7730
-      (float)stepper.position(Y_AXIS),
7731
-      (float)stepper.position(Z_AXIS),
7732
-      (float)stepper.position(E_AXIS)
7733
-    };
7734
-    report_xyze(step_count,4,0);
7714
+    const float step_count[XYZE] = { stepper.position(X_AXIS), stepper.position(Y_AXIS), stepper.position(Z_AXIS), stepper.position(E_AXIS) };
7715
+    report_xyze(step_count, 4, 0);
7735 7716
 
7736 7717
     #if IS_SCARA
7737 7718
       const float deg[XYZ] = {
@@ -7739,17 +7720,12 @@ void report_current_position() {
7739 7720
         stepper.get_axis_position_degrees(B_AXIS)
7740 7721
       };
7741 7722
       SERIAL_PROTOCOLPGM("Degrees:");
7742
-      report_xyze(deg,2);
7723
+      report_xyze(deg, 2);
7743 7724
     #endif
7744 7725
 
7745 7726
     SERIAL_PROTOCOLPGM("FromStp:");
7746 7727
     get_cartesian_from_steppers();  // writes cartes[XYZ] (with forward kinematics)
7747
-    const float from_steppers[XYZE] = {
7748
-      cartes[X_AXIS],
7749
-      cartes[Y_AXIS],
7750
-      cartes[Z_AXIS],
7751
-      stepper.get_axis_position_mm(E_AXIS)
7752
-    };
7728
+    const float from_steppers[XYZE] = { cartes[X_AXIS], cartes[Y_AXIS], cartes[Z_AXIS], stepper.get_axis_position_mm(E_AXIS) };
7753 7729
     report_xyze(from_steppers);
7754 7730
 
7755 7731
     const float diff[XYZE] = {
@@ -7764,12 +7740,12 @@ void report_current_position() {
7764 7740
 #endif // M114_DETAIL
7765 7741
 
7766 7742
 /**
7767
- * M114: Output current position to serial port
7743
+ * M114: Report current position to host
7768 7744
  */
7769 7745
 inline void gcode_M114() {
7770 7746
 
7771 7747
   #ifdef M114_DETAIL
7772
-    if ( parser.seen('D') ) {
7748
+    if (parser.seen('D')) {
7773 7749
       report_current_position_detail();
7774 7750
       return;
7775 7751
     }
@@ -7777,7 +7753,7 @@ inline void gcode_M114() {
7777 7753
 
7778 7754
   stepper.synchronize();
7779 7755
   report_current_position();
7780
-  }
7756
+}
7781 7757
 
7782 7758
 /**
7783 7759
  * M115: Capabilities string
@@ -7859,9 +7835,7 @@ inline void gcode_M115() {
7859 7835
 /**
7860 7836
  * M117: Set LCD Status Message
7861 7837
  */
7862
-inline void gcode_M117() {
7863
-  lcd_setstatus(parser.string_arg);
7864
-}
7838
+inline void gcode_M117() { lcd_setstatus(parser.string_arg); }
7865 7839
 
7866 7840
 /**
7867 7841
  * M119: Output endstop states to serial output
@@ -12749,7 +12723,7 @@ void setup() {
12749 12723
   #if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
12750 12724
     setup_endstop_interrupts();
12751 12725
   #endif
12752
-  
12726
+
12753 12727
   #if ENABLED(SWITCHING_EXTRUDER)
12754 12728
     move_extruder_servo(0);  // Initialize extruder servo
12755 12729
   #endif

+ 1
- 1
Marlin/buzzer.h Ver fichero

@@ -104,7 +104,7 @@ class Buzzer {
104 104
      * @param duration Duration of the tone in milliseconds
105 105
      * @param frequency Frequency of the tone in hertz
106 106
      */
107
-    void tone(uint16_t const &duration, uint16_t const &frequency = 0) {
107
+    void tone(const uint16_t &duration, const uint16_t &frequency = 0) {
108 108
       while (buffer.isFull()) {
109 109
         this->tick();
110 110
         thermalManager.manage_heater();

+ 4
- 4
Marlin/configuration_store.cpp Ver fichero

@@ -457,10 +457,10 @@ void MarlinSettings::postprocess() {
457 457
     #endif
458 458
 
459 459
     #if DISABLED(ULTIPANEL)
460
-      const int lcd_preheat_hotend_temp[2] = { PREHEAT_1_TEMP_HOTEND, PREHEAT_2_TEMP_HOTEND },
461
-                lcd_preheat_bed_temp[2] = { PREHEAT_1_TEMP_BED, PREHEAT_2_TEMP_BED },
462
-                lcd_preheat_fan_speed[2] = { PREHEAT_1_FAN_SPEED, PREHEAT_2_FAN_SPEED };
463
-    #endif // !ULTIPANEL
460
+      constexpr int lcd_preheat_hotend_temp[2] = { PREHEAT_1_TEMP_HOTEND, PREHEAT_2_TEMP_HOTEND },
461
+                    lcd_preheat_bed_temp[2] = { PREHEAT_1_TEMP_BED, PREHEAT_2_TEMP_BED },
462
+                    lcd_preheat_fan_speed[2] = { PREHEAT_1_FAN_SPEED, PREHEAT_2_FAN_SPEED };
463
+    #endif
464 464
 
465 465
     EEPROM_WRITE(lcd_preheat_hotend_temp);
466 466
     EEPROM_WRITE(lcd_preheat_bed_temp);

+ 1
- 1
Marlin/temperature.cpp Ver fichero

@@ -52,7 +52,7 @@
52 52
 #endif
53 53
 
54 54
 #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
55
-  static void* heater_ttbl_map[2] = {(void*)HEATER_0_TEMPTABLE, (void*)HEATER_1_TEMPTABLE };
55
+  static void* heater_ttbl_map[2] = { (void*)HEATER_0_TEMPTABLE, (void*)HEATER_1_TEMPTABLE };
56 56
   static uint8_t heater_ttbllen_map[2] = { HEATER_0_TEMPTABLE_LEN, HEATER_1_TEMPTABLE_LEN };
57 57
 #else
58 58
   static void* heater_ttbl_map[HOTENDS] = ARRAY_BY_HOTENDS((void*)HEATER_0_TEMPTABLE, (void*)HEATER_1_TEMPTABLE, (void*)HEATER_2_TEMPTABLE, (void*)HEATER_3_TEMPTABLE, (void*)HEATER_4_TEMPTABLE);

+ 30
- 33
Marlin/ultralcd_impl_HD44780.h Ver fichero

@@ -193,18 +193,19 @@ extern volatile uint8_t buttons;  //an extended version of the last checked butt
193 193
   static void lcd_implementation_update_indicators();
194 194
 #endif
195 195
 
196
-
197
-static void createChar_P(char c, PROGMEM byte *ptr) {
196
+static void createChar_P(const char c, const byte * const ptr) {
198 197
   byte temp[8];
199
-  int8_t i;
200
-
201
-  for(i=0; i<8; i++)  {
198
+  for (uint8_t i = 0; i < 8; i++)
202 199
     temp[i] = pgm_read_byte(&ptr[i]);
203
-  }
204 200
   lcd.createChar(c, temp);
205 201
 }
206 202
 
207
-const static PROGMEM byte bedTemp[8] = {
203
+static void lcd_set_custom_characters(
204
+  #if ENABLED(LCD_PROGRESS_BAR)
205
+    const bool info_screen_charset = true
206
+  #endif
207
+) {
208
+  const static PROGMEM byte bedTemp[8] = {
208 209
     B00000,
209 210
     B11111,
210 211
     B10101,
@@ -213,9 +214,9 @@ const static PROGMEM byte bedTemp[8] = {
213 214
     B11111,
214 215
     B00000,
215 216
     B00000
216
-};
217
+  };
217 218
 
218
-const static PROGMEM byte degree[8] = {
219
+  const static PROGMEM byte degree[8] = {
219 220
     B01100,
220 221
     B10010,
221 222
     B10010,
@@ -226,7 +227,7 @@ const static PROGMEM byte degree[8] = {
226 227
     B00000
227 228
   };
228 229
 
229
-const static PROGMEM byte thermometer[8] = {
230
+  const static PROGMEM byte thermometer[8] = {
230 231
     B00100,
231 232
     B01010,
232 233
     B01010,
@@ -237,7 +238,7 @@ const static PROGMEM byte thermometer[8] = {
237 238
     B01110
238 239
   };
239 240
 
240
-const static PROGMEM byte uplevel[8] = {
241
+  const static PROGMEM byte uplevel[8] = {
241 242
     B00100,
242 243
     B01110,
243 244
     B11111,
@@ -246,9 +247,9 @@ const static PROGMEM byte uplevel[8] = {
246 247
     B00000,
247 248
     B00000,
248 249
     B00000
249
-};
250
+  };
250 251
 
251
-const static PROGMEM byte feedrate[8] = {
252
+  const static PROGMEM byte feedrate[8] = {
252 253
     B11100,
253 254
     B10000,
254 255
     B11000,
@@ -257,9 +258,9 @@ const static PROGMEM byte feedrate[8] = {
257 258
     B00110,
258 259
     B00101,
259 260
     B00000
260
-};
261
+  };
261 262
 
262
-const static PROGMEM byte clock[8] = {
263
+  const static PROGMEM byte clock[8] = {
263 264
     B00000,
264 265
     B01110,
265 266
     B10011,
@@ -268,10 +269,10 @@ const static PROGMEM byte clock[8] = {
268 269
     B01110,
269 270
     B00000,
270 271
     B00000
271
-};
272
+  };
272 273
 
273
-#if ENABLED(SDSUPPORT)
274
-  const static PROGMEM byte refresh[8] = {
274
+  #if ENABLED(SDSUPPORT)
275
+    const static PROGMEM byte refresh[8] = {
275 276
       B00000,
276 277
       B00110,
277 278
       B11001,
@@ -280,8 +281,8 @@ const static PROGMEM byte clock[8] = {
280 281
       B10011,
281 282
       B01100,
282 283
       B00000,
283
-  };
284
-  const static PROGMEM byte folder[8] = {
284
+    };
285
+    const static PROGMEM byte folder[8] = {
285 286
       B00000,
286 287
       B11100,
287 288
       B11111,
@@ -290,10 +291,10 @@ const static PROGMEM byte clock[8] = {
290 291
       B11111,
291 292
       B00000,
292 293
       B00000
293
-  };
294
+    };
294 295
 
295
-  #if ENABLED(LCD_PROGRESS_BAR)
296
-    const static PROGMEM byte progress[3][8] = { {
296
+    #if ENABLED(LCD_PROGRESS_BAR)
297
+      const static PROGMEM byte progress[3][8] = { {
297 298
         B00000,
298 299
         B10000,
299 300
         B10000,
@@ -321,14 +322,8 @@ const static PROGMEM byte clock[8] = {
321 322
         B10101,
322 323
         B00000
323 324
       } };
325
+    #endif
324 326
   #endif
325
-#endif
326
-
327
-static void lcd_set_custom_characters(
328
-  #if ENABLED(LCD_PROGRESS_BAR)
329
-    const bool info_screen_charset = true
330
-  #endif
331
-) {
332 327
 
333 328
   createChar_P(LCD_BEDTEMP_CHAR, bedTemp);
334 329
   createChar_P(LCD_DEGREE_CHAR, degree);
@@ -638,10 +633,12 @@ FORCE_INLINE void _draw_heater_status(const int8_t heater, const char prefix, co
638 633
 #if ENABLED(LCD_PROGRESS_BAR)
639 634
 
640 635
   inline void lcd_draw_progress_bar(const uint8_t percent) {
641
-    int tix = (int)(percent * (LCD_WIDTH) * 3) / 100,
642
-      cel = tix / 3, rem = tix % 3, i = LCD_WIDTH;
636
+    const int tix = (int)(percent * (LCD_WIDTH) * 3) / 100,
637
+              cel = tix / 3,
638
+              rem = tix % 3;
639
+    uint8_t i = LCD_WIDTH;
643 640
     char msg[LCD_WIDTH + 1], b = ' ';
644
-    msg[i] = '\0';
641
+    msg[LCD_WIDTH] = '\0';
645 642
     while (i--) {
646 643
       if (i == cel - 1)
647 644
         b = LCD_STR_PROGRESS[2];

Loading…
Cancelar
Guardar