Skip to content

Commit

Permalink
🎨 Misc code and spacing cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Sep 13, 2021
1 parent 0aa87af commit dc5ae16
Show file tree
Hide file tree
Showing 24 changed files with 79 additions and 159 deletions.
2 changes: 1 addition & 1 deletion Marlin/src/core/serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ extern uint8_t marlin_debug_flags;
#if HAS_MULTI_SERIAL
#define _PORT_REDIRECT(n,p) REMEMBER(n,multiSerial.portMask,p)
#define _PORT_RESTORE(n,p) RESTORE(n)
#define SERIAL_ASSERT(P) if(multiSerial.portMask!=(P)){ debugger(); }
#define SERIAL_ASSERT(P) if (multiSerial.portMask!=(P)) { debugger(); }
// If we have a catchall, use that directly
#ifdef SERIAL_CATCHALL
#define _SERIAL_LEAF_2 SERIAL_CATCHALL
Expand Down
14 changes: 6 additions & 8 deletions Marlin/src/feature/mixing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,12 @@ void Mixer::refresh_collector(const float proportion/*=1.0*/, const uint8_t t/*=
#include "../module/planner.h"

gradient_t Mixer::gradient = {
false, // enabled
{0}, // color (array)
0, 0, // start_z, end_z
0, 1, // start_vtool, end_vtool
{0}, {0} // start_mix[], end_mix[]
#if ENABLED(GRADIENT_VTOOL)
, -1 // vtool_index
#endif
false, // enabled
{0}, // color (array)
0, 0, // start_z, end_z
0, 1, // start_vtool, end_vtool
{0}, {0} // start_mix[], end_mix[]
OPTARG(GRADIENT_VTOOL, -1) // vtool_index
};

float Mixer::prev_z; // = 0
Expand Down
9 changes: 5 additions & 4 deletions Marlin/src/feature/pause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,14 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load

KEEPALIVE_STATE(PAUSED_FOR_USER);
wait_for_user = true; // LCD click or M108 will clear this

TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("Load Filament")));

#if ENABLED(HOST_PROMPT_SUPPORT)
const char tool = '0' + TERN0(MULTI_FILAMENT_SENSOR, active_extruder);
host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Load Filament T"), tool, CONTINUE_STR);
#endif

TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("Load Filament")));

while (wait_for_user) {
impatient_beep(max_beep_count);
idle_no_sleep();
Expand Down Expand Up @@ -237,8 +238,8 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load

if (show_lcd) ui.pause_show_message(PAUSE_MESSAGE_PURGE);

TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Filament Purging..."), CONTINUE_STR));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired_P(PSTR("Filament Purging...")));
TERN_(HOST_PROMPT_SUPPORT, host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Filament Purging..."), CONTINUE_STR));
wait_for_user = true; // A click or M108 breaks the purge_length loop
for (float purge_count = purge_length; purge_count > 0 && wait_for_user; --purge_count)
unscaled_e_move(1, ADVANCED_PAUSE_PURGE_FEEDRATE);
Expand Down Expand Up @@ -272,7 +273,7 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load
#endif

// Keep looping if "Purge More" was selected
} while (TERN0(M600_PURGE_MORE_RESUMABLE, show_lcd && pause_menu_response == PAUSE_RESPONSE_EXTRUDE_MORE));
} while (TERN0(M600_PURGE_MORE_RESUMABLE, pause_menu_response == PAUSE_RESPONSE_EXTRUDE_MORE));

#endif
TERN_(HOST_PROMPT_SUPPORT, host_action_prompt_end());
Expand Down
8 changes: 2 additions & 6 deletions Marlin/src/feature/probe_temp_comp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,12 @@ int16_t ProbeTempComp::z_offsets_probe[cali_info_init[TSI_PROBE].measurements],

int16_t *ProbeTempComp::sensor_z_offsets[TSI_COUNT] = {
ProbeTempComp::z_offsets_probe, ProbeTempComp::z_offsets_bed
#if ENABLED(USE_TEMP_EXT_COMPENSATION)
, ProbeTempComp::z_offsets_ext
#endif
OPTARG(USE_TEMP_EXT_COMPENSATION, ProbeTempComp::z_offsets_ext)
};

const temp_calib_t ProbeTempComp::cali_info[TSI_COUNT] = {
cali_info_init[TSI_PROBE], cali_info_init[TSI_BED]
#if ENABLED(USE_TEMP_EXT_COMPENSATION)
, cali_info_init[TSI_EXT]
#endif
OPTARG(USE_TEMP_EXT_COMPENSATION, cali_info_init[TSI_EXT])
};

constexpr xyz_pos_t ProbeTempComp::park_point;
Expand Down
4 changes: 1 addition & 3 deletions Marlin/src/gcode/bedlevel/abl/G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -878,9 +878,7 @@ G29_TYPE GcodeSuite::G29() {
// Sync the planner from the current_position
if (planner.leveling_active) sync_plan_position();

#if HAS_BED_PROBE
probe.move_z_after_probing();
#endif
TERN_(HAS_BED_PROBE, probe.move_z_after_probing());

#ifdef Z_PROBE_END_SCRIPT
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Z Probe End Script: ", Z_PROBE_END_SCRIPT);
Expand Down
13 changes: 2 additions & 11 deletions Marlin/src/gcode/feature/camera/M240.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,8 @@ void GcodeSuite::M240() {
};

#ifdef PHOTO_RETRACT_MM
const float rval = parser.seenval('R') ? parser.value_linear_units() : _PHOTO_RETRACT_MM;
feedRate_t sval = (
#if ENABLED(ADVANCED_PAUSE_FEATURE)
PAUSE_PARK_RETRACT_FEEDRATE
#elif ENABLED(FWRETRACT)
RETRACT_FEEDRATE
#else
45
#endif
);
if (parser.seenval('S')) sval = parser.value_feedrate();
const float rval = parser.linearval('R', _PHOTO_RETRACT_MM);
const feedRate_t sval = parser.feedrateval('S', TERN(ADVANCED_PAUSE_FEATURE, PAUSE_PARK_RETRACT_FEEDRATE, TERN(FWRETRACT, RETRACT_FEEDRATE, 45)));
e_move_m240(-rval, sval);
#endif

Expand Down
11 changes: 1 addition & 10 deletions Marlin/src/gcode/feature/fwretract/G10_G11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,7 @@
* G10 - Retract filament according to settings of M207
* TODO: Handle 'G10 P' for tool settings and 'G10 L' for workspace settings
*/
void GcodeSuite::G10() {
#if HAS_MULTI_EXTRUDER
const bool rs = parser.boolval('S');
#endif
fwretract.retract(true
#if HAS_MULTI_EXTRUDER
, rs
#endif
);
}
void GcodeSuite::G10() { fwretract.retract(true OPTARG(HAS_MULTI_EXTRUDER, parser.boolval('S'))); }

/**
* G11 - Recover filament according to settings of M208
Expand Down
4 changes: 1 addition & 3 deletions Marlin/src/gcode/feature/pause/M701_M702.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ void GcodeSuite::M701() {
true, // show_lcd
thermalManager.still_heating(target_extruder), // pause_for_user
PAUSE_MODE_LOAD_FILAMENT // pause_mode
#if ENABLED(DUAL_X_CARRIAGE)
, target_extruder // Dual X target
#endif
OPTARG(DUAL_X_CARRIAGE, target_extruder) // Dual X target
);
#endif

Expand Down
3 changes: 2 additions & 1 deletion Marlin/src/gcode/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,8 @@ class GCodeParser {
static inline float linearval(const char c, const float dval=0) { return seenval(c) ? value_linear_units() : dval; }
static inline float axisunitsval(const char c, const AxisEnum a, const float dval=0)
{ return seenval(c) ? value_axis_units(a) : dval; }
static inline celsius_t celsiusval(const char c, const float dval=0) { return seenval(c) ? value_celsius() : dval; }
static inline celsius_t celsiusval(const char c, const celsius_t dval=0) { return seenval(c) ? value_celsius() : dval; }
static inline feedRate_t feedrateval(const char c, const feedRate_t dval=0) { return seenval(c) ? value_feedrate() : dval; }

#if ENABLED(MARLIN_DEV_MODE)

Expand Down
12 changes: 2 additions & 10 deletions Marlin/src/gcode/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,7 @@ bool GCodeQueue::RingBuffer::enqueue(const char *cmd, bool skip_ok/*=true*/
) {
if (*cmd == ';' || length >= BUFSIZE) return false;
strcpy(commands[index_w].buffer, cmd);
commit_command(skip_ok
#if HAS_MULTI_SERIAL
, serial_ind
#endif
);
commit_command(skip_ok OPTARG(HAS_MULTI_SERIAL, serial_ind));
return true;
}

Expand Down Expand Up @@ -538,11 +534,7 @@ void GCodeQueue::get_serial_commands() {
#endif

// Add the command to the queue
ring_buffer.enqueue(serial.line_buffer, false
#if HAS_MULTI_SERIAL
, p
#endif
);
ring_buffer.enqueue(serial.line_buffer, false OPTARG(HAS_MULTI_SERIAL, p));
}
else
process_stream_char(serial_char, serial.input_state, serial.line_buffer, serial.count);
Expand Down
12 changes: 6 additions & 6 deletions Marlin/src/inc/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,18 @@
* Currently only supported by DUE platform
*/
#ifndef USB_DEVICE_VENDOR_ID
#define USB_DEVICE_VENDOR_ID 0x03EB /* ATMEL VID */
#define USB_DEVICE_VENDOR_ID 0x03EB /* ATMEL VID */
#endif
#ifndef USB_DEVICE_PRODUCT_ID
#define USB_DEVICE_PRODUCT_ID 0x2424 /* MSC / CDC */
#define USB_DEVICE_PRODUCT_ID 0x2424 /* MSC / CDC */
#endif
//! USB Device string definitions (Optional)
#ifndef USB_DEVICE_MANUFACTURE_NAME
#define USB_DEVICE_MANUFACTURE_NAME WEBSITE_URL
#define USB_DEVICE_MANUFACTURE_NAME WEBSITE_URL
#endif
#ifdef CUSTOM_MACHINE_NAME
#define USB_DEVICE_PRODUCT_NAME CUSTOM_MACHINE_NAME
#define USB_DEVICE_PRODUCT_NAME CUSTOM_MACHINE_NAME
#else
#define USB_DEVICE_PRODUCT_NAME MACHINE_NAME
#define USB_DEVICE_PRODUCT_NAME MACHINE_NAME
#endif
#define USB_DEVICE_SERIAL_NAME "123985739853"
#define USB_DEVICE_SERIAL_NAME "123985739853"
4 changes: 1 addition & 3 deletions Marlin/src/lcd/dogm/u8g_dev_tft_upscale_from_128x64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,7 @@ uint8_t u8g_dev_tft_320x240_upscale_from_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, u

LOOP_L_N(y, PAGE_HEIGHT) {
uint32_t k = 0;
#if HAS_LCD_IO
buffer = (y & 1) ? bufferB : bufferA;
#endif
TERN_(HAS_LCD_IO, buffer = (y & 1) ? bufferB : bufferA);
for (uint16_t i = 0; i < (uint32_t)pb->width; i++) {
const uint8_t b = *(((uint8_t *)pb->buf) + i);
const uint16_t c = TEST(b, y) ? TFT_MARLINUI_COLOR : TFT_MARLINBG_COLOR;
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/extui/dgus/dgus_extui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ namespace ExtUI {
ScreenHandler.SetupConfirmAction(setUserConfirmed);
ScreenHandler.GotoScreen(DGUSLCD_SCREEN_POPUP);
}
else if (ScreenHandler.getCurrentScreen() == DGUSLCD_SCREEN_POPUP ) {
else if (ScreenHandler.getCurrentScreen() == DGUSLCD_SCREEN_POPUP) {
ScreenHandler.SetupConfirmAction(nullptr);
ScreenHandler.PopToOldScreen();
}
Expand Down
4 changes: 1 addition & 3 deletions Marlin/src/lcd/menu/menu_advanced.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,9 +569,7 @@ void menu_advanced_settings() {
SUBMENU(MSG_JERK, menu_advanced_jerk);
#elif HAS_JUNCTION_DEVIATION
EDIT_ITEM(float43, MSG_JUNCTION_DEVIATION, &planner.junction_deviation_mm, 0.001f, 0.3f
#if ENABLED(LIN_ADVANCE)
, planner.recalculate_max_e_jerk
#endif
OPTARG(LIN_ADVANCE, planner.recalculate_max_e_jerk)
);
#endif

Expand Down
4 changes: 1 addition & 3 deletions Marlin/src/lcd/menu/menu_ubl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,7 @@ void _lcd_ubl_edit_mesh() {
char ubl_lcd_gcode[20];
sprintf_P(ubl_lcd_gcode, PSTR("G28\nG26CPH%" PRIi16 TERN_(HAS_HEATED_BED, "B%" PRIi16))
, custom_hotend_temp
#if HAS_HEATED_BED
, custom_bed_temp
#endif
OPTARG(HAS_HEATED_BED, custom_bed_temp)
);
queue.inject(ubl_lcd_gcode);
}
Expand Down
44 changes: 10 additions & 34 deletions Marlin/src/module/planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1388,9 +1388,7 @@ void Planner::check_axes_activity() {
// Update Fan speeds
// Only if synchronous M106/M107 is disabled
//
#if HAS_TAIL_FAN_SPEED
sync_fan_speeds(tail_fan_speed);
#endif
TERN_(HAS_TAIL_FAN_SPEED, sync_fan_speeds(tail_fan_speed));

TERN_(AUTOTEMP, autotemp_task());

Expand Down Expand Up @@ -1585,11 +1583,7 @@ void Planner::check_axes_activity() {

raw.z += (
#if ENABLED(MESH_BED_LEVELING)
mbl.get_z(raw
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
, fade_scaling_factor
#endif
)
mbl.get_z(raw OPTARG(ENABLE_LEVELING_FADE_HEIGHT, fade_scaling_factor))
#elif ENABLED(AUTO_BED_LEVELING_UBL)
fade_scaling_factor ? fade_scaling_factor * ubl.get_z_correction(raw) : 0.0
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
Expand Down Expand Up @@ -1622,11 +1616,7 @@ void Planner::check_axes_activity() {

raw.z -= (
#if ENABLED(MESH_BED_LEVELING)
mbl.get_z(raw
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
, fade_scaling_factor
#endif
)
mbl.get_z(raw OPTARG(ENABLE_LEVELING_FADE_HEIGHT, fade_scaling_factor))
#elif ENABLED(AUTO_BED_LEVELING_UBL)
fade_scaling_factor ? fade_scaling_factor * ubl.get_z_correction(raw) : 0.0
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
Expand Down Expand Up @@ -1811,12 +1801,8 @@ bool Planner::_buffer_steps(const xyze_long_t &target

// Fill the block with the specified movement
if (!_populate_block(block, false, target
#if HAS_POSITION_FLOAT
, target_float
#endif
#if HAS_DIST_MM_ARG
, cart_dist_mm
#endif
OPTARG(HAS_POSITION_FLOAT, target_float)
OPTARG(HAS_DIST_MM_ARG, cart_dist_mm)
, fr_mm_s, extruder, millimeters
)) {
// Movement was not queued, probably because it was too short.
Expand Down Expand Up @@ -1975,9 +1961,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
#endif
#endif

#if HAS_EXTRUDERS
if (de < 0) SBI(dm, E_AXIS);
#endif
TERN_(HAS_EXTRUDERS, if (de < 0) SBI(dm, E_AXIS));

#if HAS_EXTRUDERS
const float esteps_float = de * e_factor[extruder];
Expand Down Expand Up @@ -2075,9 +2059,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
);
#endif

#if HAS_EXTRUDERS
steps_dist_mm.e = esteps_float * steps_to_mm[E_AXIS_N(extruder)];
#endif
TERN_(HAS_EXTRUDERS, steps_dist_mm.e = esteps_float * steps_to_mm[E_AXIS_N(extruder)]);

TERN_(LCD_SHOW_E_TOTAL, e_move_accumulator += steps_dist_mm.e);

Expand Down Expand Up @@ -2162,9 +2144,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
block->e_to_p_pressure = baricuda_e_to_p_pressure;
#endif

#if HAS_MULTI_EXTRUDER
block->extruder = extruder;
#endif
TERN_(HAS_MULTI_EXTRUDER, block->extruder = extruder);

#if ENABLED(AUTO_POWER_CONTROL)
if (LINEAR_AXIS_GANG(
Expand Down Expand Up @@ -2986,12 +2966,8 @@ bool Planner::buffer_segment(const abce_pos_t &abce

// Queue the movement. Return 'false' if the move was not queued.
if (!_buffer_steps(target
#if HAS_POSITION_FLOAT
, target_float
#endif
#if HAS_DIST_MM_ARG
, cart_dist_mm
#endif
OPTARG(HAS_POSITION_FLOAT, target_float)
OPTARG(HAS_DIST_MM_ARG, cart_dist_mm)
, fr_mm_s, extruder, millimeters)
) return false;

Expand Down
8 changes: 2 additions & 6 deletions Marlin/src/module/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2555,9 +2555,7 @@ void MarlinSettings::reset() {
TERN_(HAS_CLASSIC_E_JERK, planner.max_jerk.e = DEFAULT_EJERK);
#endif

#if HAS_JUNCTION_DEVIATION
planner.junction_deviation_mm = float(JUNCTION_DEVIATION_MM);
#endif
TERN_(HAS_JUNCTION_DEVIATION, planner.junction_deviation_mm = float(JUNCTION_DEVIATION_MM));

#if HAS_SCARA_OFFSET
scara_home_offset.reset();
Expand Down Expand Up @@ -3151,9 +3149,7 @@ void MarlinSettings::reset() {

CONFIG_ECHO_HEADING(
"Advanced: B<min_segment_time_us> S<min_feedrate> T<min_travel_feedrate>"
#if HAS_JUNCTION_DEVIATION
" J<junc_dev>"
#endif
TERN_(HAS_JUNCTION_DEVIATION, " J<junc_dev>")
#if HAS_CLASSIC_JERK
" X<max_x_jerk> Y<max_y_jerk> Z<max_z_jerk>"
TERN_(HAS_CLASSIC_E_JERK, " E<max_e_jerk>")
Expand Down
10 changes: 3 additions & 7 deletions Marlin/src/module/stepper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1428,14 +1428,10 @@ void Stepper::isr() {

// Get the interval to the next ISR call
const uint32_t interval = _MIN(
uint32_t(HAL_TIMER_TYPE_MAX), // Come back in a very long time
nextMainISR // Time until the next Pulse / Block phase
#if ENABLED(LIN_ADVANCE)
, nextAdvanceISR // Come back early for Linear Advance?
#endif
#if ENABLED(INTEGRATED_BABYSTEPPING)
, nextBabystepISR // Come back early for Babystepping?
#endif
, uint32_t(HAL_TIMER_TYPE_MAX) // Come back in a very long time
OPTARG(LIN_ADVANCE, nextAdvanceISR) // Come back early for Linear Advance?
OPTARG(INTEGRATED_BABYSTEPPING, nextBabystepISR) // Come back early for Babystepping?
);

//
Expand Down
Loading

0 comments on commit dc5ae16

Please sign in to comment.