Browse Source

Apply const, spacing, etc.

Scott Lahteine 7 years ago
parent
commit
941943c167

+ 10
- 12
Marlin/M100_Free_Mem_Chk.cpp View File

@@ -189,19 +189,17 @@ void free_memory_pool_report(char * const ptr, const int16_t size) {
189 189
    *  This is useful to check the correctness of the M100 D and the M100 F commands.
190 190
    */
191 191
   void corrupt_free_memory(char *ptr, const uint16_t size) {
192
-    if (parser.seen('C')) {
193
-      ptr += 8;
194
-      const uint16_t near_top = top_of_stack() - ptr - 250, // -250 to avoid interrupt activity that's altered the stack.
195
-                     j = near_top / (size + 1);
196
-
197
-      SERIAL_ECHOLNPGM("Corrupting free memory block.\n");
198
-      for (uint16_t i = 1; i <= size; i++) {
199
-        char * const addr = ptr + i * j;
200
-        *addr = i;
201
-        SERIAL_ECHOPAIR("\nCorrupting address: ", hex_address(addr));
202
-      }
203
-      SERIAL_EOL();
192
+    ptr += 8;
193
+    const uint16_t near_top = top_of_stack() - ptr - 250, // -250 to avoid interrupt activity that's altered the stack.
194
+                   j = near_top / (size + 1);
195
+
196
+    SERIAL_ECHOLNPGM("Corrupting free memory block.\n");
197
+    for (uint16_t i = 1; i <= size; i++) {
198
+      char * const addr = ptr + i * j;
199
+      *addr = i;
200
+      SERIAL_ECHOPAIR("\nCorrupting address: ", hex_address(addr));
204 201
     }
202
+    SERIAL_EOL();
205 203
   }
206 204
 #endif // M100_FREE_MEMORY_CORRUPTOR
207 205
 

+ 20
- 17
Marlin/Marlin_main.cpp View File

@@ -1276,16 +1276,17 @@ void get_available_commands() {
1276 1276
  *
1277 1277
  * Returns TRUE if the target is invalid
1278 1278
  */
1279
-bool get_target_extruder_from_command(int code) {
1279
+bool get_target_extruder_from_command(const uint16_t code) {
1280 1280
   if (parser.seen('T')) {
1281
-    if (parser.value_byte() >= EXTRUDERS) {
1281
+    const int8_t e = parser.value_byte();
1282
+    if (e >= EXTRUDERS) {
1282 1283
       SERIAL_ECHO_START();
1283 1284
       SERIAL_CHAR('M');
1284 1285
       SERIAL_ECHO(code);
1285
-      SERIAL_ECHOLNPAIR(" " MSG_INVALID_EXTRUDER " ", parser.value_byte());
1286
+      SERIAL_ECHOLNPAIR(" " MSG_INVALID_EXTRUDER " ", e);
1286 1287
       return true;
1287 1288
     }
1288
-    target_extruder = parser.value_byte();
1289
+    target_extruder = e;
1289 1290
   }
1290 1291
   else
1291 1292
     target_extruder = active_extruder;
@@ -5676,7 +5677,7 @@ inline void gcode_G92() {
5676 5677
         #if HAS_POSITION_SHIFT
5677 5678
           const float p = current_position[i];
5678 5679
         #endif
5679
-        float v = parser.value_axis_units((AxisEnum)i);
5680
+        const float v = parser.value_axis_units((AxisEnum)i);
5680 5681
 
5681 5682
         current_position[i] = v;
5682 5683
 
@@ -6405,7 +6406,7 @@ static bool pin_is_protected(const int8_t pin) {
6405 6406
 inline void gcode_M42() {
6406 6407
   if (!parser.seen('S')) return;
6407 6408
 
6408
-  int pin_status = parser.value_int();
6409
+  const int pin_status = parser.value_int();
6409 6410
   if (!WITHIN(pin_status, 0, 255)) return;
6410 6411
 
6411 6412
   int pin_number = parser.seen('P') ? parser.value_int() : LED_PIN;
@@ -6645,7 +6646,7 @@ inline void gcode_M42() {
6645 6646
    */
6646 6647
   inline void gcode_M43() {
6647 6648
 
6648
-    if (parser.seen('T')) {   // must be first or else it's "S" and "E" parameters will execute endstop or servo test
6649
+    if (parser.seen('T')) {   // must be first or else its "S" and "E" parameters will execute endstop or servo test
6649 6650
       toggle_pins();
6650 6651
       return;
6651 6652
     }
@@ -8268,10 +8269,10 @@ inline void gcode_M205() {
8268 8269
       home_offset[Z_AXIS] = parser.value_linear_units() - DELTA_HEIGHT;
8269 8270
       update_software_endstops(Z_AXIS);
8270 8271
     }
8271
-    if (parser.seen('L')) delta_diagonal_rod = parser.value_linear_units();
8272
-    if (parser.seen('R')) delta_radius = parser.value_linear_units();
8273
-    if (parser.seen('S')) delta_segments_per_second = parser.value_float();
8274
-    if (parser.seen('B')) delta_calibration_radius = parser.value_float();
8272
+    if (parser.seen('L')) delta_diagonal_rod             = parser.value_linear_units();
8273
+    if (parser.seen('R')) delta_radius                   = parser.value_linear_units();
8274
+    if (parser.seen('S')) delta_segments_per_second      = parser.value_float();
8275
+    if (parser.seen('B')) delta_calibration_radius       = parser.value_float();
8275 8276
     if (parser.seen('X')) delta_tower_angle_trim[A_AXIS] = parser.value_float();
8276 8277
     if (parser.seen('Y')) delta_tower_angle_trim[B_AXIS] = parser.value_float();
8277 8278
     if (parser.seen('Z')) { // rotate all 3 axis for Z = 0
@@ -8580,7 +8581,7 @@ inline void gcode_M226() {
8580 8581
    */
8581 8582
   inline void gcode_M280() {
8582 8583
     if (!parser.seen('P')) return;
8583
-    int servo_index = parser.value_int();
8584
+    const int servo_index = parser.value_int();
8584 8585
     if (WITHIN(servo_index, 0, NUM_SERVOS - 1)) {
8585 8586
       if (parser.seen('S'))
8586 8587
         MOVE_SERVO(servo_index, parser.value_int());
@@ -8753,7 +8754,7 @@ inline void gcode_M226() {
8753 8754
    *       M302 S170 P1 ; set min extrude temp to 170 but leave disabled
8754 8755
    */
8755 8756
   inline void gcode_M302() {
8756
-    bool seen_S = parser.seen('S');
8757
+    const bool seen_S = parser.seen('S');
8757 8758
     if (seen_S) {
8758 8759
       thermalManager.extrude_min_temp = parser.value_celsius();
8759 8760
       thermalManager.allow_cold_extrude = (thermalManager.extrude_min_temp == 0);
@@ -8960,10 +8961,12 @@ inline void gcode_M400() { stepper.synchronize(); }
8960 8961
    * M405: Turn on filament sensor for control
8961 8962
    */
8962 8963
   inline void gcode_M405() {
8963
-    // This is technically a linear measurement, but since it's quantized to centimeters and is a different unit than
8964
-    // everything else, it uses parser.value_int() instead of parser.value_linear_units().
8965
-    if (parser.seen('D')) meas_delay_cm = parser.value_byte();
8966
-    NOMORE(meas_delay_cm, MAX_MEASUREMENT_DELAY);
8964
+    // This is technically a linear measurement, but since it's quantized to centimeters and is a different
8965
+    // unit than everything else, it uses parser.value_byte() instead of parser.value_linear_units().
8966
+    if (parser.seen('D')) {
8967
+      meas_delay_cm = parser.value_byte();
8968
+      NOMORE(meas_delay_cm, MAX_MEASUREMENT_DELAY);
8969
+    }
8967 8970
 
8968 8971
     if (filwidth_delay_index[1] == -1) { // Initialize the ring buffer if not done since startup
8969 8972
       const uint8_t temp_ratio = thermalManager.widthFil_to_size_ratio() - 100; // -100 to scale within a signed byte

+ 1
- 1
Marlin/SdFatStructs.h View File

@@ -523,7 +523,7 @@ struct directoryEntry {
523 523
   uint8_t  reservedNT;
524 524
           /**
525 525
            * The granularity of the seconds part of creationTime is 2 seconds
526
-           * so this field is a count of tenths of a second and its valid
526
+           * so this field is a count of tenths of a second and it's valid
527 527
            * value range is 0-199 inclusive. (WHG note - seems to be hundredths)
528 528
            */
529 529
   uint8_t  creationTimeTenths;

+ 1
- 1
Marlin/example_configurations/K8400/README.md View File

@@ -2,7 +2,7 @@
2 2
 http://www.k8400.eu/
3 3
 
4 4
 Configuration files for the K8400, ported upstream from the official Velleman firmware.
5
-Like it's predecessor, (K8200), the K8400 is a 3Drag clone. There are some minor differences, documented in pins_K8400.h.
5
+Like its predecessor, (K8200), the K8400 is a 3Drag clone. There are some minor differences, documented in pins_K8400.h.
6 6
 
7 7
 Single and dual head configurations provided. Copy the correct Configuration.h and Configuration_adv.h to the /Marlin/ directory.
8 8
 

+ 1
- 1
Marlin/servo.cpp View File

@@ -95,7 +95,7 @@ static inline void handle_interrupts(timer16_Sequence_t timer, volatile uint16_t
95 95
   if (SERVO_INDEX(timer, Channel[timer]) < ServoCount && Channel[timer] < SERVOS_PER_TIMER) {
96 96
     *OCRnA = *TCNTn + SERVO(timer, Channel[timer]).ticks;
97 97
     if (SERVO(timer, Channel[timer]).Pin.isActive)    // check if activated
98
-      digitalWrite(SERVO(timer, Channel[timer]).Pin.nbr, HIGH); // its an active channel so pulse it high
98
+      digitalWrite(SERVO(timer, Channel[timer]).Pin.nbr, HIGH); // it's an active channel so pulse it high
99 99
   }
100 100
   else {
101 101
     // finished all channels so wait for the refresh period to expire before starting over

+ 11
- 11
Marlin/twibus.h View File

@@ -38,18 +38,18 @@ typedef void (*twiRequestFunc_t)();
38 38
 /**
39 39
  * TWIBUS class
40 40
  *
41
- * This class implements a wrapper around the two wire (I2C) bus, it allows
42
- * Marlin to send and request data from any slave device on the bus. This is
43
- * an experimental feature and it's inner workings as well as public facing
44
- * interface are prune to change in the future.
41
+ * This class implements a wrapper around the two wire (I2C) bus, allowing
42
+ * Marlin to send and request data from any slave device on the bus.
45 43
  *
46
- * The two main consumers of this class are M260 and M261, where M260 allows
47
- * Marlin to send a I2C packet to a device (please be aware that no repeated
48
- * starts are possible), this can be done in caching method by calling multiple
49
- * times M260 B<byte-1 value in base 10> or a one liner M260, have a look at
50
- * the gcode_M260() function for more information. M261 allows Marlin to
51
- * request data from a device, the received data is then relayed into the serial
52
- * line for host interpretation.
44
+ * The two main consumers of this class are M260 and M261. M260 provides a way
45
+ * to send an I2C packet to a device (no repeated starts) by caching up to 32
46
+ * bytes in a buffer and then sending the buffer.
47
+ * M261 requests data from a device. The received data is relayed to serial out
48
+ * for the host to interpret.
49
+ *
50
+ *  For more information see
51
+ *    - http://marlinfw.org/docs/gcode/M260.html 
52
+ *    - http://marlinfw.org/docs/gcode/M261.html 
53 53
  *
54 54
  */
55 55
 class TWIBus {

Loading…
Cancel
Save