Skip to content

Commit

Permalink
🎨 Move HAS_EXTRUDERS
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed May 21, 2021
1 parent ad30909 commit 2de54da
Show file tree
Hide file tree
Showing 25 changed files with 63 additions and 52 deletions.
2 changes: 1 addition & 1 deletion Marlin/src/feature/powerloss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW
#endif
#endif

#if EXTRUDERS
#if HAS_EXTRUDERS
HOTEND_LOOP() info.target_temperature[e] = thermalManager.degTargetHotend(e);
#endif

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/config/M221.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "../gcode.h"
#include "../../module/planner.h"

#if EXTRUDERS
#if HAS_EXTRUDERS

/**
* M221: Set extrusion percentage (M221 T0 S95)
Expand Down
10 changes: 6 additions & 4 deletions Marlin/src/gcode/gcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
case 100: M100(); break; // M100: Free Memory Report
#endif

#if EXTRUDERS
#if HAS_EXTRUDERS
case 104: M104(); break; // M104: Set hot end temperature
case 109: M109(); break; // M109: Wait for hotend temperature to reach target
#endif
Expand Down Expand Up @@ -596,8 +596,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
#endif
case 81: M81(); break; // M81: Turn off Power, including Power Supply, if possible

case 82: M82(); break; // M82: Set E axis normal mode (same as other axes)
case 83: M83(); break; // M83: Set E axis relative mode
#if HAS_EXTRUDERS
case 82: M82(); break; // M82: Set E axis normal mode (same as other axes)
case 83: M83(); break; // M83: Set E axis relative mode
#endif
case 18: case 84: M18_M84(); break; // M18/M84: Disable Steppers / Set Timeout
case 85: M85(); break; // M85: Set inactivity stepper shutdown timeout
case 92: M92(); break; // M92: Set the steps-per-unit for one or more axes
Expand Down Expand Up @@ -674,7 +676,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {

case 220: M220(); break; // M220: Set Feedrate Percentage: S<percent> ("FR" on your LCD)

#if EXTRUDERS
#if HAS_EXTRUDERS
case 221: M221(); break; // M221: Set Flow Percentage
#endif

Expand Down
13 changes: 8 additions & 5 deletions Marlin/src/gcode/gcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -633,18 +633,21 @@ class GcodeSuite {
#if ENABLED(PSU_CONTROL)
static void M80();
#endif

static void M81();
static void M82();
static void M83();

#if HAS_EXTRUDERS
static void M82();
static void M83();
#endif

static void M85();
static void M92();

#if ENABLED(M100_FREE_MEMORY_WATCHER)
static void M100();
#endif

#if EXTRUDERS
#if HAS_EXTRUDERS
static void M104();
static void M109();
#endif
Expand Down Expand Up @@ -776,7 +779,7 @@ class GcodeSuite {

static void M220();

#if EXTRUDERS
#if HAS_EXTRUDERS
static void M221();
#endif

Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/gcode/host/M360.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "../../module/motion.h"
#include "../../module/planner.h"

#if EXTRUDERS
#if HAS_EXTRUDERS
#include "../../module/temperature.h"
#endif

Expand Down Expand Up @@ -171,7 +171,7 @@ void GcodeSuite::M360() {
// Per-Extruder settings
//
config_line(PSTR("NumExtruder"), EXTRUDERS);
#if EXTRUDERS
#if HAS_EXTRUDERS
LOOP_L_N(e, EXTRUDERS) {
config_line_e(e, JERK_STR, TERN(HAS_LINEAR_E_JERK, planner.max_e_jerk[E_INDEX_N(e)], TERN(HAS_CLASSIC_JERK, planner.max_jerk.e, DEFAULT_EJERK)));
config_line_e(e, PSTR("MaxSpeed"), planner.settings.max_feedrate_mm_s[E_AXIS_N(e)]);
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/temp/M104_M109.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#include "../../inc/MarlinConfigPre.h"

#if EXTRUDERS
#if HAS_EXTRUDERS

#include "../gcode.h"
#include "../../module/temperature.h"
Expand Down
6 changes: 6 additions & 0 deletions Marlin/src/gcode/units/M82_M83.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
*
*/

#include "../../inc/MarlinConfigPre.h"

#if HAS_EXTRUDERS

#include "../gcode.h"

/**
Expand All @@ -31,3 +35,5 @@ void GcodeSuite::M82() { set_e_absolute(); }
* M83: Set E codes relative while in Absolute Coordinates (G90) mode
*/
void GcodeSuite::M83() { set_e_relative(); }

#endif // HAS_EXTRUDERS
11 changes: 7 additions & 4 deletions Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -538,16 +538,19 @@
* E_MANUAL - Number of E steppers for LCD move options
*/

#if EXTRUDERS == 0
#if EXTRUDERS
#define HAS_EXTRUDERS 1
#if EXTRUDERS > 1
#define HAS_MULTI_EXTRUDER 1
#endif
#else
#undef EXTRUDERS
#define EXTRUDERS 0
#undef SINGLENOZZLE
#undef SWITCHING_EXTRUDER
#undef SWITCHING_NOZZLE
#undef MIXING_EXTRUDER
#undef HOTEND_IDLE_TIMEOUT
#elif EXTRUDERS > 1
#define HAS_MULTI_EXTRUDER 1
#endif

#if ENABLED(SWITCHING_EXTRUDER) // One stepper for every two EXTRUDERS
Expand Down Expand Up @@ -663,7 +666,7 @@
* All the logical axes that can be commanded directly by G-code.
* Delta maps stepper-specific values to ABC steppers.
*/
#if EXTRUDERS
#if HAS_EXTRUDERS
#define LOGICAL_AXES INCREMENT(LINEAR_AXES)
#else
#define LOGICAL_AXES LINEAR_AXES
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/inc/Conditionals_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
#define SERVO_DELAY { 50 }
#endif

#if EXTRUDERS == 0
#if !HAS_EXTRUDERS
#define NO_VOLUMETRICS
#undef TEMP_SENSOR_0
#undef TEMP_SENSOR_1
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -1555,7 +1555,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#endif

#if ENABLED(G26_MESH_VALIDATION)
#if !EXTRUDERS
#if !HAS_EXTRUDERS
#error "G26_MESH_VALIDATION requires at least one extruder."
#elif !HAS_MESH
#error "G26_MESH_VALIDATION requires MESH_BED_LEVELING, AUTO_BED_LEVELING_BILINEAR, or AUTO_BED_LEVELING_UBL."
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/HD44780/marlinui_HD44780.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ void MarlinUI::draw_status_screen() {
else
#endif
{
#if EXTRUDERS
#if HAS_EXTRUDERS
c = 'E';
per = planner.flow_percentage[0];
#endif
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ void DGUSScreenHandler::HandleTemperatureChanged(DGUS_VP_Variable &var, void *va
}

void DGUSScreenHandler::HandleFlowRateChanged(DGUS_VP_Variable &var, void *val_ptr) {
#if EXTRUDERS
#if HAS_EXTRUDERS
uint16_t newvalue = swap16(*(uint16_t*)val_ptr);
uint8_t target_extruder;
switch (var.VP) {
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/lcd/menu/menu_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void menu_info_thermistors() {

START_SCREEN();

#if EXTRUDERS
#if HAS_EXTRUDERS
#define THERMISTOR_ID TEMP_SENSOR_0
#include "../thermistornames.h"
STATIC_ITEM_P(PSTR(LCD_STR_E0 ": " THERMISTOR_NAME), SS_INVERT);
Expand Down Expand Up @@ -171,7 +171,7 @@ void menu_info_thermistors() {
PSTRING_ITEM(MSG_INFO_MAX_TEMP, STRINGIFY(HEATER_7_MAXTEMP), SS_LEFT);
#endif

#if EXTRUDERS
#if HAS_EXTRUDERS
STATIC_ITEM(TERN(WATCH_HOTENDS, MSG_INFO_RUNAWAY_ON, MSG_INFO_RUNAWAY_OFF), SS_LEFT);
#endif

Expand Down Expand Up @@ -278,7 +278,7 @@ void menu_info() {
#else
SUBMENU(MSG_INFO_PRINTER_MENU, menu_info_printer); // Printer Info >
SUBMENU(MSG_INFO_BOARD_MENU, menu_info_board); // Board Info >
#if EXTRUDERS
#if HAS_EXTRUDERS
SUBMENU(MSG_INFO_THERMISTOR_MENU, menu_info_thermistors); // Thermistors >
#endif
#endif
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/menu/menu_tune.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ void menu_tune() {
//
// Flow:
//
#if EXTRUDERS
#if HAS_EXTRUDERS
EDIT_ITEM(int3, MSG_FLOW, &planner.flow_percentage[active_extruder], 10, 999, []{ planner.refresh_e_factor(active_extruder); });
// Flow En:
#if HAS_MULTI_EXTRUDER
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/module/motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ void line_to_current_position(const_feedRate_t fr_mm_s/*=feedrate_mm_s*/) {
planner.buffer_line(current_position, fr_mm_s, active_extruder);
}

#if EXTRUDERS
#if HAS_EXTRUDERS
void unscaled_e_move(const_float_t length, const_feedRate_t fr_mm_s) {
TERN_(HAS_FILAMENT_SENSOR, runout.reset());
current_position.e += length / planner.e_factor[active_extruder];
Expand Down Expand Up @@ -421,7 +421,7 @@ void _internal_move_to_destination(const_feedRate_t fr_mm_s/*=0.0f*/
const uint16_t old_pct = feedrate_percentage;
feedrate_percentage = 100;

#if EXTRUDERS
#if HAS_EXTRUDERS
const float old_fac = planner.e_factor[active_extruder];
planner.e_factor[active_extruder] = 1.0f;
#endif
Expand All @@ -433,7 +433,7 @@ void _internal_move_to_destination(const_feedRate_t fr_mm_s/*=0.0f*/

feedrate_mm_s = old_feedrate;
feedrate_percentage = old_pct;
#if EXTRUDERS
#if HAS_EXTRUDERS
planner.e_factor[active_extruder] = old_fac;
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/motion.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ void sync_plan_position_e();
*/
void line_to_current_position(const_feedRate_t fr_mm_s=feedrate_mm_s);

#if EXTRUDERS
#if HAS_EXTRUDERS
void unscaled_e_move(const_float_t length, const_feedRate_t fr_mm_s);
#endif

Expand Down
18 changes: 9 additions & 9 deletions Marlin/src/module/planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ float Planner::steps_to_mm[DISTINCT_AXES]; // (mm) Millimeters per step
xyze_bool_t Planner::last_page_dir{0};
#endif

#if EXTRUDERS
#if HAS_EXTRUDERS
int16_t Planner::flow_percentage[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(100); // Extrusion factor for each extruder
float Planner::e_factor[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(1.0f); // The flow percentage and volumetric multiplier combine to scale E movement
#endif
Expand Down Expand Up @@ -1836,7 +1836,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
db = target.b - position.b,
dc = target.c - position.c;

#if EXTRUDERS
#if HAS_EXTRUDERS
int32_t de = target.e - position.e;
#else
constexpr int32_t de = 0;
Expand All @@ -1848,7 +1848,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
" A:", target.a, " (", da, " steps)"
" B:", target.b, " (", db, " steps)"
" C:", target.c, " (", dc, " steps)"
#if EXTRUDERS
#if HAS_EXTRUDERS
" E:", target.e, " (", de, " steps)"
#endif
);
Expand Down Expand Up @@ -1921,7 +1921,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
#endif
if (de < 0) SBI(dm, E_AXIS);

#if EXTRUDERS
#if HAS_EXTRUDERS
const float esteps_float = de * e_factor[extruder];
const uint32_t esteps = ABS(esteps_float) + 0.5f;
#else
Expand Down Expand Up @@ -2003,7 +2003,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
steps_dist_mm.c = dc * steps_to_mm[C_AXIS];
#endif

#if EXTRUDERS
#if HAS_EXTRUDERS
steps_dist_mm.e = esteps_float * steps_to_mm[E_AXIS_N(extruder)];
#else
steps_dist_mm.e = 0.0f;
Expand All @@ -2013,7 +2013,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,

if (block->steps.a < MIN_STEPS_PER_SEGMENT && block->steps.b < MIN_STEPS_PER_SEGMENT && block->steps.c < MIN_STEPS_PER_SEGMENT) {
block->millimeters = (0
#if EXTRUDERS
#if HAS_EXTRUDERS
+ ABS(steps_dist_mm.e)
#endif
);
Expand Down Expand Up @@ -2046,7 +2046,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
TERN_(BACKLASH_COMPENSATION, backlash.add_correction_steps(da, db, dc, dm, block));
}

#if EXTRUDERS
#if HAS_EXTRUDERS
block->steps.e = esteps;
#endif

Expand Down Expand Up @@ -2107,7 +2107,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
#endif

// Enable extruder(s)
#if EXTRUDERS
#if HAS_EXTRUDERS
if (esteps) {
TERN_(AUTO_POWER_CONTROL, powerManager.power_on());

Expand Down Expand Up @@ -2209,7 +2209,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
}

// Limit speed on extruders, if any
#if EXTRUDERS
#if HAS_EXTRUDERS
{
current_speed.e = steps_dist_mm.e * inverse_secs;
#if HAS_MIXER_SYNC_CHANNEL
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/module/planner.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ class Planner {
static xyze_bool_t last_page_dir; // Last page direction given
#endif

#if EXTRUDERS
#if HAS_EXTRUDERS
static int16_t flow_percentage[EXTRUDERS]; // Extrusion factor for each extruder
static float e_factor[EXTRUDERS]; // The flow percentage and volumetric multiplier combine to scale E movement
#endif
Expand Down Expand Up @@ -494,7 +494,7 @@ class Planner {
static inline void set_max_jerk(const AxisEnum, const_float_t ) {}
#endif

#if EXTRUDERS
#if HAS_EXTRUDERS
FORCE_INLINE static void refresh_e_factor(const uint8_t e) {
e_factor[e] = flow_percentage[e] * 0.01f * TERN(NO_VOLUMETRICS, 1.0f, volumetric_multiplier[e]);
}
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/module/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ typedef struct SettingsDataStruct {
//
// ADVANCED_PAUSE_FEATURE
//
#if EXTRUDERS
#if HAS_EXTRUDERS
fil_change_settings_t fc_settings[EXTRUDERS]; // M603 T U L
#endif

Expand Down Expand Up @@ -1321,7 +1321,7 @@ void MarlinSettings::postprocess() {
//
// Advanced Pause filament load & unload lengths
//
#if EXTRUDERS
#if HAS_EXTRUDERS
{
#if DISABLED(ADVANCED_PAUSE_FEATURE)
const fil_change_settings_t fc_settings[EXTRUDERS] = { 0, 0 };
Expand Down Expand Up @@ -2235,7 +2235,7 @@ void MarlinSettings::postprocess() {
//
// Advanced Pause filament load & unload lengths
//
#if EXTRUDERS
#if HAS_EXTRUDERS
{
#if DISABLED(ADVANCED_PAUSE_FEATURE)
fil_change_settings_t fc_settings[EXTRUDERS];
Expand Down
Loading

0 comments on commit 2de54da

Please sign in to comment.