From 3facf34f5f7dc14093e4948a7350cf4edcb9a20a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 9 Oct 2020 16:42:23 -0500 Subject: [PATCH] Optional `M42`/`M226`; Add more features filters (#19664) --- Marlin/Configuration_adv.h | 5 ++ Marlin/src/gcode/control/M226.cpp | 6 +++ Marlin/src/gcode/control/M42.cpp | 7 ++- Marlin/src/gcode/gcode.cpp | 9 +++- Marlin/src/gcode/gcode.h | 9 ++-- Marlin/src/inc/MarlinConfig.h | 32 ++++++++---- Marlin/src/inc/MarlinConfigPre.h | 14 ++++-- Marlin/src/pins/pins.h | 2 +- .../PlatformIO/scripts/common-dependencies.h | 47 +++-------------- .../PlatformIO/scripts/common-dependencies.py | 8 ++- platformio.ini | 50 ++++++++++++++----- 11 files changed, 111 insertions(+), 78 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 8cc71ceb86..59a1813610 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3559,6 +3559,11 @@ // //#define M100_FREE_MEMORY_WATCHER +// +// M42 - Set pin states +// +//#define DIRECT_PIN_CONTROL + // // M43 - display pin status, toggle pins, watch pins, watch endstops & toggle LED, test servo probe // diff --git a/Marlin/src/gcode/control/M226.cpp b/Marlin/src/gcode/control/M226.cpp index 52e0e57a87..ad717e614d 100644 --- a/Marlin/src/gcode/control/M226.cpp +++ b/Marlin/src/gcode/control/M226.cpp @@ -20,6 +20,10 @@ * */ +#include "../../inc/MarlinConfig.h" + +#if ENABLED(DIRECT_PIN_CONTROL) + #include "../gcode.h" #include "../../MarlinCore.h" // for pin_is_protected and idle() #include "../../module/stepper.h" @@ -50,3 +54,5 @@ void GcodeSuite::M226() { } // pin_state -1 0 1 && pin > -1 } // parser.seen('P') } + +#endif // DIRECT_PIN_CONTROL diff --git a/Marlin/src/gcode/control/M42.cpp b/Marlin/src/gcode/control/M42.cpp index c88113db49..c635c06ec6 100644 --- a/Marlin/src/gcode/control/M42.cpp +++ b/Marlin/src/gcode/control/M42.cpp @@ -20,9 +20,12 @@ * */ +#include "../../inc/MarlinConfig.h" + +#if ENABLED(DIRECT_PIN_CONTROL) + #include "../gcode.h" #include "../../MarlinCore.h" // for pin_is_protected -#include "../../inc/MarlinConfig.h" #if HAS_FAN #include "../../module/temperature.h" @@ -96,3 +99,5 @@ void GcodeSuite::M42() { extDigitalWrite(pin, pin_status); analogWrite(pin, pin_status); } + +#endif // DIRECT_PIN_CONTROL diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 3d70b7c85c..cbf62e0fcf 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -445,7 +445,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { #endif // SDSUPPORT case 31: M31(); break; // M31: Report time since the start of SD print or last M109 - case 42: M42(); break; // M42: Change pin state + + #if ENABLED(DIRECT_PIN_CONTROL) + case 42: M42(); break; // M42: Change pin state + #endif #if ENABLED(PINS_DEBUGGING) case 43: M43(); break; // M43: Read pin state @@ -620,7 +623,9 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 221: M221(); break; // M221: Set Flow Percentage #endif - case 226: M226(); break; // M226: Wait until a pin reaches a state + #if ENABLED(DIRECT_PIN_CONTROL) + case 226: M226(); break; // M226: Wait until a pin reaches a state + #endif #if HAS_SERVOS case 280: M280(); break; // M280: Set servo position absolute diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index f21b7f89b1..73a3727813 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -109,7 +109,7 @@ * The '#' is necessary when calling from within sd files, as it stops buffer prereading * M33 - Get the longname version of a path. (Requires LONG_FILENAME_HOST_SUPPORT) * M34 - Set SD Card sorting options. (Requires SDCARD_SORT_ALPHA) - * M42 - Change pin status via gcode: M42 P S. LED pin assumed if P is omitted. + * M42 - Change pin status via gcode: M42 P S. LED pin assumed if P is omitted. (Requires DIRECT_PIN_CONTROL) * M43 - Display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins * M48 - Measure Z Probe repeatability: M48 P X Y V E L S. (Requires Z_MIN_PROBE_REPEATABILITY_TEST) * M73 - Set the progress percentage. (Requires LCD_SET_PROGRESS_MANUALLY) @@ -183,7 +183,7 @@ * M220 - Set Feedrate Percentage: "M220 S" (i.e., "FR" on the LCD) * Use "M220 B" to back up the Feedrate Percentage and "M220 R" to restore it. (Requires PRUSA_MMU2) * M221 - Set Flow Percentage: "M221 S" - * M226 - Wait until a pin is in a given state: "M226 P S" + * M226 - Wait until a pin is in a given state: "M226 P S" (Requires DIRECT_PIN_CONTROL) * M240 - Trigger a camera to take a photograph. (Requires PHOTO_GCODE) * M250 - Set LCD contrast: "M250 C" (0-63). (Requires LCD support) * M260 - i2c Send Data (Requires EXPERIMENTAL_I2CBUS) @@ -544,8 +544,7 @@ private: #endif #endif - static void M42(); - + TERN_(DIRECT_PIN_CONTROL, static void M42()); TERN_(PINS_DEBUGGING, static void M43()); TERN_(Z_MIN_PROBE_REPEATABILITY_TEST, static void M48()); @@ -673,7 +672,7 @@ private: static void M221(); #endif - static void M226(); + TERN_(DIRECT_PIN_CONTROL, static void M226()); TERN_(PHOTO_GCODE, static void M240()); diff --git a/Marlin/src/inc/MarlinConfig.h b/Marlin/src/inc/MarlinConfig.h index d1184cff5f..2eafa2b417 100644 --- a/Marlin/src/inc/MarlinConfig.h +++ b/Marlin/src/inc/MarlinConfig.h @@ -27,21 +27,31 @@ #include "MarlinConfigPre.h" -#include "../HAL/HAL.h" +#ifndef __MARLIN_DEPS__ + #include "../HAL/HAL.h" +#endif #include "../pins/pins.h" -#include HAL_PATH(../HAL, timers.h) -#include HAL_PATH(../HAL, spi_pins.h) + +#ifndef __MARLIN_DEPS__ + #include HAL_PATH(../HAL, timers.h) + #include HAL_PATH(../HAL, spi_pins.h) +#endif #include "Conditionals_post.h" -#include HAL_PATH(../HAL, inc/Conditionals_post.h) -#include "../core/types.h" // Ahead of sanity-checks +#ifndef __MARLIN_DEPS__ -#include "SanityCheck.h" -#include HAL_PATH(../HAL, inc/SanityCheck.h) + #include HAL_PATH(../HAL, inc/Conditionals_post.h) -// Include all core headers -#include "../core/language.h" -#include "../core/utility.h" -#include "../core/serial.h" + #include "../core/types.h" // Ahead of sanity-checks + + #include "SanityCheck.h" + #include HAL_PATH(../HAL, inc/SanityCheck.h) + + // Include all core headers + #include "../core/language.h" + #include "../core/utility.h" + #include "../core/serial.h" + +#endif diff --git a/Marlin/src/inc/MarlinConfigPre.h b/Marlin/src/inc/MarlinConfigPre.h index 1b15d49817..dfa0adba1b 100644 --- a/Marlin/src/inc/MarlinConfigPre.h +++ b/Marlin/src/inc/MarlinConfigPre.h @@ -30,7 +30,9 @@ // #include -#include "../HAL/platforms.h" +#ifndef __MARLIN_DEPS__ + #include "../HAL/platforms.h" +#endif #include "../core/boards.h" #include "../core/macros.h" @@ -45,10 +47,16 @@ #include "Version.h" #include "Conditionals_LCD.h" -#include HAL_PATH(../HAL, inc/Conditionals_LCD.h) + +#ifndef __MARLIN_DEPS__ + #include HAL_PATH(../HAL, inc/Conditionals_LCD.h) +#endif #include "../core/drivers.h" #include "../../Configuration_adv.h" #include "Conditionals_adv.h" -#include HAL_PATH(../HAL, inc/Conditionals_adv.h) + +#ifndef __MARLIN_DEPS__ + #include HAL_PATH(../HAL, inc/Conditionals_adv.h) +#endif diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 82364cc54a..a7888e54d4 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -52,7 +52,7 @@ #define HAS_FREE_AUX2_PINS !(BOTH(ULTRA_LCD, NEWPANEL) && ANY(PANEL_ONE, VIKI2, miniVIKI, MINIPANEL, REPRAPWORLD_KEYPAD)) // Test the target within the included pins file -#ifdef __MARLIN_PREBUILD__ +#ifdef __MARLIN_DEPS__ #define NOT_TARGET(V...) 0 #else #define NOT_TARGET(V...) NONE(V) diff --git a/buildroot/share/PlatformIO/scripts/common-dependencies.h b/buildroot/share/PlatformIO/scripts/common-dependencies.h index 02a4502e3f..c96907bb3f 100644 --- a/buildroot/share/PlatformIO/scripts/common-dependencies.h +++ b/buildroot/share/PlatformIO/scripts/common-dependencies.h @@ -19,7 +19,6 @@ * along with this program. If not, see . * */ -#pragma once /** * The purpose of this file is just include Marlin Configuration files, @@ -27,44 +26,9 @@ * Used by common-dependencies.py */ -#include +#define NUM_SERIAL 1 // Normally provided by HAL/HAL.h -// Include platform headers -//#include "../../../../Marlin/src/HAL/platforms.h" - -#include "../../../../Marlin/src/core/boards.h" -#include "../../../../Marlin/src/core/macros.h" -#include "../../../../Marlin/Configuration.h" - -#include "../../../../Marlin/Version.h" - -#include "../../../../Marlin/src/inc/Conditionals_LCD.h" - -#ifdef HAL_PATH - #include HAL_PATH(../../../../Marlin/src/HAL, inc/Conditionals_LCD.h) -#endif - -#include "../../../../Marlin/src/core/drivers.h" -#include "../../../../Marlin/Configuration_adv.h" - -#include "../../../../Marlin/src/inc/Conditionals_adv.h" - -#ifdef HAL_PATH - #include HAL_PATH(../../../../Marlin/src/HAL, inc/Conditionals_adv.h) -#endif - -//#include "../../../../Marlin/src/pins/pins.h" - -#ifdef HAL_PATH - #include HAL_PATH(../../../../Marlin/src/HAL, timers.h) - #include HAL_PATH(../../../../Marlin/src/HAL, spi_pins.h) -#endif - -#include "../../../../Marlin/src/inc/Conditionals_post.h" - -#ifdef HAL_PATH - #include HAL_PATH(../../../../Marlin/src/HAL, inc/Conditionals_post.h) -#endif +#include "../../../../Marlin/src/inc/MarlinConfig.h" // // Conditionals only used for [features] @@ -89,6 +53,10 @@ #define HAS_EXTRUDERS #endif +#if ENABLED(DUET_SMART_EFFECTOR) && PIN_EXISTS(SMART_EFFECTOR_MOD) + #define HAS_SMART_EFF_MOD +#endif + #if HAS_LCD_MENU #if ENABLED(BACKLASH_GCODE) #define HAS_MENU_BACKLASH @@ -145,6 +113,3 @@ #define HAS_MENU_UBL #endif #endif - -// Include pins for the current board. Platform tests will be skipped. No HAL-defined pins. -#include "../../../../Marlin/src/pins/pins.h" diff --git a/buildroot/share/PlatformIO/scripts/common-dependencies.py b/buildroot/share/PlatformIO/scripts/common-dependencies.py index 6005855156..4b4bba6258 100644 --- a/buildroot/share/PlatformIO/scripts/common-dependencies.py +++ b/buildroot/share/PlatformIO/scripts/common-dependencies.py @@ -39,6 +39,12 @@ def parse_pkg_uri(spec): FEATURE_CONFIG = {} def add_to_feat_cnf(feature, flines): + + try: + feat = FEATURE_CONFIG[feature] + except: + FEATURE_CONFIG[feature] = {} + feat = FEATURE_CONFIG[feature] atoms = re.sub(',\\s*', '\n', flines).strip().split('\n') for dep in atoms: @@ -238,7 +244,7 @@ def load_marlin_features(): else: cmd += ['-D' + s] - cmd += ['-D__MARLIN_PREBUILD__ -w -dM -E -x c++ buildroot/share/PlatformIO/scripts/common-dependencies.h'] + cmd += ['-D__MARLIN_DEPS__ -w -dM -E -x c++ buildroot/share/PlatformIO/scripts/common-dependencies.h'] cmd = ' '.join(cmd) blab(cmd) define_list = subprocess.check_output(cmd, shell=True).splitlines() diff --git a/platformio.ini b/platformio.ini index cf4dfc932a..d4beca6519 100644 --- a/platformio.ini +++ b/platformio.ini @@ -27,6 +27,7 @@ include_dir = Marlin [common] default_src_filter = + - - + - - - - - + - - - - - - - - @@ -53,10 +54,13 @@ default_src_filter = + - - + - - - - - + - - - - - + - - + - + - - - - - - @@ -65,7 +69,7 @@ default_src_filter = + - - + - - - - - - - - + - - - - - - - @@ -80,6 +84,7 @@ default_src_filter = + - - + - - - + - - - - @@ -95,7 +100,7 @@ default_src_filter = + - - + - - - - - - + - - - - - - - @@ -106,7 +111,7 @@ default_src_filter = + - - + - - - - - + - - - - @@ -114,14 +119,19 @@ default_src_filter = + - - + - - - + - - - - - - - + - - + - - - + - + - - - - @@ -169,8 +179,10 @@ default_src_filter = + - - + - - - + - - - + - - - - - - @@ -214,9 +226,13 @@ HAS_WIRED_LCD = src_filter=+ HAS_MARLINUI_HD44780 = src_filter=+ HAS_MARLINUI_U8GLIB = U8glib-HAL@~0.4.1 src_filter=+ +HAS_(FSMC|SPI)_TFT = src_filter=+ + +HAS_FSMC_TFT = src_filter=+ + +HAS_SPI_TFT = src_filter=+ + HAS_GRAPHICAL_TFT = src_filter=+ DWIN_CREALITY_LCD = src_filter=+ IS_TFTGLCD_PANEL = src_filter=+ +HAS_TOUCH_XPT2046 = src_filter=+ HAS_LCD_MENU = src_filter=+ HAS_GAMES = src_filter=+ MARLIN_BRICKOUT = src_filter=+ @@ -242,7 +258,7 @@ HAS_MENU_TEMPERATURE = src_filter=+ HAS_MENU_TMC = src_filter=+ HAS_MENU_TOUCH_SCREEN = src_filter=+ HAS_MENU_UBL = src_filter=+ -ANYCUBIC_LCD_CHIRON = src_filter=+ +ANYCUBIC_LCD_CHIRON = src_filter=+ + ANYCUBIC_LCD_I3MEGA = src_filter=+ + HAS_DGUS_LCD = src_filter=+ + TOUCH_UI_FTDI_EVE = src_filter=+ @@ -258,13 +274,15 @@ BARICUDA = src_filter=+ + + BLTOUCH = src_filter=+ CANCEL_OBJECTS = src_filter=+ + -CASE_LIGHT_ENABLE = src_filter=+ + +CASE_LIGHT_ENABLE = src_filter=+ + EXTERNAL_CLOSED_LOOP_CONTROLLER = src_filter=+ + USE_CONTROLLER_FAN = src_filter=+ DAC_STEPPER_CURRENT = src_filter=+ DIRECT_STEPPING = src_filter=+ + EMERGENCY_PARSER = src_filter=+ - I2C_POSITION_ENCODERS = src_filter=+ +IIC_BL24CXX_EEPROM = src_filter=+ +HAS_SPI_FLASH = src_filter=+ HAS_FANMUX = src_filter=+ FILAMENT_WIDTH_SENSOR = src_filter=+ + FWRETRACT = src_filter=+ + @@ -285,10 +303,10 @@ ADVANCED_PAUSE_FEATURE = src_filter=+ + HAS_POWER_MONITOR = src_filter=+ + POWER_LOSS_RECOVERY = src_filter=+ + -PROBE_TEMP_COMPENSATION = src_filter=+ + +PROBE_TEMP_COMPENSATION = src_filter=+ + HAS_FILAMENT_SENSOR = src_filter=+ + MK2_MULTIPLEXER = src_filter=+ -EXT_SOLENOID|MANUAL_SOLENOID_CONTROL = src_filter=+ +EXT_SOLENOID|MANUAL_SOLENOID_CONTROL = src_filter=+ + HAS_CUTTER = src_filter=+ + EXPERIMENTAL_I2CBUS = src_filter=+ + Z_STEPPER_AUTO_ALIGN = src_filter=+ + @@ -304,14 +322,19 @@ BACKLASH_GCODE = src_filter=+ IS_KINEMATIC = src_filter=+ HAS_EXTRA_ENDSTOPS = src_filter=+ SKEW_CORRECTION_GCODE = src_filter=+ -PINS_DEBUGGING = src_filter=- +DIRECT_PIN_CONTROL = src_filter=+ + +PINS_DEBUGGING = src_filter=+ NO_VOLUMETRICS = src_filter=- HAS_MULTI_EXTRUDER = src_filter=+ HAS_HOTEND_OFFSET = src_filter=+ EDITABLE_SERVO_ANGLES = src_filter=+ +PIDTEMP = src_filter=+ PREVENT_COLD_EXTRUSION = src_filter=+ +PIDTEMPBED = src_filter=+ HAS_USER_THERMISTORS = src_filter=+ SD_ABORT_ON_ENDSTOP_HIT = src_filter=+ +BAUD_RATE_GCODE = src_filter=+ +HAS_SMART_EFF_MOD = src_filter=+ COOLANT_CONTROL = src_filter=+ HAS_SOFTWARE_ENDSTOPS = src_filter=+ HAS_DUPLICATION_MODE = src_filter=+ @@ -336,12 +359,13 @@ LCD_SET_PROGRESS_MANUALLY = src_filter=+ TOUCH_SCREEN_CALIBRATION = src_filter=+ ARC_SUPPORT = src_filter=+ GCODE_MOTION_MODES = src_filter=+ -BABYSTEPPING = src_filter=+ +BABYSTEPPING = src_filter=+ + Z_PROBE_SLED = src_filter=+ G38_PROBE_TARGET = src_filter=+ MAGNETIC_PARKING_EXTRUDER = src_filter=+ SDSUPPORT = src_filter=+ HAS_EXTRUDERS = src_filter=+ + +AUTO_REPORT_TEMPERATURES = src_filter=+ INCH_MODE_SUPPORT = src_filter=+ TEMPERATURE_UNITS_SUPPORT = src_filter=+ NEED_HEX_PRINT = src_filter=+ @@ -559,7 +583,7 @@ extends = env:at90usb1286_cdc [env:DUE] platform = atmelsam board = due -src_filter = ${common.default_src_filter} + +src_filter = ${common.default_src_filter} + + [env:DUE_USB] platform = atmelsam @@ -635,7 +659,7 @@ lib_ldf_mode = off lib_compat_mode = strict extra_scripts = ${common.extra_scripts} Marlin/src/HAL/LPC1768/upload_extra_script.py -src_filter = ${common.default_src_filter} + +src_filter = ${common.default_src_filter} + + lib_deps = ${common.lib_deps} Servo custom_marlin.USES_LIQUIDCRYSTAL = LiquidCrystal@1.0.0 @@ -674,7 +698,7 @@ build_flags = ${common.build_flags} -DUSBCON -DUSBD_USE_CDC -DTIM_IRQ_PRIO=13 build_unflags = -std=gnu++11 -src_filter = ${common.default_src_filter} + +src_filter = ${common.default_src_filter} + + # # HAL/STM32F1 Common Environment values