From 941943c167bac5908203e7ae98f3b9f485c9fe1a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 27 Jun 2017 02:36:19 -0500 Subject: [PATCH] Apply const, spacing, etc. --- Marlin/M100_Free_Mem_Chk.cpp | 20 +++++----- Marlin/Marlin_main.cpp | 37 ++++++++++--------- Marlin/SdFatStructs.h | 2 +- Marlin/example_configurations/K8400/README.md | 2 +- Marlin/servo.cpp | 2 +- Marlin/twibus.h | 22 +++++------ 6 files changed, 43 insertions(+), 42 deletions(-) diff --git a/Marlin/M100_Free_Mem_Chk.cpp b/Marlin/M100_Free_Mem_Chk.cpp index be418b049..6620b0a16 100644 --- a/Marlin/M100_Free_Mem_Chk.cpp +++ b/Marlin/M100_Free_Mem_Chk.cpp @@ -189,19 +189,17 @@ void free_memory_pool_report(char * const ptr, const int16_t size) { * This is useful to check the correctness of the M100 D and the M100 F commands. */ void corrupt_free_memory(char *ptr, const uint16_t size) { - if (parser.seen('C')) { - ptr += 8; - const uint16_t near_top = top_of_stack() - ptr - 250, // -250 to avoid interrupt activity that's altered the stack. - j = near_top / (size + 1); + ptr += 8; + const uint16_t near_top = top_of_stack() - ptr - 250, // -250 to avoid interrupt activity that's altered the stack. + j = near_top / (size + 1); - SERIAL_ECHOLNPGM("Corrupting free memory block.\n"); - for (uint16_t i = 1; i <= size; i++) { - char * const addr = ptr + i * j; - *addr = i; - SERIAL_ECHOPAIR("\nCorrupting address: ", hex_address(addr)); - } - SERIAL_EOL(); + SERIAL_ECHOLNPGM("Corrupting free memory block.\n"); + for (uint16_t i = 1; i <= size; i++) { + char * const addr = ptr + i * j; + *addr = i; + SERIAL_ECHOPAIR("\nCorrupting address: ", hex_address(addr)); } + SERIAL_EOL(); } #endif // M100_FREE_MEMORY_CORRUPTOR diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 48cf72cc0..4ea5bdf11 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1276,16 +1276,17 @@ void get_available_commands() { * * Returns TRUE if the target is invalid */ -bool get_target_extruder_from_command(int code) { +bool get_target_extruder_from_command(const uint16_t code) { if (parser.seen('T')) { - if (parser.value_byte() >= EXTRUDERS) { + const int8_t e = parser.value_byte(); + if (e >= EXTRUDERS) { SERIAL_ECHO_START(); SERIAL_CHAR('M'); SERIAL_ECHO(code); - SERIAL_ECHOLNPAIR(" " MSG_INVALID_EXTRUDER " ", parser.value_byte()); + SERIAL_ECHOLNPAIR(" " MSG_INVALID_EXTRUDER " ", e); return true; } - target_extruder = parser.value_byte(); + target_extruder = e; } else target_extruder = active_extruder; @@ -5676,7 +5677,7 @@ inline void gcode_G92() { #if HAS_POSITION_SHIFT const float p = current_position[i]; #endif - float v = parser.value_axis_units((AxisEnum)i); + const float v = parser.value_axis_units((AxisEnum)i); current_position[i] = v; @@ -6405,7 +6406,7 @@ static bool pin_is_protected(const int8_t pin) { inline void gcode_M42() { if (!parser.seen('S')) return; - int pin_status = parser.value_int(); + const int pin_status = parser.value_int(); if (!WITHIN(pin_status, 0, 255)) return; int pin_number = parser.seen('P') ? parser.value_int() : LED_PIN; @@ -6645,7 +6646,7 @@ inline void gcode_M42() { */ inline void gcode_M43() { - if (parser.seen('T')) { // must be first or else it's "S" and "E" parameters will execute endstop or servo test + if (parser.seen('T')) { // must be first or else its "S" and "E" parameters will execute endstop or servo test toggle_pins(); return; } @@ -8268,10 +8269,10 @@ inline void gcode_M205() { home_offset[Z_AXIS] = parser.value_linear_units() - DELTA_HEIGHT; update_software_endstops(Z_AXIS); } - if (parser.seen('L')) delta_diagonal_rod = parser.value_linear_units(); - if (parser.seen('R')) delta_radius = parser.value_linear_units(); - if (parser.seen('S')) delta_segments_per_second = parser.value_float(); - if (parser.seen('B')) delta_calibration_radius = parser.value_float(); + if (parser.seen('L')) delta_diagonal_rod = parser.value_linear_units(); + if (parser.seen('R')) delta_radius = parser.value_linear_units(); + if (parser.seen('S')) delta_segments_per_second = parser.value_float(); + if (parser.seen('B')) delta_calibration_radius = parser.value_float(); if (parser.seen('X')) delta_tower_angle_trim[A_AXIS] = parser.value_float(); if (parser.seen('Y')) delta_tower_angle_trim[B_AXIS] = parser.value_float(); if (parser.seen('Z')) { // rotate all 3 axis for Z = 0 @@ -8580,7 +8581,7 @@ inline void gcode_M226() { */ inline void gcode_M280() { if (!parser.seen('P')) return; - int servo_index = parser.value_int(); + const int servo_index = parser.value_int(); if (WITHIN(servo_index, 0, NUM_SERVOS - 1)) { if (parser.seen('S')) MOVE_SERVO(servo_index, parser.value_int()); @@ -8753,7 +8754,7 @@ inline void gcode_M226() { * M302 S170 P1 ; set min extrude temp to 170 but leave disabled */ inline void gcode_M302() { - bool seen_S = parser.seen('S'); + const bool seen_S = parser.seen('S'); if (seen_S) { thermalManager.extrude_min_temp = parser.value_celsius(); thermalManager.allow_cold_extrude = (thermalManager.extrude_min_temp == 0); @@ -8960,10 +8961,12 @@ inline void gcode_M400() { stepper.synchronize(); } * M405: Turn on filament sensor for control */ inline void gcode_M405() { - // This is technically a linear measurement, but since it's quantized to centimeters and is a different unit than - // everything else, it uses parser.value_int() instead of parser.value_linear_units(). - if (parser.seen('D')) meas_delay_cm = parser.value_byte(); - NOMORE(meas_delay_cm, MAX_MEASUREMENT_DELAY); + // This is technically a linear measurement, but since it's quantized to centimeters and is a different + // unit than everything else, it uses parser.value_byte() instead of parser.value_linear_units(). + if (parser.seen('D')) { + meas_delay_cm = parser.value_byte(); + NOMORE(meas_delay_cm, MAX_MEASUREMENT_DELAY); + } if (filwidth_delay_index[1] == -1) { // Initialize the ring buffer if not done since startup const uint8_t temp_ratio = thermalManager.widthFil_to_size_ratio() - 100; // -100 to scale within a signed byte diff --git a/Marlin/SdFatStructs.h b/Marlin/SdFatStructs.h index 3e989dea9..3e78aa292 100644 --- a/Marlin/SdFatStructs.h +++ b/Marlin/SdFatStructs.h @@ -523,7 +523,7 @@ struct directoryEntry { uint8_t reservedNT; /** * The granularity of the seconds part of creationTime is 2 seconds - * so this field is a count of tenths of a second and its valid + * so this field is a count of tenths of a second and it's valid * value range is 0-199 inclusive. (WHG note - seems to be hundredths) */ uint8_t creationTimeTenths; diff --git a/Marlin/example_configurations/K8400/README.md b/Marlin/example_configurations/K8400/README.md index c9089b587..14c8f8362 100644 --- a/Marlin/example_configurations/K8400/README.md +++ b/Marlin/example_configurations/K8400/README.md @@ -2,7 +2,7 @@ http://www.k8400.eu/ Configuration files for the K8400, ported upstream from the official Velleman firmware. -Like it's predecessor, (K8200), the K8400 is a 3Drag clone. There are some minor differences, documented in pins_K8400.h. +Like its predecessor, (K8200), the K8400 is a 3Drag clone. There are some minor differences, documented in pins_K8400.h. Single and dual head configurations provided. Copy the correct Configuration.h and Configuration_adv.h to the /Marlin/ directory. diff --git a/Marlin/servo.cpp b/Marlin/servo.cpp index 3536571c1..74feb5c61 100644 --- a/Marlin/servo.cpp +++ b/Marlin/servo.cpp @@ -95,7 +95,7 @@ static inline void handle_interrupts(timer16_Sequence_t timer, volatile uint16_t if (SERVO_INDEX(timer, Channel[timer]) < ServoCount && Channel[timer] < SERVOS_PER_TIMER) { *OCRnA = *TCNTn + SERVO(timer, Channel[timer]).ticks; if (SERVO(timer, Channel[timer]).Pin.isActive) // check if activated - digitalWrite(SERVO(timer, Channel[timer]).Pin.nbr, HIGH); // its an active channel so pulse it high + digitalWrite(SERVO(timer, Channel[timer]).Pin.nbr, HIGH); // it's an active channel so pulse it high } else { // finished all channels so wait for the refresh period to expire before starting over diff --git a/Marlin/twibus.h b/Marlin/twibus.h index b93cd1c4c..5d4963934 100644 --- a/Marlin/twibus.h +++ b/Marlin/twibus.h @@ -38,18 +38,18 @@ typedef void (*twiRequestFunc_t)(); /** * TWIBUS class * - * This class implements a wrapper around the two wire (I2C) bus, it allows - * Marlin to send and request data from any slave device on the bus. This is - * an experimental feature and it's inner workings as well as public facing - * interface are prune to change in the future. + * This class implements a wrapper around the two wire (I2C) bus, allowing + * Marlin to send and request data from any slave device on the bus. * - * The two main consumers of this class are M260 and M261, where M260 allows - * Marlin to send a I2C packet to a device (please be aware that no repeated - * starts are possible), this can be done in caching method by calling multiple - * times M260 B or a one liner M260, have a look at - * the gcode_M260() function for more information. M261 allows Marlin to - * request data from a device, the received data is then relayed into the serial - * line for host interpretation. + * The two main consumers of this class are M260 and M261. M260 provides a way + * to send an I2C packet to a device (no repeated starts) by caching up to 32 + * bytes in a buffer and then sending the buffer. + * M261 requests data from a device. The received data is relayed to serial out + * for the host to interpret. + * + * For more information see + * - http://marlinfw.org/docs/gcode/M260.html + * - http://marlinfw.org/docs/gcode/M261.html * */ class TWIBus {