From 419a145fa30dc01315d5b6b69f76253b21bd7a9b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 7 Aug 2022 20:42:12 -0500 Subject: [PATCH 001/243] =?UTF-8?q?=F0=9F=94=A8=20Update=20schema=20export?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 2 +- buildroot/share/PlatformIO/scripts/schema.py | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index e5d23526dbee..6ec969474d9f 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -48,7 +48,7 @@ * 3 = schema.json - The entire configuration schema. (13 = pattern groups) * 4 = schema.yml - The entire configuration schema. */ -//#define CONFIG_EXPORT // :[1:'JSON', 2:'config.ini', 3:'schema.json', 4:'schema.yml'] +//#define CONFIG_EXPORT 2 // :[1:'JSON', 2:'config.ini', 3:'schema.json', 4:'schema.yml'] //=========================================================================== //============================= Thermal Settings ============================ diff --git a/buildroot/share/PlatformIO/scripts/schema.py b/buildroot/share/PlatformIO/scripts/schema.py index 767748757e2d..2c20f49dee35 100755 --- a/buildroot/share/PlatformIO/scripts/schema.py +++ b/buildroot/share/PlatformIO/scripts/schema.py @@ -95,7 +95,7 @@ class Parse: # Regex for #define NAME [VALUE] [COMMENT] with sanitized line defgrep = re.compile(r'^(//)?\s*(#define)\s+([A-Za-z0-9_]+)\s*(.*?)\s*(//.+)?$') # Defines to ignore - ignore = ('CONFIGURATION_H_VERSION', 'CONFIGURATION_ADV_H_VERSION', 'CONFIG_EXPORT') + ignore = ('CONFIGURATION_H_VERSION', 'CONFIGURATION_ADV_H_VERSION', 'CONFIG_EXAMPLES_DIR', 'CONFIG_EXPORT') # Start with unknown state state = Parse.NORMAL # Serial ID @@ -294,8 +294,6 @@ def atomize(s): 'sid': sid } - if val != '': define_info['value'] = val - # Type is based on the value if val == '': value_type = 'switch' @@ -318,6 +316,7 @@ def atomize(s): else 'array' if val[0] == '{' \ else '' + if val != '': define_info['value'] = val if value_type != '': define_info['type'] = value_type # Join up accumulated conditions with && From 857dc73be5bdae32e304656245e0db3dd5d49650 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 6 Aug 2022 09:17:46 +0300 Subject: [PATCH 002/243] =?UTF-8?q?=F0=9F=94=A8=20Fix=20a=20PlatformIO=20d?= =?UTF-8?q?ebug=20issue=20(#24569)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlatformIO/scripts/common-cxxflags.py | 65 ++++++++++--------- .../share/PlatformIO/scripts/simulator.py | 1 + 2 files changed, 37 insertions(+), 29 deletions(-) diff --git a/buildroot/share/PlatformIO/scripts/common-cxxflags.py b/buildroot/share/PlatformIO/scripts/common-cxxflags.py index 1e8f0dcb0552..22a0665e05d5 100644 --- a/buildroot/share/PlatformIO/scripts/common-cxxflags.py +++ b/buildroot/share/PlatformIO/scripts/common-cxxflags.py @@ -2,38 +2,45 @@ # common-cxxflags.py # Convenience script to apply customizations to CPP flags # + import pioutil if pioutil.is_pio_build(): - Import("env") + Import("env") + + cxxflags = [ + # "-Wno-incompatible-pointer-types", + # "-Wno-unused-const-variable", + # "-Wno-maybe-uninitialized", + # "-Wno-sign-compare" + ] + if "teensy" not in env["PIOENV"]: + cxxflags += ["-Wno-register"] + env.Append(CXXFLAGS=cxxflags) + + # + # Add CPU frequency as a compile time constant instead of a runtime variable + # + def add_cpu_freq(): + if "BOARD_F_CPU" in env: + env["BUILD_FLAGS"].append("-DBOARD_F_CPU=" + env["BOARD_F_CPU"]) - cxxflags = [ - #"-Wno-incompatible-pointer-types", - #"-Wno-unused-const-variable", - #"-Wno-maybe-uninitialized", - #"-Wno-sign-compare" - ] - if "teensy" not in env['PIOENV']: - cxxflags += ["-Wno-register"] - env.Append(CXXFLAGS=cxxflags) + # Useful for JTAG debugging + # + # It will separate release and debug build folders. + # It useful to keep two live versions: a debug version for debugging and another for + # release, for flashing when upload is not done automatically by jlink/stlink. + # Without this, PIO needs to recompile everything twice for any small change. + if env.GetBuildType() == "debug" and env.get("UPLOAD_PROTOCOL") not in ["jlink", "stlink", "custom"]: + env["BUILD_DIR"] = "$PROJECT_BUILD_DIR/$PIOENV/debug" - # - # Add CPU frequency as a compile time constant instead of a runtime variable - # - def add_cpu_freq(): - if 'BOARD_F_CPU' in env: - env['BUILD_FLAGS'].append('-DBOARD_F_CPU=' + env['BOARD_F_CPU']) + def on_program_ready(source, target, env): + import shutil + shutil.copy(target[0].get_abspath(), env.subst("$PROJECT_BUILD_DIR/$PIOENV")) - # Useful for JTAG debugging - # - # It will separate release and debug build folders. - # It useful to keep two live versions: a debug version for debugging and another for - # release, for flashing when upload is not done automatically by jlink/stlink. - # Without this, PIO needs to recompile everything twice for any small change. - if env.GetBuildType() == "debug" and env.get('UPLOAD_PROTOCOL') not in ['jlink', 'stlink', 'custom']: - env['BUILD_DIR'] = '$PROJECT_BUILD_DIR/$PIOENV/debug' + env.AddPostAction("$PROGPATH", on_program_ready) - # On some platform, F_CPU is a runtime variable. Since it's used to convert from ns - # to CPU cycles, this adds overhead preventing small delay (in the order of less than - # 30 cycles) to be generated correctly. By using a compile time constant instead - # the compiler will perform the computation and this overhead will be avoided - add_cpu_freq() + # On some platform, F_CPU is a runtime variable. Since it's used to convert from ns + # to CPU cycles, this adds overhead preventing small delay (in the order of less than + # 30 cycles) to be generated correctly. By using a compile time constant instead + # the compiler will perform the computation and this overhead will be avoided + add_cpu_freq() diff --git a/buildroot/share/PlatformIO/scripts/simulator.py b/buildroot/share/PlatformIO/scripts/simulator.py index 2961d2826d41..1767f83d32da 100644 --- a/buildroot/share/PlatformIO/scripts/simulator.py +++ b/buildroot/share/PlatformIO/scripts/simulator.py @@ -2,6 +2,7 @@ # simulator.py # PlatformIO pre: script for simulator builds # + import pioutil if pioutil.is_pio_build(): # Get the environment thus far for the build From 3892d08b06ce3c24be5d0d9c150e0ab035ba9ff0 Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Thu, 11 Aug 2022 11:35:36 -0700 Subject: [PATCH 003/243] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Fix?= =?UTF-8?q?=20UBL=20Build=20Mesh=20preheat=20items=20(#24598)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/src/lcd/menu/menu_ubl.cpp | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_ubl.cpp b/Marlin/src/lcd/menu/menu_ubl.cpp index 62c1770bd4c3..f26e5b29846f 100644 --- a/Marlin/src/lcd/menu/menu_ubl.cpp +++ b/Marlin/src/lcd/menu/menu_ubl.cpp @@ -312,11 +312,7 @@ void _lcd_ubl_build_mesh() { START_MENU(); BACK_ITEM(MSG_UBL_TOOLS); #if HAS_PREHEAT - #if HAS_HEATED_BED - #define PREHEAT_BED_GCODE(M) "M190I" STRINGIFY(M) "\n" - #else - #define PREHEAT_BED_GCODE(M) "" - #endif + #define PREHEAT_BED_GCODE(M) TERN(HAS_HEATED_BED, "M190I" STRINGIFY(M) "\n", "") #define BUILD_MESH_GCODE_ITEM(M) GCODES_ITEM_f(ui.get_preheat_label(M), MSG_UBL_BUILD_MESH_M, \ F( \ "G28\n" \ @@ -325,20 +321,8 @@ void _lcd_ubl_build_mesh() { "G29P1\n" \ "M104S0\n" \ "M140S0" \ - ) ) - BUILD_MESH_GCODE_ITEM(0); - #if PREHEAT_COUNT > 1 - BUILD_MESH_GCODE_ITEM(1); - #if PREHEAT_COUNT > 2 - BUILD_MESH_GCODE_ITEM(2); - #if PREHEAT_COUNT > 3 - BUILD_MESH_GCODE_ITEM(3); - #if PREHEAT_COUNT > 4 - BUILD_MESH_GCODE_ITEM(4); - #endif - #endif - #endif - #endif + ) ); + REPEAT(PREHEAT_COUNT, BUILD_MESH_GCODE_ITEM) #endif // HAS_PREHEAT SUBMENU(MSG_UBL_BUILD_CUSTOM_MESH, _lcd_ubl_custom_mesh); From fc3ea96ff982bc4dff554142a88b9b00f2286335 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 11 Aug 2022 12:41:41 -0500 Subject: [PATCH 004/243] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Add?= =?UTF-8?q?=20operator=3D=3D=20for=20C++20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/types.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index c9bb7d8c30d1..f0ddc871a556 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -752,8 +752,12 @@ struct XYZEval { // Exact comparisons. For floats a "NEAR" operation may be better. FI bool operator==(const XYZval &rs) { return true NUM_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k, && u == rs.u, && v == rs.v, && w == rs.w); } FI bool operator==(const XYZval &rs) const { return true NUM_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k, && u == rs.u, && v == rs.v, && w == rs.w); } + FI bool operator==(const XYZEval &rs) { return true LOGICAL_AXIS_GANG(&& e == rs.e, && x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k, && u == rs.u, && v == rs.v, && w == rs.w); } + FI bool operator==(const XYZEval &rs) const { return true LOGICAL_AXIS_GANG(&& e == rs.e, && x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k, && u == rs.u, && v == rs.v, && w == rs.w); } FI bool operator!=(const XYZval &rs) { return !operator==(rs); } FI bool operator!=(const XYZval &rs) const { return !operator==(rs); } + FI bool operator!=(const XYZEval &rs) { return !operator==(rs); } + FI bool operator!=(const XYZEval &rs) const { return !operator==(rs); } }; #undef _RECIP From d69893309e56423d0b951cb5064b3719800f0a2d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 8 Aug 2022 06:42:46 -0500 Subject: [PATCH 005/243] =?UTF-8?q?=F0=9F=94=A8=20Misc.=20config=20py=20up?= =?UTF-8?q?dates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../share/PlatformIO/scripts/configuration.py | 38 +++++++++---------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/buildroot/share/PlatformIO/scripts/configuration.py b/buildroot/share/PlatformIO/scripts/configuration.py index 3ab0295749a9..02395f1b8ee2 100644 --- a/buildroot/share/PlatformIO/scripts/configuration.py +++ b/buildroot/share/PlatformIO/scripts/configuration.py @@ -83,16 +83,14 @@ def apply_opt(name, val, conf=None): # Fetch configuration files from GitHub given the path. # Return True if any files were fetched. -def fetch_example(path): - if path.endswith("/"): - path = path[:-1] - - if '@' in path: - path, brch = map(strip, path.split('@')) - - url = path.replace("%", "%25").replace(" ", "%20") - if not path.startswith('http'): - url = "https://raw.githubusercontent.com/MarlinFirmware/Configurations/bugfix-2.1.x/config/%s" % url +def fetch_example(url): + if url.endswith("/"): url = url[:-1] + if url.startswith('http'): + url = url.replace("%", "%25").replace(" ", "%20") + else: + brch = "bugfix-2.1.x" + if '@' in path: path, brch = map(str.strip, path.split('@')) + url = f"https://raw.githubusercontent.com/MarlinFirmware/Configurations/{brch}/config/{url}" # Find a suitable fetch command if shutil.which("curl") is not None: @@ -108,16 +106,14 @@ def fetch_example(path): # Reset configurations to default os.system("git reset --hard HEAD") - gotfile = False - # Try to fetch the remote files + gotfile = False for fn in ("Configuration.h", "Configuration_adv.h", "_Bootscreen.h", "_Statusscreen.h"): - if os.system("%s wgot %s/%s >/dev/null 2>&1" % (fetch, url, fn)) == 0: + if os.system(f"{fetch} wgot {url}/{fn} >/dev/null 2>&1") == 0: shutil.move('wgot', config_path(fn)) gotfile = True - if Path('wgot').exists(): - shutil.rmtree('wgot') + if Path('wgot').exists(): shutil.rmtree('wgot') return gotfile @@ -144,13 +140,13 @@ def apply_all_sections(cp): apply_ini_by_name(cp, sect) # Apply certain config sections from a parsed file -def apply_sections(cp, ckey='all', addbase=False): - blab("[config] apply section key: %s" % ckey) +def apply_sections(cp, ckey='all'): + blab(f"Apply section key: {ckey}") if ckey == 'all': apply_all_sections(cp) else: # Apply the base/root config.ini settings after external files are done - if addbase or ckey in ('base', 'root'): + if ckey in ('base', 'root'): apply_ini_by_name(cp, 'config:base') # Apply historically 'Configuration.h' settings everywhere @@ -175,7 +171,7 @@ def apply_config_ini(cp): config_keys = ['base'] for ikey, ival in base_items: if ikey == 'ini_use_config': - config_keys = [ x.strip() for x in ival.split(',') ] + config_keys = map(str.strip, ival.split(',')) # For each ini_use_config item perform an action for ckey in config_keys: @@ -196,11 +192,11 @@ def apply_config_ini(cp): # For 'examples/' fetch an example set from GitHub. # For https?:// do a direct fetch of the URL. elif ckey.startswith('examples/') or ckey.startswith('http'): - addbase = True fetch_example(ckey) + ckey = 'base' # Apply keyed sections after external files are done - apply_sections(cp, 'config:' + ckey, addbase) + apply_sections(cp, 'config:' + ckey) if __name__ == "__main__": # From b5ccddbe353827cea3619e9efb38e68582e37161 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 16 Aug 2022 09:41:45 -0500 Subject: [PATCH 006/243] =?UTF-8?q?=F0=9F=8E=A8=20Fix=20'=E2=80=A6if=5Fcha?= =?UTF-8?q?in'=20Uncrustify=20option?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildroot/share/extras/uncrustify.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildroot/share/extras/uncrustify.cfg b/buildroot/share/extras/uncrustify.cfg index 06661203f09c..82044f8c7b9a 100644 --- a/buildroot/share/extras/uncrustify.cfg +++ b/buildroot/share/extras/uncrustify.cfg @@ -26,7 +26,7 @@ mod_add_long_ifdef_endif_comment = 40 mod_full_brace_do = false mod_full_brace_for = false mod_full_brace_if = false -mod_full_brace_if_chain = true +mod_full_brace_if_chain = 1 mod_full_brace_while = false mod_remove_extra_semicolon = true newlines = lf From c154302ece49db7e93aef6984d7159d89f36cee2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 17 Aug 2022 07:32:08 -0500 Subject: [PATCH 007/243] =?UTF-8?q?=F0=9F=94=A8=20Add=20args=20to=20schema?= =?UTF-8?q?.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildroot/share/PlatformIO/scripts/schema.py | 49 ++++++++++++++------ 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/buildroot/share/PlatformIO/scripts/schema.py b/buildroot/share/PlatformIO/scripts/schema.py index 2c20f49dee35..5316cb906aef 100755 --- a/buildroot/share/PlatformIO/scripts/schema.py +++ b/buildroot/share/PlatformIO/scripts/schema.py @@ -382,21 +382,40 @@ def main(): schema = None if schema: - print("Generating JSON ...") - dump_json(schema, Path('schema.json')) - group_options(schema) - dump_json(schema, Path('schema_grouped.json')) - - try: - import yaml - except ImportError: - print("Installing YAML module ...") - import subprocess - subprocess.run(['python3', '-m', 'pip', 'install', 'pyyaml']) - import yaml - - print("Generating YML ...") - dump_yaml(schema, Path('schema.yml')) + + # Get the first command line argument + import sys + if len(sys.argv) > 1: + arg = sys.argv[1] + else: + arg = 'some' + + # JSON schema + if arg in ['some', 'json', 'jsons']: + print("Generating JSON ...") + dump_json(schema, Path('schema.json')) + + # JSON schema (wildcard names) + if arg in ['group', 'jsons']: + group_options(schema) + dump_json(schema, Path('schema_grouped.json')) + + # YAML + if arg in ['some', 'yml', 'yaml']: + try: + import yaml + except ImportError: + print("Installing YAML module ...") + import subprocess + try: + subprocess.run(['python3', '-m', 'pip', 'install', 'pyyaml']) + import yaml + except: + print("Failed to install YAML module") + return + + print("Generating YML ...") + dump_yaml(schema, Path('schema.yml')) if __name__ == '__main__': main() From 0adee8fae008660895c9f993021ca3c68a173312 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 18 Aug 2022 13:03:17 -0500 Subject: [PATCH 008/243] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20strtof=20interpret?= =?UTF-8?q?ing=20a=20hex=20value?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug introduced in #21532 --- Marlin/src/gcode/parser.h | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/Marlin/src/gcode/parser.h b/Marlin/src/gcode/parser.h index 3f5290e81c67..c05d6f32c521 100644 --- a/Marlin/src/gcode/parser.h +++ b/Marlin/src/gcode/parser.h @@ -256,22 +256,20 @@ class GCodeParser { // Float removes 'E' to prevent scientific notation interpretation static float value_float() { - if (value_ptr) { - char *e = value_ptr; - for (;;) { - const char c = *e; - if (c == '\0' || c == ' ') break; - if (c == 'E' || c == 'e') { - *e = '\0'; - const float ret = strtof(value_ptr, nullptr); - *e = c; - return ret; - } - ++e; + if (!value_ptr) return 0; + char *e = value_ptr; + for (;;) { + const char c = *e; + if (c == '\0' || c == ' ') break; + if (c == 'E' || c == 'e' || c == 'X' || c == 'x') { + *e = '\0'; + const float ret = strtof(value_ptr, nullptr); + *e = c; + return ret; } - return strtof(value_ptr, nullptr); + ++e; } - return 0; + return strtof(value_ptr, nullptr); } // Code value as a long or ulong From 98e6aacbefb87489c3e79fa5735834a018ce0d9e Mon Sep 17 00:00:00 2001 From: Graham Reed Date: Fri, 19 Aug 2022 16:48:27 +0100 Subject: [PATCH 009/243] =?UTF-8?q?=F0=9F=94=A8=20Fix=20LPC1768=20automati?= =?UTF-8?q?c=20upload=20port=20(#24599)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/LPC1768/upload_extra_script.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Marlin/src/HAL/LPC1768/upload_extra_script.py b/Marlin/src/HAL/LPC1768/upload_extra_script.py index 3e23c63ca19e..2db600abc784 100755 --- a/Marlin/src/HAL/LPC1768/upload_extra_script.py +++ b/Marlin/src/HAL/LPC1768/upload_extra_script.py @@ -82,11 +82,11 @@ def before_upload(source, target, env): for drive in drives: try: fpath = mpath / drive - files = [ x for x in fpath.iterdir() if x.is_file() ] + filenames = [ x.name for x in fpath.iterdir() if x.is_file() ] except: continue else: - if target_filename in files: + if target_filename in filenames: upload_disk = mpath / drive target_file_found = True break @@ -104,21 +104,21 @@ def before_upload(source, target, env): # platformio.ini will accept this for a OSX upload port designation: 'upload_port = /media/media_name/drive' # dpath = Path('/Volumes') # human readable names - drives = [ x for x in dpath.iterdir() ] + drives = [ x for x in dpath.iterdir() if x.is_dir() ] if target_drive in drives and not target_file_found: # set upload if not found target file yet target_drive_found = True upload_disk = dpath / target_drive for drive in drives: try: - fpath = dpath / drive # will get an error if the drive is protected - files = [ x for x in fpath.iterdir() ] + fpath = dpath / drive # will get an error if the drive is protected + filenames = [ x.name for x in fpath.iterdir() if x.is_file() ] except: continue else: - if target_filename in files: - if not target_file_found: - upload_disk = dpath / drive + if target_filename in filenames: + upload_disk = dpath / drive target_file_found = True + break # # Set upload_port to drive if found From d93c41a257bbc1097d4fbaba4cfd5ddd54be71a8 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 9 Aug 2022 07:58:20 -0500 Subject: [PATCH 010/243] =?UTF-8?q?=F0=9F=94=A8=20Misc.=20schema=20updates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration.h | 7 ++++++- buildroot/share/PlatformIO/scripts/schema.py | 10 +++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 2c16b8fb53fe..683b61298b83 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -141,6 +141,8 @@ // Choose your own or use a service like https://www.uuidgenerator.net/version4 //#define MACHINE_UUID "00000000-0000-0000-0000-000000000000" +// @section stepper drivers + /** * Stepper Drivers * @@ -240,6 +242,8 @@ //#define SINGLENOZZLE_STANDBY_FAN #endif +// @section multi-material + /** * Multi-Material Unit * Set to one of these predefined models: @@ -252,6 +256,7 @@ * * Requires NOZZLE_PARK_FEATURE to park print head in case MMU unit fails. * See additional options in Configuration_adv.h. + * :["PRUSA_MMU1", "PRUSA_MMU2", "PRUSA_MMU2S", "EXTENDABLE_EMU_MMU2", "EXTENDABLE_EMU_MMU2S"] */ //#define MMU_MODEL PRUSA_MMU2 @@ -1629,7 +1634,7 @@ #define DISABLE_E false // Disable the extruder when not stepping #define DISABLE_INACTIVE_EXTRUDER // Keep only the active extruder enabled -// @section machine +// @section motion // Invert the stepper direction. Change (or reverse the motor connector) if an axis goes the wrong way. #define INVERT_X_DIR false diff --git a/buildroot/share/PlatformIO/scripts/schema.py b/buildroot/share/PlatformIO/scripts/schema.py index 5316cb906aef..34df4c906f23 100755 --- a/buildroot/share/PlatformIO/scripts/schema.py +++ b/buildroot/share/PlatformIO/scripts/schema.py @@ -213,11 +213,8 @@ def use_comment(c, opt, sec, bufref): elif cpos2 != -1 and (cpos2 < cpos1 or cpos1 == -1): cpos = cpos2 - # Expire end-of-line options after first use - if cline.startswith(':'): eol_options = True - # Comment after a define may be continued on the following lines - if state == Parse.NORMAL and defmatch != None and cpos > 10: + if defmatch != None and cpos > 10: state = Parse.EOL_COMMENT comment_buff = [] @@ -225,9 +222,12 @@ def use_comment(c, opt, sec, bufref): if cpos != -1: cline, line = line[cpos+2:].strip(), line[:cpos].strip() - # Strip leading '*' from block comments if state == Parse.BLOCK_COMMENT: + # Strip leading '*' from block comments if cline.startswith('*'): cline = cline[1:].strip() + else: + # Expire end-of-line options after first use + if cline.startswith(':'): eol_options = True # Buffer a non-empty comment start if cline != '': From ff09ea13a4ef86d810ebb69eb08933c448c9e32c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 19 Aug 2022 11:00:52 -0500 Subject: [PATCH 011/243] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Use?= =?UTF-8?q?=20spaces=20indent=20for=20Python?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .editorconfig | 6 +- Marlin/src/HAL/LPC1768/upload_extra_script.py | 224 ++--- Marlin/src/feature/spindle_laser.h | 2 +- .../scripts/SAMD51_grandcentral_m4.py | 20 +- .../share/PlatformIO/scripts/chitu_crypt.py | 174 ++-- .../scripts/common-dependencies-post.py | 16 +- .../PlatformIO/scripts/common-dependencies.py | 488 +++++------ .../share/PlatformIO/scripts/configuration.py | 388 ++++----- .../share/PlatformIO/scripts/custom_board.py | 16 +- .../PlatformIO/scripts/download_mks_assets.py | 84 +- .../scripts/fix_framework_weakness.py | 44 +- .../scripts/generic_create_variant.py | 98 +-- .../jgaurora_a5s_a1_with_bootloader.py | 46 +- buildroot/share/PlatformIO/scripts/lerdge.py | 62 +- buildroot/share/PlatformIO/scripts/marlin.py | 82 +- .../share/PlatformIO/scripts/mc-apply.py | 106 +-- .../PlatformIO/scripts/offset_and_rename.py | 102 +-- buildroot/share/PlatformIO/scripts/openblt.py | 26 +- buildroot/share/PlatformIO/scripts/pioutil.py | 10 +- .../PlatformIO/scripts/preflight-checks.py | 240 +++--- .../share/PlatformIO/scripts/preprocessor.py | 140 ++-- .../share/PlatformIO/scripts/random-bin.py | 6 +- buildroot/share/PlatformIO/scripts/schema.py | 770 +++++++++--------- .../share/PlatformIO/scripts/signature.py | 484 +++++------ .../share/PlatformIO/scripts/simulator.py | 62 +- .../PlatformIO/scripts/stm32_serialbuffer.py | 112 +-- buildroot/share/scripts/upload.py | 628 +++++++------- get_test_targets.py | 4 +- 28 files changed, 2222 insertions(+), 2218 deletions(-) diff --git a/.editorconfig b/.editorconfig index b8f6ef7f8e32..57a5b2fb5ea4 100644 --- a/.editorconfig +++ b/.editorconfig @@ -14,6 +14,10 @@ end_of_line = lf indent_style = space indent_size = 2 -[{*.py,*.conf,*.sublime-project}] +[{*.py}] +indent_style = space +indent_size = 4 + +[{*.conf,*.sublime-project}] indent_style = tab indent_size = 4 diff --git a/Marlin/src/HAL/LPC1768/upload_extra_script.py b/Marlin/src/HAL/LPC1768/upload_extra_script.py index 2db600abc784..52c9a8e2ecee 100755 --- a/Marlin/src/HAL/LPC1768/upload_extra_script.py +++ b/Marlin/src/HAL/LPC1768/upload_extra_script.py @@ -9,127 +9,127 @@ import pioutil if pioutil.is_pio_build(): - target_filename = "FIRMWARE.CUR" - target_drive = "REARM" + target_filename = "FIRMWARE.CUR" + target_drive = "REARM" - import platform + import platform - current_OS = platform.system() - Import("env") + current_OS = platform.system() + Import("env") - def print_error(e): - print('\nUnable to find destination disk (%s)\n' \ - 'Please select it in platformio.ini using the upload_port keyword ' \ - '(https://docs.platformio.org/en/latest/projectconf/section_env_upload.html) ' \ - 'or copy the firmware (.pio/build/%s/firmware.bin) manually to the appropriate disk\n' \ - %(e, env.get('PIOENV'))) + def print_error(e): + print('\nUnable to find destination disk (%s)\n' \ + 'Please select it in platformio.ini using the upload_port keyword ' \ + '(https://docs.platformio.org/en/latest/projectconf/section_env_upload.html) ' \ + 'or copy the firmware (.pio/build/%s/firmware.bin) manually to the appropriate disk\n' \ + %(e, env.get('PIOENV'))) - def before_upload(source, target, env): - try: - from pathlib import Path - # - # Find a disk for upload - # - upload_disk = 'Disk not found' - target_file_found = False - target_drive_found = False - if current_OS == 'Windows': - # - # platformio.ini will accept this for a Windows upload port designation: 'upload_port = L:' - # Windows - doesn't care about the disk's name, only cares about the drive letter - import subprocess,string - from ctypes import windll - from pathlib import PureWindowsPath + def before_upload(source, target, env): + try: + from pathlib import Path + # + # Find a disk for upload + # + upload_disk = 'Disk not found' + target_file_found = False + target_drive_found = False + if current_OS == 'Windows': + # + # platformio.ini will accept this for a Windows upload port designation: 'upload_port = L:' + # Windows - doesn't care about the disk's name, only cares about the drive letter + import subprocess,string + from ctypes import windll + from pathlib import PureWindowsPath - # getting list of drives - # https://stackoverflow.com/questions/827371/is-there-a-way-to-list-all-the-available-drive-letters-in-python - drives = [] - bitmask = windll.kernel32.GetLogicalDrives() - for letter in string.ascii_uppercase: - if bitmask & 1: - drives.append(letter) - bitmask >>= 1 + # getting list of drives + # https://stackoverflow.com/questions/827371/is-there-a-way-to-list-all-the-available-drive-letters-in-python + drives = [] + bitmask = windll.kernel32.GetLogicalDrives() + for letter in string.ascii_uppercase: + if bitmask & 1: + drives.append(letter) + bitmask >>= 1 - for drive in drives: - final_drive_name = drive + ':' - # print ('disc check: {}'.format(final_drive_name)) - try: - volume_info = str(subprocess.check_output('cmd /C dir ' + final_drive_name, stderr=subprocess.STDOUT)) - except Exception as e: - print ('error:{}'.format(e)) - continue - else: - if target_drive in volume_info and not target_file_found: # set upload if not found target file yet - target_drive_found = True - upload_disk = PureWindowsPath(final_drive_name) - if target_filename in volume_info: - if not target_file_found: - upload_disk = PureWindowsPath(final_drive_name) - target_file_found = True + for drive in drives: + final_drive_name = drive + ':' + # print ('disc check: {}'.format(final_drive_name)) + try: + volume_info = str(subprocess.check_output('cmd /C dir ' + final_drive_name, stderr=subprocess.STDOUT)) + except Exception as e: + print ('error:{}'.format(e)) + continue + else: + if target_drive in volume_info and not target_file_found: # set upload if not found target file yet + target_drive_found = True + upload_disk = PureWindowsPath(final_drive_name) + if target_filename in volume_info: + if not target_file_found: + upload_disk = PureWindowsPath(final_drive_name) + target_file_found = True - elif current_OS == 'Linux': - # - # platformio.ini will accept this for a Linux upload port designation: 'upload_port = /media/media_name/drive' - # - import getpass - user = getpass.getuser() - mpath = Path('media', user) - drives = [ x for x in mpath.iterdir() if x.is_dir() ] - if target_drive in drives: # If target drive is found, use it. - target_drive_found = True - upload_disk = mpath / target_drive - else: - for drive in drives: - try: - fpath = mpath / drive - filenames = [ x.name for x in fpath.iterdir() if x.is_file() ] - except: - continue - else: - if target_filename in filenames: - upload_disk = mpath / drive - target_file_found = True - break - # - # set upload_port to drive if found - # + elif current_OS == 'Linux': + # + # platformio.ini will accept this for a Linux upload port designation: 'upload_port = /media/media_name/drive' + # + import getpass + user = getpass.getuser() + mpath = Path('media', user) + drives = [ x for x in mpath.iterdir() if x.is_dir() ] + if target_drive in drives: # If target drive is found, use it. + target_drive_found = True + upload_disk = mpath / target_drive + else: + for drive in drives: + try: + fpath = mpath / drive + filenames = [ x.name for x in fpath.iterdir() if x.is_file() ] + except: + continue + else: + if target_filename in filenames: + upload_disk = mpath / drive + target_file_found = True + break + # + # set upload_port to drive if found + # - if target_file_found or target_drive_found: - env.Replace( - UPLOAD_FLAGS="-P$UPLOAD_PORT" - ) + if target_file_found or target_drive_found: + env.Replace( + UPLOAD_FLAGS="-P$UPLOAD_PORT" + ) - elif current_OS == 'Darwin': # MAC - # - # platformio.ini will accept this for a OSX upload port designation: 'upload_port = /media/media_name/drive' - # - dpath = Path('/Volumes') # human readable names - drives = [ x for x in dpath.iterdir() if x.is_dir() ] - if target_drive in drives and not target_file_found: # set upload if not found target file yet - target_drive_found = True - upload_disk = dpath / target_drive - for drive in drives: - try: - fpath = dpath / drive # will get an error if the drive is protected - filenames = [ x.name for x in fpath.iterdir() if x.is_file() ] - except: - continue - else: - if target_filename in filenames: - upload_disk = dpath / drive - target_file_found = True - break + elif current_OS == 'Darwin': # MAC + # + # platformio.ini will accept this for a OSX upload port designation: 'upload_port = /media/media_name/drive' + # + dpath = Path('/Volumes') # human readable names + drives = [ x for x in dpath.iterdir() if x.is_dir() ] + if target_drive in drives and not target_file_found: # set upload if not found target file yet + target_drive_found = True + upload_disk = dpath / target_drive + for drive in drives: + try: + fpath = dpath / drive # will get an error if the drive is protected + filenames = [ x.name for x in fpath.iterdir() if x.is_file() ] + except: + continue + else: + if target_filename in filenames: + upload_disk = dpath / drive + target_file_found = True + break - # - # Set upload_port to drive if found - # - if target_file_found or target_drive_found: - env.Replace(UPLOAD_PORT=str(upload_disk)) - print('\nUpload disk: ', upload_disk, '\n') - else: - print_error('Autodetect Error') + # + # Set upload_port to drive if found + # + if target_file_found or target_drive_found: + env.Replace(UPLOAD_PORT=str(upload_disk)) + print('\nUpload disk: ', upload_disk, '\n') + else: + print_error('Autodetect Error') - except Exception as e: - print_error(str(e)) + except Exception as e: + print_error(str(e)) - env.AddPreAction("upload", before_upload) + env.AddPreAction("upload", before_upload) diff --git a/Marlin/src/feature/spindle_laser.h b/Marlin/src/feature/spindle_laser.h index b667da25bb42..0a99585bc099 100644 --- a/Marlin/src/feature/spindle_laser.h +++ b/Marlin/src/feature/spindle_laser.h @@ -285,7 +285,7 @@ class SpindleLaser { if (!menuPower) menuPower = cpwr_to_upwr(SPEED_POWER_STARTUP); power = upower_to_ocr(menuPower); apply_power(power); - } else + } else apply_power(0); } diff --git a/buildroot/share/PlatformIO/scripts/SAMD51_grandcentral_m4.py b/buildroot/share/PlatformIO/scripts/SAMD51_grandcentral_m4.py index e7442f2485b8..4cd553a3da6c 100644 --- a/buildroot/share/PlatformIO/scripts/SAMD51_grandcentral_m4.py +++ b/buildroot/share/PlatformIO/scripts/SAMD51_grandcentral_m4.py @@ -4,17 +4,17 @@ # import pioutil if pioutil.is_pio_build(): - from os.path import join, isfile - import shutil + from os.path import join, isfile + import shutil - Import("env") + Import("env") - mf = env["MARLIN_FEATURES"] - rxBuf = mf["RX_BUFFER_SIZE"] if "RX_BUFFER_SIZE" in mf else "0" - txBuf = mf["TX_BUFFER_SIZE"] if "TX_BUFFER_SIZE" in mf else "0" + mf = env["MARLIN_FEATURES"] + rxBuf = mf["RX_BUFFER_SIZE"] if "RX_BUFFER_SIZE" in mf else "0" + txBuf = mf["TX_BUFFER_SIZE"] if "TX_BUFFER_SIZE" in mf else "0" - serialBuf = str(max(int(rxBuf), int(txBuf), 350)) + serialBuf = str(max(int(rxBuf), int(txBuf), 350)) - build_flags = env.get('BUILD_FLAGS') - build_flags.append("-DSERIAL_BUFFER_SIZE=" + serialBuf) - env.Replace(BUILD_FLAGS=build_flags) + build_flags = env.get('BUILD_FLAGS') + build_flags.append("-DSERIAL_BUFFER_SIZE=" + serialBuf) + env.Replace(BUILD_FLAGS=build_flags) diff --git a/buildroot/share/PlatformIO/scripts/chitu_crypt.py b/buildroot/share/PlatformIO/scripts/chitu_crypt.py index 76792030cf7d..4e81061a19ad 100644 --- a/buildroot/share/PlatformIO/scripts/chitu_crypt.py +++ b/buildroot/share/PlatformIO/scripts/chitu_crypt.py @@ -4,123 +4,123 @@ # import pioutil if pioutil.is_pio_build(): - import struct,uuid,marlin + import struct,uuid,marlin - board = marlin.env.BoardConfig() + board = marlin.env.BoardConfig() - def calculate_crc(contents, seed): - accumulating_xor_value = seed; + def calculate_crc(contents, seed): + accumulating_xor_value = seed; - for i in range(0, len(contents), 4): - value = struct.unpack('> ip + # shift the xor_seed left by the bits in IP. + xor_seed = xor_seed >> ip - # load a byte into IP - ip = r0[loop_counter] + # load a byte into IP + ip = r0[loop_counter] - # XOR the seed with r7 - xor_seed = xor_seed ^ r7 + # XOR the seed with r7 + xor_seed = xor_seed ^ r7 - # and then with IP - xor_seed = xor_seed ^ ip + # and then with IP + xor_seed = xor_seed ^ ip - #Now store the byte back - r1[loop_counter] = xor_seed & 0xFF + #Now store the byte back + r1[loop_counter] = xor_seed & 0xFF - #increment the loop_counter - loop_counter = loop_counter + 1 + #increment the loop_counter + loop_counter = loop_counter + 1 - def encrypt_file(input, output_file, file_length): - input_file = bytearray(input.read()) - block_size = 0x800 - key_length = 0x18 + def encrypt_file(input, output_file, file_length): + input_file = bytearray(input.read()) + block_size = 0x800 + key_length = 0x18 - uid_value = uuid.uuid4() - file_key = int(uid_value.hex[0:8], 16) + uid_value = uuid.uuid4() + file_key = int(uid_value.hex[0:8], 16) - xor_crc = 0xEF3D4323; + xor_crc = 0xEF3D4323; - # the input file is exepcted to be in chunks of 0x800 - # so round the size - while len(input_file) % block_size != 0: - input_file.extend(b'0x0') + # the input file is exepcted to be in chunks of 0x800 + # so round the size + while len(input_file) % block_size != 0: + input_file.extend(b'0x0') - # write the file header - output_file.write(struct.pack(">I", 0x443D2D3F)) - # encrypt the contents using a known file header key + # write the file header + output_file.write(struct.pack(">I", 0x443D2D3F)) + # encrypt the contents using a known file header key - # write the file_key - output_file.write(struct.pack("= level: - print("[deps] %s" % str) - - def add_to_feat_cnf(feature, flines): - - try: - feat = FEATURE_CONFIG[feature] - except: - FEATURE_CONFIG[feature] = {} - - # Get a reference to the FEATURE_CONFIG under construction - feat = FEATURE_CONFIG[feature] - - # Split up passed lines on commas or newlines and iterate - # Add common options to the features config under construction - # For lib_deps replace a previous instance of the same library - atoms = re.sub(r',\s*', '\n', flines).strip().split('\n') - for line in atoms: - parts = line.split('=') - name = parts.pop(0) - if name in ['build_flags', 'extra_scripts', 'src_filter', 'lib_ignore']: - feat[name] = '='.join(parts) - blab("[%s] %s=%s" % (feature, name, feat[name]), 3) - else: - for dep in re.split(r',\s*', line): - lib_name = re.sub(r'@([~^]|[<>]=?)?[\d.]+', '', dep.strip()).split('=').pop(0) - lib_re = re.compile('(?!^' + lib_name + '\\b)') - feat['lib_deps'] = list(filter(lib_re.match, feat['lib_deps'])) + [dep] - blab("[%s] lib_deps = %s" % (feature, dep), 3) - - def load_features(): - blab("========== Gather [features] entries...") - for key in ProjectConfig().items('features'): - feature = key[0].upper() - if not feature in FEATURE_CONFIG: - FEATURE_CONFIG[feature] = { 'lib_deps': [] } - add_to_feat_cnf(feature, key[1]) - - # Add options matching custom_marlin.MY_OPTION to the pile - blab("========== Gather custom_marlin entries...") - for n in env.GetProjectOptions(): - key = n[0] - mat = re.match(r'custom_marlin\.(.+)', key) - if mat: - try: - val = env.GetProjectOption(key) - except: - val = None - if val: - opt = mat[1].upper() - blab("%s.custom_marlin.%s = '%s'" % ( env['PIOENV'], opt, val )) - add_to_feat_cnf(opt, val) - - def get_all_known_libs(): - known_libs = [] - for feature in FEATURE_CONFIG: - feat = FEATURE_CONFIG[feature] - if not 'lib_deps' in feat: - continue - for dep in feat['lib_deps']: - known_libs.append(PackageSpec(dep).name) - return known_libs - - def get_all_env_libs(): - env_libs = [] - lib_deps = env.GetProjectOption('lib_deps') - for dep in lib_deps: - env_libs.append(PackageSpec(dep).name) - return env_libs - - def set_env_field(field, value): - proj = env.GetProjectConfig() - proj.set("env:" + env['PIOENV'], field, value) - - # All unused libs should be ignored so that if a library - # exists in .pio/lib_deps it will not break compilation. - def force_ignore_unused_libs(): - env_libs = get_all_env_libs() - known_libs = get_all_known_libs() - diff = (list(set(known_libs) - set(env_libs))) - lib_ignore = env.GetProjectOption('lib_ignore') + diff - blab("Ignore libraries: %s" % lib_ignore) - set_env_field('lib_ignore', lib_ignore) - - def apply_features_config(): - load_features() - blab("========== Apply enabled features...") - for feature in FEATURE_CONFIG: - if not env.MarlinHas(feature): - continue - - feat = FEATURE_CONFIG[feature] - - if 'lib_deps' in feat and len(feat['lib_deps']): - blab("========== Adding lib_deps for %s... " % feature, 2) - - # feat to add - deps_to_add = {} - for dep in feat['lib_deps']: - deps_to_add[PackageSpec(dep).name] = dep - blab("==================== %s... " % dep, 2) - - # Does the env already have the dependency? - deps = env.GetProjectOption('lib_deps') - for dep in deps: - name = PackageSpec(dep).name - if name in deps_to_add: - del deps_to_add[name] - - # Are there any libraries that should be ignored? - lib_ignore = env.GetProjectOption('lib_ignore') - for dep in deps: - name = PackageSpec(dep).name - if name in deps_to_add: - del deps_to_add[name] - - # Is there anything left? - if len(deps_to_add) > 0: - # Only add the missing dependencies - set_env_field('lib_deps', deps + list(deps_to_add.values())) - - if 'build_flags' in feat: - f = feat['build_flags'] - blab("========== Adding build_flags for %s: %s" % (feature, f), 2) - new_flags = env.GetProjectOption('build_flags') + [ f ] - env.Replace(BUILD_FLAGS=new_flags) - - if 'extra_scripts' in feat: - blab("Running extra_scripts for %s... " % feature, 2) - env.SConscript(feat['extra_scripts'], exports="env") - - if 'src_filter' in feat: - blab("========== Adding build_src_filter for %s... " % feature, 2) - src_filter = ' '.join(env.GetProjectOption('src_filter')) - # first we need to remove the references to the same folder - my_srcs = re.findall(r'[+-](<.*?>)', feat['src_filter']) - cur_srcs = re.findall(r'[+-](<.*?>)', src_filter) - for d in my_srcs: - if d in cur_srcs: - src_filter = re.sub(r'[+-]' + d, '', src_filter) - - src_filter = feat['src_filter'] + ' ' + src_filter - set_env_field('build_src_filter', [src_filter]) - env.Replace(SRC_FILTER=src_filter) - - if 'lib_ignore' in feat: - blab("========== Adding lib_ignore for %s... " % feature, 2) - lib_ignore = env.GetProjectOption('lib_ignore') + [feat['lib_ignore']] - set_env_field('lib_ignore', lib_ignore) - - # - # Use the compiler to get a list of all enabled features - # - def load_marlin_features(): - if 'MARLIN_FEATURES' in env: - return - - # Process defines - from preprocessor import run_preprocessor - define_list = run_preprocessor(env) - marlin_features = {} - for define in define_list: - feature = define[8:].strip().decode().split(' ') - feature, definition = feature[0], ' '.join(feature[1:]) - marlin_features[feature] = definition - env['MARLIN_FEATURES'] = marlin_features - - # - # Return True if a matching feature is enabled - # - def MarlinHas(env, feature): - load_marlin_features() - r = re.compile('^' + feature + '$') - found = list(filter(r.match, env['MARLIN_FEATURES'])) - - # Defines could still be 'false' or '0', so check - some_on = False - if len(found): - for f in found: - val = env['MARLIN_FEATURES'][f] - if val in [ '', '1', 'true' ]: - some_on = True - elif val in env['MARLIN_FEATURES']: - some_on = env.MarlinHas(val) - - return some_on - - validate_pio() - - try: - verbose = int(env.GetProjectOption('custom_verbose')) - except: - pass - - # - # Add a method for other PIO scripts to query enabled features - # - env.AddMethod(MarlinHas) - - # - # Add dependencies for enabled Marlin features - # - apply_features_config() - force_ignore_unused_libs() - - #print(env.Dump()) - - from signature import compute_build_signature - compute_build_signature(env) + import subprocess,os,re + Import("env") + + from platformio.package.meta import PackageSpec + from platformio.project.config import ProjectConfig + + verbose = 0 + FEATURE_CONFIG = {} + + def validate_pio(): + PIO_VERSION_MIN = (6, 0, 1) + try: + from platformio import VERSION as PIO_VERSION + weights = (1000, 100, 1) + version_min = sum([x[0] * float(re.sub(r'[^0-9]', '.', str(x[1]))) for x in zip(weights, PIO_VERSION_MIN)]) + version_cur = sum([x[0] * float(re.sub(r'[^0-9]', '.', str(x[1]))) for x in zip(weights, PIO_VERSION)]) + if version_cur < version_min: + print() + print("**************************************************") + print("****** An update to PlatformIO is ******") + print("****** required to build Marlin Firmware. ******") + print("****** ******") + print("****** Minimum version: ", PIO_VERSION_MIN, " ******") + print("****** Current Version: ", PIO_VERSION, " ******") + print("****** ******") + print("****** Update PlatformIO and try again. ******") + print("**************************************************") + print() + exit(1) + except SystemExit: + exit(1) + except: + print("Can't detect PlatformIO Version") + + def blab(str,level=1): + if verbose >= level: + print("[deps] %s" % str) + + def add_to_feat_cnf(feature, flines): + + try: + feat = FEATURE_CONFIG[feature] + except: + FEATURE_CONFIG[feature] = {} + + # Get a reference to the FEATURE_CONFIG under construction + feat = FEATURE_CONFIG[feature] + + # Split up passed lines on commas or newlines and iterate + # Add common options to the features config under construction + # For lib_deps replace a previous instance of the same library + atoms = re.sub(r',\s*', '\n', flines).strip().split('\n') + for line in atoms: + parts = line.split('=') + name = parts.pop(0) + if name in ['build_flags', 'extra_scripts', 'src_filter', 'lib_ignore']: + feat[name] = '='.join(parts) + blab("[%s] %s=%s" % (feature, name, feat[name]), 3) + else: + for dep in re.split(r',\s*', line): + lib_name = re.sub(r'@([~^]|[<>]=?)?[\d.]+', '', dep.strip()).split('=').pop(0) + lib_re = re.compile('(?!^' + lib_name + '\\b)') + feat['lib_deps'] = list(filter(lib_re.match, feat['lib_deps'])) + [dep] + blab("[%s] lib_deps = %s" % (feature, dep), 3) + + def load_features(): + blab("========== Gather [features] entries...") + for key in ProjectConfig().items('features'): + feature = key[0].upper() + if not feature in FEATURE_CONFIG: + FEATURE_CONFIG[feature] = { 'lib_deps': [] } + add_to_feat_cnf(feature, key[1]) + + # Add options matching custom_marlin.MY_OPTION to the pile + blab("========== Gather custom_marlin entries...") + for n in env.GetProjectOptions(): + key = n[0] + mat = re.match(r'custom_marlin\.(.+)', key) + if mat: + try: + val = env.GetProjectOption(key) + except: + val = None + if val: + opt = mat[1].upper() + blab("%s.custom_marlin.%s = '%s'" % ( env['PIOENV'], opt, val )) + add_to_feat_cnf(opt, val) + + def get_all_known_libs(): + known_libs = [] + for feature in FEATURE_CONFIG: + feat = FEATURE_CONFIG[feature] + if not 'lib_deps' in feat: + continue + for dep in feat['lib_deps']: + known_libs.append(PackageSpec(dep).name) + return known_libs + + def get_all_env_libs(): + env_libs = [] + lib_deps = env.GetProjectOption('lib_deps') + for dep in lib_deps: + env_libs.append(PackageSpec(dep).name) + return env_libs + + def set_env_field(field, value): + proj = env.GetProjectConfig() + proj.set("env:" + env['PIOENV'], field, value) + + # All unused libs should be ignored so that if a library + # exists in .pio/lib_deps it will not break compilation. + def force_ignore_unused_libs(): + env_libs = get_all_env_libs() + known_libs = get_all_known_libs() + diff = (list(set(known_libs) - set(env_libs))) + lib_ignore = env.GetProjectOption('lib_ignore') + diff + blab("Ignore libraries: %s" % lib_ignore) + set_env_field('lib_ignore', lib_ignore) + + def apply_features_config(): + load_features() + blab("========== Apply enabled features...") + for feature in FEATURE_CONFIG: + if not env.MarlinHas(feature): + continue + + feat = FEATURE_CONFIG[feature] + + if 'lib_deps' in feat and len(feat['lib_deps']): + blab("========== Adding lib_deps for %s... " % feature, 2) + + # feat to add + deps_to_add = {} + for dep in feat['lib_deps']: + deps_to_add[PackageSpec(dep).name] = dep + blab("==================== %s... " % dep, 2) + + # Does the env already have the dependency? + deps = env.GetProjectOption('lib_deps') + for dep in deps: + name = PackageSpec(dep).name + if name in deps_to_add: + del deps_to_add[name] + + # Are there any libraries that should be ignored? + lib_ignore = env.GetProjectOption('lib_ignore') + for dep in deps: + name = PackageSpec(dep).name + if name in deps_to_add: + del deps_to_add[name] + + # Is there anything left? + if len(deps_to_add) > 0: + # Only add the missing dependencies + set_env_field('lib_deps', deps + list(deps_to_add.values())) + + if 'build_flags' in feat: + f = feat['build_flags'] + blab("========== Adding build_flags for %s: %s" % (feature, f), 2) + new_flags = env.GetProjectOption('build_flags') + [ f ] + env.Replace(BUILD_FLAGS=new_flags) + + if 'extra_scripts' in feat: + blab("Running extra_scripts for %s... " % feature, 2) + env.SConscript(feat['extra_scripts'], exports="env") + + if 'src_filter' in feat: + blab("========== Adding build_src_filter for %s... " % feature, 2) + src_filter = ' '.join(env.GetProjectOption('src_filter')) + # first we need to remove the references to the same folder + my_srcs = re.findall(r'[+-](<.*?>)', feat['src_filter']) + cur_srcs = re.findall(r'[+-](<.*?>)', src_filter) + for d in my_srcs: + if d in cur_srcs: + src_filter = re.sub(r'[+-]' + d, '', src_filter) + + src_filter = feat['src_filter'] + ' ' + src_filter + set_env_field('build_src_filter', [src_filter]) + env.Replace(SRC_FILTER=src_filter) + + if 'lib_ignore' in feat: + blab("========== Adding lib_ignore for %s... " % feature, 2) + lib_ignore = env.GetProjectOption('lib_ignore') + [feat['lib_ignore']] + set_env_field('lib_ignore', lib_ignore) + + # + # Use the compiler to get a list of all enabled features + # + def load_marlin_features(): + if 'MARLIN_FEATURES' in env: + return + + # Process defines + from preprocessor import run_preprocessor + define_list = run_preprocessor(env) + marlin_features = {} + for define in define_list: + feature = define[8:].strip().decode().split(' ') + feature, definition = feature[0], ' '.join(feature[1:]) + marlin_features[feature] = definition + env['MARLIN_FEATURES'] = marlin_features + + # + # Return True if a matching feature is enabled + # + def MarlinHas(env, feature): + load_marlin_features() + r = re.compile('^' + feature + '$') + found = list(filter(r.match, env['MARLIN_FEATURES'])) + + # Defines could still be 'false' or '0', so check + some_on = False + if len(found): + for f in found: + val = env['MARLIN_FEATURES'][f] + if val in [ '', '1', 'true' ]: + some_on = True + elif val in env['MARLIN_FEATURES']: + some_on = env.MarlinHas(val) + + return some_on + + validate_pio() + + try: + verbose = int(env.GetProjectOption('custom_verbose')) + except: + pass + + # + # Add a method for other PIO scripts to query enabled features + # + env.AddMethod(MarlinHas) + + # + # Add dependencies for enabled Marlin features + # + apply_features_config() + force_ignore_unused_libs() + + #print(env.Dump()) + + from signature import compute_build_signature + compute_build_signature(env) diff --git a/buildroot/share/PlatformIO/scripts/configuration.py b/buildroot/share/PlatformIO/scripts/configuration.py index 02395f1b8ee2..93ed12fae66f 100644 --- a/buildroot/share/PlatformIO/scripts/configuration.py +++ b/buildroot/share/PlatformIO/scripts/configuration.py @@ -7,229 +7,229 @@ verbose = 0 def blab(str,level=1): - if verbose >= level: print(f"[config] {str}") + if verbose >= level: print(f"[config] {str}") def config_path(cpath): - return Path("Marlin", cpath) + return Path("Marlin", cpath) # Apply a single name = on/off ; name = value ; etc. # TODO: Limit to the given (optional) configuration def apply_opt(name, val, conf=None): - if name == "lcd": name, val = val, "on" - - # Create a regex to match the option and capture parts of the line - regex = re.compile(rf'^(\s*)(//\s*)?(#define\s+)({name}\b)(\s*)(.*?)(\s*)(//.*)?$', re.IGNORECASE) - - # Find and enable and/or update all matches - for file in ("Configuration.h", "Configuration_adv.h"): - fullpath = config_path(file) - lines = fullpath.read_text().split('\n') - found = False - for i in range(len(lines)): - line = lines[i] - match = regex.match(line) - if match and match[4].upper() == name.upper(): - found = True - # For boolean options un/comment the define - if val in ("on", "", None): - newline = re.sub(r'^(\s*)//+\s*(#define)(\s{1,3})?(\s*)', r'\1\2 \4', line) - elif val == "off": - newline = re.sub(r'^(\s*)(#define)(\s{1,3})?(\s*)', r'\1//\2 \4', line) - else: - # For options with values, enable and set the value - newline = match[1] + match[3] + match[4] + match[5] + val - if match[8]: - sp = match[7] if match[7] else ' ' - newline += sp + match[8] - lines[i] = newline - blab(f"Set {name} to {val}") - - # If the option was found, write the modified lines - if found: - fullpath.write_text('\n'.join(lines)) - break - - # If the option didn't appear in either config file, add it - if not found: - # OFF options are added as disabled items so they appear - # in config dumps. Useful for custom settings. - prefix = "" - if val == "off": - prefix, val = "//", "" # Item doesn't appear in config dump - #val = "false" # Item appears in config dump - - # Uppercase the option unless already mixed/uppercase - added = name.upper() if name.islower() else name - - # Add the provided value after the name - if val != "on" and val != "" and val is not None: - added += " " + val - - # Prepend the new option after the first set of #define lines - fullpath = config_path("Configuration.h") - with fullpath.open() as f: - lines = f.readlines() - linenum = 0 - gotdef = False - for line in lines: - isdef = line.startswith("#define") - if not gotdef: - gotdef = isdef - elif not isdef: - break - linenum += 1 - lines.insert(linenum, f"{prefix}#define {added} // Added by config.ini\n") - fullpath.write_text('\n'.join(lines)) + if name == "lcd": name, val = val, "on" + + # Create a regex to match the option and capture parts of the line + regex = re.compile(rf'^(\s*)(//\s*)?(#define\s+)({name}\b)(\s*)(.*?)(\s*)(//.*)?$', re.IGNORECASE) + + # Find and enable and/or update all matches + for file in ("Configuration.h", "Configuration_adv.h"): + fullpath = config_path(file) + lines = fullpath.read_text().split('\n') + found = False + for i in range(len(lines)): + line = lines[i] + match = regex.match(line) + if match and match[4].upper() == name.upper(): + found = True + # For boolean options un/comment the define + if val in ("on", "", None): + newline = re.sub(r'^(\s*)//+\s*(#define)(\s{1,3})?(\s*)', r'\1\2 \4', line) + elif val == "off": + newline = re.sub(r'^(\s*)(#define)(\s{1,3})?(\s*)', r'\1//\2 \4', line) + else: + # For options with values, enable and set the value + newline = match[1] + match[3] + match[4] + match[5] + val + if match[8]: + sp = match[7] if match[7] else ' ' + newline += sp + match[8] + lines[i] = newline + blab(f"Set {name} to {val}") + + # If the option was found, write the modified lines + if found: + fullpath.write_text('\n'.join(lines)) + break + + # If the option didn't appear in either config file, add it + if not found: + # OFF options are added as disabled items so they appear + # in config dumps. Useful for custom settings. + prefix = "" + if val == "off": + prefix, val = "//", "" # Item doesn't appear in config dump + #val = "false" # Item appears in config dump + + # Uppercase the option unless already mixed/uppercase + added = name.upper() if name.islower() else name + + # Add the provided value after the name + if val != "on" and val != "" and val is not None: + added += " " + val + + # Prepend the new option after the first set of #define lines + fullpath = config_path("Configuration.h") + with fullpath.open() as f: + lines = f.readlines() + linenum = 0 + gotdef = False + for line in lines: + isdef = line.startswith("#define") + if not gotdef: + gotdef = isdef + elif not isdef: + break + linenum += 1 + lines.insert(linenum, f"{prefix}#define {added} // Added by config.ini\n") + fullpath.write_text('\n'.join(lines)) # Fetch configuration files from GitHub given the path. # Return True if any files were fetched. def fetch_example(url): - if url.endswith("/"): url = url[:-1] - if url.startswith('http'): - url = url.replace("%", "%25").replace(" ", "%20") - else: - brch = "bugfix-2.1.x" - if '@' in path: path, brch = map(str.strip, path.split('@')) - url = f"https://raw.githubusercontent.com/MarlinFirmware/Configurations/{brch}/config/{url}" - - # Find a suitable fetch command - if shutil.which("curl") is not None: - fetch = "curl -L -s -S -f -o" - elif shutil.which("wget") is not None: - fetch = "wget -q -O" - else: - blab("Couldn't find curl or wget", -1) - return False - - import os - - # Reset configurations to default - os.system("git reset --hard HEAD") - - # Try to fetch the remote files - gotfile = False - for fn in ("Configuration.h", "Configuration_adv.h", "_Bootscreen.h", "_Statusscreen.h"): - if os.system(f"{fetch} wgot {url}/{fn} >/dev/null 2>&1") == 0: - shutil.move('wgot', config_path(fn)) - gotfile = True - - if Path('wgot').exists(): shutil.rmtree('wgot') - - return gotfile + if url.endswith("/"): url = url[:-1] + if url.startswith('http'): + url = url.replace("%", "%25").replace(" ", "%20") + else: + brch = "bugfix-2.1.x" + if '@' in path: path, brch = map(str.strip, path.split('@')) + url = f"https://raw.githubusercontent.com/MarlinFirmware/Configurations/{brch}/config/{url}" + + # Find a suitable fetch command + if shutil.which("curl") is not None: + fetch = "curl -L -s -S -f -o" + elif shutil.which("wget") is not None: + fetch = "wget -q -O" + else: + blab("Couldn't find curl or wget", -1) + return False + + import os + + # Reset configurations to default + os.system("git reset --hard HEAD") + + # Try to fetch the remote files + gotfile = False + for fn in ("Configuration.h", "Configuration_adv.h", "_Bootscreen.h", "_Statusscreen.h"): + if os.system(f"{fetch} wgot {url}/{fn} >/dev/null 2>&1") == 0: + shutil.move('wgot', config_path(fn)) + gotfile = True + + if Path('wgot').exists(): shutil.rmtree('wgot') + + return gotfile def section_items(cp, sectkey): - return cp.items(sectkey) if sectkey in cp.sections() else [] + return cp.items(sectkey) if sectkey in cp.sections() else [] # Apply all items from a config section def apply_ini_by_name(cp, sect): - iniok = True - if sect in ('config:base', 'config:root'): - iniok = False - items = section_items(cp, 'config:base') + section_items(cp, 'config:root') - else: - items = cp.items(sect) + iniok = True + if sect in ('config:base', 'config:root'): + iniok = False + items = section_items(cp, 'config:base') + section_items(cp, 'config:root') + else: + items = cp.items(sect) - for item in items: - if iniok or not item[0].startswith('ini_'): - apply_opt(item[0], item[1]) + for item in items: + if iniok or not item[0].startswith('ini_'): + apply_opt(item[0], item[1]) # Apply all config sections from a parsed file def apply_all_sections(cp): - for sect in cp.sections(): - if sect.startswith('config:'): - apply_ini_by_name(cp, sect) + for sect in cp.sections(): + if sect.startswith('config:'): + apply_ini_by_name(cp, sect) # Apply certain config sections from a parsed file def apply_sections(cp, ckey='all'): - blab(f"Apply section key: {ckey}") - if ckey == 'all': - apply_all_sections(cp) - else: - # Apply the base/root config.ini settings after external files are done - if ckey in ('base', 'root'): - apply_ini_by_name(cp, 'config:base') - - # Apply historically 'Configuration.h' settings everywhere - if ckey == 'basic': - apply_ini_by_name(cp, 'config:basic') - - # Apply historically Configuration_adv.h settings everywhere - # (Some of which rely on defines in 'Conditionals_LCD.h') - elif ckey in ('adv', 'advanced'): - apply_ini_by_name(cp, 'config:advanced') - - # Apply a specific config: section directly - elif ckey.startswith('config:'): - apply_ini_by_name(cp, ckey) + blab(f"Apply section key: {ckey}") + if ckey == 'all': + apply_all_sections(cp) + else: + # Apply the base/root config.ini settings after external files are done + if ckey in ('base', 'root'): + apply_ini_by_name(cp, 'config:base') + + # Apply historically 'Configuration.h' settings everywhere + if ckey == 'basic': + apply_ini_by_name(cp, 'config:basic') + + # Apply historically Configuration_adv.h settings everywhere + # (Some of which rely on defines in 'Conditionals_LCD.h') + elif ckey in ('adv', 'advanced'): + apply_ini_by_name(cp, 'config:advanced') + + # Apply a specific config: section directly + elif ckey.startswith('config:'): + apply_ini_by_name(cp, ckey) # Apply settings from a top level config.ini def apply_config_ini(cp): - blab("=" * 20 + " Gather 'config.ini' entries...") - - # Pre-scan for ini_use_config to get config_keys - base_items = section_items(cp, 'config:base') + section_items(cp, 'config:root') - config_keys = ['base'] - for ikey, ival in base_items: - if ikey == 'ini_use_config': - config_keys = map(str.strip, ival.split(',')) - - # For each ini_use_config item perform an action - for ckey in config_keys: - addbase = False - - # For a key ending in .ini load and parse another .ini file - if ckey.endswith('.ini'): - sect = 'base' - if '@' in ckey: sect, ckey = ckey.split('@') - other_ini = configparser.ConfigParser() - other_ini.read(config_path(ckey)) - apply_sections(other_ini, sect) - - # (Allow 'example/' as a shortcut for 'examples/') - elif ckey.startswith('example/'): - ckey = 'examples' + ckey[7:] - - # For 'examples/' fetch an example set from GitHub. - # For https?:// do a direct fetch of the URL. - elif ckey.startswith('examples/') or ckey.startswith('http'): - fetch_example(ckey) - ckey = 'base' - - # Apply keyed sections after external files are done - apply_sections(cp, 'config:' + ckey) + blab("=" * 20 + " Gather 'config.ini' entries...") + + # Pre-scan for ini_use_config to get config_keys + base_items = section_items(cp, 'config:base') + section_items(cp, 'config:root') + config_keys = ['base'] + for ikey, ival in base_items: + if ikey == 'ini_use_config': + config_keys = map(str.strip, ival.split(',')) + + # For each ini_use_config item perform an action + for ckey in config_keys: + addbase = False + + # For a key ending in .ini load and parse another .ini file + if ckey.endswith('.ini'): + sect = 'base' + if '@' in ckey: sect, ckey = ckey.split('@') + other_ini = configparser.ConfigParser() + other_ini.read(config_path(ckey)) + apply_sections(other_ini, sect) + + # (Allow 'example/' as a shortcut for 'examples/') + elif ckey.startswith('example/'): + ckey = 'examples' + ckey[7:] + + # For 'examples/' fetch an example set from GitHub. + # For https?:// do a direct fetch of the URL. + elif ckey.startswith('examples/') or ckey.startswith('http'): + fetch_example(ckey) + ckey = 'base' + + # Apply keyed sections after external files are done + apply_sections(cp, 'config:' + ckey) if __name__ == "__main__": - # - # From command line use the given file name - # - import sys - args = sys.argv[1:] - if len(args) > 0: - if args[0].endswith('.ini'): - ini_file = args[0] - else: - print("Usage: %s <.ini file>" % sys.argv[0]) - else: - ini_file = config_path('config.ini') - - if ini_file: - user_ini = configparser.ConfigParser() - user_ini.read(ini_file) - apply_config_ini(user_ini) + # + # From command line use the given file name + # + import sys + args = sys.argv[1:] + if len(args) > 0: + if args[0].endswith('.ini'): + ini_file = args[0] + else: + print("Usage: %s <.ini file>" % sys.argv[0]) + else: + ini_file = config_path('config.ini') + + if ini_file: + user_ini = configparser.ConfigParser() + user_ini.read(ini_file) + apply_config_ini(user_ini) else: - # - # From within PlatformIO use the loaded INI file - # - import pioutil - if pioutil.is_pio_build(): + # + # From within PlatformIO use the loaded INI file + # + import pioutil + if pioutil.is_pio_build(): - Import("env") + Import("env") - try: - verbose = int(env.GetProjectOption('custom_verbose')) - except: - pass + try: + verbose = int(env.GetProjectOption('custom_verbose')) + except: + pass - from platformio.project.config import ProjectConfig - apply_config_ini(ProjectConfig()) + from platformio.project.config import ProjectConfig + apply_config_ini(ProjectConfig()) diff --git a/buildroot/share/PlatformIO/scripts/custom_board.py b/buildroot/share/PlatformIO/scripts/custom_board.py index da3bdca0bbe7..7a8fe91be066 100644 --- a/buildroot/share/PlatformIO/scripts/custom_board.py +++ b/buildroot/share/PlatformIO/scripts/custom_board.py @@ -6,13 +6,13 @@ # import pioutil if pioutil.is_pio_build(): - import marlin - board = marlin.env.BoardConfig() + import marlin + board = marlin.env.BoardConfig() - address = board.get("build.address", "") - if address: - marlin.relocate_firmware(address) + address = board.get("build.address", "") + if address: + marlin.relocate_firmware(address) - ldscript = board.get("build.ldscript", "") - if ldscript: - marlin.custom_ld_script(ldscript) + ldscript = board.get("build.ldscript", "") + if ldscript: + marlin.custom_ld_script(ldscript) diff --git a/buildroot/share/PlatformIO/scripts/download_mks_assets.py b/buildroot/share/PlatformIO/scripts/download_mks_assets.py index 8d186b755f51..661fb2e438e4 100644 --- a/buildroot/share/PlatformIO/scripts/download_mks_assets.py +++ b/buildroot/share/PlatformIO/scripts/download_mks_assets.py @@ -4,50 +4,50 @@ # import pioutil if pioutil.is_pio_build(): - Import("env") - import requests,zipfile,tempfile,shutil - from pathlib import Path + Import("env") + import requests,zipfile,tempfile,shutil + from pathlib import Path - url = "https://github.com/makerbase-mks/Mks-Robin-Nano-Marlin2.0-Firmware/archive/0263cdaccf.zip" - deps_path = Path(env.Dictionary("PROJECT_LIBDEPS_DIR")) - zip_path = deps_path / "mks-assets.zip" - assets_path = Path(env.Dictionary("PROJECT_BUILD_DIR"), env.Dictionary("PIOENV"), "assets") + url = "https://github.com/makerbase-mks/Mks-Robin-Nano-Marlin2.0-Firmware/archive/0263cdaccf.zip" + deps_path = Path(env.Dictionary("PROJECT_LIBDEPS_DIR")) + zip_path = deps_path / "mks-assets.zip" + assets_path = Path(env.Dictionary("PROJECT_BUILD_DIR"), env.Dictionary("PIOENV"), "assets") - def download_mks_assets(): - print("Downloading MKS Assets") - r = requests.get(url, stream=True) - # the user may have a very clean workspace, - # so create the PROJECT_LIBDEPS_DIR directory if not exits - if not deps_path.exists(): - deps_path.mkdir() - with zip_path.open('wb') as fd: - for chunk in r.iter_content(chunk_size=128): - fd.write(chunk) + def download_mks_assets(): + print("Downloading MKS Assets") + r = requests.get(url, stream=True) + # the user may have a very clean workspace, + # so create the PROJECT_LIBDEPS_DIR directory if not exits + if not deps_path.exists(): + deps_path.mkdir() + with zip_path.open('wb') as fd: + for chunk in r.iter_content(chunk_size=128): + fd.write(chunk) - def copy_mks_assets(): - print("Copying MKS Assets") - output_path = Path(tempfile.mkdtemp()) - zip_obj = zipfile.ZipFile(zip_path, 'r') - zip_obj.extractall(output_path) - zip_obj.close() - if assets_path.exists() and not assets_path.is_dir(): - assets_path.unlink() - if not assets_path.exists(): - assets_path.mkdir() - base_path = '' - for filename in output_path.iterdir(): - base_path = filename - fw_path = (output_path / base_path / 'Firmware') - font_path = fw_path / 'mks_font' - for filename in font_path.iterdir(): - shutil.copy(font_path / filename, assets_path) - pic_path = fw_path / 'mks_pic' - for filename in pic_path.iterdir(): - shutil.copy(pic_path / filename, assets_path) - shutil.rmtree(output_path, ignore_errors=True) + def copy_mks_assets(): + print("Copying MKS Assets") + output_path = Path(tempfile.mkdtemp()) + zip_obj = zipfile.ZipFile(zip_path, 'r') + zip_obj.extractall(output_path) + zip_obj.close() + if assets_path.exists() and not assets_path.is_dir(): + assets_path.unlink() + if not assets_path.exists(): + assets_path.mkdir() + base_path = '' + for filename in output_path.iterdir(): + base_path = filename + fw_path = (output_path / base_path / 'Firmware') + font_path = fw_path / 'mks_font' + for filename in font_path.iterdir(): + shutil.copy(font_path / filename, assets_path) + pic_path = fw_path / 'mks_pic' + for filename in pic_path.iterdir(): + shutil.copy(pic_path / filename, assets_path) + shutil.rmtree(output_path, ignore_errors=True) - if not zip_path.exists(): - download_mks_assets() + if not zip_path.exists(): + download_mks_assets() - if not assets_path.exists(): - copy_mks_assets() + if not assets_path.exists(): + copy_mks_assets() diff --git a/buildroot/share/PlatformIO/scripts/fix_framework_weakness.py b/buildroot/share/PlatformIO/scripts/fix_framework_weakness.py index 83ed17ccca1c..879a7da3d49b 100644 --- a/buildroot/share/PlatformIO/scripts/fix_framework_weakness.py +++ b/buildroot/share/PlatformIO/scripts/fix_framework_weakness.py @@ -4,32 +4,32 @@ import pioutil if pioutil.is_pio_build(): - import shutil - from os.path import join, isfile - from pprint import pprint + import shutil + from os.path import join, isfile + from pprint import pprint - Import("env") + Import("env") - if env.MarlinHas("POSTMORTEM_DEBUGGING"): - FRAMEWORK_DIR = env.PioPlatform().get_package_dir("framework-arduinoststm32-maple") - patchflag_path = join(FRAMEWORK_DIR, ".exc-patching-done") + if env.MarlinHas("POSTMORTEM_DEBUGGING"): + FRAMEWORK_DIR = env.PioPlatform().get_package_dir("framework-arduinoststm32-maple") + patchflag_path = join(FRAMEWORK_DIR, ".exc-patching-done") - # patch file only if we didn't do it before - if not isfile(patchflag_path): - print("Patching libmaple exception handlers") - original_file = join(FRAMEWORK_DIR, "STM32F1", "cores", "maple", "libmaple", "exc.S") - backup_file = join(FRAMEWORK_DIR, "STM32F1", "cores", "maple", "libmaple", "exc.S.bak") - src_file = join("buildroot", "share", "PlatformIO", "scripts", "exc.S") + # patch file only if we didn't do it before + if not isfile(patchflag_path): + print("Patching libmaple exception handlers") + original_file = join(FRAMEWORK_DIR, "STM32F1", "cores", "maple", "libmaple", "exc.S") + backup_file = join(FRAMEWORK_DIR, "STM32F1", "cores", "maple", "libmaple", "exc.S.bak") + src_file = join("buildroot", "share", "PlatformIO", "scripts", "exc.S") - assert isfile(original_file) and isfile(src_file) - shutil.copyfile(original_file, backup_file) - shutil.copyfile(src_file, original_file); + assert isfile(original_file) and isfile(src_file) + shutil.copyfile(original_file, backup_file) + shutil.copyfile(src_file, original_file); - def _touch(path): - with open(path, "w") as fp: - fp.write("") + def _touch(path): + with open(path, "w") as fp: + fp.write("") - env.Execute(lambda *args, **kwargs: _touch(patchflag_path)) - print("Done patching exception handler") + env.Execute(lambda *args, **kwargs: _touch(patchflag_path)) + print("Done patching exception handler") - print("Libmaple modified and ready for post mortem debugging") + print("Libmaple modified and ready for post mortem debugging") diff --git a/buildroot/share/PlatformIO/scripts/generic_create_variant.py b/buildroot/share/PlatformIO/scripts/generic_create_variant.py index 5e3637604fb2..49d4c98d3e15 100644 --- a/buildroot/share/PlatformIO/scripts/generic_create_variant.py +++ b/buildroot/share/PlatformIO/scripts/generic_create_variant.py @@ -7,52 +7,52 @@ # import pioutil if pioutil.is_pio_build(): - import shutil,marlin - from pathlib import Path - - # - # Get the platform name from the 'platform_packages' option, - # or look it up by the platform.class.name. - # - env = marlin.env - platform = env.PioPlatform() - - from platformio.package.meta import PackageSpec - platform_packages = env.GetProjectOption('platform_packages') - - # Remove all tool items from platform_packages - platform_packages = [x for x in platform_packages if not x.startswith("platformio/tool-")] - - if len(platform_packages) == 0: - framewords = { - "Ststm32Platform": "framework-arduinoststm32", - "AtmelavrPlatform": "framework-arduino-avr" - } - platform_name = framewords[platform.__class__.__name__] - else: - platform_name = PackageSpec(platform_packages[0]).name - - if platform_name in [ "usb-host-msc", "usb-host-msc-cdc-msc", "usb-host-msc-cdc-msc-2", "usb-host-msc-cdc-msc-3", "tool-stm32duino", "biqu-bx-workaround", "main" ]: - platform_name = "framework-arduinoststm32" - - FRAMEWORK_DIR = Path(platform.get_package_dir(platform_name)) - assert FRAMEWORK_DIR.is_dir() - - board = env.BoardConfig() - - #mcu_type = board.get("build.mcu")[:-2] - variant = board.get("build.variant") - #series = mcu_type[:7].upper() + "xx" - - # Prepare a new empty folder at the destination - variant_dir = FRAMEWORK_DIR / "variants" / variant - if variant_dir.is_dir(): - shutil.rmtree(variant_dir) - if not variant_dir.is_dir(): - variant_dir.mkdir() - - # Source dir is a local variant sub-folder - source_dir = Path("buildroot/share/PlatformIO/variants", variant) - assert source_dir.is_dir() - - marlin.copytree(source_dir, variant_dir) + import shutil,marlin + from pathlib import Path + + # + # Get the platform name from the 'platform_packages' option, + # or look it up by the platform.class.name. + # + env = marlin.env + platform = env.PioPlatform() + + from platformio.package.meta import PackageSpec + platform_packages = env.GetProjectOption('platform_packages') + + # Remove all tool items from platform_packages + platform_packages = [x for x in platform_packages if not x.startswith("platformio/tool-")] + + if len(platform_packages) == 0: + framewords = { + "Ststm32Platform": "framework-arduinoststm32", + "AtmelavrPlatform": "framework-arduino-avr" + } + platform_name = framewords[platform.__class__.__name__] + else: + platform_name = PackageSpec(platform_packages[0]).name + + if platform_name in [ "usb-host-msc", "usb-host-msc-cdc-msc", "usb-host-msc-cdc-msc-2", "usb-host-msc-cdc-msc-3", "tool-stm32duino", "biqu-bx-workaround", "main" ]: + platform_name = "framework-arduinoststm32" + + FRAMEWORK_DIR = Path(platform.get_package_dir(platform_name)) + assert FRAMEWORK_DIR.is_dir() + + board = env.BoardConfig() + + #mcu_type = board.get("build.mcu")[:-2] + variant = board.get("build.variant") + #series = mcu_type[:7].upper() + "xx" + + # Prepare a new empty folder at the destination + variant_dir = FRAMEWORK_DIR / "variants" / variant + if variant_dir.is_dir(): + shutil.rmtree(variant_dir) + if not variant_dir.is_dir(): + variant_dir.mkdir() + + # Source dir is a local variant sub-folder + source_dir = Path("buildroot/share/PlatformIO/variants", variant) + assert source_dir.is_dir() + + marlin.copytree(source_dir, variant_dir) diff --git a/buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py b/buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py index b9516931b514..9256751096c5 100644 --- a/buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py +++ b/buildroot/share/PlatformIO/scripts/jgaurora_a5s_a1_with_bootloader.py @@ -5,31 +5,31 @@ import pioutil if pioutil.is_pio_build(): - # Append ${PROGNAME}.bin firmware after bootloader and save it as 'jgaurora_firmware.bin' - def addboot(source, target, env): - from pathlib import Path + # Append ${PROGNAME}.bin firmware after bootloader and save it as 'jgaurora_firmware.bin' + def addboot(source, target, env): + from pathlib import Path - fw_path = Path(target[0].path) - fwb_path = fw_path.parent / 'firmware_with_bootloader.bin' - with fwb_path.open("wb") as fwb_file: - bl_path = Path("buildroot/share/PlatformIO/scripts/jgaurora_bootloader.bin") - bl_file = bl_path.open("rb") - while True: - b = bl_file.read(1) - if b == b'': break - else: fwb_file.write(b) + fw_path = Path(target[0].path) + fwb_path = fw_path.parent / 'firmware_with_bootloader.bin' + with fwb_path.open("wb") as fwb_file: + bl_path = Path("buildroot/share/PlatformIO/scripts/jgaurora_bootloader.bin") + bl_file = bl_path.open("rb") + while True: + b = bl_file.read(1) + if b == b'': break + else: fwb_file.write(b) - with fw_path.open("rb") as fw_file: - while True: - b = fw_file.read(1) - if b == b'': break - else: fwb_file.write(b) + with fw_path.open("rb") as fw_file: + while True: + b = fw_file.read(1) + if b == b'': break + else: fwb_file.write(b) - fws_path = Path(target[0].dir.path, 'firmware_for_sd_upload.bin') - if fws_path.exists(): - fws_path.unlink() + fws_path = Path(target[0].dir.path, 'firmware_for_sd_upload.bin') + if fws_path.exists(): + fws_path.unlink() - fw_path.rename(fws_path) + fw_path.rename(fws_path) - import marlin - marlin.add_post_action(addboot); + import marlin + marlin.add_post_action(addboot); diff --git a/buildroot/share/PlatformIO/scripts/lerdge.py b/buildroot/share/PlatformIO/scripts/lerdge.py index dc0c633139df..607fe312ac84 100644 --- a/buildroot/share/PlatformIO/scripts/lerdge.py +++ b/buildroot/share/PlatformIO/scripts/lerdge.py @@ -7,41 +7,41 @@ # import pioutil if pioutil.is_pio_build(): - import os,marlin + import os,marlin - board = marlin.env.BoardConfig() + board = marlin.env.BoardConfig() - def encryptByte(byte): - byte = 0xFF & ((byte << 6) | (byte >> 2)) - i = 0x58 + byte - j = 0x05 + byte + (i >> 8) - byte = (0xF8 & i) | (0x07 & j) - return byte + def encryptByte(byte): + byte = 0xFF & ((byte << 6) | (byte >> 2)) + i = 0x58 + byte + j = 0x05 + byte + (i >> 8) + byte = (0xF8 & i) | (0x07 & j) + return byte - def encrypt_file(input, output_file, file_length): - input_file = bytearray(input.read()) - for i in range(len(input_file)): - input_file[i] = encryptByte(input_file[i]) - output_file.write(input_file) + def encrypt_file(input, output_file, file_length): + input_file = bytearray(input.read()) + for i in range(len(input_file)): + input_file[i] = encryptByte(input_file[i]) + output_file.write(input_file) - # Encrypt ${PROGNAME}.bin and save it with the name given in build.crypt_lerdge - def encrypt(source, target, env): - fwpath = target[0].path - enname = board.get("build.crypt_lerdge") - print("Encrypting %s to %s" % (fwpath, enname)) - fwfile = open(fwpath, "rb") - enfile = open(target[0].dir.path + "/" + enname, "wb") - length = os.path.getsize(fwpath) + # Encrypt ${PROGNAME}.bin and save it with the name given in build.crypt_lerdge + def encrypt(source, target, env): + fwpath = target[0].path + enname = board.get("build.crypt_lerdge") + print("Encrypting %s to %s" % (fwpath, enname)) + fwfile = open(fwpath, "rb") + enfile = open(target[0].dir.path + "/" + enname, "wb") + length = os.path.getsize(fwpath) - encrypt_file(fwfile, enfile, length) + encrypt_file(fwfile, enfile, length) - fwfile.close() - enfile.close() - os.remove(fwpath) + fwfile.close() + enfile.close() + os.remove(fwpath) - if 'crypt_lerdge' in board.get("build").keys(): - if board.get("build.crypt_lerdge") != "": - marlin.add_post_action(encrypt) - else: - print("LERDGE builds require output file via board_build.crypt_lerdge = 'filename' parameter") - exit(1) + if 'crypt_lerdge' in board.get("build").keys(): + if board.get("build.crypt_lerdge") != "": + marlin.add_post_action(encrypt) + else: + print("LERDGE builds require output file via board_build.crypt_lerdge = 'filename' parameter") + exit(1) diff --git a/buildroot/share/PlatformIO/scripts/marlin.py b/buildroot/share/PlatformIO/scripts/marlin.py index 068d0331a82e..169dd9d3c3a5 100644 --- a/buildroot/share/PlatformIO/scripts/marlin.py +++ b/buildroot/share/PlatformIO/scripts/marlin.py @@ -9,64 +9,64 @@ env = DefaultEnvironment() def copytree(src, dst, symlinks=False, ignore=None): - for item in src.iterdir(): - if item.is_dir(): - shutil.copytree(item, dst / item.name, symlinks, ignore) - else: - shutil.copy2(item, dst / item.name) + for item in src.iterdir(): + if item.is_dir(): + shutil.copytree(item, dst / item.name, symlinks, ignore) + else: + shutil.copy2(item, dst / item.name) def replace_define(field, value): - for define in env['CPPDEFINES']: - if define[0] == field: - env['CPPDEFINES'].remove(define) - env['CPPDEFINES'].append((field, value)) + for define in env['CPPDEFINES']: + if define[0] == field: + env['CPPDEFINES'].remove(define) + env['CPPDEFINES'].append((field, value)) # Relocate the firmware to a new address, such as "0x08005000" def relocate_firmware(address): - replace_define("VECT_TAB_ADDR", address) + replace_define("VECT_TAB_ADDR", address) # Relocate the vector table with a new offset def relocate_vtab(address): - replace_define("VECT_TAB_OFFSET", address) + replace_define("VECT_TAB_OFFSET", address) # Replace the existing -Wl,-T with the given ldscript path def custom_ld_script(ldname): - apath = str(Path("buildroot/share/PlatformIO/ldscripts", ldname).resolve()) - for i, flag in enumerate(env["LINKFLAGS"]): - if "-Wl,-T" in flag: - env["LINKFLAGS"][i] = "-Wl,-T" + apath - elif flag == "-T": - env["LINKFLAGS"][i + 1] = apath + apath = str(Path("buildroot/share/PlatformIO/ldscripts", ldname).resolve()) + for i, flag in enumerate(env["LINKFLAGS"]): + if "-Wl,-T" in flag: + env["LINKFLAGS"][i] = "-Wl,-T" + apath + elif flag == "-T": + env["LINKFLAGS"][i + 1] = apath # Encrypt ${PROGNAME}.bin and save it with a new name. This applies (mostly) to MKS boards # This PostAction is set up by offset_and_rename.py for envs with 'build.encrypt_mks'. def encrypt_mks(source, target, env, new_name): - import sys + import sys - key = [0xA3, 0xBD, 0xAD, 0x0D, 0x41, 0x11, 0xBB, 0x8D, 0xDC, 0x80, 0x2D, 0xD0, 0xD2, 0xC4, 0x9B, 0x1E, 0x26, 0xEB, 0xE3, 0x33, 0x4A, 0x15, 0xE4, 0x0A, 0xB3, 0xB1, 0x3C, 0x93, 0xBB, 0xAF, 0xF7, 0x3E] + key = [0xA3, 0xBD, 0xAD, 0x0D, 0x41, 0x11, 0xBB, 0x8D, 0xDC, 0x80, 0x2D, 0xD0, 0xD2, 0xC4, 0x9B, 0x1E, 0x26, 0xEB, 0xE3, 0x33, 0x4A, 0x15, 0xE4, 0x0A, 0xB3, 0xB1, 0x3C, 0x93, 0xBB, 0xAF, 0xF7, 0x3E] - # If FIRMWARE_BIN is defined by config, override all - mf = env["MARLIN_FEATURES"] - if "FIRMWARE_BIN" in mf: new_name = mf["FIRMWARE_BIN"] + # If FIRMWARE_BIN is defined by config, override all + mf = env["MARLIN_FEATURES"] + if "FIRMWARE_BIN" in mf: new_name = mf["FIRMWARE_BIN"] - fwpath = Path(target[0].path) - fwfile = fwpath.open("rb") - enfile = Path(target[0].dir.path, new_name).open("wb") - length = fwpath.stat().st_size - position = 0 - try: - while position < length: - byte = fwfile.read(1) - if 320 <= position < 31040: - byte = chr(ord(byte) ^ key[position & 31]) - if sys.version_info[0] > 2: - byte = bytes(byte, 'latin1') - enfile.write(byte) - position += 1 - finally: - fwfile.close() - enfile.close() - fwpath.unlink() + fwpath = Path(target[0].path) + fwfile = fwpath.open("rb") + enfile = Path(target[0].dir.path, new_name).open("wb") + length = fwpath.stat().st_size + position = 0 + try: + while position < length: + byte = fwfile.read(1) + if 320 <= position < 31040: + byte = chr(ord(byte) ^ key[position & 31]) + if sys.version_info[0] > 2: + byte = bytes(byte, 'latin1') + enfile.write(byte) + position += 1 + finally: + fwfile.close() + enfile.close() + fwpath.unlink() def add_post_action(action): - env.AddPostAction(str(Path("$BUILD_DIR", "${PROGNAME}.bin")), action); + env.AddPostAction(str(Path("$BUILD_DIR", "${PROGNAME}.bin")), action); diff --git a/buildroot/share/PlatformIO/scripts/mc-apply.py b/buildroot/share/PlatformIO/scripts/mc-apply.py index f71d192679d3..ed0ed795c6b1 100755 --- a/buildroot/share/PlatformIO/scripts/mc-apply.py +++ b/buildroot/share/PlatformIO/scripts/mc-apply.py @@ -11,59 +11,59 @@ output_suffix = '.sh' if opt_output else '' if '--bare-output' in sys.argv else '.gen' try: - with open('marlin_config.json', 'r') as infile: - conf = json.load(infile) - for key in conf: - # We don't care about the hash when restoring here - if key == '__INITIAL_HASH': - continue - if key == 'VERSION': - for k, v in sorted(conf[key].items()): - print(k + ': ' + v) - continue - # The key is the file name, so let's build it now - outfile = open('Marlin/' + key + output_suffix, 'w') - for k, v in sorted(conf[key].items()): - # Make define line now - if opt_output: - if v != '': - if '"' in v: - v = "'%s'" % v - elif ' ' in v: - v = '"%s"' % v - define = 'opt_set ' + k + ' ' + v + '\n' - else: - define = 'opt_enable ' + k + '\n' - else: - define = '#define ' + k + ' ' + v + '\n' - outfile.write(define) - outfile.close() + with open('marlin_config.json', 'r') as infile: + conf = json.load(infile) + for key in conf: + # We don't care about the hash when restoring here + if key == '__INITIAL_HASH': + continue + if key == 'VERSION': + for k, v in sorted(conf[key].items()): + print(k + ': ' + v) + continue + # The key is the file name, so let's build it now + outfile = open('Marlin/' + key + output_suffix, 'w') + for k, v in sorted(conf[key].items()): + # Make define line now + if opt_output: + if v != '': + if '"' in v: + v = "'%s'" % v + elif ' ' in v: + v = '"%s"' % v + define = 'opt_set ' + k + ' ' + v + '\n' + else: + define = 'opt_enable ' + k + '\n' + else: + define = '#define ' + k + ' ' + v + '\n' + outfile.write(define) + outfile.close() - # Try to apply changes to the actual configuration file (in order to keep useful comments) - if output_suffix != '': - # Move the existing configuration so it doesn't interfere - shutil.move('Marlin/' + key, 'Marlin/' + key + '.orig') - infile_lines = open('Marlin/' + key + '.orig', 'r').read().split('\n') - outfile = open('Marlin/' + key, 'w') - for line in infile_lines: - sline = line.strip(" \t\n\r") - if sline[:7] == "#define": - # Extract the key here (we don't care about the value) - kv = sline[8:].strip().split(' ') - if kv[0] in conf[key]: - outfile.write('#define ' + kv[0] + ' ' + conf[key][kv[0]] + '\n') - # Remove the key from the dict, so we can still write all missing keys at the end of the file - del conf[key][kv[0]] - else: - outfile.write(line + '\n') - else: - outfile.write(line + '\n') - # Process any remaining defines here - for k, v in sorted(conf[key].items()): - define = '#define ' + k + ' ' + v + '\n' - outfile.write(define) - outfile.close() + # Try to apply changes to the actual configuration file (in order to keep useful comments) + if output_suffix != '': + # Move the existing configuration so it doesn't interfere + shutil.move('Marlin/' + key, 'Marlin/' + key + '.orig') + infile_lines = open('Marlin/' + key + '.orig', 'r').read().split('\n') + outfile = open('Marlin/' + key, 'w') + for line in infile_lines: + sline = line.strip(" \t\n\r") + if sline[:7] == "#define": + # Extract the key here (we don't care about the value) + kv = sline[8:].strip().split(' ') + if kv[0] in conf[key]: + outfile.write('#define ' + kv[0] + ' ' + conf[key][kv[0]] + '\n') + # Remove the key from the dict, so we can still write all missing keys at the end of the file + del conf[key][kv[0]] + else: + outfile.write(line + '\n') + else: + outfile.write(line + '\n') + # Process any remaining defines here + for k, v in sorted(conf[key].items()): + define = '#define ' + k + ' ' + v + '\n' + outfile.write(define) + outfile.close() - print('Output configuration written to: ' + 'Marlin/' + key + output_suffix) + print('Output configuration written to: ' + 'Marlin/' + key + output_suffix) except: - print('No marlin_config.json found.') + print('No marlin_config.json found.') diff --git a/buildroot/share/PlatformIO/scripts/offset_and_rename.py b/buildroot/share/PlatformIO/scripts/offset_and_rename.py index 10a34d9c7390..98b345d698df 100644 --- a/buildroot/share/PlatformIO/scripts/offset_and_rename.py +++ b/buildroot/share/PlatformIO/scripts/offset_and_rename.py @@ -2,59 +2,59 @@ # offset_and_rename.py # # - If 'build.offset' is provided, either by JSON or by the environment... -# - Set linker flag LD_FLASH_OFFSET and relocate the VTAB based on 'build.offset'. -# - Set linker flag LD_MAX_DATA_SIZE based on 'build.maximum_ram_size'. -# - Define STM32_FLASH_SIZE from 'upload.maximum_size' for use by Flash-based EEPROM emulation. +# - Set linker flag LD_FLASH_OFFSET and relocate the VTAB based on 'build.offset'. +# - Set linker flag LD_MAX_DATA_SIZE based on 'build.maximum_ram_size'. +# - Define STM32_FLASH_SIZE from 'upload.maximum_size' for use by Flash-based EEPROM emulation. # # - For 'board_build.rename' add a post-action to rename the firmware file. # import pioutil if pioutil.is_pio_build(): - import sys,marlin - - env = marlin.env - board = env.BoardConfig() - board_keys = board.get("build").keys() - - # - # For build.offset define LD_FLASH_OFFSET, used by ldscript.ld - # - if 'offset' in board_keys: - LD_FLASH_OFFSET = board.get("build.offset") - marlin.relocate_vtab(LD_FLASH_OFFSET) - - # Flash size - maximum_flash_size = int(board.get("upload.maximum_size") / 1024) - marlin.replace_define('STM32_FLASH_SIZE', maximum_flash_size) - - # Get upload.maximum_ram_size (defined by /buildroot/share/PlatformIO/boards/VARIOUS.json) - maximum_ram_size = board.get("upload.maximum_ram_size") - - for i, flag in enumerate(env["LINKFLAGS"]): - if "-Wl,--defsym=LD_FLASH_OFFSET" in flag: - env["LINKFLAGS"][i] = "-Wl,--defsym=LD_FLASH_OFFSET=" + LD_FLASH_OFFSET - if "-Wl,--defsym=LD_MAX_DATA_SIZE" in flag: - env["LINKFLAGS"][i] = "-Wl,--defsym=LD_MAX_DATA_SIZE=" + str(maximum_ram_size - 40) - - # - # For build.encrypt_mks rename and encode the firmware file. - # - if 'encrypt_mks' in board_keys: - - # Encrypt ${PROGNAME}.bin and save it with the name given in build.encrypt_mks - def encrypt(source, target, env): - marlin.encrypt_mks(source, target, env, board.get("build.encrypt_mks")) - - if board.get("build.encrypt_mks") != "": - marlin.add_post_action(encrypt) - - # - # For build.rename simply rename the firmware file. - # - if 'rename' in board_keys: - - def rename_target(source, target, env): - from pathlib import Path - Path(target[0].path).replace(Path(target[0].dir.path, board.get("build.rename"))) - - marlin.add_post_action(rename_target) + import sys,marlin + + env = marlin.env + board = env.BoardConfig() + board_keys = board.get("build").keys() + + # + # For build.offset define LD_FLASH_OFFSET, used by ldscript.ld + # + if 'offset' in board_keys: + LD_FLASH_OFFSET = board.get("build.offset") + marlin.relocate_vtab(LD_FLASH_OFFSET) + + # Flash size + maximum_flash_size = int(board.get("upload.maximum_size") / 1024) + marlin.replace_define('STM32_FLASH_SIZE', maximum_flash_size) + + # Get upload.maximum_ram_size (defined by /buildroot/share/PlatformIO/boards/VARIOUS.json) + maximum_ram_size = board.get("upload.maximum_ram_size") + + for i, flag in enumerate(env["LINKFLAGS"]): + if "-Wl,--defsym=LD_FLASH_OFFSET" in flag: + env["LINKFLAGS"][i] = "-Wl,--defsym=LD_FLASH_OFFSET=" + LD_FLASH_OFFSET + if "-Wl,--defsym=LD_MAX_DATA_SIZE" in flag: + env["LINKFLAGS"][i] = "-Wl,--defsym=LD_MAX_DATA_SIZE=" + str(maximum_ram_size - 40) + + # + # For build.encrypt_mks rename and encode the firmware file. + # + if 'encrypt_mks' in board_keys: + + # Encrypt ${PROGNAME}.bin and save it with the name given in build.encrypt_mks + def encrypt(source, target, env): + marlin.encrypt_mks(source, target, env, board.get("build.encrypt_mks")) + + if board.get("build.encrypt_mks") != "": + marlin.add_post_action(encrypt) + + # + # For build.rename simply rename the firmware file. + # + if 'rename' in board_keys: + + def rename_target(source, target, env): + from pathlib import Path + Path(target[0].path).replace(Path(target[0].dir.path, board.get("build.rename"))) + + marlin.add_post_action(rename_target) diff --git a/buildroot/share/PlatformIO/scripts/openblt.py b/buildroot/share/PlatformIO/scripts/openblt.py index 33e82898f7b4..104bd142cac9 100644 --- a/buildroot/share/PlatformIO/scripts/openblt.py +++ b/buildroot/share/PlatformIO/scripts/openblt.py @@ -3,18 +3,18 @@ # import pioutil if pioutil.is_pio_build(): - import os,sys - from os.path import join + import os,sys + from os.path import join - Import("env") + Import("env") - board = env.BoardConfig() - board_keys = board.get("build").keys() - if 'encode' in board_keys: - env.AddPostAction( - join("$BUILD_DIR", "${PROGNAME}.bin"), - env.VerboseAction(" ".join([ - "$OBJCOPY", "-O", "srec", - "\"$BUILD_DIR/${PROGNAME}.elf\"", "\"" + join("$BUILD_DIR", board.get("build.encode")) + "\"" - ]), "Building " + board.get("build.encode")) - ) + board = env.BoardConfig() + board_keys = board.get("build").keys() + if 'encode' in board_keys: + env.AddPostAction( + join("$BUILD_DIR", "${PROGNAME}.bin"), + env.VerboseAction(" ".join([ + "$OBJCOPY", "-O", "srec", + "\"$BUILD_DIR/${PROGNAME}.elf\"", "\"" + join("$BUILD_DIR", board.get("build.encode")) + "\"" + ]), "Building " + board.get("build.encode")) + ) diff --git a/buildroot/share/PlatformIO/scripts/pioutil.py b/buildroot/share/PlatformIO/scripts/pioutil.py index 32096dab3f25..5ae28a62f393 100644 --- a/buildroot/share/PlatformIO/scripts/pioutil.py +++ b/buildroot/share/PlatformIO/scripts/pioutil.py @@ -4,10 +4,10 @@ # Make sure 'vscode init' is not the current command def is_pio_build(): - from SCons.Script import DefaultEnvironment - env = DefaultEnvironment() - return not env.IsIntegrationDump() + from SCons.Script import DefaultEnvironment + env = DefaultEnvironment() + return not env.IsIntegrationDump() def get_pio_version(): - from platformio import util - return util.pioversion_to_intstr() + from platformio import util + return util.pioversion_to_intstr() diff --git a/buildroot/share/PlatformIO/scripts/preflight-checks.py b/buildroot/share/PlatformIO/scripts/preflight-checks.py index 0fa9f9d6cc99..56394e17aaa0 100644 --- a/buildroot/share/PlatformIO/scripts/preflight-checks.py +++ b/buildroot/share/PlatformIO/scripts/preflight-checks.py @@ -5,123 +5,123 @@ import pioutil if pioutil.is_pio_build(): - import os,re,sys - from pathlib import Path - Import("env") - - def get_envs_for_board(board): - ppath = Path("Marlin/src/pins/pins.h") - with ppath.open() as file: - - if sys.platform == 'win32': - envregex = r"(?:env|win):" - elif sys.platform == 'darwin': - envregex = r"(?:env|mac|uni):" - elif sys.platform == 'linux': - envregex = r"(?:env|lin|uni):" - else: - envregex = r"(?:env):" - - r = re.compile(r"if\s+MB\((.+)\)") - if board.startswith("BOARD_"): - board = board[6:] - - for line in file: - mbs = r.findall(line) - if mbs and board in re.split(r",\s*", mbs[0]): - line = file.readline() - found_envs = re.match(r"\s*#include .+" + envregex, line) - if found_envs: - envlist = re.findall(envregex + r"(\w+)", line) - return [ "env:"+s for s in envlist ] - return [] - - def check_envs(build_env, board_envs, config): - if build_env in board_envs: - return True - ext = config.get(build_env, 'extends', default=None) - if ext: - if isinstance(ext, str): - return check_envs(ext, board_envs, config) - elif isinstance(ext, list): - for ext_env in ext: - if check_envs(ext_env, board_envs, config): - return True - return False - - def sanity_check_target(): - # Sanity checks: - if 'PIOENV' not in env: - raise SystemExit("Error: PIOENV is not defined. This script is intended to be used with PlatformIO") - - # Require PlatformIO 6.1.1 or later - vers = pioutil.get_pio_version() - if vers < [6, 1, 1]: - raise SystemExit("Error: Marlin requires PlatformIO >= 6.1.1. Use 'pio upgrade' to get a newer version.") - - if 'MARLIN_FEATURES' not in env: - raise SystemExit("Error: this script should be used after common Marlin scripts") - - if 'MOTHERBOARD' not in env['MARLIN_FEATURES']: - raise SystemExit("Error: MOTHERBOARD is not defined in Configuration.h") - - build_env = env['PIOENV'] - motherboard = env['MARLIN_FEATURES']['MOTHERBOARD'] - board_envs = get_envs_for_board(motherboard) - config = env.GetProjectConfig() - result = check_envs("env:"+build_env, board_envs, config) - - if not result: - err = "Error: Build environment '%s' is incompatible with %s. Use one of these: %s" % \ - ( build_env, motherboard, ", ".join([ e[4:] for e in board_envs if e.startswith("env:") ]) ) - raise SystemExit(err) - - # - # Check for Config files in two common incorrect places - # - epath = Path(env['PROJECT_DIR']) - for p in [ epath, epath / "config" ]: - for f in ("Configuration.h", "Configuration_adv.h"): - if (p / f).is_file(): - err = "ERROR: Config files found in directory %s. Please move them into the Marlin subfolder." % p - raise SystemExit(err) - - # - # Find the name.cpp.o or name.o and remove it - # - def rm_ofile(subdir, name): - build_dir = Path(env['PROJECT_BUILD_DIR'], build_env); - for outdir in (build_dir, build_dir / "debug"): - for ext in (".cpp.o", ".o"): - fpath = outdir / "src/src" / subdir / (name + ext) - if fpath.exists(): - fpath.unlink() - - # - # Give warnings on every build - # - rm_ofile("inc", "Warnings") - - # - # Rebuild 'settings.cpp' for EEPROM_INIT_NOW - # - if 'EEPROM_INIT_NOW' in env['MARLIN_FEATURES']: - rm_ofile("module", "settings") - - # - # Check for old files indicating an entangled Marlin (mixing old and new code) - # - mixedin = [] - p = Path(env['PROJECT_DIR'], "Marlin/src/lcd/dogm") - for f in [ "ultralcd_DOGM.cpp", "ultralcd_DOGM.h" ]: - if (p / f).is_file(): - mixedin += [ f ] - p = Path(env['PROJECT_DIR'], "Marlin/src/feature/bedlevel/abl") - for f in [ "abl.cpp", "abl.h" ]: - if (p / f).is_file(): - mixedin += [ f ] - if mixedin: - err = "ERROR: Old files fell into your Marlin folder. Remove %s and try again" % ", ".join(mixedin) - raise SystemExit(err) - - sanity_check_target() + import os,re,sys + from pathlib import Path + Import("env") + + def get_envs_for_board(board): + ppath = Path("Marlin/src/pins/pins.h") + with ppath.open() as file: + + if sys.platform == 'win32': + envregex = r"(?:env|win):" + elif sys.platform == 'darwin': + envregex = r"(?:env|mac|uni):" + elif sys.platform == 'linux': + envregex = r"(?:env|lin|uni):" + else: + envregex = r"(?:env):" + + r = re.compile(r"if\s+MB\((.+)\)") + if board.startswith("BOARD_"): + board = board[6:] + + for line in file: + mbs = r.findall(line) + if mbs and board in re.split(r",\s*", mbs[0]): + line = file.readline() + found_envs = re.match(r"\s*#include .+" + envregex, line) + if found_envs: + envlist = re.findall(envregex + r"(\w+)", line) + return [ "env:"+s for s in envlist ] + return [] + + def check_envs(build_env, board_envs, config): + if build_env in board_envs: + return True + ext = config.get(build_env, 'extends', default=None) + if ext: + if isinstance(ext, str): + return check_envs(ext, board_envs, config) + elif isinstance(ext, list): + for ext_env in ext: + if check_envs(ext_env, board_envs, config): + return True + return False + + def sanity_check_target(): + # Sanity checks: + if 'PIOENV' not in env: + raise SystemExit("Error: PIOENV is not defined. This script is intended to be used with PlatformIO") + + # Require PlatformIO 6.1.1 or later + vers = pioutil.get_pio_version() + if vers < [6, 1, 1]: + raise SystemExit("Error: Marlin requires PlatformIO >= 6.1.1. Use 'pio upgrade' to get a newer version.") + + if 'MARLIN_FEATURES' not in env: + raise SystemExit("Error: this script should be used after common Marlin scripts") + + if 'MOTHERBOARD' not in env['MARLIN_FEATURES']: + raise SystemExit("Error: MOTHERBOARD is not defined in Configuration.h") + + build_env = env['PIOENV'] + motherboard = env['MARLIN_FEATURES']['MOTHERBOARD'] + board_envs = get_envs_for_board(motherboard) + config = env.GetProjectConfig() + result = check_envs("env:"+build_env, board_envs, config) + + if not result: + err = "Error: Build environment '%s' is incompatible with %s. Use one of these: %s" % \ + ( build_env, motherboard, ", ".join([ e[4:] for e in board_envs if e.startswith("env:") ]) ) + raise SystemExit(err) + + # + # Check for Config files in two common incorrect places + # + epath = Path(env['PROJECT_DIR']) + for p in [ epath, epath / "config" ]: + for f in ("Configuration.h", "Configuration_adv.h"): + if (p / f).is_file(): + err = "ERROR: Config files found in directory %s. Please move them into the Marlin subfolder." % p + raise SystemExit(err) + + # + # Find the name.cpp.o or name.o and remove it + # + def rm_ofile(subdir, name): + build_dir = Path(env['PROJECT_BUILD_DIR'], build_env); + for outdir in (build_dir, build_dir / "debug"): + for ext in (".cpp.o", ".o"): + fpath = outdir / "src/src" / subdir / (name + ext) + if fpath.exists(): + fpath.unlink() + + # + # Give warnings on every build + # + rm_ofile("inc", "Warnings") + + # + # Rebuild 'settings.cpp' for EEPROM_INIT_NOW + # + if 'EEPROM_INIT_NOW' in env['MARLIN_FEATURES']: + rm_ofile("module", "settings") + + # + # Check for old files indicating an entangled Marlin (mixing old and new code) + # + mixedin = [] + p = Path(env['PROJECT_DIR'], "Marlin/src/lcd/dogm") + for f in [ "ultralcd_DOGM.cpp", "ultralcd_DOGM.h" ]: + if (p / f).is_file(): + mixedin += [ f ] + p = Path(env['PROJECT_DIR'], "Marlin/src/feature/bedlevel/abl") + for f in [ "abl.cpp", "abl.h" ]: + if (p / f).is_file(): + mixedin += [ f ] + if mixedin: + err = "ERROR: Old files fell into your Marlin folder. Remove %s and try again" % ", ".join(mixedin) + raise SystemExit(err) + + sanity_check_target() diff --git a/buildroot/share/PlatformIO/scripts/preprocessor.py b/buildroot/share/PlatformIO/scripts/preprocessor.py index 19e8dfe0e1ae..ad24ed7be430 100644 --- a/buildroot/share/PlatformIO/scripts/preprocessor.py +++ b/buildroot/share/PlatformIO/scripts/preprocessor.py @@ -7,8 +7,8 @@ verbose = 0 def blab(str): - if verbose: - print(str) + if verbose: + print(str) ################################################################################ # @@ -16,36 +16,36 @@ def blab(str): # preprocessor_cache = {} def run_preprocessor(env, fn=None): - filename = fn or 'buildroot/share/PlatformIO/scripts/common-dependencies.h' - if filename in preprocessor_cache: - return preprocessor_cache[filename] - - # Process defines - build_flags = env.get('BUILD_FLAGS') - build_flags = env.ParseFlagsExtended(build_flags) - - cxx = search_compiler(env) - cmd = ['"' + cxx + '"'] - - # Build flags from board.json - #if 'BOARD' in env: - # cmd += [env.BoardConfig().get("build.extra_flags")] - for s in build_flags['CPPDEFINES']: - if isinstance(s, tuple): - cmd += ['-D' + s[0] + '=' + str(s[1])] - else: - cmd += ['-D' + s] - - cmd += ['-D__MARLIN_DEPS__ -w -dM -E -x c++'] - depcmd = cmd + [ filename ] - cmd = ' '.join(depcmd) - blab(cmd) - try: - define_list = subprocess.check_output(cmd, shell=True).splitlines() - except: - define_list = {} - preprocessor_cache[filename] = define_list - return define_list + filename = fn or 'buildroot/share/PlatformIO/scripts/common-dependencies.h' + if filename in preprocessor_cache: + return preprocessor_cache[filename] + + # Process defines + build_flags = env.get('BUILD_FLAGS') + build_flags = env.ParseFlagsExtended(build_flags) + + cxx = search_compiler(env) + cmd = ['"' + cxx + '"'] + + # Build flags from board.json + #if 'BOARD' in env: + # cmd += [env.BoardConfig().get("build.extra_flags")] + for s in build_flags['CPPDEFINES']: + if isinstance(s, tuple): + cmd += ['-D' + s[0] + '=' + str(s[1])] + else: + cmd += ['-D' + s] + + cmd += ['-D__MARLIN_DEPS__ -w -dM -E -x c++'] + depcmd = cmd + [ filename ] + cmd = ' '.join(depcmd) + blab(cmd) + try: + define_list = subprocess.check_output(cmd, shell=True).splitlines() + except: + define_list = {} + preprocessor_cache[filename] = define_list + return define_list ################################################################################ @@ -54,41 +54,41 @@ def run_preprocessor(env, fn=None): # def search_compiler(env): - from pathlib import Path, PurePath - - ENV_BUILD_PATH = Path(env['PROJECT_BUILD_DIR'], env['PIOENV']) - GCC_PATH_CACHE = ENV_BUILD_PATH / ".gcc_path" - - try: - gccpath = env.GetProjectOption('custom_gcc') - blab("Getting compiler from env") - return gccpath - except: - pass - - # Warning: The cached .gcc_path will obscure a newly-installed toolkit - if not nocache and GCC_PATH_CACHE.exists(): - blab("Getting g++ path from cache") - return GCC_PATH_CACHE.read_text() - - # Use any item in $PATH corresponding to a platformio toolchain bin folder - path_separator = ':' - gcc_exe = '*g++' - if env['PLATFORM'] == 'win32': - path_separator = ';' - gcc_exe += ".exe" - - # Search for the compiler in PATH - for ppath in map(Path, env['ENV']['PATH'].split(path_separator)): - if ppath.match(env['PROJECT_PACKAGES_DIR'] + "/**/bin"): - for gpath in ppath.glob(gcc_exe): - gccpath = str(gpath.resolve()) - # Cache the g++ path to no search always - if not nocache and ENV_BUILD_PATH.exists(): - blab("Caching g++ for current env") - GCC_PATH_CACHE.write_text(gccpath) - return gccpath - - gccpath = env.get('CXX') - blab("Couldn't find a compiler! Fallback to %s" % gccpath) - return gccpath + from pathlib import Path, PurePath + + ENV_BUILD_PATH = Path(env['PROJECT_BUILD_DIR'], env['PIOENV']) + GCC_PATH_CACHE = ENV_BUILD_PATH / ".gcc_path" + + try: + gccpath = env.GetProjectOption('custom_gcc') + blab("Getting compiler from env") + return gccpath + except: + pass + + # Warning: The cached .gcc_path will obscure a newly-installed toolkit + if not nocache and GCC_PATH_CACHE.exists(): + blab("Getting g++ path from cache") + return GCC_PATH_CACHE.read_text() + + # Use any item in $PATH corresponding to a platformio toolchain bin folder + path_separator = ':' + gcc_exe = '*g++' + if env['PLATFORM'] == 'win32': + path_separator = ';' + gcc_exe += ".exe" + + # Search for the compiler in PATH + for ppath in map(Path, env['ENV']['PATH'].split(path_separator)): + if ppath.match(env['PROJECT_PACKAGES_DIR'] + "/**/bin"): + for gpath in ppath.glob(gcc_exe): + gccpath = str(gpath.resolve()) + # Cache the g++ path to no search always + if not nocache and ENV_BUILD_PATH.exists(): + blab("Caching g++ for current env") + GCC_PATH_CACHE.write_text(gccpath) + return gccpath + + gccpath = env.get('CXX') + blab("Couldn't find a compiler! Fallback to %s" % gccpath) + return gccpath diff --git a/buildroot/share/PlatformIO/scripts/random-bin.py b/buildroot/share/PlatformIO/scripts/random-bin.py index 5a88906c3092..dc8634ea7d64 100644 --- a/buildroot/share/PlatformIO/scripts/random-bin.py +++ b/buildroot/share/PlatformIO/scripts/random-bin.py @@ -4,6 +4,6 @@ # import pioutil if pioutil.is_pio_build(): - from datetime import datetime - Import("env") - env['PROGNAME'] = datetime.now().strftime("firmware-%Y%m%d-%H%M%S") + from datetime import datetime + Import("env") + env['PROGNAME'] = datetime.now().strftime("firmware-%Y%m%d-%H%M%S") diff --git a/buildroot/share/PlatformIO/scripts/schema.py b/buildroot/share/PlatformIO/scripts/schema.py index 34df4c906f23..103aa1f072dc 100755 --- a/buildroot/share/PlatformIO/scripts/schema.py +++ b/buildroot/share/PlatformIO/scripts/schema.py @@ -9,413 +9,413 @@ from pathlib import Path def extend_dict(d:dict, k:tuple): - if len(k) >= 1 and k[0] not in d: - d[k[0]] = {} - if len(k) >= 2 and k[1] not in d[k[0]]: - d[k[0]][k[1]] = {} - if len(k) >= 3 and k[2] not in d[k[0]][k[1]]: - d[k[0]][k[1]][k[2]] = {} + if len(k) >= 1 and k[0] not in d: + d[k[0]] = {} + if len(k) >= 2 and k[1] not in d[k[0]]: + d[k[0]][k[1]] = {} + if len(k) >= 3 and k[2] not in d[k[0]][k[1]]: + d[k[0]][k[1]][k[2]] = {} grouping_patterns = [ - re.compile(r'^([XYZIJKUVW]|[XYZ]2|Z[34]|E[0-7])$'), - re.compile(r'^AXIS\d$'), - re.compile(r'^(MIN|MAX)$'), - re.compile(r'^[0-8]$'), - re.compile(r'^HOTEND[0-7]$'), - re.compile(r'^(HOTENDS|BED|PROBE|COOLER)$'), - re.compile(r'^[XYZIJKUVW]M(IN|AX)$') + re.compile(r'^([XYZIJKUVW]|[XYZ]2|Z[34]|E[0-7])$'), + re.compile(r'^AXIS\d$'), + re.compile(r'^(MIN|MAX)$'), + re.compile(r'^[0-8]$'), + re.compile(r'^HOTEND[0-7]$'), + re.compile(r'^(HOTENDS|BED|PROBE|COOLER)$'), + re.compile(r'^[XYZIJKUVW]M(IN|AX)$') ] # If the indexed part of the option name matches a pattern # then add it to the dictionary. def find_grouping(gdict, filekey, sectkey, optkey, pindex): - optparts = optkey.split('_') - if 1 < len(optparts) > pindex: - for patt in grouping_patterns: - if patt.match(optparts[pindex]): - subkey = optparts[pindex] - modkey = '_'.join(optparts) - optparts[pindex] = '*' - wildkey = '_'.join(optparts) - kkey = f'{filekey}|{sectkey}|{wildkey}' - if kkey not in gdict: gdict[kkey] = [] - gdict[kkey].append((subkey, modkey)) + optparts = optkey.split('_') + if 1 < len(optparts) > pindex: + for patt in grouping_patterns: + if patt.match(optparts[pindex]): + subkey = optparts[pindex] + modkey = '_'.join(optparts) + optparts[pindex] = '*' + wildkey = '_'.join(optparts) + kkey = f'{filekey}|{sectkey}|{wildkey}' + if kkey not in gdict: gdict[kkey] = [] + gdict[kkey].append((subkey, modkey)) # Build a list of potential groups. Only those with multiple items will be grouped. def group_options(schema): - for pindex in range(10, -1, -1): - found_groups = {} - for filekey, f in schema.items(): - for sectkey, s in f.items(): - for optkey in s: - find_grouping(found_groups, filekey, sectkey, optkey, pindex) - - fkeys = [ k for k in found_groups.keys() ] - for kkey in fkeys: - items = found_groups[kkey] - if len(items) > 1: - f, s, w = kkey.split('|') - extend_dict(schema, (f, s, w)) # Add wildcard group to schema - for subkey, optkey in items: # Add all items to wildcard group - schema[f][s][w][subkey] = schema[f][s][optkey] # Move non-wildcard item to wildcard group - del schema[f][s][optkey] - del found_groups[kkey] + for pindex in range(10, -1, -1): + found_groups = {} + for filekey, f in schema.items(): + for sectkey, s in f.items(): + for optkey in s: + find_grouping(found_groups, filekey, sectkey, optkey, pindex) + + fkeys = [ k for k in found_groups.keys() ] + for kkey in fkeys: + items = found_groups[kkey] + if len(items) > 1: + f, s, w = kkey.split('|') + extend_dict(schema, (f, s, w)) # Add wildcard group to schema + for subkey, optkey in items: # Add all items to wildcard group + schema[f][s][w][subkey] = schema[f][s][optkey] # Move non-wildcard item to wildcard group + del schema[f][s][optkey] + del found_groups[kkey] # Extract all board names from boards.h def load_boards(): - bpath = Path("Marlin/src/core/boards.h") - if bpath.is_file(): - with bpath.open() as bfile: - boards = [] - for line in bfile: - if line.startswith("#define BOARD_"): - bname = line.split()[1] - if bname != "BOARD_UNKNOWN": boards.append(bname) - return "['" + "','".join(boards) + "']" - return '' + bpath = Path("Marlin/src/core/boards.h") + if bpath.is_file(): + with bpath.open() as bfile: + boards = [] + for line in bfile: + if line.startswith("#define BOARD_"): + bname = line.split()[1] + if bname != "BOARD_UNKNOWN": boards.append(bname) + return "['" + "','".join(boards) + "']" + return '' # # Extract a schema from the current configuration files # def extract(): - # Load board names from boards.h - boards = load_boards() - - # Parsing states - class Parse: - NORMAL = 0 # No condition yet - BLOCK_COMMENT = 1 # Looking for the end of the block comment - EOL_COMMENT = 2 # EOL comment started, maybe add the next comment? - GET_SENSORS = 3 # Gathering temperature sensor options - ERROR = 9 # Syntax error - - # List of files to process, with shorthand - filekey = { 'Configuration.h':'basic', 'Configuration_adv.h':'advanced' } - # A JSON object to store the data - sch_out = { 'basic':{}, 'advanced':{} } - # Regex for #define NAME [VALUE] [COMMENT] with sanitized line - defgrep = re.compile(r'^(//)?\s*(#define)\s+([A-Za-z0-9_]+)\s*(.*?)\s*(//.+)?$') - # Defines to ignore - ignore = ('CONFIGURATION_H_VERSION', 'CONFIGURATION_ADV_H_VERSION', 'CONFIG_EXAMPLES_DIR', 'CONFIG_EXPORT') - # Start with unknown state - state = Parse.NORMAL - # Serial ID - sid = 0 - # Loop through files and parse them line by line - for fn, fk in filekey.items(): - with Path("Marlin", fn).open() as fileobj: - section = 'none' # Current Settings section - line_number = 0 # Counter for the line number of the file - conditions = [] # Create a condition stack for the current file - comment_buff = [] # A temporary buffer for comments - options_json = '' # A buffer for the most recent options JSON found - eol_options = False # The options came from end of line, so only apply once - join_line = False # A flag that the line should be joined with the previous one - line = '' # A line buffer to handle \ continuation - last_added_ref = None # Reference to the last added item - # Loop through the lines in the file - for the_line in fileobj.readlines(): - line_number += 1 - - # Clean the line for easier parsing - the_line = the_line.strip() - - if join_line: # A previous line is being made longer - line += (' ' if line else '') + the_line - else: # Otherwise, start the line anew - line, line_start = the_line, line_number - - # If the resulting line ends with a \, don't process now. - # Strip the end off. The next line will be joined with it. - join_line = line.endswith("\\") - if join_line: - line = line[:-1].strip() - continue - else: - line_end = line_number - - defmatch = defgrep.match(line) - - # Special handling for EOL comments after a #define. - # At this point the #define is already digested and inserted, - # so we have to extend it - if state == Parse.EOL_COMMENT: - # If the line is not a comment, we're done with the EOL comment - if not defmatch and the_line.startswith('//'): - comment_buff.append(the_line[2:].strip()) - else: - last_added_ref['comment'] = ' '.join(comment_buff) - comment_buff = [] - state = Parse.NORMAL - - def use_comment(c, opt, sec, bufref): - if c.startswith(':'): # If the comment starts with : then it has magic JSON - d = c[1:].strip() # Strip the leading : - cbr = c.rindex('}') if d.startswith('{') else c.rindex(']') if d.startswith('[') else 0 - if cbr: - opt, cmt = c[1:cbr+1].strip(), c[cbr+1:].strip() - if cmt != '': bufref.append(cmt) - else: - opt = c[1:].strip() - elif c.startswith('@section'): # Start a new section - sec = c[8:].strip() - elif not c.startswith('========'): - bufref.append(c) - return opt, sec - - # In a block comment, capture lines up to the end of the comment. - # Assume nothing follows the comment closure. - if state in (Parse.BLOCK_COMMENT, Parse.GET_SENSORS): - endpos = line.find('*/') - if endpos < 0: - cline = line - else: - cline, line = line[:endpos].strip(), line[endpos+2:].strip() - - # Temperature sensors are done - if state == Parse.GET_SENSORS: - options_json = f'[ {options_json[:-2]} ]' - - state = Parse.NORMAL - - # Strip the leading '*' from block comments - if cline.startswith('*'): cline = cline[1:].strip() - - # Collect temperature sensors - if state == Parse.GET_SENSORS: - sens = re.match(r'^(-?\d+)\s*:\s*(.+)$', cline) - if sens: - s2 = sens[2].replace("'","''") - options_json += f"{sens[1]}:'{s2}', " - - elif state == Parse.BLOCK_COMMENT: - - # Look for temperature sensors - if cline == "Temperature sensors available:": - state, cline = Parse.GET_SENSORS, "Temperature Sensors" - - options_json, section = use_comment(cline, options_json, section, comment_buff) - - # For the normal state we're looking for any non-blank line - elif state == Parse.NORMAL: - # Skip a commented define when evaluating comment opening - st = 2 if re.match(r'^//\s*#define', line) else 0 - cpos1 = line.find('/*') # Start a block comment on the line? - cpos2 = line.find('//', st) # Start an end of line comment on the line? - - # Only the first comment starter gets evaluated - cpos = -1 - if cpos1 != -1 and (cpos1 < cpos2 or cpos2 == -1): - cpos = cpos1 - comment_buff = [] - state = Parse.BLOCK_COMMENT - eol_options = False - - elif cpos2 != -1 and (cpos2 < cpos1 or cpos1 == -1): - cpos = cpos2 - - # Comment after a define may be continued on the following lines - if defmatch != None and cpos > 10: - state = Parse.EOL_COMMENT - comment_buff = [] - - # Process the start of a new comment - if cpos != -1: - cline, line = line[cpos+2:].strip(), line[:cpos].strip() - - if state == Parse.BLOCK_COMMENT: - # Strip leading '*' from block comments - if cline.startswith('*'): cline = cline[1:].strip() - else: - # Expire end-of-line options after first use - if cline.startswith(':'): eol_options = True - - # Buffer a non-empty comment start - if cline != '': - options_json, section = use_comment(cline, options_json, section, comment_buff) - - # If the line has nothing before the comment, go to the next line - if line == '': - options_json = '' - continue - - # Parenthesize the given expression if needed - def atomize(s): - if s == '' \ - or re.match(r'^[A-Za-z0-9_]*(\([^)]+\))?$', s) \ - or re.match(r'^[A-Za-z0-9_]+ == \d+?$', s): - return s - return f'({s})' - - # - # The conditions stack is an array containing condition-arrays. - # Each condition-array lists the conditions for the current block. - # IF/N/DEF adds a new condition-array to the stack. - # ELSE/ELIF/ENDIF pop the condition-array. - # ELSE/ELIF negate the last item in the popped condition-array. - # ELIF adds a new condition to the end of the array. - # ELSE/ELIF re-push the condition-array. - # - cparts = line.split() - iselif, iselse = cparts[0] == '#elif', cparts[0] == '#else' - if iselif or iselse or cparts[0] == '#endif': - if len(conditions) == 0: - raise Exception(f'no #if block at line {line_number}') - - # Pop the last condition-array from the stack - prev = conditions.pop() - - if iselif or iselse: - prev[-1] = '!' + prev[-1] # Invert the last condition - if iselif: prev.append(atomize(line[5:].strip())) - conditions.append(prev) - - elif cparts[0] == '#if': - conditions.append([ atomize(line[3:].strip()) ]) - elif cparts[0] == '#ifdef': - conditions.append([ f'defined({line[6:].strip()})' ]) - elif cparts[0] == '#ifndef': - conditions.append([ f'!defined({line[7:].strip()})' ]) - - # Handle a complete #define line - elif defmatch != None: - - # Get the match groups into vars - enabled, define_name, val = defmatch[1] == None, defmatch[3], defmatch[4] - - # Increment the serial ID - sid += 1 - - # Create a new dictionary for the current #define - define_info = { - 'section': section, - 'name': define_name, - 'enabled': enabled, - 'line': line_start, - 'sid': sid - } - - # Type is based on the value - if val == '': - value_type = 'switch' - elif re.match(r'^(true|false)$', val): - value_type = 'bool' - val = val == 'true' - elif re.match(r'^[-+]?\s*\d+$', val): - value_type = 'int' - val = int(val) - elif re.match(r'[-+]?\s*(\d+\.|\d*\.\d+)([eE][-+]?\d+)?[fF]?', val): - value_type = 'float' - val = float(val.replace('f','')) - else: - value_type = 'string' if val[0] == '"' \ - else 'char' if val[0] == "'" \ - else 'state' if re.match(r'^(LOW|HIGH)$', val) \ - else 'enum' if re.match(r'^[A-Za-z0-9_]{3,}$', val) \ - else 'int[]' if re.match(r'^{(\s*[-+]?\s*\d+\s*(,\s*)?)+}$', val) \ - else 'float[]' if re.match(r'^{(\s*[-+]?\s*(\d+\.|\d*\.\d+)([eE][-+]?\d+)?[fF]?\s*(,\s*)?)+}$', val) \ - else 'array' if val[0] == '{' \ - else '' - - if val != '': define_info['value'] = val - if value_type != '': define_info['type'] = value_type - - # Join up accumulated conditions with && - if conditions: define_info['requires'] = ' && '.join(sum(conditions, [])) - - # If the comment_buff is not empty, add the comment to the info - if comment_buff: - full_comment = '\n'.join(comment_buff) - - # An EOL comment will be added later - # The handling could go here instead of above - if state == Parse.EOL_COMMENT: - define_info['comment'] = '' - else: - define_info['comment'] = full_comment - comment_buff = [] - - # If the comment specifies units, add that to the info - units = re.match(r'^\(([^)]+)\)', full_comment) - if units: - units = units[1] - if units == 's' or units == 'sec': units = 'seconds' - define_info['units'] = units - - # Set the options for the current #define - if define_name == "MOTHERBOARD" and boards != '': - define_info['options'] = boards - elif options_json != '': - define_info['options'] = options_json - if eol_options: options_json = '' - - # Create section dict if it doesn't exist yet - if section not in sch_out[fk]: sch_out[fk][section] = {} - - # If define has already been seen... - if define_name in sch_out[fk][section]: - info = sch_out[fk][section][define_name] - if isinstance(info, dict): info = [ info ] # Convert a single dict into a list - info.append(define_info) # Add to the list - else: - # Add the define dict with name as key - sch_out[fk][section][define_name] = define_info - - if state == Parse.EOL_COMMENT: - last_added_ref = define_info - - return sch_out + # Load board names from boards.h + boards = load_boards() + + # Parsing states + class Parse: + NORMAL = 0 # No condition yet + BLOCK_COMMENT = 1 # Looking for the end of the block comment + EOL_COMMENT = 2 # EOL comment started, maybe add the next comment? + GET_SENSORS = 3 # Gathering temperature sensor options + ERROR = 9 # Syntax error + + # List of files to process, with shorthand + filekey = { 'Configuration.h':'basic', 'Configuration_adv.h':'advanced' } + # A JSON object to store the data + sch_out = { 'basic':{}, 'advanced':{} } + # Regex for #define NAME [VALUE] [COMMENT] with sanitized line + defgrep = re.compile(r'^(//)?\s*(#define)\s+([A-Za-z0-9_]+)\s*(.*?)\s*(//.+)?$') + # Defines to ignore + ignore = ('CONFIGURATION_H_VERSION', 'CONFIGURATION_ADV_H_VERSION', 'CONFIG_EXAMPLES_DIR', 'CONFIG_EXPORT') + # Start with unknown state + state = Parse.NORMAL + # Serial ID + sid = 0 + # Loop through files and parse them line by line + for fn, fk in filekey.items(): + with Path("Marlin", fn).open() as fileobj: + section = 'none' # Current Settings section + line_number = 0 # Counter for the line number of the file + conditions = [] # Create a condition stack for the current file + comment_buff = [] # A temporary buffer for comments + options_json = '' # A buffer for the most recent options JSON found + eol_options = False # The options came from end of line, so only apply once + join_line = False # A flag that the line should be joined with the previous one + line = '' # A line buffer to handle \ continuation + last_added_ref = None # Reference to the last added item + # Loop through the lines in the file + for the_line in fileobj.readlines(): + line_number += 1 + + # Clean the line for easier parsing + the_line = the_line.strip() + + if join_line: # A previous line is being made longer + line += (' ' if line else '') + the_line + else: # Otherwise, start the line anew + line, line_start = the_line, line_number + + # If the resulting line ends with a \, don't process now. + # Strip the end off. The next line will be joined with it. + join_line = line.endswith("\\") + if join_line: + line = line[:-1].strip() + continue + else: + line_end = line_number + + defmatch = defgrep.match(line) + + # Special handling for EOL comments after a #define. + # At this point the #define is already digested and inserted, + # so we have to extend it + if state == Parse.EOL_COMMENT: + # If the line is not a comment, we're done with the EOL comment + if not defmatch and the_line.startswith('//'): + comment_buff.append(the_line[2:].strip()) + else: + last_added_ref['comment'] = ' '.join(comment_buff) + comment_buff = [] + state = Parse.NORMAL + + def use_comment(c, opt, sec, bufref): + if c.startswith(':'): # If the comment starts with : then it has magic JSON + d = c[1:].strip() # Strip the leading : + cbr = c.rindex('}') if d.startswith('{') else c.rindex(']') if d.startswith('[') else 0 + if cbr: + opt, cmt = c[1:cbr+1].strip(), c[cbr+1:].strip() + if cmt != '': bufref.append(cmt) + else: + opt = c[1:].strip() + elif c.startswith('@section'): # Start a new section + sec = c[8:].strip() + elif not c.startswith('========'): + bufref.append(c) + return opt, sec + + # In a block comment, capture lines up to the end of the comment. + # Assume nothing follows the comment closure. + if state in (Parse.BLOCK_COMMENT, Parse.GET_SENSORS): + endpos = line.find('*/') + if endpos < 0: + cline = line + else: + cline, line = line[:endpos].strip(), line[endpos+2:].strip() + + # Temperature sensors are done + if state == Parse.GET_SENSORS: + options_json = f'[ {options_json[:-2]} ]' + + state = Parse.NORMAL + + # Strip the leading '*' from block comments + if cline.startswith('*'): cline = cline[1:].strip() + + # Collect temperature sensors + if state == Parse.GET_SENSORS: + sens = re.match(r'^(-?\d+)\s*:\s*(.+)$', cline) + if sens: + s2 = sens[2].replace("'","''") + options_json += f"{sens[1]}:'{s2}', " + + elif state == Parse.BLOCK_COMMENT: + + # Look for temperature sensors + if cline == "Temperature sensors available:": + state, cline = Parse.GET_SENSORS, "Temperature Sensors" + + options_json, section = use_comment(cline, options_json, section, comment_buff) + + # For the normal state we're looking for any non-blank line + elif state == Parse.NORMAL: + # Skip a commented define when evaluating comment opening + st = 2 if re.match(r'^//\s*#define', line) else 0 + cpos1 = line.find('/*') # Start a block comment on the line? + cpos2 = line.find('//', st) # Start an end of line comment on the line? + + # Only the first comment starter gets evaluated + cpos = -1 + if cpos1 != -1 and (cpos1 < cpos2 or cpos2 == -1): + cpos = cpos1 + comment_buff = [] + state = Parse.BLOCK_COMMENT + eol_options = False + + elif cpos2 != -1 and (cpos2 < cpos1 or cpos1 == -1): + cpos = cpos2 + + # Comment after a define may be continued on the following lines + if defmatch != None and cpos > 10: + state = Parse.EOL_COMMENT + comment_buff = [] + + # Process the start of a new comment + if cpos != -1: + cline, line = line[cpos+2:].strip(), line[:cpos].strip() + + if state == Parse.BLOCK_COMMENT: + # Strip leading '*' from block comments + if cline.startswith('*'): cline = cline[1:].strip() + else: + # Expire end-of-line options after first use + if cline.startswith(':'): eol_options = True + + # Buffer a non-empty comment start + if cline != '': + options_json, section = use_comment(cline, options_json, section, comment_buff) + + # If the line has nothing before the comment, go to the next line + if line == '': + options_json = '' + continue + + # Parenthesize the given expression if needed + def atomize(s): + if s == '' \ + or re.match(r'^[A-Za-z0-9_]*(\([^)]+\))?$', s) \ + or re.match(r'^[A-Za-z0-9_]+ == \d+?$', s): + return s + return f'({s})' + + # + # The conditions stack is an array containing condition-arrays. + # Each condition-array lists the conditions for the current block. + # IF/N/DEF adds a new condition-array to the stack. + # ELSE/ELIF/ENDIF pop the condition-array. + # ELSE/ELIF negate the last item in the popped condition-array. + # ELIF adds a new condition to the end of the array. + # ELSE/ELIF re-push the condition-array. + # + cparts = line.split() + iselif, iselse = cparts[0] == '#elif', cparts[0] == '#else' + if iselif or iselse or cparts[0] == '#endif': + if len(conditions) == 0: + raise Exception(f'no #if block at line {line_number}') + + # Pop the last condition-array from the stack + prev = conditions.pop() + + if iselif or iselse: + prev[-1] = '!' + prev[-1] # Invert the last condition + if iselif: prev.append(atomize(line[5:].strip())) + conditions.append(prev) + + elif cparts[0] == '#if': + conditions.append([ atomize(line[3:].strip()) ]) + elif cparts[0] == '#ifdef': + conditions.append([ f'defined({line[6:].strip()})' ]) + elif cparts[0] == '#ifndef': + conditions.append([ f'!defined({line[7:].strip()})' ]) + + # Handle a complete #define line + elif defmatch != None: + + # Get the match groups into vars + enabled, define_name, val = defmatch[1] == None, defmatch[3], defmatch[4] + + # Increment the serial ID + sid += 1 + + # Create a new dictionary for the current #define + define_info = { + 'section': section, + 'name': define_name, + 'enabled': enabled, + 'line': line_start, + 'sid': sid + } + + # Type is based on the value + if val == '': + value_type = 'switch' + elif re.match(r'^(true|false)$', val): + value_type = 'bool' + val = val == 'true' + elif re.match(r'^[-+]?\s*\d+$', val): + value_type = 'int' + val = int(val) + elif re.match(r'[-+]?\s*(\d+\.|\d*\.\d+)([eE][-+]?\d+)?[fF]?', val): + value_type = 'float' + val = float(val.replace('f','')) + else: + value_type = 'string' if val[0] == '"' \ + else 'char' if val[0] == "'" \ + else 'state' if re.match(r'^(LOW|HIGH)$', val) \ + else 'enum' if re.match(r'^[A-Za-z0-9_]{3,}$', val) \ + else 'int[]' if re.match(r'^{(\s*[-+]?\s*\d+\s*(,\s*)?)+}$', val) \ + else 'float[]' if re.match(r'^{(\s*[-+]?\s*(\d+\.|\d*\.\d+)([eE][-+]?\d+)?[fF]?\s*(,\s*)?)+}$', val) \ + else 'array' if val[0] == '{' \ + else '' + + if val != '': define_info['value'] = val + if value_type != '': define_info['type'] = value_type + + # Join up accumulated conditions with && + if conditions: define_info['requires'] = ' && '.join(sum(conditions, [])) + + # If the comment_buff is not empty, add the comment to the info + if comment_buff: + full_comment = '\n'.join(comment_buff) + + # An EOL comment will be added later + # The handling could go here instead of above + if state == Parse.EOL_COMMENT: + define_info['comment'] = '' + else: + define_info['comment'] = full_comment + comment_buff = [] + + # If the comment specifies units, add that to the info + units = re.match(r'^\(([^)]+)\)', full_comment) + if units: + units = units[1] + if units == 's' or units == 'sec': units = 'seconds' + define_info['units'] = units + + # Set the options for the current #define + if define_name == "MOTHERBOARD" and boards != '': + define_info['options'] = boards + elif options_json != '': + define_info['options'] = options_json + if eol_options: options_json = '' + + # Create section dict if it doesn't exist yet + if section not in sch_out[fk]: sch_out[fk][section] = {} + + # If define has already been seen... + if define_name in sch_out[fk][section]: + info = sch_out[fk][section][define_name] + if isinstance(info, dict): info = [ info ] # Convert a single dict into a list + info.append(define_info) # Add to the list + else: + # Add the define dict with name as key + sch_out[fk][section][define_name] = define_info + + if state == Parse.EOL_COMMENT: + last_added_ref = define_info + + return sch_out def dump_json(schema:dict, jpath:Path): - with jpath.open('w') as jfile: - json.dump(schema, jfile, ensure_ascii=False, indent=2) + with jpath.open('w') as jfile: + json.dump(schema, jfile, ensure_ascii=False, indent=2) def dump_yaml(schema:dict, ypath:Path): - import yaml - with ypath.open('w') as yfile: - yaml.dump(schema, yfile, default_flow_style=False, width=120, indent=2) + import yaml + with ypath.open('w') as yfile: + yaml.dump(schema, yfile, default_flow_style=False, width=120, indent=2) def main(): - try: - schema = extract() - except Exception as exc: - print("Error: " + str(exc)) - schema = None - - if schema: - - # Get the first command line argument - import sys - if len(sys.argv) > 1: - arg = sys.argv[1] - else: - arg = 'some' - - # JSON schema - if arg in ['some', 'json', 'jsons']: - print("Generating JSON ...") - dump_json(schema, Path('schema.json')) - - # JSON schema (wildcard names) - if arg in ['group', 'jsons']: - group_options(schema) - dump_json(schema, Path('schema_grouped.json')) - - # YAML - if arg in ['some', 'yml', 'yaml']: - try: - import yaml - except ImportError: - print("Installing YAML module ...") - import subprocess - try: - subprocess.run(['python3', '-m', 'pip', 'install', 'pyyaml']) - import yaml - except: - print("Failed to install YAML module") - return - - print("Generating YML ...") - dump_yaml(schema, Path('schema.yml')) + try: + schema = extract() + except Exception as exc: + print("Error: " + str(exc)) + schema = None + + if schema: + + # Get the first command line argument + import sys + if len(sys.argv) > 1: + arg = sys.argv[1] + else: + arg = 'some' + + # JSON schema + if arg in ['some', 'json', 'jsons']: + print("Generating JSON ...") + dump_json(schema, Path('schema.json')) + + # JSON schema (wildcard names) + if arg in ['group', 'jsons']: + group_options(schema) + dump_json(schema, Path('schema_grouped.json')) + + # YAML + if arg in ['some', 'yml', 'yaml']: + try: + import yaml + except ImportError: + print("Installing YAML module ...") + import subprocess + try: + subprocess.run(['python3', '-m', 'pip', 'install', 'pyyaml']) + import yaml + except: + print("Failed to install YAML module") + return + + print("Generating YML ...") + dump_yaml(schema, Path('schema.yml')) if __name__ == '__main__': - main() + main() diff --git a/buildroot/share/PlatformIO/scripts/signature.py b/buildroot/share/PlatformIO/scripts/signature.py index 43d56ac6e1a4..ea878d9a6752 100644 --- a/buildroot/share/PlatformIO/scripts/signature.py +++ b/buildroot/share/PlatformIO/scripts/signature.py @@ -16,32 +16,32 @@ # resulting config.ini to produce more exact configuration files. # def extract_defines(filepath): - f = open(filepath, encoding="utf8").read().split("\n") - a = [] - for line in f: - sline = line.strip() - if sline[:7] == "#define": - # Extract the key here (we don't care about the value) - kv = sline[8:].strip().split() - a.append(kv[0]) - return a + f = open(filepath, encoding="utf8").read().split("\n") + a = [] + for line in f: + sline = line.strip() + if sline[:7] == "#define": + # Extract the key here (we don't care about the value) + kv = sline[8:].strip().split() + a.append(kv[0]) + return a # Compute the SHA256 hash of a file def get_file_sha256sum(filepath): - sha256_hash = hashlib.sha256() - with open(filepath,"rb") as f: - # Read and update hash string value in blocks of 4K - for byte_block in iter(lambda: f.read(4096),b""): - sha256_hash.update(byte_block) - return sha256_hash.hexdigest() + sha256_hash = hashlib.sha256() + with open(filepath,"rb") as f: + # Read and update hash string value in blocks of 4K + for byte_block in iter(lambda: f.read(4096),b""): + sha256_hash.update(byte_block) + return sha256_hash.hexdigest() # # Compress a JSON file into a zip file # import zipfile def compress_file(filepath, outpath): - with zipfile.ZipFile(outpath, 'w', compression=zipfile.ZIP_BZIP2, compresslevel=9) as zipf: - zipf.write(filepath, compress_type=zipfile.ZIP_BZIP2, compresslevel=9) + with zipfile.ZipFile(outpath, 'w', compression=zipfile.ZIP_BZIP2, compresslevel=9) as zipf: + zipf.write(filepath, compress_type=zipfile.ZIP_BZIP2, compresslevel=9) # # Compute the build signature. The idea is to extract all defines in the configuration headers @@ -49,228 +49,228 @@ def compress_file(filepath, outpath): # We can reverse the signature to get a 1:1 equivalent configuration file # def compute_build_signature(env): - if 'BUILD_SIGNATURE' in env: - return - - # Definitions from these files will be kept - files_to_keep = [ 'Marlin/Configuration.h', 'Marlin/Configuration_adv.h' ] - - build_path = Path(env['PROJECT_BUILD_DIR'], env['PIOENV']) - - # Check if we can skip processing - hashes = '' - for header in files_to_keep: - hashes += get_file_sha256sum(header)[0:10] - - marlin_json = build_path / 'marlin_config.json' - marlin_zip = build_path / 'mc.zip' - - # Read existing config file - try: - with marlin_json.open() as infile: - conf = json.load(infile) - if conf['__INITIAL_HASH'] == hashes: - # Same configuration, skip recomputing the building signature - compress_file(marlin_json, marlin_zip) - return - except: - pass - - # Get enabled config options based on preprocessor - from preprocessor import run_preprocessor - complete_cfg = run_preprocessor(env) - - # Dumb #define extraction from the configuration files - conf_defines = {} - all_defines = [] - for header in files_to_keep: - defines = extract_defines(header) - # To filter only the define we want - all_defines += defines - # To remember from which file it cames from - conf_defines[header.split('/')[-1]] = defines - - r = re.compile(r"\(+(\s*-*\s*_.*)\)+") - - # First step is to collect all valid macros - defines = {} - for line in complete_cfg: - - # Split the define from the value - key_val = line[8:].strip().decode().split(' ') - key, value = key_val[0], ' '.join(key_val[1:]) - - # Ignore values starting with two underscore, since it's low level - if len(key) > 2 and key[0:2] == "__" : - continue - # Ignore values containing a parenthesis (likely a function macro) - if '(' in key and ')' in key: - continue - - # Then filter dumb values - if r.match(value): - continue - - defines[key] = value if len(value) else "" - - # - # Continue to gather data for CONFIGURATION_EMBEDDING or CONFIG_EXPORT - # - if not ('CONFIGURATION_EMBEDDING' in defines or 'CONFIG_EXPORT' in defines): - return - - # Second step is to filter useless macro - resolved_defines = {} - for key in defines: - # Remove all boards now - if key.startswith("BOARD_") and key != "BOARD_INFO_NAME": - continue - # Remove all keys ending by "_NAME" as it does not make a difference to the configuration - if key.endswith("_NAME") and key != "CUSTOM_MACHINE_NAME": - continue - # Remove all keys ending by "_T_DECLARED" as it's a copy of extraneous system stuff - if key.endswith("_T_DECLARED"): - continue - # Remove keys that are not in the #define list in the Configuration list - if key not in all_defines + [ 'DETAILED_BUILD_VERSION', 'STRING_DISTRIBUTION_DATE' ]: - continue - - # Don't be that smart guy here - resolved_defines[key] = defines[key] - - # Generate a build signature now - # We are making an object that's a bit more complex than a basic dictionary here - data = {} - data['__INITIAL_HASH'] = hashes - # First create a key for each header here - for header in conf_defines: - data[header] = {} - - # Then populate the object where each key is going to (that's a O(N^2) algorithm here...) - for key in resolved_defines: - for header in conf_defines: - if key in conf_defines[header]: - data[header][key] = resolved_defines[key] - - # Every python needs this toy - def tryint(key): - try: - return int(defines[key]) - except: - return 0 - - config_dump = tryint('CONFIG_EXPORT') - - # - # Produce an INI file if CONFIG_EXPORT == 2 - # - if config_dump == 2: - print("Generating config.ini ...") - config_ini = build_path / 'config.ini' - with config_ini.open('w') as outfile: - ignore = ('CONFIGURATION_H_VERSION', 'CONFIGURATION_ADV_H_VERSION', 'CONFIG_EXPORT') - filegrp = { 'Configuration.h':'config:basic', 'Configuration_adv.h':'config:advanced' } - vers = defines["CONFIGURATION_H_VERSION"] - dt_string = datetime.now().strftime("%Y-%m-%d at %H:%M:%S") - ini_fmt = '{0:40}{1}\n' - outfile.write( - '#\n' - + '# Marlin Firmware\n' - + '# config.ini - Options to apply before the build\n' - + '#\n' - + f'# Generated by Marlin build on {dt_string}\n' - + '#\n' - + '\n' - + '[config:base]\n' - + ini_fmt.format('ini_use_config', ' = all') - + ini_fmt.format('ini_config_vers', f' = {vers}') - ) - # Loop through the data array of arrays - for header in data: - if header.startswith('__'): - continue - outfile.write('\n[' + filegrp[header] + ']\n') - for key in sorted(data[header]): - if key not in ignore: - val = 'on' if data[header][key] == '' else data[header][key] - outfile.write(ini_fmt.format(key.lower(), ' = ' + val)) - - # - # Produce a schema.json file if CONFIG_EXPORT == 3 - # - if config_dump >= 3: - try: - conf_schema = schema.extract() - except Exception as exc: - print("Error: " + str(exc)) - conf_schema = None - - if conf_schema: - # - # Produce a schema.json file if CONFIG_EXPORT == 3 - # - if config_dump in (3, 13): - print("Generating schema.json ...") - schema.dump_json(conf_schema, build_path / 'schema.json') - if config_dump == 13: - schema.group_options(conf_schema) - schema.dump_json(conf_schema, build_path / 'schema_grouped.json') - - # - # Produce a schema.yml file if CONFIG_EXPORT == 4 - # - elif config_dump == 4: - print("Generating schema.yml ...") - try: - import yaml - except ImportError: - env.Execute(env.VerboseAction( - '$PYTHONEXE -m pip install "pyyaml"', - "Installing YAML for schema.yml export", - )) - import yaml - schema.dump_yaml(conf_schema, build_path / 'schema.yml') - - # Append the source code version and date - data['VERSION'] = {} - data['VERSION']['DETAILED_BUILD_VERSION'] = resolved_defines['DETAILED_BUILD_VERSION'] - data['VERSION']['STRING_DISTRIBUTION_DATE'] = resolved_defines['STRING_DISTRIBUTION_DATE'] - try: - curver = subprocess.check_output(["git", "describe", "--match=NeVeRmAtCh", "--always"]).strip() - data['VERSION']['GIT_REF'] = curver.decode() - except: - pass - - # - # Produce a JSON file for CONFIGURATION_EMBEDDING or CONFIG_EXPORT == 1 - # - if config_dump == 1 or 'CONFIGURATION_EMBEDDING' in defines: - with marlin_json.open('w') as outfile: - json.dump(data, outfile, separators=(',', ':')) - - # - # The rest only applies to CONFIGURATION_EMBEDDING - # - if not 'CONFIGURATION_EMBEDDING' in defines: - return - - # Compress the JSON file as much as we can - compress_file(marlin_json, marlin_zip) - - # Generate a C source file for storing this array - with open('Marlin/src/mczip.h','wb') as result_file: - result_file.write( - b'#ifndef NO_CONFIGURATION_EMBEDDING_WARNING\n' - + b' #warning "Generated file \'mc.zip\' is embedded (Define NO_CONFIGURATION_EMBEDDING_WARNING to suppress this warning.)"\n' - + b'#endif\n' - + b'const unsigned char mc_zip[] PROGMEM = {\n ' - ) - count = 0 - for b in (build_path / 'mc.zip').open('rb').read(): - result_file.write(b' 0x%02X,' % b) - count += 1 - if count % 16 == 0: - result_file.write(b'\n ') - if count % 16: - result_file.write(b'\n') - result_file.write(b'};\n') + if 'BUILD_SIGNATURE' in env: + return + + # Definitions from these files will be kept + files_to_keep = [ 'Marlin/Configuration.h', 'Marlin/Configuration_adv.h' ] + + build_path = Path(env['PROJECT_BUILD_DIR'], env['PIOENV']) + + # Check if we can skip processing + hashes = '' + for header in files_to_keep: + hashes += get_file_sha256sum(header)[0:10] + + marlin_json = build_path / 'marlin_config.json' + marlin_zip = build_path / 'mc.zip' + + # Read existing config file + try: + with marlin_json.open() as infile: + conf = json.load(infile) + if conf['__INITIAL_HASH'] == hashes: + # Same configuration, skip recomputing the building signature + compress_file(marlin_json, marlin_zip) + return + except: + pass + + # Get enabled config options based on preprocessor + from preprocessor import run_preprocessor + complete_cfg = run_preprocessor(env) + + # Dumb #define extraction from the configuration files + conf_defines = {} + all_defines = [] + for header in files_to_keep: + defines = extract_defines(header) + # To filter only the define we want + all_defines += defines + # To remember from which file it cames from + conf_defines[header.split('/')[-1]] = defines + + r = re.compile(r"\(+(\s*-*\s*_.*)\)+") + + # First step is to collect all valid macros + defines = {} + for line in complete_cfg: + + # Split the define from the value + key_val = line[8:].strip().decode().split(' ') + key, value = key_val[0], ' '.join(key_val[1:]) + + # Ignore values starting with two underscore, since it's low level + if len(key) > 2 and key[0:2] == "__" : + continue + # Ignore values containing a parenthesis (likely a function macro) + if '(' in key and ')' in key: + continue + + # Then filter dumb values + if r.match(value): + continue + + defines[key] = value if len(value) else "" + + # + # Continue to gather data for CONFIGURATION_EMBEDDING or CONFIG_EXPORT + # + if not ('CONFIGURATION_EMBEDDING' in defines or 'CONFIG_EXPORT' in defines): + return + + # Second step is to filter useless macro + resolved_defines = {} + for key in defines: + # Remove all boards now + if key.startswith("BOARD_") and key != "BOARD_INFO_NAME": + continue + # Remove all keys ending by "_NAME" as it does not make a difference to the configuration + if key.endswith("_NAME") and key != "CUSTOM_MACHINE_NAME": + continue + # Remove all keys ending by "_T_DECLARED" as it's a copy of extraneous system stuff + if key.endswith("_T_DECLARED"): + continue + # Remove keys that are not in the #define list in the Configuration list + if key not in all_defines + [ 'DETAILED_BUILD_VERSION', 'STRING_DISTRIBUTION_DATE' ]: + continue + + # Don't be that smart guy here + resolved_defines[key] = defines[key] + + # Generate a build signature now + # We are making an object that's a bit more complex than a basic dictionary here + data = {} + data['__INITIAL_HASH'] = hashes + # First create a key for each header here + for header in conf_defines: + data[header] = {} + + # Then populate the object where each key is going to (that's a O(N^2) algorithm here...) + for key in resolved_defines: + for header in conf_defines: + if key in conf_defines[header]: + data[header][key] = resolved_defines[key] + + # Every python needs this toy + def tryint(key): + try: + return int(defines[key]) + except: + return 0 + + config_dump = tryint('CONFIG_EXPORT') + + # + # Produce an INI file if CONFIG_EXPORT == 2 + # + if config_dump == 2: + print("Generating config.ini ...") + config_ini = build_path / 'config.ini' + with config_ini.open('w') as outfile: + ignore = ('CONFIGURATION_H_VERSION', 'CONFIGURATION_ADV_H_VERSION', 'CONFIG_EXPORT') + filegrp = { 'Configuration.h':'config:basic', 'Configuration_adv.h':'config:advanced' } + vers = defines["CONFIGURATION_H_VERSION"] + dt_string = datetime.now().strftime("%Y-%m-%d at %H:%M:%S") + ini_fmt = '{0:40}{1}\n' + outfile.write( + '#\n' + + '# Marlin Firmware\n' + + '# config.ini - Options to apply before the build\n' + + '#\n' + + f'# Generated by Marlin build on {dt_string}\n' + + '#\n' + + '\n' + + '[config:base]\n' + + ini_fmt.format('ini_use_config', ' = all') + + ini_fmt.format('ini_config_vers', f' = {vers}') + ) + # Loop through the data array of arrays + for header in data: + if header.startswith('__'): + continue + outfile.write('\n[' + filegrp[header] + ']\n') + for key in sorted(data[header]): + if key not in ignore: + val = 'on' if data[header][key] == '' else data[header][key] + outfile.write(ini_fmt.format(key.lower(), ' = ' + val)) + + # + # Produce a schema.json file if CONFIG_EXPORT == 3 + # + if config_dump >= 3: + try: + conf_schema = schema.extract() + except Exception as exc: + print("Error: " + str(exc)) + conf_schema = None + + if conf_schema: + # + # Produce a schema.json file if CONFIG_EXPORT == 3 + # + if config_dump in (3, 13): + print("Generating schema.json ...") + schema.dump_json(conf_schema, build_path / 'schema.json') + if config_dump == 13: + schema.group_options(conf_schema) + schema.dump_json(conf_schema, build_path / 'schema_grouped.json') + + # + # Produce a schema.yml file if CONFIG_EXPORT == 4 + # + elif config_dump == 4: + print("Generating schema.yml ...") + try: + import yaml + except ImportError: + env.Execute(env.VerboseAction( + '$PYTHONEXE -m pip install "pyyaml"', + "Installing YAML for schema.yml export", + )) + import yaml + schema.dump_yaml(conf_schema, build_path / 'schema.yml') + + # Append the source code version and date + data['VERSION'] = {} + data['VERSION']['DETAILED_BUILD_VERSION'] = resolved_defines['DETAILED_BUILD_VERSION'] + data['VERSION']['STRING_DISTRIBUTION_DATE'] = resolved_defines['STRING_DISTRIBUTION_DATE'] + try: + curver = subprocess.check_output(["git", "describe", "--match=NeVeRmAtCh", "--always"]).strip() + data['VERSION']['GIT_REF'] = curver.decode() + except: + pass + + # + # Produce a JSON file for CONFIGURATION_EMBEDDING or CONFIG_EXPORT == 1 + # + if config_dump == 1 or 'CONFIGURATION_EMBEDDING' in defines: + with marlin_json.open('w') as outfile: + json.dump(data, outfile, separators=(',', ':')) + + # + # The rest only applies to CONFIGURATION_EMBEDDING + # + if not 'CONFIGURATION_EMBEDDING' in defines: + return + + # Compress the JSON file as much as we can + compress_file(marlin_json, marlin_zip) + + # Generate a C source file for storing this array + with open('Marlin/src/mczip.h','wb') as result_file: + result_file.write( + b'#ifndef NO_CONFIGURATION_EMBEDDING_WARNING\n' + + b' #warning "Generated file \'mc.zip\' is embedded (Define NO_CONFIGURATION_EMBEDDING_WARNING to suppress this warning.)"\n' + + b'#endif\n' + + b'const unsigned char mc_zip[] PROGMEM = {\n ' + ) + count = 0 + for b in (build_path / 'mc.zip').open('rb').read(): + result_file.write(b' 0x%02X,' % b) + count += 1 + if count % 16 == 0: + result_file.write(b'\n ') + if count % 16: + result_file.write(b'\n') + result_file.write(b'};\n') diff --git a/buildroot/share/PlatformIO/scripts/simulator.py b/buildroot/share/PlatformIO/scripts/simulator.py index 1767f83d32da..608258c4d17a 100644 --- a/buildroot/share/PlatformIO/scripts/simulator.py +++ b/buildroot/share/PlatformIO/scripts/simulator.py @@ -5,49 +5,49 @@ import pioutil if pioutil.is_pio_build(): - # Get the environment thus far for the build - Import("env") + # Get the environment thus far for the build + Import("env") - #print(env.Dump()) + #print(env.Dump()) - # - # Give the binary a distinctive name - # + # + # Give the binary a distinctive name + # - env['PROGNAME'] = "MarlinSimulator" + env['PROGNAME'] = "MarlinSimulator" - # - # If Xcode is installed add the path to its Frameworks folder, - # or if Mesa is installed try to use its GL/gl.h. - # + # + # If Xcode is installed add the path to its Frameworks folder, + # or if Mesa is installed try to use its GL/gl.h. + # - import sys - if sys.platform == 'darwin': + import sys + if sys.platform == 'darwin': - # - # Silence half of the ranlib warnings. (No equivalent for 'ARFLAGS') - # - env['RANLIBFLAGS'] += [ "-no_warning_for_no_symbols" ] + # + # Silence half of the ranlib warnings. (No equivalent for 'ARFLAGS') + # + env['RANLIBFLAGS'] += [ "-no_warning_for_no_symbols" ] - # Default paths for Xcode and a lucky GL/gl.h dropped by Mesa - xcode_path = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks" - mesa_path = "/opt/local/include/GL/gl.h" + # Default paths for Xcode and a lucky GL/gl.h dropped by Mesa + xcode_path = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks" + mesa_path = "/opt/local/include/GL/gl.h" - import os.path + import os.path - if os.path.exists(xcode_path): + if os.path.exists(xcode_path): - env['BUILD_FLAGS'] += [ "-F" + xcode_path ] - print("Using OpenGL framework headers from Xcode.app") + env['BUILD_FLAGS'] += [ "-F" + xcode_path ] + print("Using OpenGL framework headers from Xcode.app") - elif os.path.exists(mesa_path): + elif os.path.exists(mesa_path): - env['BUILD_FLAGS'] += [ '-D__MESA__' ] - print("Using OpenGL header from", mesa_path) + env['BUILD_FLAGS'] += [ '-D__MESA__' ] + print("Using OpenGL header from", mesa_path) - else: + else: - print("\n\nNo OpenGL headers found. Install Xcode for matching headers, or use 'sudo port install mesa' to get a GL/gl.h.\n\n") + print("\n\nNo OpenGL headers found. Install Xcode for matching headers, or use 'sudo port install mesa' to get a GL/gl.h.\n\n") - # Break out of the PIO build immediately - sys.exit(1) + # Break out of the PIO build immediately + sys.exit(1) diff --git a/buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py b/buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py index 033803009e52..1f5f6eec78ba 100644 --- a/buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py +++ b/buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py @@ -3,59 +3,59 @@ # import pioutil if pioutil.is_pio_build(): - Import("env") - - # Get a build flag's value or None - def getBuildFlagValue(name): - for flag in build_flags: - if isinstance(flag, list) and flag[0] == name: - return flag[1] - - return None - - # Get an overriding buffer size for RX or TX from the build flags - def getInternalSize(side): - return getBuildFlagValue(f"MF_{side}_BUFFER_SIZE") or \ - getBuildFlagValue(f"SERIAL_{side}_BUFFER_SIZE") or \ - getBuildFlagValue(f"USART_{side}_BUF_SIZE") - - # Get the largest defined buffer size for RX or TX - def getBufferSize(side, default): - # Get a build flag value or fall back to the given default - internal = int(getInternalSize(side) or default) - flag = side + "_BUFFER_SIZE" - # Return the largest value - return max(int(mf[flag]), internal) if flag in mf else internal - - # Add a build flag if it's not already defined - def tryAddFlag(name, value): - if getBuildFlagValue(name) is None: - env.Append(BUILD_FLAGS=[f"-D{name}={value}"]) - - # Marlin uses the `RX_BUFFER_SIZE` \ `TX_BUFFER_SIZE` options to - # configure buffer sizes for receiving \ transmitting serial data. - # Stm32duino uses another set of defines for the same purpose, so this - # script gets the values from the configuration and uses them to define - # `SERIAL_RX_BUFFER_SIZE` and `SERIAL_TX_BUFFER_SIZE` as global build - # flags so they are available for use by the platform. - # - # The script will set the value as the default one (64 bytes) - # or the user-configured one, whichever is higher. - # - # Marlin's default buffer sizes are 128 for RX and 32 for TX. - # The highest value is taken (128/64). - # - # If MF_*_BUFFER_SIZE, SERIAL_*_BUFFER_SIZE, USART_*_BUF_SIZE, are - # defined, the first of these values will be used as the minimum. - build_flags = env.ParseFlags(env.get('BUILD_FLAGS'))["CPPDEFINES"] - mf = env["MARLIN_FEATURES"] - - # Get the largest defined buffer sizes for RX or TX, using defaults for undefined - rxBuf = getBufferSize("RX", 128) - txBuf = getBufferSize("TX", 64) - - # Provide serial buffer sizes to the stm32duino platform - tryAddFlag("SERIAL_RX_BUFFER_SIZE", rxBuf) - tryAddFlag("SERIAL_TX_BUFFER_SIZE", txBuf) - tryAddFlag("USART_RX_BUF_SIZE", rxBuf) - tryAddFlag("USART_TX_BUF_SIZE", txBuf) + Import("env") + + # Get a build flag's value or None + def getBuildFlagValue(name): + for flag in build_flags: + if isinstance(flag, list) and flag[0] == name: + return flag[1] + + return None + + # Get an overriding buffer size for RX or TX from the build flags + def getInternalSize(side): + return getBuildFlagValue(f"MF_{side}_BUFFER_SIZE") or \ + getBuildFlagValue(f"SERIAL_{side}_BUFFER_SIZE") or \ + getBuildFlagValue(f"USART_{side}_BUF_SIZE") + + # Get the largest defined buffer size for RX or TX + def getBufferSize(side, default): + # Get a build flag value or fall back to the given default + internal = int(getInternalSize(side) or default) + flag = side + "_BUFFER_SIZE" + # Return the largest value + return max(int(mf[flag]), internal) if flag in mf else internal + + # Add a build flag if it's not already defined + def tryAddFlag(name, value): + if getBuildFlagValue(name) is None: + env.Append(BUILD_FLAGS=[f"-D{name}={value}"]) + + # Marlin uses the `RX_BUFFER_SIZE` \ `TX_BUFFER_SIZE` options to + # configure buffer sizes for receiving \ transmitting serial data. + # Stm32duino uses another set of defines for the same purpose, so this + # script gets the values from the configuration and uses them to define + # `SERIAL_RX_BUFFER_SIZE` and `SERIAL_TX_BUFFER_SIZE` as global build + # flags so they are available for use by the platform. + # + # The script will set the value as the default one (64 bytes) + # or the user-configured one, whichever is higher. + # + # Marlin's default buffer sizes are 128 for RX and 32 for TX. + # The highest value is taken (128/64). + # + # If MF_*_BUFFER_SIZE, SERIAL_*_BUFFER_SIZE, USART_*_BUF_SIZE, are + # defined, the first of these values will be used as the minimum. + build_flags = env.ParseFlags(env.get('BUILD_FLAGS'))["CPPDEFINES"] + mf = env["MARLIN_FEATURES"] + + # Get the largest defined buffer sizes for RX or TX, using defaults for undefined + rxBuf = getBufferSize("RX", 128) + txBuf = getBufferSize("TX", 64) + + # Provide serial buffer sizes to the stm32duino platform + tryAddFlag("SERIAL_RX_BUFFER_SIZE", rxBuf) + tryAddFlag("SERIAL_TX_BUFFER_SIZE", txBuf) + tryAddFlag("USART_RX_BUF_SIZE", rxBuf) + tryAddFlag("USART_TX_BUF_SIZE", txBuf) diff --git a/buildroot/share/scripts/upload.py b/buildroot/share/scripts/upload.py index 52fa1abc549b..ef042fcdedba 100644 --- a/buildroot/share/scripts/upload.py +++ b/buildroot/share/scripts/upload.py @@ -25,320 +25,320 @@ #-----------------# def Upload(source, target, env): - #-------# - # Debug # - #-------# - Debug = False # Set to True to enable script debug - def debugPrint(data): - if Debug: print(f"[Debug]: {data}") - - #------------------# - # Marlin functions # - #------------------# - def _GetMarlinEnv(marlinEnv, feature): - if not marlinEnv: return None - return marlinEnv[feature] if feature in marlinEnv else None - - #----------------# - # Port functions # - #----------------# - def _GetUploadPort(env): - debugPrint('Autodetecting upload port...') - env.AutodetectUploadPort(env) - portName = env.subst('$UPLOAD_PORT') - if not portName: - raise Exception('Error detecting the upload port.') - debugPrint('OK') - return portName - - #-------------------------# - # Simple serial functions # - #-------------------------# - def _OpenPort(): - # Open serial port - if port.is_open: return - debugPrint('Opening upload port...') - port.open() - port.reset_input_buffer() - debugPrint('OK') - - def _ClosePort(): - # Open serial port - if port is None: return - if not port.is_open: return - debugPrint('Closing upload port...') - port.close() - debugPrint('OK') - - def _Send(data): - debugPrint(f'>> {data}') - strdata = bytearray(data, 'utf8') + b'\n' - port.write(strdata) - time.sleep(0.010) - - def _Recv(): - clean_responses = [] - responses = port.readlines() - for Resp in responses: - # Suppress invalid chars (coming from debug info) - try: - clean_response = Resp.decode('utf8').rstrip().lstrip() - clean_responses.append(clean_response) - debugPrint(f'<< {clean_response}') - except: - pass - return clean_responses - - #------------------# - # SDCard functions # - #------------------# - def _CheckSDCard(): - debugPrint('Checking SD card...') - _Send('M21') - Responses = _Recv() - if len(Responses) < 1 or not any('SD card ok' in r for r in Responses): - raise Exception('Error accessing SD card') - debugPrint('SD Card OK') - return True - - #----------------# - # File functions # - #----------------# - def _GetFirmwareFiles(UseLongFilenames): - debugPrint('Get firmware files...') - _Send(f"M20 F{'L' if UseLongFilenames else ''}") - Responses = _Recv() - if len(Responses) < 3 or not any('file list' in r for r in Responses): - raise Exception('Error getting firmware files') - debugPrint('OK') - return Responses - - def _FilterFirmwareFiles(FirmwareList, UseLongFilenames): - Firmwares = [] - for FWFile in FirmwareList: - # For long filenames take the 3rd column of the firmwares list - if UseLongFilenames: - Space = 0 - Space = FWFile.find(' ') - if Space >= 0: Space = FWFile.find(' ', Space + 1) - if Space >= 0: FWFile = FWFile[Space + 1:] - if not '/' in FWFile and '.BIN' in FWFile.upper(): - Firmwares.append(FWFile[:FWFile.upper().index('.BIN') + 4]) - return Firmwares - - def _RemoveFirmwareFile(FirmwareFile): - _Send(f'M30 /{FirmwareFile}') - Responses = _Recv() - Removed = len(Responses) >= 1 and any('File deleted' in r for r in Responses) - if not Removed: - raise Exception(f"Firmware file '{FirmwareFile}' not removed") - return Removed - - def _RollbackUpload(FirmwareFile): - if not rollback: return - print(f"Rollback: trying to delete firmware '{FirmwareFile}'...") - _OpenPort() - # Wait for SD card release - time.sleep(1) - # Remount SD card - _CheckSDCard() - print(' OK' if _RemoveFirmwareFile(FirmwareFile) else ' Error!') - _ClosePort() - - - #---------------------# - # Callback Entrypoint # - #---------------------# - port = None - protocol = None - filetransfer = None - rollback = False - - # Get Marlin evironment vars - MarlinEnv = env['MARLIN_FEATURES'] - marlin_pioenv = _GetMarlinEnv(MarlinEnv, 'PIOENV') - marlin_motherboard = _GetMarlinEnv(MarlinEnv, 'MOTHERBOARD') - marlin_board_info_name = _GetMarlinEnv(MarlinEnv, 'BOARD_INFO_NAME') - marlin_board_custom_build_flags = _GetMarlinEnv(MarlinEnv, 'BOARD_CUSTOM_BUILD_FLAGS') - marlin_firmware_bin = _GetMarlinEnv(MarlinEnv, 'FIRMWARE_BIN') - marlin_long_filename_host_support = _GetMarlinEnv(MarlinEnv, 'LONG_FILENAME_HOST_SUPPORT') is not None - marlin_longname_write = _GetMarlinEnv(MarlinEnv, 'LONG_FILENAME_WRITE_SUPPORT') is not None - marlin_custom_firmware_upload = _GetMarlinEnv(MarlinEnv, 'CUSTOM_FIRMWARE_UPLOAD') is not None - marlin_short_build_version = _GetMarlinEnv(MarlinEnv, 'SHORT_BUILD_VERSION') - marlin_string_config_h_author = _GetMarlinEnv(MarlinEnv, 'STRING_CONFIG_H_AUTHOR') - - # Get firmware upload params - upload_firmware_source_name = str(source[0]) # Source firmware filename - upload_speed = env['UPLOAD_SPEED'] if 'UPLOAD_SPEED' in env else 115200 - # baud rate of serial connection - upload_port = _GetUploadPort(env) # Serial port to use - - # Set local upload params - upload_firmware_target_name = os.path.basename(upload_firmware_source_name) - # Target firmware filename - upload_timeout = 1000 # Communication timout, lossy/slow connections need higher values - upload_blocksize = 512 # Transfer block size. 512 = Autodetect - upload_compression = True # Enable compression - upload_error_ratio = 0 # Simulated corruption ratio - upload_test = False # Benchmark the serial link without storing the file - upload_reset = True # Trigger a soft reset for firmware update after the upload - - # Set local upload params based on board type to change script behavior - # "upload_delete_old_bins": delete all *.bin files in the root of SD Card - upload_delete_old_bins = marlin_motherboard in ['BOARD_CREALITY_V4', 'BOARD_CREALITY_V4210', 'BOARD_CREALITY_V422', 'BOARD_CREALITY_V423', - 'BOARD_CREALITY_V427', 'BOARD_CREALITY_V431', 'BOARD_CREALITY_V452', 'BOARD_CREALITY_V453', - 'BOARD_CREALITY_V24S1'] - # "upload_random_name": generate a random 8.3 firmware filename to upload - upload_random_filename = marlin_motherboard in ['BOARD_CREALITY_V4', 'BOARD_CREALITY_V4210', 'BOARD_CREALITY_V422', 'BOARD_CREALITY_V423', - 'BOARD_CREALITY_V427', 'BOARD_CREALITY_V431', 'BOARD_CREALITY_V452', 'BOARD_CREALITY_V453', - 'BOARD_CREALITY_V24S1'] and not marlin_long_filename_host_support - - try: - - # Start upload job - print(f"Uploading firmware '{os.path.basename(upload_firmware_target_name)}' to '{marlin_motherboard}' via '{upload_port}'") - - # Dump some debug info - if Debug: - print('Upload using:') - print('---- Marlin -----------------------------------') - print(f' PIOENV : {marlin_pioenv}') - print(f' SHORT_BUILD_VERSION : {marlin_short_build_version}') - print(f' STRING_CONFIG_H_AUTHOR : {marlin_string_config_h_author}') - print(f' MOTHERBOARD : {marlin_motherboard}') - print(f' BOARD_INFO_NAME : {marlin_board_info_name}') - print(f' CUSTOM_BUILD_FLAGS : {marlin_board_custom_build_flags}') - print(f' FIRMWARE_BIN : {marlin_firmware_bin}') - print(f' LONG_FILENAME_HOST_SUPPORT : {marlin_long_filename_host_support}') - print(f' LONG_FILENAME_WRITE_SUPPORT : {marlin_longname_write}') - print(f' CUSTOM_FIRMWARE_UPLOAD : {marlin_custom_firmware_upload}') - print('---- Upload parameters ------------------------') - print(f' Source : {upload_firmware_source_name}') - print(f' Target : {upload_firmware_target_name}') - print(f' Port : {upload_port} @ {upload_speed} baudrate') - print(f' Timeout : {upload_timeout}') - print(f' Block size : {upload_blocksize}') - print(f' Compression : {upload_compression}') - print(f' Error ratio : {upload_error_ratio}') - print(f' Test : {upload_test}') - print(f' Reset : {upload_reset}') - print('-----------------------------------------------') - - # Custom implementations based on board parameters - # Generate a new 8.3 random filename - if upload_random_filename: - upload_firmware_target_name = f"fw-{''.join(random.choices('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', k=5))}.BIN" - print(f"Board {marlin_motherboard}: Overriding firmware filename to '{upload_firmware_target_name}'") - - # Delete all *.bin files on the root of SD Card (if flagged) - if upload_delete_old_bins: - # CUSTOM_FIRMWARE_UPLOAD is needed for this feature - if not marlin_custom_firmware_upload: - raise Exception(f"CUSTOM_FIRMWARE_UPLOAD must be enabled in 'Configuration_adv.h' for '{marlin_motherboard}'") - - # Init & Open serial port - port = serial.Serial(upload_port, baudrate = upload_speed, write_timeout = 0, timeout = 0.1) - _OpenPort() - - # Check SD card status - _CheckSDCard() - - # Get firmware files - FirmwareFiles = _GetFirmwareFiles(marlin_long_filename_host_support) - if Debug: - for FirmwareFile in FirmwareFiles: - print(f'Found: {FirmwareFile}') - - # Get all 1st level firmware files (to remove) - OldFirmwareFiles = _FilterFirmwareFiles(FirmwareFiles[1:len(FirmwareFiles)-2], marlin_long_filename_host_support) # Skip header and footers of list - if len(OldFirmwareFiles) == 0: - print('No old firmware files to delete') - else: - print(f"Remove {len(OldFirmwareFiles)} old firmware file{'s' if len(OldFirmwareFiles) != 1 else ''}:") - for OldFirmwareFile in OldFirmwareFiles: - print(f" -Removing- '{OldFirmwareFile}'...") - print(' OK' if _RemoveFirmwareFile(OldFirmwareFile) else ' Error!') - - # Close serial - _ClosePort() - - # Cleanup completed - debugPrint('Cleanup completed') - - # WARNING! The serial port must be closed here because the serial transfer that follow needs it! - - # Upload firmware file - debugPrint(f"Copy '{upload_firmware_source_name}' --> '{upload_firmware_target_name}'") - protocol = MarlinBinaryProtocol.Protocol(upload_port, upload_speed, upload_blocksize, float(upload_error_ratio), int(upload_timeout)) - #echologger = MarlinBinaryProtocol.EchoProtocol(protocol) - protocol.connect() - # Mark the rollback (delete broken transfer) from this point on - rollback = True - filetransfer = MarlinBinaryProtocol.FileTransferProtocol(protocol) - transferOK = filetransfer.copy(upload_firmware_source_name, upload_firmware_target_name, upload_compression, upload_test) - protocol.disconnect() - - # Notify upload completed - protocol.send_ascii('M117 Firmware uploaded' if transferOK else 'M117 Firmware upload failed') - - # Remount SD card - print('Wait for SD card release...') - time.sleep(1) - print('Remount SD card') - protocol.send_ascii('M21') - - # Transfer failed? - if not transferOK: - protocol.shutdown() - _RollbackUpload(upload_firmware_target_name) - else: - # Trigger firmware update - if upload_reset: - print('Trigger firmware update...') - protocol.send_ascii('M997', True) - protocol.shutdown() - - print('Firmware update completed' if transferOK else 'Firmware update failed') - return 0 if transferOK else -1 - - except KeyboardInterrupt: - print('Aborted by user') - if filetransfer: filetransfer.abort() - if protocol: - protocol.disconnect() - protocol.shutdown() - _RollbackUpload(upload_firmware_target_name) - _ClosePort() - raise - - except serial.SerialException as se: - # This exception is raised only for send_ascii data (not for binary transfer) - print(f'Serial excepion: {se}, transfer aborted') - if protocol: - protocol.disconnect() - protocol.shutdown() - _RollbackUpload(upload_firmware_target_name) - _ClosePort() - raise Exception(se) - - except MarlinBinaryProtocol.FatalError: - print('Too many retries, transfer aborted') - if protocol: - protocol.disconnect() - protocol.shutdown() - _RollbackUpload(upload_firmware_target_name) - _ClosePort() - raise - - except Exception as ex: - print(f"\nException: {ex}, transfer aborted") - if protocol: - protocol.disconnect() - protocol.shutdown() - _RollbackUpload(upload_firmware_target_name) - _ClosePort() - print('Firmware not updated') - raise + #-------# + # Debug # + #-------# + Debug = False # Set to True to enable script debug + def debugPrint(data): + if Debug: print(f"[Debug]: {data}") + + #------------------# + # Marlin functions # + #------------------# + def _GetMarlinEnv(marlinEnv, feature): + if not marlinEnv: return None + return marlinEnv[feature] if feature in marlinEnv else None + + #----------------# + # Port functions # + #----------------# + def _GetUploadPort(env): + debugPrint('Autodetecting upload port...') + env.AutodetectUploadPort(env) + portName = env.subst('$UPLOAD_PORT') + if not portName: + raise Exception('Error detecting the upload port.') + debugPrint('OK') + return portName + + #-------------------------# + # Simple serial functions # + #-------------------------# + def _OpenPort(): + # Open serial port + if port.is_open: return + debugPrint('Opening upload port...') + port.open() + port.reset_input_buffer() + debugPrint('OK') + + def _ClosePort(): + # Open serial port + if port is None: return + if not port.is_open: return + debugPrint('Closing upload port...') + port.close() + debugPrint('OK') + + def _Send(data): + debugPrint(f'>> {data}') + strdata = bytearray(data, 'utf8') + b'\n' + port.write(strdata) + time.sleep(0.010) + + def _Recv(): + clean_responses = [] + responses = port.readlines() + for Resp in responses: + # Suppress invalid chars (coming from debug info) + try: + clean_response = Resp.decode('utf8').rstrip().lstrip() + clean_responses.append(clean_response) + debugPrint(f'<< {clean_response}') + except: + pass + return clean_responses + + #------------------# + # SDCard functions # + #------------------# + def _CheckSDCard(): + debugPrint('Checking SD card...') + _Send('M21') + Responses = _Recv() + if len(Responses) < 1 or not any('SD card ok' in r for r in Responses): + raise Exception('Error accessing SD card') + debugPrint('SD Card OK') + return True + + #----------------# + # File functions # + #----------------# + def _GetFirmwareFiles(UseLongFilenames): + debugPrint('Get firmware files...') + _Send(f"M20 F{'L' if UseLongFilenames else ''}") + Responses = _Recv() + if len(Responses) < 3 or not any('file list' in r for r in Responses): + raise Exception('Error getting firmware files') + debugPrint('OK') + return Responses + + def _FilterFirmwareFiles(FirmwareList, UseLongFilenames): + Firmwares = [] + for FWFile in FirmwareList: + # For long filenames take the 3rd column of the firmwares list + if UseLongFilenames: + Space = 0 + Space = FWFile.find(' ') + if Space >= 0: Space = FWFile.find(' ', Space + 1) + if Space >= 0: FWFile = FWFile[Space + 1:] + if not '/' in FWFile and '.BIN' in FWFile.upper(): + Firmwares.append(FWFile[:FWFile.upper().index('.BIN') + 4]) + return Firmwares + + def _RemoveFirmwareFile(FirmwareFile): + _Send(f'M30 /{FirmwareFile}') + Responses = _Recv() + Removed = len(Responses) >= 1 and any('File deleted' in r for r in Responses) + if not Removed: + raise Exception(f"Firmware file '{FirmwareFile}' not removed") + return Removed + + def _RollbackUpload(FirmwareFile): + if not rollback: return + print(f"Rollback: trying to delete firmware '{FirmwareFile}'...") + _OpenPort() + # Wait for SD card release + time.sleep(1) + # Remount SD card + _CheckSDCard() + print(' OK' if _RemoveFirmwareFile(FirmwareFile) else ' Error!') + _ClosePort() + + + #---------------------# + # Callback Entrypoint # + #---------------------# + port = None + protocol = None + filetransfer = None + rollback = False + + # Get Marlin evironment vars + MarlinEnv = env['MARLIN_FEATURES'] + marlin_pioenv = _GetMarlinEnv(MarlinEnv, 'PIOENV') + marlin_motherboard = _GetMarlinEnv(MarlinEnv, 'MOTHERBOARD') + marlin_board_info_name = _GetMarlinEnv(MarlinEnv, 'BOARD_INFO_NAME') + marlin_board_custom_build_flags = _GetMarlinEnv(MarlinEnv, 'BOARD_CUSTOM_BUILD_FLAGS') + marlin_firmware_bin = _GetMarlinEnv(MarlinEnv, 'FIRMWARE_BIN') + marlin_long_filename_host_support = _GetMarlinEnv(MarlinEnv, 'LONG_FILENAME_HOST_SUPPORT') is not None + marlin_longname_write = _GetMarlinEnv(MarlinEnv, 'LONG_FILENAME_WRITE_SUPPORT') is not None + marlin_custom_firmware_upload = _GetMarlinEnv(MarlinEnv, 'CUSTOM_FIRMWARE_UPLOAD') is not None + marlin_short_build_version = _GetMarlinEnv(MarlinEnv, 'SHORT_BUILD_VERSION') + marlin_string_config_h_author = _GetMarlinEnv(MarlinEnv, 'STRING_CONFIG_H_AUTHOR') + + # Get firmware upload params + upload_firmware_source_name = str(source[0]) # Source firmware filename + upload_speed = env['UPLOAD_SPEED'] if 'UPLOAD_SPEED' in env else 115200 + # baud rate of serial connection + upload_port = _GetUploadPort(env) # Serial port to use + + # Set local upload params + upload_firmware_target_name = os.path.basename(upload_firmware_source_name) + # Target firmware filename + upload_timeout = 1000 # Communication timout, lossy/slow connections need higher values + upload_blocksize = 512 # Transfer block size. 512 = Autodetect + upload_compression = True # Enable compression + upload_error_ratio = 0 # Simulated corruption ratio + upload_test = False # Benchmark the serial link without storing the file + upload_reset = True # Trigger a soft reset for firmware update after the upload + + # Set local upload params based on board type to change script behavior + # "upload_delete_old_bins": delete all *.bin files in the root of SD Card + upload_delete_old_bins = marlin_motherboard in ['BOARD_CREALITY_V4', 'BOARD_CREALITY_V4210', 'BOARD_CREALITY_V422', 'BOARD_CREALITY_V423', + 'BOARD_CREALITY_V427', 'BOARD_CREALITY_V431', 'BOARD_CREALITY_V452', 'BOARD_CREALITY_V453', + 'BOARD_CREALITY_V24S1'] + # "upload_random_name": generate a random 8.3 firmware filename to upload + upload_random_filename = marlin_motherboard in ['BOARD_CREALITY_V4', 'BOARD_CREALITY_V4210', 'BOARD_CREALITY_V422', 'BOARD_CREALITY_V423', + 'BOARD_CREALITY_V427', 'BOARD_CREALITY_V431', 'BOARD_CREALITY_V452', 'BOARD_CREALITY_V453', + 'BOARD_CREALITY_V24S1'] and not marlin_long_filename_host_support + + try: + + # Start upload job + print(f"Uploading firmware '{os.path.basename(upload_firmware_target_name)}' to '{marlin_motherboard}' via '{upload_port}'") + + # Dump some debug info + if Debug: + print('Upload using:') + print('---- Marlin -----------------------------------') + print(f' PIOENV : {marlin_pioenv}') + print(f' SHORT_BUILD_VERSION : {marlin_short_build_version}') + print(f' STRING_CONFIG_H_AUTHOR : {marlin_string_config_h_author}') + print(f' MOTHERBOARD : {marlin_motherboard}') + print(f' BOARD_INFO_NAME : {marlin_board_info_name}') + print(f' CUSTOM_BUILD_FLAGS : {marlin_board_custom_build_flags}') + print(f' FIRMWARE_BIN : {marlin_firmware_bin}') + print(f' LONG_FILENAME_HOST_SUPPORT : {marlin_long_filename_host_support}') + print(f' LONG_FILENAME_WRITE_SUPPORT : {marlin_longname_write}') + print(f' CUSTOM_FIRMWARE_UPLOAD : {marlin_custom_firmware_upload}') + print('---- Upload parameters ------------------------') + print(f' Source : {upload_firmware_source_name}') + print(f' Target : {upload_firmware_target_name}') + print(f' Port : {upload_port} @ {upload_speed} baudrate') + print(f' Timeout : {upload_timeout}') + print(f' Block size : {upload_blocksize}') + print(f' Compression : {upload_compression}') + print(f' Error ratio : {upload_error_ratio}') + print(f' Test : {upload_test}') + print(f' Reset : {upload_reset}') + print('-----------------------------------------------') + + # Custom implementations based on board parameters + # Generate a new 8.3 random filename + if upload_random_filename: + upload_firmware_target_name = f"fw-{''.join(random.choices('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', k=5))}.BIN" + print(f"Board {marlin_motherboard}: Overriding firmware filename to '{upload_firmware_target_name}'") + + # Delete all *.bin files on the root of SD Card (if flagged) + if upload_delete_old_bins: + # CUSTOM_FIRMWARE_UPLOAD is needed for this feature + if not marlin_custom_firmware_upload: + raise Exception(f"CUSTOM_FIRMWARE_UPLOAD must be enabled in 'Configuration_adv.h' for '{marlin_motherboard}'") + + # Init & Open serial port + port = serial.Serial(upload_port, baudrate = upload_speed, write_timeout = 0, timeout = 0.1) + _OpenPort() + + # Check SD card status + _CheckSDCard() + + # Get firmware files + FirmwareFiles = _GetFirmwareFiles(marlin_long_filename_host_support) + if Debug: + for FirmwareFile in FirmwareFiles: + print(f'Found: {FirmwareFile}') + + # Get all 1st level firmware files (to remove) + OldFirmwareFiles = _FilterFirmwareFiles(FirmwareFiles[1:len(FirmwareFiles)-2], marlin_long_filename_host_support) # Skip header and footers of list + if len(OldFirmwareFiles) == 0: + print('No old firmware files to delete') + else: + print(f"Remove {len(OldFirmwareFiles)} old firmware file{'s' if len(OldFirmwareFiles) != 1 else ''}:") + for OldFirmwareFile in OldFirmwareFiles: + print(f" -Removing- '{OldFirmwareFile}'...") + print(' OK' if _RemoveFirmwareFile(OldFirmwareFile) else ' Error!') + + # Close serial + _ClosePort() + + # Cleanup completed + debugPrint('Cleanup completed') + + # WARNING! The serial port must be closed here because the serial transfer that follow needs it! + + # Upload firmware file + debugPrint(f"Copy '{upload_firmware_source_name}' --> '{upload_firmware_target_name}'") + protocol = MarlinBinaryProtocol.Protocol(upload_port, upload_speed, upload_blocksize, float(upload_error_ratio), int(upload_timeout)) + #echologger = MarlinBinaryProtocol.EchoProtocol(protocol) + protocol.connect() + # Mark the rollback (delete broken transfer) from this point on + rollback = True + filetransfer = MarlinBinaryProtocol.FileTransferProtocol(protocol) + transferOK = filetransfer.copy(upload_firmware_source_name, upload_firmware_target_name, upload_compression, upload_test) + protocol.disconnect() + + # Notify upload completed + protocol.send_ascii('M117 Firmware uploaded' if transferOK else 'M117 Firmware upload failed') + + # Remount SD card + print('Wait for SD card release...') + time.sleep(1) + print('Remount SD card') + protocol.send_ascii('M21') + + # Transfer failed? + if not transferOK: + protocol.shutdown() + _RollbackUpload(upload_firmware_target_name) + else: + # Trigger firmware update + if upload_reset: + print('Trigger firmware update...') + protocol.send_ascii('M997', True) + protocol.shutdown() + + print('Firmware update completed' if transferOK else 'Firmware update failed') + return 0 if transferOK else -1 + + except KeyboardInterrupt: + print('Aborted by user') + if filetransfer: filetransfer.abort() + if protocol: + protocol.disconnect() + protocol.shutdown() + _RollbackUpload(upload_firmware_target_name) + _ClosePort() + raise + + except serial.SerialException as se: + # This exception is raised only for send_ascii data (not for binary transfer) + print(f'Serial excepion: {se}, transfer aborted') + if protocol: + protocol.disconnect() + protocol.shutdown() + _RollbackUpload(upload_firmware_target_name) + _ClosePort() + raise Exception(se) + + except MarlinBinaryProtocol.FatalError: + print('Too many retries, transfer aborted') + if protocol: + protocol.disconnect() + protocol.shutdown() + _RollbackUpload(upload_firmware_target_name) + _ClosePort() + raise + + except Exception as ex: + print(f"\nException: {ex}, transfer aborted") + if protocol: + protocol.disconnect() + protocol.shutdown() + _RollbackUpload(upload_firmware_target_name) + _ClosePort() + print('Firmware not updated') + raise # Attach custom upload callback env.Replace(UPLOADCMD=Upload) diff --git a/get_test_targets.py b/get_test_targets.py index ce2080eba016..a38e3a594adf 100755 --- a/get_test_targets.py +++ b/get_test_targets.py @@ -6,7 +6,7 @@ with open('.github/workflows/test-builds.yml') as f: - github_configuration = yaml.safe_load(f) + github_configuration = yaml.safe_load(f) test_platforms = github_configuration\ - ['jobs']['test_builds']['strategy']['matrix']['test-platform'] + ['jobs']['test_builds']['strategy']['matrix']['test-platform'] print(' '.join(test_platforms)) From cfe1d52bf247f5152e51f87ff7d770c0aef63a56 Mon Sep 17 00:00:00 2001 From: Protomosh <43253582+Protomosh@users.noreply.github.com> Date: Fri, 19 Aug 2022 20:57:27 +0300 Subject: [PATCH 012/243] =?UTF-8?q?=F0=9F=90=9B=20Fix=20DGUS=20Reloaded=20?= =?UTF-8?q?+=20STM32=20(#24600)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/extui/dgus/DGUSDisplay.h | 1 - .../src/lcd/extui/dgus/DGUSScreenHandler.cpp | 47 +++---- Marlin/src/lcd/extui/dgus/DGUSScreenHandler.h | 4 + .../lcd/extui/dgus/mks/DGUSScreenHandler.cpp | 121 ++++++++---------- .../src/lcd/extui/dgus_reloaded/DGUSDisplay.h | 11 +- .../lcd/extui/dgus_reloaded/DGUSRxHandler.cpp | 22 ++-- .../lcd/extui/dgus_reloaded/DGUSRxHandler.h | 2 +- .../lcd/extui/dgus_reloaded/DGUSTxHandler.h | 2 + 8 files changed, 102 insertions(+), 108 deletions(-) diff --git a/Marlin/src/lcd/extui/dgus/DGUSDisplay.h b/Marlin/src/lcd/extui/dgus/DGUSDisplay.h index b6773db03be9..c307ff44787e 100644 --- a/Marlin/src/lcd/extui/dgus/DGUSDisplay.h +++ b/Marlin/src/lcd/extui/dgus/DGUSDisplay.h @@ -39,7 +39,6 @@ enum DGUSLCD_Screens : uint8_t; -//#define DEBUG_DGUSLCD #define DEBUG_OUT ENABLED(DEBUG_DGUSLCD) #include "../../../core/debug_out.h" diff --git a/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp index 0f34d76cfac4..37543a237c0b 100644 --- a/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.cpp @@ -152,10 +152,10 @@ void DGUSScreenHandler::DGUSLCD_SendPrintTimeToDisplay(DGUS_VP_Variable &var) { // Send an uint8_t between 0 and 100 to a variable scale to 0..255 void DGUSScreenHandler::DGUSLCD_PercentageToUint8(DGUS_VP_Variable &var, void *val_ptr) { if (var.memadr) { - uint16_t value = swap16(*(uint16_t*)val_ptr); - DEBUG_ECHOLNPGM("FAN value get:", value); + const uint16_t value = BE16_P(val_ptr); + DEBUG_ECHOLNPGM("Got percent:", value); *(uint8_t*)var.memadr = map(constrain(value, 0, 100), 0, 100, 0, 255); - DEBUG_ECHOLNPGM("FAN value change:", *(uint8_t*)var.memadr); + DEBUG_ECHOLNPGM("Set uint8:", *(uint8_t*)var.memadr); } } @@ -264,10 +264,10 @@ void DGUSScreenHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var) static uint16_t period = 0; static uint16_t index = 0; //DEBUG_ECHOPGM(" DGUSLCD_SendWaitingStatusToDisplay ", var.VP); - //DEBUG_ECHOLNPGM(" data ", swap16(index)); + //DEBUG_ECHOLNPGM(" data ", BE16_P(&index)); if (period++ > DGUS_UI_WAITING_STATUS_PERIOD) { dgusdisplay.WriteVariable(var.VP, index); - //DEBUG_ECHOLNPGM(" data ", swap16(index)); + //DEBUG_ECHOLNPGM(" data ", BE16_P(&index)); if (++index >= DGUS_UI_WAITING_STATUS) index = 0; period = 0; } @@ -306,7 +306,7 @@ void DGUSScreenHandler::DGUSLCD_SendHeaterStatusToDisplay(DGUS_VP_Variable &var) void DGUSScreenHandler::DGUSLCD_SD_ScrollFilelist(DGUS_VP_Variable& var, void *val_ptr) { auto old_top = top_file; - const int16_t scroll = (int16_t)swap16(*(uint16_t*)val_ptr); + const int16_t scroll = (int16_t)BE16_P(val_ptr); if (scroll) { top_file += scroll; DEBUG_ECHOPGM("new topfile calculated:", top_file); @@ -391,7 +391,7 @@ void DGUSScreenHandler::HandleAllHeatersOff(DGUS_VP_Variable &var, void *val_ptr } void DGUSScreenHandler::HandleTemperatureChanged(DGUS_VP_Variable &var, void *val_ptr) { - celsius_t newvalue = swap16(*(uint16_t*)val_ptr); + celsius_t newvalue = BE16_P(val_ptr); celsius_t acceptedvalue; switch (var.VP) { @@ -426,7 +426,7 @@ void DGUSScreenHandler::HandleTemperatureChanged(DGUS_VP_Variable &var, void *va void DGUSScreenHandler::HandleFlowRateChanged(DGUS_VP_Variable &var, void *val_ptr) { #if HAS_EXTRUDERS - uint16_t newvalue = swap16(*(uint16_t*)val_ptr); + const uint16_t newvalue = BE16_P(val_ptr); uint8_t target_extruder; switch (var.VP) { default: return; @@ -446,7 +446,7 @@ void DGUSScreenHandler::HandleFlowRateChanged(DGUS_VP_Variable &var, void *val_p void DGUSScreenHandler::HandleManualExtrude(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleManualExtrude"); - int16_t movevalue = swap16(*(uint16_t*)val_ptr); + const int16_t movevalue = BE16_P(val_ptr); float target = movevalue * 0.01f; ExtUI::extruder_t target_extruder; @@ -468,19 +468,19 @@ void DGUSScreenHandler::HandleManualExtrude(DGUS_VP_Variable &var, void *val_ptr #if ENABLED(DGUS_UI_MOVE_DIS_OPTION) void DGUSScreenHandler::HandleManualMoveOption(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleManualMoveOption"); - *(uint16_t*)var.memadr = swap16(*(uint16_t*)val_ptr); + *(uint16_t*)var.memadr = BE16_P(val_ptr); } #endif void DGUSScreenHandler::HandleMotorLockUnlock(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleMotorLockUnlock"); - const int16_t lock = swap16(*(uint16_t*)val_ptr); + const int16_t lock = BE16_P(val_ptr); queue.enqueue_one_now(lock ? F("M18") : F("M17")); } void DGUSScreenHandler::HandleSettings(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleSettings"); - uint16_t value = swap16(*(uint16_t*)val_ptr); + const uint16_t value = BE16_P(val_ptr); switch (value) { default: break; case 1: @@ -494,11 +494,9 @@ void DGUSScreenHandler::HandleSettings(DGUS_VP_Variable &var, void *val_ptr) { } void DGUSScreenHandler::HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandleStepPerMMChanged"); - - uint16_t value_raw = swap16(*(uint16_t*)val_ptr); - DEBUG_ECHOLNPGM("value_raw:", value_raw); - float value = (float)value_raw / 10; + const uint16_t value_raw = BE16_P(val_ptr); + DEBUG_ECHOLNPGM("HandleStepPerMMChanged:", value_raw); + const float value = (float)value_raw / 10; ExtUI::axis_t axis; switch (var.VP) { case VP_X_STEP_PER_MM: axis = ExtUI::axis_t::X; break; @@ -510,15 +508,12 @@ void DGUSScreenHandler::HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ ExtUI::setAxisSteps_per_mm(value, axis); DEBUG_ECHOLNPGM("value_set:", ExtUI::getAxisSteps_per_mm(axis)); skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel - return; } void DGUSScreenHandler::HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("HandleStepPerMMExtruderChanged"); - - uint16_t value_raw = swap16(*(uint16_t*)val_ptr); - DEBUG_ECHOLNPGM("value_raw:", value_raw); - float value = (float)value_raw / 10; + const uint16_t value_raw = BE16_P(val_ptr); + DEBUG_ECHOLNPGM("HandleStepPerMMExtruderChanged:", value_raw); + const float value = (float)value_raw / 10; ExtUI::extruder_t extruder; switch (var.VP) { default: return; @@ -575,7 +570,7 @@ void DGUSScreenHandler::HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, vo void DGUSScreenHandler::HandleProbeOffsetZChanged(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleProbeOffsetZChanged"); - const float offset = float(int16_t(swap16(*(uint16_t*)val_ptr))) / 100.0f; + const float offset = float(int16_t(BE16_P(val_ptr))) / 100.0f; ExtUI::setZOffset_mm(offset); skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel return; @@ -621,7 +616,7 @@ void DGUSScreenHandler::HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr void DGUSScreenHandler::HandlePreheat(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandlePreheat"); - const uint16_t preheat_option = swap16(*(uint16_t*)val_ptr); + const uint16_t preheat_option = BE16_P(val_ptr); switch (preheat_option) { default: switch (var.VP) { @@ -644,7 +639,7 @@ void DGUSScreenHandler::HandleHeaterControl(DGUS_VP_Variable &var, void *val_ptr #if ENABLED(POWER_LOSS_RECOVERY) void DGUSScreenHandler::HandlePowerLossRecovery(DGUS_VP_Variable &var, void *val_ptr) { - uint16_t value = swap16(*(uint16_t*)val_ptr); + uint16_t value = BE16_P(val_ptr); if (value) { queue.inject(F("M1000")); dgusdisplay.WriteVariable(VP_SD_Print_Filename, filelist.filename(), 32, true); diff --git a/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.h b/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.h index 4b627fe0f69f..575a71d2892f 100644 --- a/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.h +++ b/Marlin/src/lcd/extui/dgus/DGUSScreenHandler.h @@ -42,6 +42,10 @@ #endif +// endianness swap +#define BE16_P(V) ( ((uint8_t*)(V))[0] << 8U | ((uint8_t*)(V))[1] ) +#define BE32_P(V) ( ((uint8_t*)(V))[0] << 24U | ((uint8_t*)(V))[1] << 16U | ((uint8_t*)(V))[2] << 8U | ((uint8_t*)(V))[3] ) + #if ENABLED(DGUS_LCD_UI_ORIGIN) #include "origin/DGUSScreenHandler.h" #elif ENABLED(DGUS_LCD_UI_MKS) diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp index 531788cc3f1f..36ab016b35a6 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp @@ -54,9 +54,6 @@ bool DGUSAutoTurnOff = false; MKS_Language mks_language_index; // Initialized by settings.load() -// endianness swap -uint32_t swap32(const uint32_t value) { return (value & 0x000000FFU) << 24U | (value & 0x0000FF00U) << 8U | (value & 0x00FF0000U) >> 8U | (value & 0xFF000000U) >> 24U; } - #if 0 void DGUSScreenHandlerMKS::sendinfoscreen_ch(const uint16_t *line1, const uint16_t *line2, const uint16_t *line3, const uint16_t *line4) { dgusdisplay.WriteVariable(VP_MSGSTR1, line1, 32, true); @@ -108,10 +105,10 @@ void DGUSScreenHandlerMKS::DGUSLCD_SendPrintTimeToDisplay(DGUS_VP_Variable &var) void DGUSScreenHandlerMKS::DGUSLCD_SetUint8(DGUS_VP_Variable &var, void *val_ptr) { if (var.memadr) { - const uint16_t value = swap16(*(uint16_t*)val_ptr); - DEBUG_ECHOLNPGM("FAN value get:", value); + const uint16_t value = BE16_P(val_ptr); + DEBUG_ECHOLNPGM("Got uint8:", value); *(uint8_t*)var.memadr = map(constrain(value, 0, 255), 0, 255, 0, 255); - DEBUG_ECHOLNPGM("FAN value change:", *(uint8_t*)var.memadr); + DEBUG_ECHOLNPGM("Set uint8:", *(uint8_t*)var.memadr); } } @@ -152,7 +149,7 @@ void DGUSScreenHandlerMKS::DGUSLCD_SendTMCStepValue(DGUS_VP_Variable &var) { #if ENABLED(SDSUPPORT) void DGUSScreenHandler::DGUSLCD_SD_FileSelected(DGUS_VP_Variable &var, void *val_ptr) { - uint16_t touched_nr = (int16_t)swap16(*(uint16_t*)val_ptr) + top_file; + uint16_t touched_nr = (int16_t)BE16_P(val_ptr) + top_file; if (touched_nr != 0x0F && touched_nr > filelist.count()) return; if (!filelist.seek(touched_nr) && touched_nr != 0x0F) return; @@ -191,7 +188,7 @@ void DGUSScreenHandlerMKS::DGUSLCD_SendTMCStepValue(DGUS_VP_Variable &var) { void DGUSScreenHandler::DGUSLCD_SD_ResumePauseAbort(DGUS_VP_Variable &var, void *val_ptr) { if (!ExtUI::isPrintingFromMedia()) return; // avoid race condition when user stays in this menu and printer finishes. - switch (swap16(*(uint16_t*)val_ptr)) { + switch (BE16_P(val_ptr)) { case 0: { // Resume auto cs = getCurrentScreen(); if (runout_mks.runout_status != RUNOUT_WAITING_STATUS && runout_mks.runout_status != UNRUNOUT_STATUS) { @@ -268,7 +265,7 @@ void DGUSScreenHandlerMKS::DGUSLCD_SendTMCStepValue(DGUS_VP_Variable &var) { #else void DGUSScreenHandlerMKS::PrintReturn(DGUS_VP_Variable& var, void *val_ptr) { - uint16_t value = swap16(*(uint16_t*)val_ptr); + const uint16_t value = BE16_P(val_ptr); if (value == 0x0F) GotoScreen(DGUSLCD_SCREEN_MAIN); } #endif // SDSUPPORT @@ -315,7 +312,7 @@ void DGUSScreenHandler::ScreenChangeHook(DGUS_VP_Variable &var, void *val_ptr) { } void DGUSScreenHandlerMKS::ScreenBackChange(DGUS_VP_Variable &var, void *val_ptr) { - const uint16_t target = swap16(*(uint16_t *)val_ptr); + const uint16_t target = BE16_P(val_ptr); DEBUG_ECHOLNPGM(" back = 0x%x", target); switch (target) { } @@ -331,7 +328,7 @@ void DGUSScreenHandlerMKS::ZoffsetConfirm(DGUS_VP_Variable &var, void *val_ptr) void DGUSScreenHandlerMKS::GetTurnOffCtrl(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("GetTurnOffCtrl\n"); - const uint16_t value = swap16(*(uint16_t *)val_ptr); + const uint16_t value = BE16_P(val_ptr); switch (value) { case 0 ... 1: DGUSAutoTurnOff = (bool)value; break; default: break; @@ -340,7 +337,7 @@ void DGUSScreenHandlerMKS::GetTurnOffCtrl(DGUS_VP_Variable &var, void *val_ptr) void DGUSScreenHandlerMKS::GetMinExtrudeTemp(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("GetMinExtrudeTemp"); - const uint16_t value = swap16(*(uint16_t *)val_ptr); + const uint16_t value = BE16_P(val_ptr); TERN_(PREVENT_COLD_EXTRUSION, thermalManager.extrude_min_temp = value); mks_min_extrusion_temp = value; settings.save(); @@ -348,7 +345,7 @@ void DGUSScreenHandlerMKS::GetMinExtrudeTemp(DGUS_VP_Variable &var, void *val_pt void DGUSScreenHandlerMKS::GetZoffsetDistance(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("GetZoffsetDistance"); - const uint16_t value = swap16(*(uint16_t *)val_ptr); + const uint16_t value = BE16_P(val_ptr); float val_distance = 0; switch (value) { case 0: val_distance = 0.01; break; @@ -362,11 +359,11 @@ void DGUSScreenHandlerMKS::GetZoffsetDistance(DGUS_VP_Variable &var, void *val_p void DGUSScreenHandlerMKS::GetManualMovestep(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("\nGetManualMovestep"); - *(uint16_t *)var.memadr = swap16(*(uint16_t *)val_ptr); + *(uint16_t *)var.memadr = BE16_P(val_ptr); } void DGUSScreenHandlerMKS::EEPROM_CTRL(DGUS_VP_Variable &var, void *val_ptr) { - const uint16_t eep_flag = swap16(*(uint16_t *)val_ptr); + const uint16_t eep_flag = BE16_P(val_ptr); switch (eep_flag) { case 0: settings.save(); @@ -384,7 +381,7 @@ void DGUSScreenHandlerMKS::EEPROM_CTRL(DGUS_VP_Variable &var, void *val_ptr) { } void DGUSScreenHandlerMKS::Z_offset_select(DGUS_VP_Variable &var, void *val_ptr) { - const uint16_t z_value = swap16(*(uint16_t *)val_ptr); + const uint16_t z_value = BE16_P(val_ptr); switch (z_value) { case 0: Z_distance = 0.01; break; case 1: Z_distance = 0.1; break; @@ -396,22 +393,22 @@ void DGUSScreenHandlerMKS::Z_offset_select(DGUS_VP_Variable &var, void *val_ptr) void DGUSScreenHandlerMKS::GetOffsetValue(DGUS_VP_Variable &var, void *val_ptr) { #if HAS_BED_PROBE - int32_t value = swap32(*(int32_t *)val_ptr); - float Offset = value / 100.0f; + const int32_t value = BE32_P(val_ptr); + const float Offset = value / 100.0f; DEBUG_ECHOLNPGM("\nget int6 offset >> ", value, 6); - #endif - switch (var.VP) { - case VP_OFFSET_X: TERN_(HAS_BED_PROBE, probe.offset.x = Offset); break; - case VP_OFFSET_Y: TERN_(HAS_BED_PROBE, probe.offset.y = Offset); break; - case VP_OFFSET_Z: TERN_(HAS_BED_PROBE, probe.offset.z = Offset); break; - default: break; - } - settings.save(); + switch (var.VP) { + default: break; + case VP_OFFSET_X: probe.offset.x = Offset; break; + case VP_OFFSET_Y: probe.offset.y = Offset; break; + case VP_OFFSET_Z: probe.offset.z = Offset; break; + } + settings.save(); + #endif } void DGUSScreenHandlerMKS::LanguageChange(DGUS_VP_Variable &var, void *val_ptr) { - const uint16_t lag_flag = swap16(*(uint16_t *)val_ptr); + const uint16_t lag_flag = BE16_P(val_ptr); switch (lag_flag) { case MKS_SimpleChinese: DGUS_LanguageDisplay(MKS_SimpleChinese); @@ -436,10 +433,10 @@ void DGUSScreenHandlerMKS::LanguageChange(DGUS_VP_Variable &var, void *val_ptr) #endif void DGUSScreenHandlerMKS::Level_Ctrl(DGUS_VP_Variable &var, void *val_ptr) { - const uint16_t lev_but = swap16(*(uint16_t *)val_ptr); #if ENABLED(MESH_BED_LEVELING) auto cs = getCurrentScreen(); #endif + const uint16_t lev_but = BE16_P(val_ptr); switch (lev_but) { case 0: #if ENABLED(AUTO_BED_LEVELING_BILINEAR) @@ -483,7 +480,7 @@ void DGUSScreenHandlerMKS::Level_Ctrl(DGUS_VP_Variable &var, void *val_ptr) { } void DGUSScreenHandlerMKS::MeshLevelDistanceConfig(DGUS_VP_Variable &var, void *val_ptr) { - const uint16_t mesh_dist = swap16(*(uint16_t *)val_ptr); + const uint16_t mesh_dist = BE16_P(val_ptr); switch (mesh_dist) { case 0: mesh_adj_distance = 0.01; break; case 1: mesh_adj_distance = 0.1; break; @@ -494,7 +491,7 @@ void DGUSScreenHandlerMKS::MeshLevelDistanceConfig(DGUS_VP_Variable &var, void * void DGUSScreenHandlerMKS::MeshLevel(DGUS_VP_Variable &var, void *val_ptr) { #if ENABLED(MESH_BED_LEVELING) - const uint16_t mesh_value = swap16(*(uint16_t *)val_ptr); + const uint16_t mesh_value = BE16_P(val_ptr); // static uint8_t a_first_level = 1; char cmd_buf[30]; float offset = mesh_adj_distance; @@ -592,8 +589,8 @@ void DGUSScreenHandlerMKS::SD_FileBack(DGUS_VP_Variable&, void*) { } void DGUSScreenHandlerMKS::LCD_BLK_Adjust(DGUS_VP_Variable &var, void *val_ptr) { - const uint16_t lcd_value = swap16(*(uint16_t *)val_ptr); + const uint16_t lcd_value = BE16_P(val_ptr); lcd_default_light = constrain(lcd_value, 10, 100); const uint16_t lcd_data[2] = { lcd_default_light, lcd_default_light }; @@ -601,7 +598,7 @@ void DGUSScreenHandlerMKS::LCD_BLK_Adjust(DGUS_VP_Variable &var, void *val_ptr) } void DGUSScreenHandlerMKS::ManualAssistLeveling(DGUS_VP_Variable &var, void *val_ptr) { - const int16_t point_value = swap16(*(uint16_t *)val_ptr); + const int16_t point_value = BE16_P(val_ptr); // Insist on leveling first time at this screen static bool first_level_flag = false; @@ -655,7 +652,7 @@ void DGUSScreenHandlerMKS::ManualAssistLeveling(DGUS_VP_Variable &var, void *val #define mks_max(a, b) ((a) > (b)) ? (a) : (b) void DGUSScreenHandlerMKS::TMC_ChangeConfig(DGUS_VP_Variable &var, void *val_ptr) { #if EITHER(HAS_TRINAMIC_CONFIG, HAS_STEALTHCHOP) - const uint16_t tmc_value = swap16(*(uint16_t*)val_ptr); + const uint16_t tmc_value = BE16_P(val_ptr); #endif switch (var.VP) { @@ -748,7 +745,7 @@ void DGUSScreenHandlerMKS::TMC_ChangeConfig(DGUS_VP_Variable &var, void *val_ptr void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleManualMove"); - int16_t movevalue = swap16(*(uint16_t*)val_ptr); + int16_t movevalue = BE16_P(val_ptr); // Choose Move distance if (manualMoveStep == 0x01) manualMoveStep = 10; @@ -893,7 +890,7 @@ void DGUSScreenHandler::HandleManualMove(DGUS_VP_Variable &var, void *val_ptr) { } void DGUSScreenHandlerMKS::GetParkPos(DGUS_VP_Variable &var, void *val_ptr) { - const int16_t value_pos = swap16(*(int16_t*)val_ptr); + const int16_t value_pos = BE16_P(val_ptr); switch (var.VP) { case VP_X_PARK_POS: mks_park_pos.x = value_pos; break; @@ -907,7 +904,7 @@ void DGUSScreenHandlerMKS::GetParkPos(DGUS_VP_Variable &var, void *val_ptr) { void DGUSScreenHandlerMKS::HandleChangeLevelPoint(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleChangeLevelPoint"); - const int16_t value_raw = swap16(*(int16_t*)val_ptr); + const int16_t value_raw = BE16_P(val_ptr); DEBUG_ECHOLNPGM("value_raw:", value_raw); *(int16_t*)var.memadr = value_raw; @@ -919,7 +916,7 @@ void DGUSScreenHandlerMKS::HandleChangeLevelPoint(DGUS_VP_Variable &var, void *v void DGUSScreenHandlerMKS::HandleStepPerMMChanged(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleStepPerMMChanged"); - const uint16_t value_raw = swap16(*(uint16_t*)val_ptr); + const uint16_t value_raw = BE16_P(val_ptr); const float value = (float)value_raw; DEBUG_ECHOLNPGM("value_raw:", value_raw); @@ -941,7 +938,7 @@ void DGUSScreenHandlerMKS::HandleStepPerMMChanged(DGUS_VP_Variable &var, void *v void DGUSScreenHandlerMKS::HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleStepPerMMExtruderChanged"); - const uint16_t value_raw = swap16(*(uint16_t*)val_ptr); + const uint16_t value_raw = BE16_P(val_ptr); const float value = (float)value_raw; DEBUG_ECHOLNPGM("value_raw:", value_raw); @@ -966,7 +963,7 @@ void DGUSScreenHandlerMKS::HandleStepPerMMExtruderChanged(DGUS_VP_Variable &var, void DGUSScreenHandlerMKS::HandleMaxSpeedChange(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleMaxSpeedChange"); - const uint16_t value_raw = swap16(*(uint16_t*)val_ptr); + const uint16_t value_raw = BE16_P(val_ptr); const float value = (float)value_raw; DEBUG_ECHOLNPGM("value_raw:", value_raw); @@ -988,7 +985,7 @@ void DGUSScreenHandlerMKS::HandleMaxSpeedChange(DGUS_VP_Variable &var, void *val void DGUSScreenHandlerMKS::HandleExtruderMaxSpeedChange(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleExtruderMaxSpeedChange"); - const uint16_t value_raw = swap16(*(uint16_t*)val_ptr); + const uint16_t value_raw = BE16_P(val_ptr); const float value = (float)value_raw; DEBUG_ECHOLNPGM("value_raw:", value_raw); @@ -1013,7 +1010,7 @@ void DGUSScreenHandlerMKS::HandleExtruderMaxSpeedChange(DGUS_VP_Variable &var, v void DGUSScreenHandlerMKS::HandleMaxAccChange(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleMaxAccChange"); - const uint16_t value_raw = swap16(*(uint16_t*)val_ptr); + const uint16_t value_raw = BE16_P(val_ptr); const float value = (float)value_raw; DEBUG_ECHOLNPGM("value_raw:", value_raw); @@ -1035,7 +1032,7 @@ void DGUSScreenHandlerMKS::HandleMaxAccChange(DGUS_VP_Variable &var, void *val_p void DGUSScreenHandlerMKS::HandleExtruderAccChange(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleExtruderAccChange"); - uint16_t value_raw = swap16(*(uint16_t*)val_ptr); + uint16_t value_raw = BE16_P(val_ptr); DEBUG_ECHOLNPGM("value_raw:", value_raw); float value = (float)value_raw; ExtUI::extruder_t extruder; @@ -1056,32 +1053,32 @@ void DGUSScreenHandlerMKS::HandleExtruderAccChange(DGUS_VP_Variable &var, void * } void DGUSScreenHandlerMKS::HandleTravelAccChange(DGUS_VP_Variable &var, void *val_ptr) { - uint16_t value_travel = swap16(*(uint16_t*)val_ptr); + uint16_t value_travel = BE16_P(val_ptr); planner.settings.travel_acceleration = (float)value_travel; skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } void DGUSScreenHandlerMKS::HandleFeedRateMinChange(DGUS_VP_Variable &var, void *val_ptr) { - uint16_t value_t = swap16(*(uint16_t*)val_ptr); + uint16_t value_t = BE16_P(val_ptr); planner.settings.min_feedrate_mm_s = (float)value_t; skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } void DGUSScreenHandlerMKS::HandleMin_T_F(DGUS_VP_Variable &var, void *val_ptr) { - uint16_t value_t_f = swap16(*(uint16_t*)val_ptr); + uint16_t value_t_f = BE16_P(val_ptr); planner.settings.min_travel_feedrate_mm_s = (float)value_t_f; skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } void DGUSScreenHandlerMKS::HandleAccChange(DGUS_VP_Variable &var, void *val_ptr) { - uint16_t value_acc = swap16(*(uint16_t*)val_ptr); + uint16_t value_acc = BE16_P(val_ptr); planner.settings.acceleration = (float)value_acc; skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } #if ENABLED(PREVENT_COLD_EXTRUSION) void DGUSScreenHandlerMKS::HandleGetExMinTemp(DGUS_VP_Variable &var, void *val_ptr) { - const uint16_t value_ex_min_temp = swap16(*(uint16_t*)val_ptr); + const uint16_t value_ex_min_temp = BE16_P(val_ptr); thermalManager.extrude_min_temp = value_ex_min_temp; skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } @@ -1089,7 +1086,7 @@ void DGUSScreenHandlerMKS::HandleAccChange(DGUS_VP_Variable &var, void *val_ptr) #if HAS_PID_HEATING void DGUSScreenHandler::HandleTemperaturePIDChanged(DGUS_VP_Variable &var, void *val_ptr) { - const uint16_t rawvalue = swap16(*(uint16_t*)val_ptr); + const uint16_t rawvalue = BE16_P(val_ptr); DEBUG_ECHOLNPGM("V1:", rawvalue); const float value = 1.0f * rawvalue; DEBUG_ECHOLNPGM("V2:", value); @@ -1125,9 +1122,9 @@ void DGUSScreenHandlerMKS::HandleAccChange(DGUS_VP_Variable &var, void *val_ptr) #if ENABLED(BABYSTEPPING) void DGUSScreenHandler::HandleLiveAdjustZ(DGUS_VP_Variable &var, void *val_ptr) { DEBUG_ECHOLNPGM("HandleLiveAdjustZ"); - float step = ZOffset_distance; + const float step = ZOffset_distance; - uint16_t flag = swap16(*(uint16_t*)val_ptr); + const uint16_t flag = BE16_P(val_ptr); switch (flag) { case 0: if (step == 0.01) @@ -1159,34 +1156,26 @@ void DGUSScreenHandlerMKS::HandleAccChange(DGUS_VP_Variable &var, void *val_ptr) z_offset_add += ZOffset_distance; break; - default: - break; + default: break; } ForceCompleteUpdate(); } #endif // BABYSTEPPING void DGUSScreenHandlerMKS::GetManualFilament(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("GetManualFilament"); - - uint16_t value_len = swap16(*(uint16_t*)val_ptr); + const uint16_t value_len = BE16_P(val_ptr); + const float value = (float)value_len; - float value = (float)value_len; - - DEBUG_ECHOLNPGM("Get Filament len value:", value); + DEBUG_ECHOLNPGM("GetManualFilament:", value); distanceFilament = value; skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } void DGUSScreenHandlerMKS::GetManualFilamentSpeed(DGUS_VP_Variable &var, void *val_ptr) { - DEBUG_ECHOLNPGM("GetManualFilamentSpeed"); - - uint16_t value_len = swap16(*(uint16_t*)val_ptr); - - DEBUG_ECHOLNPGM("filamentSpeed_mm_s value:", value_len); - + const uint16_t value_len = BE16_P(val_ptr); filamentSpeed_mm_s = value_len; + DEBUG_ECHOLNPGM("GetManualFilamentSpeed:", value_len); skipVP = var.VP; // don't overwrite value the next update time as the display might autoincrement in parallel } @@ -1205,7 +1194,7 @@ void DGUSScreenHandlerMKS::FilamentLoadUnload(DGUS_VP_Variable &var, void *val_p if (!print_job_timer.isPaused() && !queue.ring_buffer.empty()) return; - const uint16_t val_t = swap16(*(uint16_t*)val_ptr); + const uint16_t val_t = BE16_P(val_ptr); switch (val_t) { default: break; case 0: @@ -1291,7 +1280,7 @@ void DGUSScreenHandlerMKS::FilamentUnLoad(DGUS_VP_Variable &var, void *val_ptr) uint8_t e_temp = 0; filament_data.heated = false; - uint16_t preheat_option = swap16(*(uint16_t*)val_ptr); + uint16_t preheat_option = BE16_P(val_ptr); if (preheat_option >= 10) { // Unload filament type preheat_option -= 10; filament_data.action = 2; diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.h b/Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.h index fa5bf3039696..d115f7c02ba5 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.h +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.h @@ -21,7 +21,10 @@ */ #pragma once -/* DGUS implementation written by coldtobi in 2019 for Marlin */ +/** + * DGUS implementation written by coldtobi in 2019. + * Updated for STM32G0B1RE by Protomosh in 2022. + */ #include "config/DGUS_Screen.h" #include "config/DGUS_Control.h" @@ -30,11 +33,13 @@ #include "../../../inc/MarlinConfigPre.h" #include "../../../MarlinCore.h" +#define DEBUG_DGUSLCD // Uncomment for debug messages #define DEBUG_OUT ENABLED(DEBUG_DGUSLCD) #include "../../../core/debug_out.h" -#define Swap16(val) ((uint16_t)(((uint16_t)(val) >> 8) |\ - ((uint16_t)(val) << 8))) +// New endianness swap for 32bit mcu (tested with STM32G0B1RE) +#define BE16_P(V) ( ((uint8_t*)(V))[0] << 8U | ((uint8_t*)(V))[1] ) +#define BE32_P(V) ( ((uint8_t*)(V))[0] << 24U | ((uint8_t*)(V))[1] << 16U | ((uint8_t*)(V))[2] << 8U | ((uint8_t*)(V))[3] ) // Low-Level access to the display. class DGUSDisplay { diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp b/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp index 88fe30a0273f..ce03ab6b8340 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp @@ -215,7 +215,7 @@ void DGUSRxHandler::PrintResume(DGUS_VP &vp, void *data_ptr) { void DGUSRxHandler::Feedrate(DGUS_VP &vp, void *data_ptr) { UNUSED(vp); - const int16_t feedrate = Swap16(*(int16_t*)data_ptr); + const int16_t feedrate = BE16_P(data_ptr); ExtUI::setFeedrate_percent(feedrate); @@ -223,7 +223,7 @@ void DGUSRxHandler::Feedrate(DGUS_VP &vp, void *data_ptr) { } void DGUSRxHandler::Flowrate(DGUS_VP &vp, void *data_ptr) { - const int16_t flowrate = Swap16(*(int16_t*)data_ptr); + const int16_t flowrate = BE16_P(data_ptr); switch (vp.addr) { default: return; @@ -246,7 +246,7 @@ void DGUSRxHandler::Flowrate(DGUS_VP &vp, void *data_ptr) { void DGUSRxHandler::BabystepSet(DGUS_VP &vp, void *data_ptr) { UNUSED(vp); - const int16_t data = Swap16(*(int16_t*)data_ptr); + const int16_t data = BE16_P(data_ptr); const float offset = dgus_display.FromFixedPoint(data); const int16_t steps = ExtUI::mmToWholeSteps(offset - ExtUI::getZOffset_mm(), ExtUI::Z); @@ -315,7 +315,7 @@ void DGUSRxHandler::TempPreset(DGUS_VP &vp, void *data_ptr) { } void DGUSRxHandler::TempTarget(DGUS_VP &vp, void *data_ptr) { - const int16_t temp = Swap16(*(int16_t*)data_ptr); + const int16_t temp = BE16_P(data_ptr); switch (vp.addr) { default: return; @@ -338,7 +338,7 @@ void DGUSRxHandler::TempTarget(DGUS_VP &vp, void *data_ptr) { void DGUSRxHandler::TempCool(DGUS_VP &vp, void *data_ptr) { UNUSED(vp); - const DGUS_Data::Heater heater = (DGUS_Data::Heater)Swap16(*(uint16_t*)data_ptr); + const DGUS_Data::Heater heater = (DGUS_Data::Heater)BE16_P(data_ptr); switch (heater) { default: return; @@ -397,7 +397,7 @@ void DGUSRxHandler::ZOffset(DGUS_VP &vp, void *data_ptr) { return; } - const int16_t data = Swap16(*(int16_t*)data_ptr); + const int16_t data = BE16_P(data_ptr); const float offset = dgus_display.FromFixedPoint(data); const int16_t steps = ExtUI::mmToWholeSteps(offset - ExtUI::getZOffset_mm(), ExtUI::Z); @@ -546,7 +546,7 @@ void DGUSRxHandler::DisableABL(DGUS_VP &vp, void *data_ptr) { void DGUSRxHandler::FilamentSelect(DGUS_VP &vp, void *data_ptr) { UNUSED(vp); - const DGUS_Data::Extruder extruder = (DGUS_Data::Extruder)Swap16(*(uint16_t*)data_ptr); + const DGUS_Data::Extruder extruder = (DGUS_Data::Extruder)BE16_P(data_ptr); switch (extruder) { default: return; @@ -563,7 +563,7 @@ void DGUSRxHandler::FilamentSelect(DGUS_VP &vp, void *data_ptr) { void DGUSRxHandler::FilamentLength(DGUS_VP &vp, void *data_ptr) { UNUSED(vp); - const uint16_t length = Swap16(*(uint16_t*)data_ptr); + const uint16_t length = BE16_P(data_ptr); dgus_screen_handler.filament_length = constrain(length, 0, EXTRUDE_MAXLENGTH); @@ -644,7 +644,7 @@ void DGUSRxHandler::Home(DGUS_VP &vp, void *data_ptr) { } void DGUSRxHandler::Move(DGUS_VP &vp, void *data_ptr) { - const int16_t data = Swap16(*(int16_t*)data_ptr); + const int16_t data = BE16_P(data_ptr); const float position = dgus_display.FromFixedPoint(data); ExtUI::axis_t axis; @@ -816,7 +816,7 @@ void DGUSRxHandler::SettingsExtra(DGUS_VP &vp, void *data_ptr) { void DGUSRxHandler::PIDSelect(DGUS_VP &vp, void *data_ptr) { UNUSED(vp); - const DGUS_Data::Heater heater = (DGUS_Data::Heater)Swap16(*(uint16_t*)data_ptr); + const DGUS_Data::Heater heater = (DGUS_Data::Heater)BE16_P(data_ptr); switch (heater) { default: return; @@ -846,7 +846,7 @@ void DGUSRxHandler::PIDSetTemp(DGUS_VP &vp, void *data_ptr) { return; } - uint16_t temp = Swap16(*(uint16_t*)data_ptr); + uint16_t temp = BE16_P(data_ptr); switch (dgus_screen_handler.pid_heater) { default: return; diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.h b/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.h index c2e6e4308e5a..4cad11fc0b0b 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.h +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.h @@ -107,7 +107,7 @@ namespace DGUSRxHandler { break; } case 2: { - const uint16_t data = Swap16(*(uint16_t*)data_ptr); + const uint16_t data = BE16_P(data_ptr); *(T*)vp.extra = (T)data; break; } diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.h b/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.h index 94632fe385e6..7d1b46773b25 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.h +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.h @@ -24,6 +24,8 @@ #include "DGUSDisplay.h" #include "definition/DGUS_VP.h" +#define Swap16(val) ((uint16_t)(((uint16_t)(val) >> 8) | ((uint16_t)(val) << 8))) + namespace DGUSTxHandler { #if ENABLED(SDSUPPORT) From b4af335b7ab1bedd011335ea06bfb1d1c2928c03 Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Fri, 19 Aug 2022 11:11:15 -0700 Subject: [PATCH 013/243] =?UTF-8?q?=F0=9F=94=A7=20Remove=20STM32F4=20Print?= =?UTF-8?q?=20Counter=20Sanity=20Check=20(#24605)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration.h | 2 +- Marlin/src/HAL/STM32/inc/Conditionals_post.h | 5 +++++ Marlin/src/HAL/STM32/inc/SanityCheck.h | 5 ----- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 683b61298b83..b30ba9b8d3fa 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -2362,7 +2362,7 @@ */ //#define PRINTCOUNTER #if ENABLED(PRINTCOUNTER) - #define PRINTCOUNTER_SAVE_INTERVAL 60 // (minutes) EEPROM save interval during print + #define PRINTCOUNTER_SAVE_INTERVAL 60 // (minutes) EEPROM save interval during print. A value of 0 will save stats at end of print. #endif // @section security diff --git a/Marlin/src/HAL/STM32/inc/Conditionals_post.h b/Marlin/src/HAL/STM32/inc/Conditionals_post.h index 18826e11d24a..5ac476618292 100644 --- a/Marlin/src/HAL/STM32/inc/Conditionals_post.h +++ b/Marlin/src/HAL/STM32/inc/Conditionals_post.h @@ -27,3 +27,8 @@ #elif EITHER(I2C_EEPROM, SPI_EEPROM) #define USE_SHARED_EEPROM 1 #endif + +// Some STM32F4 boards may lose steps when saving to EEPROM during print (PR #17946) +#if defined(STM32F4xx) && PRINTCOUNTER_SAVE_INTERVAL > 0 + #define PRINTCOUNTER_SYNC 1 +#endif diff --git a/Marlin/src/HAL/STM32/inc/SanityCheck.h b/Marlin/src/HAL/STM32/inc/SanityCheck.h index 0f1a2acaa41c..a440695a06f4 100644 --- a/Marlin/src/HAL/STM32/inc/SanityCheck.h +++ b/Marlin/src/HAL/STM32/inc/SanityCheck.h @@ -37,11 +37,6 @@ #error "SDCARD_EEPROM_EMULATION requires SDSUPPORT. Enable SDSUPPORT or choose another EEPROM emulation." #endif -#if defined(STM32F4xx) && BOTH(PRINTCOUNTER, FLASH_EEPROM_EMULATION) - #warning "FLASH_EEPROM_EMULATION may cause long delays when writing and should not be used while printing." - #error "Disable PRINTCOUNTER or choose another EEPROM emulation." -#endif - #if !defined(STM32F4xx) && ENABLED(FLASH_EEPROM_LEVELING) #error "FLASH_EEPROM_LEVELING is currently only supported on STM32F4 hardware." #endif From bdd5f3678eff031d098f22a92b0d097bac3a41b3 Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Fri, 19 Aug 2022 11:37:43 -0700 Subject: [PATCH 014/243] =?UTF-8?q?=F0=9F=93=BA=20Add=20to=20MKS=20UI=20Ab?= =?UTF-8?q?out=20Screen=20(#24610)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/extui/mks_ui/draw_about.cpp | 19 ++++++++++++++----- Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Marlin/src/lcd/extui/mks_ui/draw_about.cpp b/Marlin/src/lcd/extui/mks_ui/draw_about.cpp index 49ee6eee7377..e254523e1241 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_about.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_about.cpp @@ -31,7 +31,7 @@ extern lv_group_t *g; static lv_obj_t *scr; -static lv_obj_t *fw_type, *board; +static lv_obj_t *fw_type, *board, *website, *uuid, *protocol; enum { ID_A_RETURN = 1 }; @@ -48,11 +48,20 @@ void lv_draw_about() { scr = lv_screen_create(ABOUT_UI); lv_big_button_create(scr, "F:/bmp_return.bin", common_menu.text_back, BTN_X_PIXEL * 3 + INTERVAL_V * 4, BTN_Y_PIXEL + INTERVAL_H + titleHeight, event_handler, ID_A_RETURN); - fw_type = lv_label_create(scr, "Firmware: Marlin " SHORT_BUILD_VERSION); - lv_obj_align(fw_type, nullptr, LV_ALIGN_CENTER, 0, -20); + board = lv_label_create(scr, BOARD_INFO_NAME); + lv_obj_align(board, nullptr, LV_ALIGN_CENTER, 0, -80); - board = lv_label_create(scr, "Board: " BOARD_INFO_NAME); - lv_obj_align(board, nullptr, LV_ALIGN_CENTER, 0, -60); + fw_type = lv_label_create(scr, "Marlin " SHORT_BUILD_VERSION " (" STRING_DISTRIBUTION_DATE ")"); + lv_obj_align(fw_type, nullptr, LV_ALIGN_CENTER, 0, -50); + + website = lv_label_create(scr, WEBSITE_URL); + lv_obj_align(website, nullptr, LV_ALIGN_CENTER, 0, -20); + + uuid = lv_label_create(scr, "UUID: " DEFAULT_MACHINE_UUID); + lv_obj_align(uuid, nullptr, LV_ALIGN_CENTER, 0, 10); + + protocol = lv_label_create(scr, "Protocol: " PROTOCOL_VERSION); + lv_obj_align(protocol, nullptr, LV_ALIGN_CENTER, 0, 40); } void lv_clear_about() { diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h index 115058a19f77..9801676c2e9e 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO.h @@ -29,7 +29,7 @@ #define ALLOW_STM32DUINO #include "env_validate.h" -#define BOARD_INFO_NAME "MKS Robin Nano" +#define BOARD_INFO_NAME "MKS Robin Nano V1" // // Release PB4 (Y_ENABLE_PIN) from JTAG NRST role From 5145266b0db80f52b81d3060082498960664445a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 20 Aug 2022 06:41:00 -0500 Subject: [PATCH 015/243] =?UTF-8?q?=F0=9F=8E=A8=20Some=20automated=20clean?= =?UTF-8?q?up?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/NATIVE_SIM/tft/xpt2046.h | 2 +- Marlin/src/HAL/STM32/tft/tft_fsmc.cpp | 2 +- Marlin/src/HAL/STM32/tft/tft_spi.cpp | 2 +- Marlin/src/core/macros.h | 2 +- Marlin/src/inc/SanityCheck.h | 4 +- .../ftdi_eve_lib/basic/resolutions.h | 2 +- .../variants/MARLIN_ARCHIM/variant.cpp | 2 +- .../MARLIN_BTT_SKR_SE_BX/hal_conf_extra.h | 16 +- .../variants/MARLIN_BTT_SKR_SE_BX/variant.cpp | 28 ++-- .../variants/MARLIN_F103Rx/PeripheralPins.c | 20 +-- .../MARLIN_F103VE_LONGER/hal_conf_custom.h | 2 +- .../variants/MARLIN_F103VE_LONGER/variant.h | 2 +- .../variants/MARLIN_F103Vx/PeripheralPins.c | 16 +- .../variants/MARLIN_F103Zx/hal_conf_custom.h | 16 +- .../variants/MARLIN_F4x7Vx/hal_conf_extra.h | 14 +- .../variants/MARLIN_G0B1RE/PeripheralPins.c | 2 +- .../variant_MARLIN_STM32G0B1RE.cpp | 2 +- .../variants/MARLIN_H743Vx/PeripheralPins.c | 2 +- .../variant_MARLIN_STM32H743VX.cpp | 2 +- .../variant_MARLIN_STM32H743VX.h | 8 +- .../MARLIN_TH3D_EZBOARD_V2/hal_conf_extra.h | 14 +- .../marlin_maple_CHITU_F103/board.cpp | 156 +++++++++--------- .../marlin_maple_CHITU_F103/wirish/boards.cpp | 6 +- .../marlin_maple_MEEB_3DP/wirish/boards.cpp | 2 +- 24 files changed, 162 insertions(+), 162 deletions(-) diff --git a/Marlin/src/HAL/NATIVE_SIM/tft/xpt2046.h b/Marlin/src/HAL/NATIVE_SIM/tft/xpt2046.h index b131853643a8..4e999f88ff98 100644 --- a/Marlin/src/HAL/NATIVE_SIM/tft/xpt2046.h +++ b/Marlin/src/HAL/NATIVE_SIM/tft/xpt2046.h @@ -51,7 +51,7 @@ enum XPTCoordinate : uint8_t { XPT2046_Z2 = 0x40 | XPT2046_CONTROL | XPT2046_DFR_MODE, }; -#if !defined(XPT2046_Z1_THRESHOLD) +#ifndef XPT2046_Z1_THRESHOLD #define XPT2046_Z1_THRESHOLD 10 #endif diff --git a/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp b/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp index e68b3c126939..3df982e48b8e 100644 --- a/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp +++ b/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp @@ -147,7 +147,7 @@ uint32_t TFT_FSMC::ReadID(tft_data_t Reg) { } bool TFT_FSMC::isBusy() { - #if defined(STM32F1xx) + #ifdef STM32F1xx volatile bool dmaEnabled = (DMAtx.Instance->CCR & DMA_CCR_EN) != RESET; #elif defined(STM32F4xx) volatile bool dmaEnabled = DMAtx.Instance->CR & DMA_SxCR_EN; diff --git a/Marlin/src/HAL/STM32/tft/tft_spi.cpp b/Marlin/src/HAL/STM32/tft/tft_spi.cpp index 2e18c8a64c06..e455164c7736 100644 --- a/Marlin/src/HAL/STM32/tft/tft_spi.cpp +++ b/Marlin/src/HAL/STM32/tft/tft_spi.cpp @@ -179,7 +179,7 @@ uint32_t TFT_SPI::ReadID(uint16_t Reg) { } bool TFT_SPI::isBusy() { - #if defined(STM32F1xx) + #ifdef STM32F1xx volatile bool dmaEnabled = (DMAtx.Instance->CCR & DMA_CCR_EN) != RESET; #elif defined(STM32F4xx) volatile bool dmaEnabled = DMAtx.Instance->CR & DMA_SxCR_EN; diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index ddcf27b2b855..8dfcb875ac4e 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -21,7 +21,7 @@ */ #pragma once -#if !defined(__has_include) +#ifndef __has_include #define __has_include(...) 1 #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index ff8730d07b9a..7c0625dec44e 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2276,7 +2276,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS * Redundant temperature sensor config */ #if HAS_TEMP_REDUNDANT - #if !defined(TEMP_SENSOR_REDUNDANT_SOURCE) + #ifndef TEMP_SENSOR_REDUNDANT_SOURCE #error "TEMP_SENSOR_REDUNDANT requires TEMP_SENSOR_REDUNDANT_SOURCE." #elif !defined(TEMP_SENSOR_REDUNDANT_TARGET) #error "TEMP_SENSOR_REDUNDANT requires TEMP_SENSOR_REDUNDANT_TARGET." @@ -2984,7 +2984,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #if ENABLED(ANYCUBIC_LCD_CHIRON) - #if !defined(BEEPER_PIN) + #ifndef BEEPER_PIN #error "ANYCUBIC_LCD_CHIRON requires BEEPER_PIN" #elif DISABLED(SDSUPPORT) #error "ANYCUBIC_LCD_CHIRON requires SDSUPPORT" diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/basic/resolutions.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/basic/resolutions.h index 0c600fa0a580..524ebfafaadf 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/basic/resolutions.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/basic/resolutions.h @@ -97,7 +97,7 @@ #elif defined(TOUCH_UI_800x480) namespace FTDI { - #if defined(TOUCH_UI_800x480_GENERIC) + #ifdef TOUCH_UI_800x480_GENERIC constexpr uint8_t Pclk = 2; constexpr uint16_t Hsize = 800; constexpr uint16_t Vsize = 480; diff --git a/buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/variant.cpp b/buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/variant.cpp index 72ad45ef4602..5e8e1cc7e4ea 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/variant.cpp +++ b/buildroot/share/PlatformIO/variants/MARLIN_ARCHIM/variant.cpp @@ -413,7 +413,7 @@ void init( void ) // Disable pull-up on every pin for (unsigned i = 0; i < PINS_COUNT; i++) - digitalWrite(i, LOW); + digitalWrite(i, LOW); // Enable parallel access on PIO output data registers PIOA->PIO_OWER = 0xFFFFFFFF; diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/hal_conf_extra.h index 99f3a30443b6..92730f594520 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/hal_conf_extra.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/hal_conf_extra.h @@ -100,11 +100,11 @@ extern "C" { * This value is used by the RCC HAL module to compute the system frequency * (when HSE is used as system clock source, directly or through the PLL). */ -#if !defined (HSE_VALUE) +#ifndef HSE_VALUE #define HSE_VALUE ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */ #endif /* HSE_VALUE */ -#if !defined (HSE_STARTUP_TIMEOUT) +#ifndef HSE_STARTUP_TIMEOUT #define HSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for HSE start up, in ms */ #endif /* HSE_STARTUP_TIMEOUT */ @@ -112,7 +112,7 @@ extern "C" { * @brief Internal oscillator (CSI) default value. * This value is the default CSI value after Reset. */ -#if !defined (CSI_VALUE) +#ifndef CSI_VALUE #define CSI_VALUE ((uint32_t)4000000) /*!< Value of the Internal oscillator in Hz*/ #endif /* CSI_VALUE */ @@ -121,7 +121,7 @@ extern "C" { * This value is used by the RCC HAL module to compute the system frequency * (when HSI is used as system clock source, directly or through the PLL). */ -#if !defined (HSI_VALUE) +#ifndef HSI_VALUE #define HSI_VALUE ((uint32_t)64000000) /*!< Value of the Internal oscillator in Hz*/ #endif /* HSI_VALUE */ @@ -129,16 +129,16 @@ extern "C" { * @brief External Low Speed oscillator (LSE) value. * This value is used by the UART, RTC HAL module to compute the system frequency */ -#if !defined (LSE_VALUE) +#ifndef LSE_VALUE #define LSE_VALUE ((uint32_t)32768) /*!< Value of the External oscillator in Hz*/ #endif /* LSE_VALUE */ -#if !defined (LSE_STARTUP_TIMEOUT) +#ifndef LSE_STARTUP_TIMEOUT #define LSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for LSE start up, in ms */ #endif /* LSE_STARTUP_TIMEOUT */ -#if !defined (LSI_VALUE) +#ifndef LSI_VALUE #define LSI_VALUE ((uint32_t)32000) /*!< LSI Typical Value in Hz*/ #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz The real value may vary depending on the variations @@ -148,7 +148,7 @@ in voltage and temperature.*/ * This value is used by the I2S HAL module to compute the I2S clock source * frequency, this source is inserted directly through I2S_CKIN pad. */ -#if !defined (EXTERNAL_CLOCK_VALUE) +#ifndef EXTERNAL_CLOCK_VALUE #define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External clock in Hz*/ #endif /* EXTERNAL_CLOCK_VALUE */ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/variant.cpp b/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/variant.cpp index 203e9fc9b8f8..ce2f2a0aa305 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/variant.cpp +++ b/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/variant.cpp @@ -184,7 +184,7 @@ void SystemClockStartupInit() { PWR->CR3 &= ~(1 << 2); // SCUEN=0 PWR->D3CR |= 3 << 14; // VOS=3,Scale1,1.15~1.26V core voltage - while((PWR->D3CR & (1 << 13)) == 0); // Wait for the voltage to stabilize + while((PWR->D3CR & (1 << 13)) == 0); // Wait for the voltage to stabilize RCC->CR |= 1<<16; // Enable HSE uint16_t timeout = 0; @@ -198,9 +198,9 @@ void SystemClockStartupInit() { RCC->PLLCKSELR |= 2 << 0; // PLLSRC[1:0] = 2, HSE for PLL clock source RCC->PLLCKSELR |= 5 << 4; // DIVM1[5:0] = pllm, Prescaler for PLL1 RCC->PLL1DIVR |= (160 - 1) << 0; // DIVN1[8:0] = plln - 1, Multiplication factor for PLL1 VCO - RCC->PLL1DIVR |= (2 - 1) << 9; // DIVP1[6:0] = pllp - 1, PLL1 DIVP division factor + RCC->PLL1DIVR |= (2 - 1) << 9; // DIVP1[6:0] = pllp - 1, PLL1 DIVP division factor RCC->PLL1DIVR |= (4 - 1) << 16; // DIVQ1[6:0] = pllq - 1, PLL1 DIVQ division factor - RCC->PLL1DIVR |= 1 << 24; // DIVR1[6:0] = pllr - 1, PLL1 DIVR division factor + RCC->PLL1DIVR |= 1 << 24; // DIVR1[6:0] = pllr - 1, PLL1 DIVR division factor RCC->PLLCFGR |= 2 << 2; // PLL1 input (ref1_ck) clock range frequency is between 4 and 8 MHz RCC->PLLCFGR |= 0 << 1; // PLL1 VCO selection, 0: 192 to 836 MHz, 1 : 150 to 420 MHz RCC->PLLCFGR |= 3 << 16; // pll1_q_ck and pll1_p_ck output is enabled @@ -209,7 +209,7 @@ void SystemClockStartupInit() { // PLL2 DIVR clock frequency = 220MHz, so that SDRAM clock can be set to 110MHz RCC->PLLCKSELR |= 25 << 12; // DIVM2[5:0] = 25, Prescaler for PLL2 - RCC->PLL2DIVR |= (440 - 1) << 0; // DIVN2[8:0] = 440 - 1, Multiplication factor for PLL2 VCO + RCC->PLL2DIVR |= (440 - 1) << 0; // DIVN2[8:0] = 440 - 1, Multiplication factor for PLL2 VCO RCC->PLL2DIVR |= (2 - 1) << 9; // DIVP2[6:0] = 2-1, PLL2 DIVP division factor RCC->PLL2DIVR |= (2 - 1) << 24; // DIVR2[6:0] = 2-1, PLL2 DIVR division factor RCC->PLLCFGR |= 0 << 6; // PLL2RGE[1:0]=0, PLL2 input (ref2_ck) clock range frequency is between 1 and 2 MHz @@ -271,8 +271,8 @@ uint8_t MPU_Set_Protection(uint32_t baseaddr, uint32_t size, uint32_t rnum, uint uint8_t rnr = 0; if ((size % 32) || size == 0) return 1; rnr = MPU_Convert_Bytes_To_POT(size) - 1; - SCB->SHCSR &= ~(1 << 16); //disable MemManage - MPU->CTRL &= ~(1 << 0); //disable MPU + SCB->SHCSR &= ~(1 << 16); //disable MemManage + MPU->CTRL &= ~(1 << 0); //disable MPU MPU->RNR = rnum; MPU->RBAR = baseaddr; tempreg |= 0 << 28; @@ -286,21 +286,21 @@ uint8_t MPU_Set_Protection(uint32_t baseaddr, uint32_t size, uint32_t rnum, uint tempreg |= 1 << 0; MPU->RASR = tempreg; MPU->CTRL = (1 << 2) | (1 << 0); //enable PRIVDEFENA - SCB->SHCSR |= 1 << 16; //enable MemManage + SCB->SHCSR |= 1 << 16; //enable MemManage return 0; } void MPU_Memory_Protection(void) { - MPU_Set_Protection(0x20000000, 128 * 1024, 1, MPU_REGION_FULL_ACCESS, 0, 1, 1); // protect DTCM 128k, Sharing is prohibited, cache is allowed, and buffering is allowed + MPU_Set_Protection(0x20000000, 128 * 1024, 1, MPU_REGION_FULL_ACCESS, 0, 1, 1); // protect DTCM 128k, Sharing is prohibited, cache is allowed, and buffering is allowed - MPU_Set_Protection(0x24000000, 512 * 1024, 2, MPU_REGION_FULL_ACCESS, 0, 1, 1); // protect AXI SRAM, Sharing is prohibited, cache is allowed, and buffering is allowed - MPU_Set_Protection(0x30000000, 512 * 1024, 3, MPU_REGION_FULL_ACCESS, 0, 1, 1); // protect SRAM1~SRAM3, Sharing is prohibited, cache is allowed, and buffering is allowed - MPU_Set_Protection(0x38000000, 64 * 1024, 4, MPU_REGION_FULL_ACCESS, 0, 1, 1); // protect SRAM4, Sharing is prohibited, cache is allowed, and buffering is allowed + MPU_Set_Protection(0x24000000, 512 * 1024, 2, MPU_REGION_FULL_ACCESS, 0, 1, 1); // protect AXI SRAM, Sharing is prohibited, cache is allowed, and buffering is allowed + MPU_Set_Protection(0x30000000, 512 * 1024, 3, MPU_REGION_FULL_ACCESS, 0, 1, 1); // protect SRAM1~SRAM3, Sharing is prohibited, cache is allowed, and buffering is allowed + MPU_Set_Protection(0x38000000, 64 * 1024, 4, MPU_REGION_FULL_ACCESS, 0, 1, 1); // protect SRAM4, Sharing is prohibited, cache is allowed, and buffering is allowed - MPU_Set_Protection(0x60000000, 64 * 1024 * 1024, 5, MPU_REGION_FULL_ACCESS, 0, 0, 0); // protect LCD FMC 64M, No sharing, no cache, no buffering - MPU_Set_Protection(0XC0000000, 32 * 1024 * 1024, 6, MPU_REGION_FULL_ACCESS, 0, 1, 1); // protect SDRAM 32M, Sharing is prohibited, cache is allowed, and buffering is allowed - MPU_Set_Protection(0X80000000, 256 * 1024 * 1024, 7, MPU_REGION_FULL_ACCESS, 0, 0, 0); // protect NAND FLASH 256M, No sharing, no cache, no buffering + MPU_Set_Protection(0x60000000, 64 * 1024 * 1024, 5, MPU_REGION_FULL_ACCESS, 0, 0, 0); // protect LCD FMC 64M, No sharing, no cache, no buffering + MPU_Set_Protection(0XC0000000, 32 * 1024 * 1024, 6, MPU_REGION_FULL_ACCESS, 0, 1, 1); // protect SDRAM 32M, Sharing is prohibited, cache is allowed, and buffering is allowed + MPU_Set_Protection(0X80000000, 256 * 1024 * 1024, 7, MPU_REGION_FULL_ACCESS, 0, 0, 0); // protect NAND FLASH 256M, No sharing, no cache, no buffering } /** diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103Rx/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_F103Rx/PeripheralPins.c index 56ae00b41b59..6fb5453e58aa 100755 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103Rx/PeripheralPins.c +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103Rx/PeripheralPins.c @@ -136,7 +136,7 @@ WEAK const PinMap PinMap_PWM[] = { #endif {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 0)}, // TIM2_CH3 // {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_PARTIAL_1, 3, 0)}, // TIM2_CH3 -#if defined(STM32F103xG) +#ifdef STM32F103xG // {PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 0)}, // TIM5_CH3 #endif #if defined(STM32F103xE) || defined(STM32F103xG) @@ -148,11 +148,11 @@ WEAK const PinMap PinMap_PWM[] = { #else {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 4, 0)}, // TIM2_CH4 #endif -#if defined(STM32F103xG) +#ifdef STM32F103xG // {PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM9_CH2 #endif {PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM3_CH1 -#if defined(STM32F103xG) +#ifdef STM32F103xG // {PA_6, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM13_CH1 #endif // {PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM3_CH2 @@ -161,7 +161,7 @@ WEAK const PinMap PinMap_PWM[] = { #else {PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM1_PARTIAL, 1, 1)}, // TIM1_CH1N #endif -#if defined(STM32F103xG) +#ifdef STM32F103xG // {PA_7, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM14_CH1 #endif {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM1_CH1 @@ -196,10 +196,10 @@ WEAK const PinMap PinMap_PWM[] = { {PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 0)}, // TIM4_CH3 {PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 4, 0)}, // TIM4_CH4 #endif -#if defined(STM32F103xG) +#ifdef STM32F103xG // {PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM10_CH1 #endif -#if defined(STM32F103xG) +#ifdef STM32F103xG // {PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM11_CH1 #endif {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_PARTIAL_2, 3, 0)}, // TIM2_CH3 @@ -208,11 +208,11 @@ WEAK const PinMap PinMap_PWM[] = { // {PB_11, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_ENABLE, 4, 0)}, // TIM2_CH4 {PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 1)}, // TIM1_CH1N {PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 1)}, // TIM1_CH2N -#if defined(STM32F103xG) +#ifdef STM32F103xG // {PB_14, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM12_CH1 #endif {PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 1)}, // TIM1_CH3N -#if defined(STM32F103xG) +#ifdef STM32F103xG // {PB_15, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM12_CH2 #endif {PC_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM3_ENABLE, 1, 0)}, // TIM3_CH1 @@ -249,7 +249,7 @@ WEAK const PinMap PinMap_UART_TX[] = { #if defined(STM32F103xE) || defined(STM32F103xG) {PC_10, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE)}, #endif -#if defined(STM32F103xB) +#ifdef STM32F103xB {PC_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_USART3_PARTIAL)}, #endif #if defined(STM32F103xE) || defined(STM32F103xG) @@ -270,7 +270,7 @@ WEAK const PinMap PinMap_UART_RX[] = { #if defined(STM32F103xE) || defined(STM32F103xG) {PC_11, UART4, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, AFIO_NONE)}, #endif -#if defined(STM32F103xB) +#ifdef STM32F103xB {PC_11, USART3, STM_PIN_DATA(STM_MODE_INPUT, GPIO_PULLUP, AFIO_USART3_PARTIAL)}, #endif #if defined(STM32F103xE) || defined(STM32F103xG) diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/hal_conf_custom.h b/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/hal_conf_custom.h index 3440343ffa1e..b684a090e7ba 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/hal_conf_custom.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/hal_conf_custom.h @@ -171,7 +171,7 @@ extern "C" { * Activated: CRC code is present inside driver * Deactivated: CRC code cleaned from driver */ -#if !defined(USE_SPI_CRC) +#ifndef USE_SPI_CRC #define USE_SPI_CRC 0 #endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/variant.h index e64272745b9d..8e4f248c2e2f 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/variant.h @@ -139,7 +139,7 @@ extern "C" { #define PIN_SERIAL2_TX PA2 // Extra HAL modules -#if defined(STM32F103xE) +#ifdef STM32F103xE //#define HAL_DAC_MODULE_ENABLED (unused or maybe for the eeprom write?) #define HAL_SD_MODULE_ENABLED #define HAL_SRAM_MODULE_ENABLED diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/PeripheralPins.c index 339a55916c14..fd429266a358 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/PeripheralPins.c +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/PeripheralPins.c @@ -143,17 +143,17 @@ WEAK const PinMap PinMap_PWM[] = { #else {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 4, 0)}, // TIM2_CH4 #endif -#if defined(STM32F103xG) +#ifdef STM32F103xG //{PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM9_CH2 #endif {PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM3_CH1 -#if defined(STM32F103xG) +#ifdef STM32F103xG //{PA_6, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM13_CH1 #endif {PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM1_PARTIAL, 1, 1)}, // TIM1_CH1N //{PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM3_CH2 //{PA_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 1)}, // TIM8_CH1N -#if defined(STM32F103xG) +#ifdef STM32F103xG //{PA_7, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM14_CH1 #endif {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM1_CH1 @@ -185,11 +185,11 @@ WEAK const PinMap PinMap_PWM[] = { {PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM4_CH1 {PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM4_CH2 {PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 0)}, // TIM4_CH3 -#if defined(STM32F103xG) +#ifdef STM32F103xG //{PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM10_CH1 #endif {PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 4, 0)}, // TIM4_CH4 -#if defined(STM32F103xG) +#ifdef STM32F103xG //{PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM11_CH1 #endif {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_PARTIAL_2, 3, 0)}, // TIM2_CH3 @@ -198,11 +198,11 @@ WEAK const PinMap PinMap_PWM[] = { //{PB_11, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM2_ENABLE, 4, 0)}, // TIM2_CH4 {PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 1)}, // TIM1_CH1N {PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 1)}, // TIM1_CH2N -#if defined(STM32F103xG) +#ifdef STM32F103xG //{PB_14, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 1, 0)}, // TIM12_CH1 #endif {PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 3, 1)}, // TIM1_CH3N -#if defined(STM32F103xG) +#ifdef STM32F103xG //{PB_15, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_NONE, 2, 0)}, // TIM12_CH2 #endif {PC_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM3_ENABLE, 1, 0)}, // TIM3_CH1 @@ -223,7 +223,7 @@ WEAK const PinMap PinMap_PWM[] = { {PD_13, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM4_ENABLE, 2, 0)}, // TIM4_CH2 {PD_14, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM4_ENABLE, 3, 0)}, // TIM4_CH3 {PD_15, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM4_ENABLE, 4, 0)}, // TIM4_CH4 -#if defined(STM32F103xG) +#ifdef STM32F103xG {PE_5, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM9_ENABLE, 1, 0)}, // TIM9_CH1 {PE_6, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, AFIO_TIM9_ENABLE, 2, 0)}, // TIM9_CH2 #endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/hal_conf_custom.h b/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/hal_conf_custom.h index a41247b9b1f6..2443052621d7 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/hal_conf_custom.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/hal_conf_custom.h @@ -81,15 +81,15 @@ extern "C" { * This value is used by the RCC HAL module to compute the system frequency * (when HSE is used as system clock source, directly or through the PLL). */ -#if !defined (HSE_VALUE) -#if defined(USE_STM3210C_EVAL) +#ifndef HSE_VALUE +#ifdef USE_STM3210C_EVAL #define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */ #else #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ #endif #endif /* HSE_VALUE */ -#if !defined (HSE_STARTUP_TIMEOUT) +#ifndef HSE_STARTUP_TIMEOUT #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ #endif /* HSE_STARTUP_TIMEOUT */ @@ -98,14 +98,14 @@ extern "C" { * This value is used by the RCC HAL module to compute the system frequency * (when HSI is used as system clock source, directly or through the PLL). */ -#if !defined (HSI_VALUE) +#ifndef HSI_VALUE #define HSI_VALUE 8000000U /*!< Value of the Internal oscillator in Hz */ #endif /* HSI_VALUE */ /** * @brief Internal Low Speed oscillator (LSI) value. */ -#if !defined (LSI_VALUE) +#ifndef LSI_VALUE #define LSI_VALUE 40000U /*!< LSI Typical Value in Hz */ #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz The real value may vary depending on the variations @@ -114,11 +114,11 @@ extern "C" { * @brief External Low Speed oscillator (LSE) value. * This value is used by the UART, RTC HAL module to compute the system frequency */ -#if !defined (LSE_VALUE) +#ifndef LSE_VALUE #define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */ #endif /* LSE_VALUE */ -#if !defined (LSE_STARTUP_TIMEOUT) +#ifndef LSE_STARTUP_TIMEOUT #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ #endif /* LSE_STARTUP_TIMEOUT */ @@ -129,7 +129,7 @@ extern "C" { /** * @brief This is the HAL system configuration section */ -#if !defined(VDD_VALUE) +#ifndef VDD_VALUE #define VDD_VALUE 3300U /*!< Value of VDD in mv */ #endif #if !defined (TICK_INT_PRIORITY) diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/hal_conf_extra.h index 952fe3c5b881..d246a1e7454e 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/hal_conf_extra.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/hal_conf_extra.h @@ -91,11 +91,11 @@ * This value is used by the RCC HAL module to compute the system frequency * (when HSE is used as system clock source, directly or through the PLL). */ -#if !defined (HSE_VALUE) +#ifndef HSE_VALUE #define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */ #endif /* HSE_VALUE */ -#if !defined (HSE_STARTUP_TIMEOUT) +#ifndef HSE_STARTUP_TIMEOUT #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ #endif /* HSE_STARTUP_TIMEOUT */ @@ -104,14 +104,14 @@ * This value is used by the RCC HAL module to compute the system frequency * (when HSI is used as system clock source, directly or through the PLL). */ -#if !defined (HSI_VALUE) +#ifndef HSI_VALUE #define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz */ #endif /* HSI_VALUE */ /** * @brief Internal Low Speed oscillator (LSI) value. */ -#if !defined (LSI_VALUE) +#ifndef LSI_VALUE #define LSI_VALUE 32000U /*!< LSI Typical Value in Hz */ #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz The real value may vary depending on the variations @@ -119,11 +119,11 @@ /** * @brief External Low Speed oscillator (LSE) value. */ -#if !defined (LSE_VALUE) +#ifndef LSE_VALUE #define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */ #endif /* LSE_VALUE */ -#if !defined (LSE_STARTUP_TIMEOUT) +#ifndef LSE_STARTUP_TIMEOUT #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ #endif /* LSE_STARTUP_TIMEOUT */ @@ -132,7 +132,7 @@ * This value is used by the I2S HAL module to compute the I2S clock source * frequency, this source is inserted directly through I2S_CKIN pad. */ -#if !defined (EXTERNAL_CLOCK_VALUE) +#ifndef EXTERNAL_CLOCK_VALUE #define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External oscillator in Hz*/ #endif /* EXTERNAL_CLOCK_VALUE */ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/PeripheralPins.c index 0abfc70700d8..eb95de1495f7 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/PeripheralPins.c +++ b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/PeripheralPins.c @@ -15,7 +15,7 @@ * STM32G0C1R(C-E)IxN.xml, STM32G0C1R(C-E)TxN.xml * CubeMX DB release 6.0.30 */ -#if !defined(CUSTOM_PERIPHERAL_PINS) +#ifndef CUSTOM_PERIPHERAL_PINS #include "Arduino.h" #include "PeripheralPins.h" diff --git a/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.cpp b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.cpp index 8af7150dc781..d18509f35f71 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.cpp +++ b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.cpp @@ -11,7 +11,7 @@ ******************************************************************************* */ -#if defined(STM32G0B1xx) +#ifdef STM32G0B1xx #include "pins_arduino.h" // Digital PinName array diff --git a/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/PeripheralPins.c index 49c4cbb87aa9..d5ccda9f9bc8 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/PeripheralPins.c +++ b/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/PeripheralPins.c @@ -17,7 +17,7 @@ * STM32H753VIHx.xml, STM32H753VITx.xml * CubeMX DB release 6.0.30 */ -#if !defined(CUSTOM_PERIPHERAL_PINS) +#ifndef CUSTOM_PERIPHERAL_PINS #include "Arduino.h" #include "PeripheralPins.h" diff --git a/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/variant_MARLIN_STM32H743VX.cpp b/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/variant_MARLIN_STM32H743VX.cpp index 7813f8860e58..814149f6c776 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/variant_MARLIN_STM32H743VX.cpp +++ b/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/variant_MARLIN_STM32H743VX.cpp @@ -10,7 +10,7 @@ * ******************************************************************************* */ -#if defined(STM32H743xx) +#ifdef STM32H743xx #include "pins_arduino.h" // Digital PinName array diff --git a/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/variant_MARLIN_STM32H743VX.h b/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/variant_MARLIN_STM32H743VX.h index 35cf65dee9b9..c4635c4b1f64 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/variant_MARLIN_STM32H743VX.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/variant_MARLIN_STM32H743VX.h @@ -226,16 +226,16 @@ #endif // Extra HAL modules -#if !defined(HAL_DAC_MODULE_DISABLED) +#ifndef HAL_DAC_MODULE_DISABLED #define HAL_DAC_MODULE_ENABLED #endif -#if !defined(HAL_ETH_MODULE_DISABLED) +#ifndef HAL_ETH_MODULE_DISABLED #define HAL_ETH_MODULE_ENABLED #endif -#if !defined(HAL_QSPI_MODULE_DISABLED) +#ifndef HAL_QSPI_MODULE_DISABLED #define HAL_QSPI_MODULE_ENABLED #endif -#if !defined(HAL_SD_MODULE_DISABLED) +#ifndef HAL_SD_MODULE_DISABLED #define HAL_SD_MODULE_ENABLED #endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/hal_conf_extra.h index 2ad290502338..a5961a488bf7 100755 --- a/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/hal_conf_extra.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/hal_conf_extra.h @@ -91,11 +91,11 @@ * This value is used by the RCC HAL module to compute the system frequency * (when HSE is used as system clock source, directly or through the PLL). */ -#if !defined (HSE_VALUE) +#ifndef HSE_VALUE #define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */ #endif /* HSE_VALUE */ -#if !defined (HSE_STARTUP_TIMEOUT) +#ifndef HSE_STARTUP_TIMEOUT #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ #endif /* HSE_STARTUP_TIMEOUT */ @@ -104,14 +104,14 @@ * This value is used by the RCC HAL module to compute the system frequency * (when HSI is used as system clock source, directly or through the PLL). */ -#if !defined (HSI_VALUE) +#ifndef HSI_VALUE #define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz */ #endif /* HSI_VALUE */ /** * @brief Internal Low Speed oscillator (LSI) value. */ -#if !defined (LSI_VALUE) +#ifndef LSI_VALUE #define LSI_VALUE 32000U /*!< LSI Typical Value in Hz */ #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz The real value may vary depending on the variations @@ -119,11 +119,11 @@ /** * @brief External Low Speed oscillator (LSE) value. */ -#if !defined (LSE_VALUE) +#ifndef LSE_VALUE #define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */ #endif /* LSE_VALUE */ -#if !defined (LSE_STARTUP_TIMEOUT) +#ifndef LSE_STARTUP_TIMEOUT #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ #endif /* LSE_STARTUP_TIMEOUT */ @@ -132,7 +132,7 @@ * This value is used by the I2S HAL module to compute the I2S clock source * frequency, this source is inserted directly through I2S_CKIN pad. */ -#if !defined (EXTERNAL_CLOCK_VALUE) +#ifndef EXTERNAL_CLOCK_VALUE #define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External oscillator in Hz*/ #endif /* EXTERNAL_CLOCK_VALUE */ diff --git a/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/board.cpp b/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/board.cpp index 6083664b9408..8a4320a66458 100644 --- a/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/board.cpp +++ b/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/board.cpp @@ -131,74 +131,74 @@ extern const stm32_pin_info PIN_MAP[BOARD_NR_GPIO_PINS] = { {&gpioc, NULL, NULL, 14, 0, ADCx}, /* PC14 OSC32_IN */ {&gpioc, NULL, NULL, 15, 0, ADCx}, /* PC15 OSC32_OUT */ - {&gpiod, NULL, NULL, 0, 0, ADCx} , /* PD0 OSC_IN */ - {&gpiod, NULL, NULL, 1, 0, ADCx} , /* PD1 OSC_OUT */ - {&gpiod, NULL, NULL, 2, 0, ADCx} , /* PD2 TIM3_ETR/UART5_RX SDIO_CMD */ - - {&gpiod, NULL, NULL, 3, 0, ADCx} , /* PD3 FSMC_CLK */ - {&gpiod, NULL, NULL, 4, 0, ADCx} , /* PD4 FSMC_NOE */ - {&gpiod, NULL, NULL, 5, 0, ADCx} , /* PD5 FSMC_NWE */ - {&gpiod, NULL, NULL, 6, 0, ADCx} , /* PD6 FSMC_NWAIT */ - {&gpiod, NULL, NULL, 7, 0, ADCx} , /* PD7 FSMC_NE1/FSMC_NCE2 */ - {&gpiod, NULL, NULL, 8, 0, ADCx} , /* PD8 FSMC_D13 */ - {&gpiod, NULL, NULL, 9, 0, ADCx} , /* PD9 FSMC_D14 */ - {&gpiod, NULL, NULL, 10, 0, ADCx} , /* PD10 FSMC_D15 */ - {&gpiod, NULL, NULL, 11, 0, ADCx} , /* PD11 FSMC_A16 */ - {&gpiod, NULL, NULL, 12, 0, ADCx} , /* PD12 FSMC_A17 */ - {&gpiod, NULL, NULL, 13, 0, ADCx} , /* PD13 FSMC_A18 */ - {&gpiod, NULL, NULL, 14, 0, ADCx} , /* PD14 FSMC_D0 */ - {&gpiod, NULL, NULL, 15, 0, ADCx} , /* PD15 FSMC_D1 */ - - {&gpioe, NULL, NULL, 0, 0, ADCx} , /* PE0 */ - {&gpioe, NULL, NULL, 1, 0, ADCx} , /* PE1 */ - {&gpioe, NULL, NULL, 2, 0, ADCx} , /* PE2 */ - {&gpioe, NULL, NULL, 3, 0, ADCx} , /* PE3 */ - {&gpioe, NULL, NULL, 4, 0, ADCx} , /* PE4 */ - {&gpioe, NULL, NULL, 5, 0, ADCx} , /* PE5 */ - {&gpioe, NULL, NULL, 6, 0, ADCx} , /* PE6 */ - {&gpioe, NULL, NULL, 7, 0, ADCx} , /* PE7 */ - {&gpioe, NULL, NULL, 8, 0, ADCx} , /* PE8 */ - {&gpioe, NULL, NULL, 9, 0, ADCx} , /* PE9 */ - {&gpioe, NULL, NULL, 10, 0, ADCx} , /* PE10 */ - {&gpioe, NULL, NULL, 11, 0, ADCx} , /* PE11 */ - {&gpioe, NULL, NULL, 12, 0, ADCx} , /* PE12 */ - {&gpioe, NULL, NULL, 13, 0, ADCx} , /* PE13 */ - {&gpioe, NULL, NULL, 14, 0, ADCx} , /* PE14 */ - {&gpioe, NULL, NULL, 15, 0, ADCx} , /* PE15 */ - - {&gpiof, NULL, NULL, 0, 0, ADCx} , /* PF0 */ - {&gpiof, NULL, NULL, 1, 0, ADCx} , /* PF1 */ - {&gpiof, NULL, NULL, 2, 0, ADCx} , /* PF2 */ - {&gpiof, NULL, NULL, 3, 0, ADCx} , /* PF3 */ - {&gpiof, NULL, NULL, 4, 0, ADCx} , /* PF4 */ - {&gpiof, NULL, NULL, 5, 0, ADCx} , /* PF5 */ - {&gpiof, NULL, NULL, 6, 0, ADCx} , /* PF6 */ - {&gpiof, NULL, NULL, 7, 0, ADCx} , /* PF7 */ - {&gpiof, NULL, NULL, 8, 0, ADCx} , /* PF8 */ - {&gpiof, NULL, NULL, 9, 0, ADCx} , /* PF9 */ - {&gpiof, NULL, NULL, 10, 0, ADCx} , /* PF10 */ - {&gpiof, NULL, NULL, 11, 0, ADCx} , /* PF11 */ - {&gpiof, NULL, NULL, 12, 0, ADCx} , /* PF12 */ - {&gpiof, NULL, NULL, 13, 0, ADCx} , /* PF13 */ - {&gpiof, NULL, NULL, 14, 0, ADCx} , /* PF14 */ - {&gpiof, NULL, NULL, 15, 0, ADCx} , /* PF15 */ - - {&gpiog, NULL, NULL, 0, 0, ADCx} , /* PG0 */ - {&gpiog, NULL, NULL, 1, 0, ADCx} , /* PG1 */ - {&gpiog, NULL, NULL, 2, 0, ADCx} , /* PG2 */ - {&gpiog, NULL, NULL, 3, 0, ADCx} , /* PG3 */ - {&gpiog, NULL, NULL, 4, 0, ADCx} , /* PG4 */ - {&gpiog, NULL, NULL, 5, 0, ADCx} , /* PG5 */ - {&gpiog, NULL, NULL, 6, 0, ADCx} , /* PG6 */ - {&gpiog, NULL, NULL, 7, 0, ADCx} , /* PG7 */ - {&gpiog, NULL, NULL, 8, 0, ADCx} , /* PG8 */ - {&gpiog, NULL, NULL, 9, 0, ADCx} , /* PG9 */ - {&gpiog, NULL, NULL, 10, 0, ADCx} , /* PG10 */ - {&gpiog, NULL, NULL, 11, 0, ADCx} , /* PG11 */ - {&gpiog, NULL, NULL, 12, 0, ADCx} , /* PG12 */ - {&gpiog, NULL, NULL, 13, 0, ADCx} , /* PG13 */ - {&gpiog, NULL, NULL, 14, 0, ADCx} , /* PG14 */ - {&gpiog, NULL, NULL, 15, 0, ADCx} /* PG15 */ + {&gpiod, NULL, NULL, 0, 0, ADCx} , /* PD0 OSC_IN */ + {&gpiod, NULL, NULL, 1, 0, ADCx} , /* PD1 OSC_OUT */ + {&gpiod, NULL, NULL, 2, 0, ADCx} , /* PD2 TIM3_ETR/UART5_RX SDIO_CMD */ + + {&gpiod, NULL, NULL, 3, 0, ADCx} , /* PD3 FSMC_CLK */ + {&gpiod, NULL, NULL, 4, 0, ADCx} , /* PD4 FSMC_NOE */ + {&gpiod, NULL, NULL, 5, 0, ADCx} , /* PD5 FSMC_NWE */ + {&gpiod, NULL, NULL, 6, 0, ADCx} , /* PD6 FSMC_NWAIT */ + {&gpiod, NULL, NULL, 7, 0, ADCx} , /* PD7 FSMC_NE1/FSMC_NCE2 */ + {&gpiod, NULL, NULL, 8, 0, ADCx} , /* PD8 FSMC_D13 */ + {&gpiod, NULL, NULL, 9, 0, ADCx} , /* PD9 FSMC_D14 */ + {&gpiod, NULL, NULL, 10, 0, ADCx} , /* PD10 FSMC_D15 */ + {&gpiod, NULL, NULL, 11, 0, ADCx} , /* PD11 FSMC_A16 */ + {&gpiod, NULL, NULL, 12, 0, ADCx} , /* PD12 FSMC_A17 */ + {&gpiod, NULL, NULL, 13, 0, ADCx} , /* PD13 FSMC_A18 */ + {&gpiod, NULL, NULL, 14, 0, ADCx} , /* PD14 FSMC_D0 */ + {&gpiod, NULL, NULL, 15, 0, ADCx} , /* PD15 FSMC_D1 */ + + {&gpioe, NULL, NULL, 0, 0, ADCx} , /* PE0 */ + {&gpioe, NULL, NULL, 1, 0, ADCx} , /* PE1 */ + {&gpioe, NULL, NULL, 2, 0, ADCx} , /* PE2 */ + {&gpioe, NULL, NULL, 3, 0, ADCx} , /* PE3 */ + {&gpioe, NULL, NULL, 4, 0, ADCx} , /* PE4 */ + {&gpioe, NULL, NULL, 5, 0, ADCx} , /* PE5 */ + {&gpioe, NULL, NULL, 6, 0, ADCx} , /* PE6 */ + {&gpioe, NULL, NULL, 7, 0, ADCx} , /* PE7 */ + {&gpioe, NULL, NULL, 8, 0, ADCx} , /* PE8 */ + {&gpioe, NULL, NULL, 9, 0, ADCx} , /* PE9 */ + {&gpioe, NULL, NULL, 10, 0, ADCx} , /* PE10 */ + {&gpioe, NULL, NULL, 11, 0, ADCx} , /* PE11 */ + {&gpioe, NULL, NULL, 12, 0, ADCx} , /* PE12 */ + {&gpioe, NULL, NULL, 13, 0, ADCx} , /* PE13 */ + {&gpioe, NULL, NULL, 14, 0, ADCx} , /* PE14 */ + {&gpioe, NULL, NULL, 15, 0, ADCx} , /* PE15 */ + + {&gpiof, NULL, NULL, 0, 0, ADCx} , /* PF0 */ + {&gpiof, NULL, NULL, 1, 0, ADCx} , /* PF1 */ + {&gpiof, NULL, NULL, 2, 0, ADCx} , /* PF2 */ + {&gpiof, NULL, NULL, 3, 0, ADCx} , /* PF3 */ + {&gpiof, NULL, NULL, 4, 0, ADCx} , /* PF4 */ + {&gpiof, NULL, NULL, 5, 0, ADCx} , /* PF5 */ + {&gpiof, NULL, NULL, 6, 0, ADCx} , /* PF6 */ + {&gpiof, NULL, NULL, 7, 0, ADCx} , /* PF7 */ + {&gpiof, NULL, NULL, 8, 0, ADCx} , /* PF8 */ + {&gpiof, NULL, NULL, 9, 0, ADCx} , /* PF9 */ + {&gpiof, NULL, NULL, 10, 0, ADCx} , /* PF10 */ + {&gpiof, NULL, NULL, 11, 0, ADCx} , /* PF11 */ + {&gpiof, NULL, NULL, 12, 0, ADCx} , /* PF12 */ + {&gpiof, NULL, NULL, 13, 0, ADCx} , /* PF13 */ + {&gpiof, NULL, NULL, 14, 0, ADCx} , /* PF14 */ + {&gpiof, NULL, NULL, 15, 0, ADCx} , /* PF15 */ + + {&gpiog, NULL, NULL, 0, 0, ADCx} , /* PG0 */ + {&gpiog, NULL, NULL, 1, 0, ADCx} , /* PG1 */ + {&gpiog, NULL, NULL, 2, 0, ADCx} , /* PG2 */ + {&gpiog, NULL, NULL, 3, 0, ADCx} , /* PG3 */ + {&gpiog, NULL, NULL, 4, 0, ADCx} , /* PG4 */ + {&gpiog, NULL, NULL, 5, 0, ADCx} , /* PG5 */ + {&gpiog, NULL, NULL, 6, 0, ADCx} , /* PG6 */ + {&gpiog, NULL, NULL, 7, 0, ADCx} , /* PG7 */ + {&gpiog, NULL, NULL, 8, 0, ADCx} , /* PG8 */ + {&gpiog, NULL, NULL, 9, 0, ADCx} , /* PG9 */ + {&gpiog, NULL, NULL, 10, 0, ADCx} , /* PG10 */ + {&gpiog, NULL, NULL, 11, 0, ADCx} , /* PG11 */ + {&gpiog, NULL, NULL, 12, 0, ADCx} , /* PG12 */ + {&gpiog, NULL, NULL, 13, 0, ADCx} , /* PG13 */ + {&gpiog, NULL, NULL, 14, 0, ADCx} , /* PG14 */ + {&gpiog, NULL, NULL, 15, 0, ADCx} /* PG15 */ }; /* Basically everything that is defined as having a timer us PWM */ @@ -219,15 +219,15 @@ extern const uint8 boardUsedPins[BOARD_NR_USED_PINS] __FLASH__ = { #ifdef SERIAL_USB - DEFINE_HWSERIAL(Serial1, 1); - DEFINE_HWSERIAL(Serial2, 2); - DEFINE_HWSERIAL(Serial3, 3); - DEFINE_HWSERIAL_UART(Serial4, 4); - DEFINE_HWSERIAL_UART(Serial5, 5); + DEFINE_HWSERIAL(Serial1, 1); + DEFINE_HWSERIAL(Serial2, 2); + DEFINE_HWSERIAL(Serial3, 3); + DEFINE_HWSERIAL_UART(Serial4, 4); + DEFINE_HWSERIAL_UART(Serial5, 5); #else - DEFINE_HWSERIAL(Serial, 1); - DEFINE_HWSERIAL(Serial1, 2); - DEFINE_HWSERIAL(Serial2, 3); - DEFINE_HWSERIAL_UART(Serial3, 4); - DEFINE_HWSERIAL_UART(Serial4, 5); + DEFINE_HWSERIAL(Serial, 1); + DEFINE_HWSERIAL(Serial1, 2); + DEFINE_HWSERIAL(Serial2, 3); + DEFINE_HWSERIAL_UART(Serial3, 4); + DEFINE_HWSERIAL_UART(Serial4, 5); #endif diff --git a/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/wirish/boards.cpp b/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/wirish/boards.cpp index f22cf354e208..657b92e2243f 100644 --- a/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/wirish/boards.cpp +++ b/buildroot/share/PlatformIO/variants/marlin_maple_CHITU_F103/wirish/boards.cpp @@ -144,10 +144,10 @@ static void setup_clocks(void) { * present. If no bootloader is present, the user NVIC usually starts * at the Flash base address, 0x08000000. */ -#if defined(BOOTLOADER_maple) - #define USER_ADDR_ROM 0x08005000 +#ifdef BOOTLOADER_maple + #define USER_ADDR_ROM 0x08005000 #else - #define USER_ADDR_ROM 0x08000000 + #define USER_ADDR_ROM 0x08000000 #endif #define USER_ADDR_RAM 0x20000C00 extern char __text_start__; diff --git a/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/wirish/boards.cpp b/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/wirish/boards.cpp index 77dcbcf848d3..1494cec56381 100644 --- a/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/wirish/boards.cpp +++ b/buildroot/share/PlatformIO/variants/marlin_maple_MEEB_3DP/wirish/boards.cpp @@ -144,7 +144,7 @@ static void setup_clocks(void) { * present. If no bootloader is present, the user NVIC usually starts * at the Flash base address, 0x08000000. */ -#if defined(BOOTLOADER_maple) +#ifdef BOOTLOADER_maple #define USER_ADDR_ROM 0x08002000 #else #define USER_ADDR_ROM 0x08000000 From 37a7da075f415b361daa25b95e37b1acf88ea0c0 Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Mon, 22 Aug 2022 07:53:51 -0700 Subject: [PATCH 016/243] =?UTF-8?q?=F0=9F=94=A7=20Fix=20Skew=20Correction?= =?UTF-8?q?=20defaults=20(#24601)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index b30ba9b8d3fa..9d82b3cc40a2 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -2134,9 +2134,8 @@ #define XY_DIAG_BD 282.8427124746 #define XY_SIDE_AD 200 - // Or, set the default skew factors directly here - // to override the above measurements: - #define XY_SKEW_FACTOR 0.0 + // Or, set the XY skew factor directly: + //#define XY_SKEW_FACTOR 0.0 //#define SKEW_CORRECTION_FOR_Z #if ENABLED(SKEW_CORRECTION_FOR_Z) @@ -2145,8 +2144,10 @@ #define YZ_DIAG_AC 282.8427124746 #define YZ_DIAG_BD 282.8427124746 #define YZ_SIDE_AD 200 - #define XZ_SKEW_FACTOR 0.0 - #define YZ_SKEW_FACTOR 0.0 + + // Or, set the Z skew factors directly: + //#define XZ_SKEW_FACTOR 0.0 + //#define YZ_SKEW_FACTOR 0.0 #endif // Enable this option for M852 to set skew at runtime From d94a41527f8c00241d31eb82c0d0b0ef380269c0 Mon Sep 17 00:00:00 2001 From: Alexey Galakhov Date: Mon, 22 Aug 2022 17:11:53 +0200 Subject: [PATCH 017/243] =?UTF-8?q?=F0=9F=90=9B=20Fix=20JyersUI=20(#24652)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/e3v2/common/dwin_api.cpp | 10 +- Marlin/src/lcd/e3v2/jyersui/dwin.cpp | 150 ++++++++++++------------ 2 files changed, 79 insertions(+), 81 deletions(-) diff --git a/Marlin/src/lcd/e3v2/common/dwin_api.cpp b/Marlin/src/lcd/e3v2/common/dwin_api.cpp index 3f699465a9c8..79998219a95e 100644 --- a/Marlin/src/lcd/e3v2/common/dwin_api.cpp +++ b/Marlin/src/lcd/e3v2/common/dwin_api.cpp @@ -234,7 +234,7 @@ void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis, // *string: The string // rlimit: To limit the drawn string length void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const char * const string, uint16_t rlimit/*=0xFFFF*/) { - #if DISABLED(DWIN_LCD_PROUI) + #if NONE(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) DWIN_Draw_Rectangle(1, bColor, x, y, x + (fontWidth(size) * strlen_P(string)), y + fontHeight(size)); #endif constexpr uint8_t widthAdjust = 0; @@ -266,7 +266,9 @@ void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint32_t value) { size_t i = 0; - DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * iNum + 1, y + fontHeight(size)); + #if DISABLED(DWIN_CREALITY_LCD_JYERSUI) + DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * iNum + 1, y + fontHeight(size)); + #endif DWIN_Byte(i, 0x14); // Bit 7: bshow // Bit 6: 1 = signed; 0 = unsigned number; @@ -314,7 +316,9 @@ void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_ uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, int32_t value) { //uint8_t *fvalue = (uint8_t*)&value; size_t i = 0; - DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * (iNum+fNum+1), y + fontHeight(size)); + #if DISABLED(DWIN_CREALITY_LCD_JYERSUI) + DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * (iNum+fNum+1), y + fontHeight(size)); + #endif DWIN_Byte(i, 0x14); DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size); DWIN_Word(i, color); diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index 285013d7504e..b29ad9e63abe 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -204,6 +204,55 @@ bool probe_deployed = false; CrealityDWINClass CrealityDWIN; +template +class TextScroller { +public: + static const unsigned SIZE = N; + static const unsigned SPACE = S; + typedef char Buffer[SIZE + 1]; + + inline TextScroller() + : scrollpos(0) + { } + + inline void reset() { + scrollpos = 0; + } + + const char* scroll(size_t& pos, Buffer &buf, const char * text, bool *updated = nullptr) { + const size_t len = strlen(text); + if (len > SIZE) { + if (updated) *updated = true; + if (scrollpos >= len + SPACE) scrollpos = 0; + pos = 0; + if (scrollpos < len) { + const size_t n = min(len - scrollpos, SIZE); + memcpy(buf, text + scrollpos, n); + pos += n; + } + if (pos < SIZE) { + const size_t n = min(len + SPACE - scrollpos, SIZE - pos); + memset(buf + pos, ' ', n); + pos += n; + } + if (pos < SIZE) { + const size_t n = SIZE - pos; + memcpy(buf + pos, text, n); + pos += n; + } + buf[pos] = '\0'; + ++scrollpos; + return buf; + } else { + pos = len; + return text; + } + } + +private: + uint16_t scrollpos; +}; + #if HAS_MESH struct Mesh_Settings { @@ -689,31 +738,13 @@ void CrealityDWINClass::Draw_Print_Screen() { } void CrealityDWINClass::Draw_Print_Filename(const bool reset/*=false*/) { - static uint8_t namescrl = 0; - if (reset) namescrl = 0; + typedef TextScroller<30> Scroller; + static Scroller scroller; + if (reset) scroller.reset(); if (process == Print) { - constexpr int8_t maxlen = 30; - char *outstr = filename; - size_t slen = strlen(filename); - int8_t outlen = slen; - if (slen > maxlen) { - char dispname[maxlen + 1]; - int8_t pos = slen - namescrl, len = maxlen; - if (pos >= 0) { - NOMORE(len, pos); - LOOP_L_N(i, len) dispname[i] = filename[i + namescrl]; - } - else { - const int8_t mp = maxlen + pos; - LOOP_L_N(i, mp) dispname[i] = ' '; - LOOP_S_L_N(i, mp, maxlen) dispname[i] = filename[i - mp]; - if (mp <= 0) namescrl = 0; - } - dispname[len] = '\0'; - outstr = dispname; - outlen = maxlen; - namescrl++; - } + Scroller::Buffer buf; + size_t outlen = 0; + const char* outstr = scroller.scroll(outlen, buf, filename); DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 50, DWIN_WIDTH - 8, 80); const int8_t npos = (DWIN_WIDTH - outlen * MENU_CHR_W) / 2; DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, npos, 60, outstr); @@ -973,57 +1004,30 @@ void CrealityDWINClass::Popup_Select() { } void CrealityDWINClass::Update_Status_Bar(bool refresh/*=false*/) { + typedef TextScroller<30> Scroller; static bool new_msg; - static uint8_t msgscrl = 0; + static Scroller scroller; static char lastmsg[64]; if (strcmp(lastmsg, statusmsg) != 0 || refresh) { strcpy(lastmsg, statusmsg); - msgscrl = 0; + scroller.reset(); new_msg = true; } - size_t len = strlen(statusmsg); - int8_t pos = len; - if (pos > 30) { - pos -= msgscrl; - len = pos; - if (len > 30) - len = 30; - char dispmsg[len + 1]; - if (pos >= 0) { - LOOP_L_N(i, len) dispmsg[i] = statusmsg[i + msgscrl]; - } - else { - LOOP_L_N(i, 30 + pos) dispmsg[i] = ' '; - LOOP_S_L_N(i, 30 + pos, 30) dispmsg[i] = statusmsg[i - (30 + pos)]; - } - dispmsg[len] = '\0'; + Scroller::Buffer buf; + size_t len = 0; + const char* dispmsg = scroller.scroll(len, buf, statusmsg, &new_msg); + if (new_msg) { + new_msg = false; if (process == Print) { DWIN_Draw_Rectangle(1, Color_Grey, 8, 214, DWIN_WIDTH - 8, 238); - const int8_t npos = (DWIN_WIDTH - 30 * MENU_CHR_W) / 2; + const int8_t npos = (DWIN_WIDTH - len * MENU_CHR_W) / 2; DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 219, dispmsg); } else { DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 352, DWIN_WIDTH - 8, 376); - const int8_t npos = (DWIN_WIDTH - 30 * MENU_CHR_W) / 2; + const int8_t npos = (DWIN_WIDTH - len * MENU_CHR_W) / 2; DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 357, dispmsg); } - if (-pos >= 30) msgscrl = 0; - msgscrl++; - } - else { - if (new_msg) { - new_msg = false; - if (process == Print) { - DWIN_Draw_Rectangle(1, Color_Grey, 8, 214, DWIN_WIDTH - 8, 238); - const int8_t npos = (DWIN_WIDTH - strlen(statusmsg) * MENU_CHR_W) / 2; - DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 219, statusmsg); - } - else { - DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 352, DWIN_WIDTH - 8, 376); - const int8_t npos = (DWIN_WIDTH - strlen(statusmsg) * MENU_CHR_W) / 2; - DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 357, statusmsg); - } - } } } @@ -4168,35 +4172,25 @@ void CrealityDWINClass::Option_Control() { } void CrealityDWINClass::File_Control() { + typedef TextScroller Scroller; + static Scroller scroller; EncoderState encoder_diffState = Encoder_ReceiveAnalyze(); - static uint8_t filescrl = 0; if (encoder_diffState == ENCODER_DIFF_NO) { if (selection > 0) { card.getfilename_sorted(SD_ORDER(selection - 1, card.get_num_Files())); char * const filename = card.longest_filename(); size_t len = strlen(filename); - int8_t pos = len; + size_t pos = len; if (!card.flag.filenameIsDir) while (pos && filename[pos] != '.') pos--; if (pos > MENU_CHAR_LIMIT) { static millis_t time = 0; if (PENDING(millis(), time)) return; time = millis() + 200; - pos -= filescrl; - len = _MIN(pos, MENU_CHAR_LIMIT); - char name[len + 1]; - if (pos >= 0) { - LOOP_L_N(i, len) name[i] = filename[i + filescrl]; - } - else { - LOOP_L_N(i, MENU_CHAR_LIMIT + pos) name[i] = ' '; - LOOP_S_L_N(i, MENU_CHAR_LIMIT + pos, MENU_CHAR_LIMIT) name[i] = filename[i - (MENU_CHAR_LIMIT + pos)]; - } - name[len] = '\0'; + Scroller::Buffer buf; + const char* const name = scroller.scroll(pos, buf, filename); DWIN_Draw_Rectangle(1, Color_Bg_Black, LBLX, MBASE(selection - scrollpos) - 14, 271, MBASE(selection - scrollpos) + 28); Draw_Menu_Item(selection - scrollpos, card.flag.filenameIsDir ? ICON_More : ICON_File, name); - if (-pos >= MENU_CHAR_LIMIT) filescrl = 0; - filescrl++; DWIN_UpdateLCD(); } } @@ -4208,7 +4202,7 @@ void CrealityDWINClass::File_Control() { DWIN_Draw_Rectangle(1, Color_Bg_Black, LBLX, MBASE(selection - scrollpos) - 14, 271, MBASE(selection - scrollpos) + 28); Draw_SD_Item(selection, selection - scrollpos); } - filescrl = 0; + scroller.reset(); selection++; // Select Down if (selection > scrollpos + MROWS) { scrollpos++; @@ -4221,7 +4215,7 @@ void CrealityDWINClass::File_Control() { DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33); DWIN_Draw_Rectangle(1, Color_Bg_Black, LBLX, MBASE(selection - scrollpos) - 14, 271, MBASE(selection - scrollpos) + 28); Draw_SD_Item(selection, selection - scrollpos); - filescrl = 0; + scroller.reset(); selection--; // Select Up if (selection < scrollpos) { scrollpos--; From a31e65e30b0d71da113db8540a8c49aa3f07034c Mon Sep 17 00:00:00 2001 From: EvilGremlin <22657714+EvilGremlin@users.noreply.github.com> Date: Mon, 22 Aug 2022 18:31:02 +0300 Subject: [PATCH 018/243] =?UTF-8?q?=E2=9C=A8=20Robin=20Nano=20v1=20CDC=20(?= =?UTF-8?q?USB=20mod)=20(#24619)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/pins/pins.h | 6 +- .../src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h | 4 +- .../pins/stm32f1/pins_MKS_ROBIN_NANO_common.h | 13 ++++- .../PlatformIO/scripts/offset_and_rename.py | 7 ++- buildroot/tests/mks_robin_nano_v1_2_usbmod | 19 ++++++ buildroot/tests/mks_robin_nano_v1_3_f4_usbmod | 19 ++++++ .../{mks_robin_nano35 => mks_robin_nano_v1v2} | 0 ...nano35_maple => mks_robin_nano_v1v2_maple} | 0 ini/renamed.ini | 8 +++ ini/stm32f1-maple.ini | 6 +- ini/stm32f1.ini | 24 ++++++-- ini/stm32f4.ini | 58 +++++++++++-------- 12 files changed, 123 insertions(+), 41 deletions(-) create mode 100755 buildroot/tests/mks_robin_nano_v1_2_usbmod create mode 100755 buildroot/tests/mks_robin_nano_v1_3_f4_usbmod rename buildroot/tests/{mks_robin_nano35 => mks_robin_nano_v1v2} (100%) rename buildroot/tests/{mks_robin_nano35_maple => mks_robin_nano_v1v2_maple} (100%) diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 37e222d004ff..1bd58487e75a 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -512,9 +512,9 @@ #elif MB(MKS_ROBIN_MINI) #include "stm32f1/pins_MKS_ROBIN_MINI.h" // STM32F1 env:mks_robin_mini env:mks_robin_mini_maple #elif MB(MKS_ROBIN_NANO) - #include "stm32f1/pins_MKS_ROBIN_NANO.h" // STM32F1 env:mks_robin_nano35 env:mks_robin_nano35_maple + #include "stm32f1/pins_MKS_ROBIN_NANO.h" // STM32F1 env:mks_robin_nano_v1v2 env:mks_robin_nano_v1v2_maple env:mks_robin_nano_v1_2_usbmod #elif MB(MKS_ROBIN_NANO_V2) - #include "stm32f1/pins_MKS_ROBIN_NANO_V2.h" // STM32F1 env:mks_robin_nano35 env:mks_robin_nano35_maple + #include "stm32f1/pins_MKS_ROBIN_NANO_V2.h" // STM32F1 env:mks_robin_nano_v1v2 env:mks_robin_nano3_v1v2_maple #elif MB(MKS_ROBIN_LITE) #include "stm32f1/pins_MKS_ROBIN_LITE.h" // STM32F1 env:mks_robin_lite env:mks_robin_lite_maple #elif MB(MKS_ROBIN_LITE3) @@ -694,7 +694,7 @@ #elif MB(OPULO_LUMEN_REV3) #include "stm32f4/pins_OPULO_LUMEN_REV3.h" // STM32F4 env:Opulo_Lumen_REV3 #elif MB(MKS_ROBIN_NANO_V1_3_F4) - #include "stm32f4/pins_MKS_ROBIN_NANO_V1_3_F4.h" // STM32F4 env:mks_robin_nano_v1_3_f4 + #include "stm32f4/pins_MKS_ROBIN_NANO_V1_3_F4.h" // STM32F4 env:mks_robin_nano_v1_3_f4 env:mks_robin_nano_v1_3_f4_usbmod #elif MB(MKS_EAGLE) #include "stm32f4/pins_MKS_EAGLE.h" // STM32F4 env:mks_eagle #elif MB(ARTILLERY_RUBY) diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h index 9ce5d270b556..9c6373bef987 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h @@ -35,7 +35,9 @@ #define BOARD_INFO_NAME "MKS Robin nano V2.0" -#define BOARD_NO_NATIVE_USB +#ifndef USB_MOD + #define BOARD_NO_NATIVE_USB +#endif #define USES_DIAG_PINS // Avoid conflict with TIMER_SERVO when using the STM32 HAL diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h index 0eb7bbdffeb4..6f1a790580ad 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h @@ -29,7 +29,9 @@ #error "MKS Robin nano boards support up to 2 hotends / E steppers." #endif -#define BOARD_NO_NATIVE_USB +#ifndef USB_MOD + #define BOARD_NO_NATIVE_USB +#endif // Avoid conflict with TIMER_SERVO when using the STM32 HAL #define TEMP_TIMER 5 @@ -58,9 +60,14 @@ // Limit Switches // #define X_STOP_PIN PA15 -#define Y_STOP_PIN PA12 -#define Z_MIN_PIN PA11 #define Z_MAX_PIN PC4 +#ifndef USB_MOD + #define Y_STOP_PIN PA12 + #define Z_MIN_PIN PA11 +#else + #define Y_STOP_PIN PB10 + #define Z_MIN_PIN PB11 +#endif // // Steppers diff --git a/buildroot/share/PlatformIO/scripts/offset_and_rename.py b/buildroot/share/PlatformIO/scripts/offset_and_rename.py index 98b345d698df..6a095210ece3 100644 --- a/buildroot/share/PlatformIO/scripts/offset_and_rename.py +++ b/buildroot/share/PlatformIO/scripts/offset_and_rename.py @@ -53,8 +53,13 @@ def encrypt(source, target, env): # if 'rename' in board_keys: + # If FIRMWARE_BIN is defined by config, override all + mf = env["MARLIN_FEATURES"] + if "FIRMWARE_BIN" in mf: new_name = mf["FIRMWARE_BIN"] + else: new_name = board.get("build.rename") + def rename_target(source, target, env): from pathlib import Path - Path(target[0].path).replace(Path(target[0].dir.path, board.get("build.rename"))) + Path(target[0].path).replace(Path(target[0].dir.path, new_name)) marlin.add_post_action(rename_target) diff --git a/buildroot/tests/mks_robin_nano_v1_2_usbmod b/buildroot/tests/mks_robin_nano_v1_2_usbmod new file mode 100755 index 000000000000..a3ec1d4075d9 --- /dev/null +++ b/buildroot/tests/mks_robin_nano_v1_2_usbmod @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# +# Build tests for MKS Robin nano +# (STM32F1 genericSTM32F103VE) +# + +# exit on first failure +set -e + +# +# MKS/ZNP Robin nano v1.2 Emulated DOGM FSMC and native USB mod +# +use_example_configs Mks/Robin +opt_add USB_MOD +opt_set MOTHERBOARD BOARD_MKS_ROBIN_NANO SERIAL_PORT -1 +exec_test $1 $2 "MKS/ZNP Robin nano v1.2 Emulated DOGM FSMC and native USB mod" "$3" + +# cleanup +restore_configs diff --git a/buildroot/tests/mks_robin_nano_v1_3_f4_usbmod b/buildroot/tests/mks_robin_nano_v1_3_f4_usbmod new file mode 100755 index 000000000000..5213eb84f796 --- /dev/null +++ b/buildroot/tests/mks_robin_nano_v1_3_f4_usbmod @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +# +# Build tests for MKS Robin nano +# (STM32F4 genericSTM32F407VE) +# + +# exit on first failure +set -e + +# +# MKS/ZNP Robin nano v1.3 Emulated DOGM FSMC and native USB mod +# +use_example_configs Mks/Robin +opt_add USB_MOD +opt_set MOTHERBOARD BOARD_MKS_ROBIN_NANO_V1_3_F4 SERIAL_PORT -1 +exec_test $1 $2 "MKS/ZNP Robin nano v1.3 Emulated DOGM FSMC and native USB mod" "$3" + +# cleanup +restore_configs diff --git a/buildroot/tests/mks_robin_nano35 b/buildroot/tests/mks_robin_nano_v1v2 similarity index 100% rename from buildroot/tests/mks_robin_nano35 rename to buildroot/tests/mks_robin_nano_v1v2 diff --git a/buildroot/tests/mks_robin_nano35_maple b/buildroot/tests/mks_robin_nano_v1v2_maple similarity index 100% rename from buildroot/tests/mks_robin_nano35_maple rename to buildroot/tests/mks_robin_nano_v1v2_maple diff --git a/ini/renamed.ini b/ini/renamed.ini index 75f5dc3accc7..5785bfac67e3 100644 --- a/ini/renamed.ini +++ b/ini/renamed.ini @@ -56,3 +56,11 @@ extends = renamed [env:STM32F103VE_GTM32] # Renamed to STM32F103VE_GTM32_maple extends = renamed + +[env:mks_robin_nano_35] +# Renamed to mks_robin_nano_v1v2 +extends = renamed + +[env:mks_robin_nano_35_maple] +# Renamed to mks_robin_nano_v1v2_maple +extends = renamed diff --git a/ini/stm32f1-maple.ini b/ini/stm32f1-maple.ini index 84055bebab29..fcf320293c6d 100644 --- a/ini/stm32f1-maple.ini +++ b/ini/stm32f1-maple.ini @@ -203,17 +203,15 @@ board_build.ldscript = mks_robin_mini.ld build_flags = ${STM32F1_maple.build_flags} -DMCU_STM32F103VE # -# MKS Robin Nano (STM32F103VET6) +# MKS Robin Nano v1.x and v2 (STM32F103VET6) # -[env:mks_robin_nano35_maple] +[env:mks_robin_nano_v1v2_maple] extends = STM32F1_maple board = genericSTM32F103VE board_build.address = 0x08007000 board_build.rename = Robin_nano35.bin board_build.ldscript = mks_robin_nano.ld build_flags = ${STM32F1_maple.build_flags} -DMCU_STM32F103VE -DSS_TIMER=4 -debug_tool = jlink -upload_protocol = jlink # # MKS Robin (STM32F103ZET6) diff --git a/ini/stm32f1.ini b/ini/stm32f1.ini index 1e29ea6de5ed..f06eef459472 100644 --- a/ini/stm32f1.ini +++ b/ini/stm32f1.ini @@ -216,23 +216,35 @@ build_flags = ${stm32_variant.build_flags} build_unflags = ${stm32_variant.build_unflags} -DUSBCON -DUSBD_USE_CDC -# -# MKS Robin Nano V1.2 and V2 -# -[env:mks_robin_nano35] +[mks_robin_nano_v1v2_common] extends = stm32_variant board = genericSTM32F103VE board_build.variant = MARLIN_F103Vx board_build.encrypt_mks = Robin_nano35.bin board_build.offset = 0x7000 board_upload.offset_address = 0x08007000 +debug_tool = stlink +upload_protocol = stlink + +# +# MKS Robin Nano V1.2 and V2 +# +[env:mks_robin_nano_v1v2] +extends = mks_robin_nano_v1v2_common build_flags = ${stm32_variant.build_flags} -DMCU_STM32F103VE -DSS_TIMER=4 -DENABLE_HWSERIAL3 -DTIMER_TONE=TIM3 -DTIMER_SERVO=TIM2 build_unflags = ${stm32_variant.build_unflags} -DUSBCON -DUSBD_USE_CDC -debug_tool = jlink -upload_protocol = jlink + +# +# MKS/ZNP Robin Nano v1.2 with native USB modification +# +[env:mks_robin_nano_v1_2_usbmod] +extends = mks_robin_nano_v1v2_common +build_flags = ${common_stm32.build_flags} + -DMCU_STM32F103VE -DSS_TIMER=4 + -DTIMER_TONE=TIM3 -DTIMER_SERVO=TIM2 # # Mingda MPX_ARM_MINI diff --git a/ini/stm32f4.ini b/ini/stm32f4.ini index 5e0d4a13ecb4..0857dec39819 100644 --- a/ini/stm32f4.ini +++ b/ini/stm32f4.ini @@ -570,42 +570,54 @@ board_upload.offset_address = 0x0800C000 extra_scripts = ${stm32_variant.extra_scripts} buildroot/share/PlatformIO/scripts/openblt.py -# -# BOARD_MKS_ROBIN_NANO_V1_3_F4 -# - MKS Robin Nano V1.3 (STM32F407VET6) 5 Pololu Plug -# - MKS Robin Nano-S V1.3 (STM32F407VET6) 4 TMC2225 + 1 Pololu Plug -# -[env:mks_robin_nano_v1_3_f4] +[mks_robin_nano_v1_3_f4_common] extends = stm32_variant board = marlin_STM32F407VGT6_CCM board_build.variant = MARLIN_F4x7Vx board_build.offset = 0x8000 board_upload.offset_address = 0x08008000 board_build.rename = Robin_nano35.bin -build_flags = ${stm32_variant.build_flags} - -DMCU_STM32F407VE -DSS_TIMER=4 -DENABLE_HWSERIAL3 - -DSTM32_FLASH_SIZE=512 - -DTIMER_TONE=TIM3 -DTIMER_SERVO=TIM2 - -DHAL_SD_MODULE_ENABLED - -DHAL_SRAM_MODULE_ENABLED -build_unflags = ${stm32_variant.build_unflags} - -DUSBCON -DUSBD_USE_CDC debug_tool = jlink upload_protocol = jlink +# +# BOARD_MKS_ROBIN_NANO_V1_3_F4 +# - MKS Robin Nano V1.3 (STM32F407VET6, 5 Pololu Plug) +# - MKS Robin Nano-S V1.3 (STM32F407VET6, 4 TMC2225, 1 Pololu Plug) +# - ZNP Robin Nano V1.3 (STM32F407VET6, 2 TMC2208, 2 A4988, 1x Polulu plug) +# +[env:mks_robin_nano_v1_3_f4] +extends = mks_robin_nano_v1_3_f4_common +build_flags = ${stm32_variant.build_flags} + -DMCU_STM32F407VE -DENABLE_HWSERIAL3 -DSTM32_FLASH_SIZE=512 + -DTIMER_SERVO=TIM2 -DTIMER_TONE=TIM3 -DSS_TIMER=4 + -DHAL_SD_MODULE_ENABLED -DHAL_SRAM_MODULE_ENABLED +build_unflags = ${stm32_variant.build_unflags} + -DUSBCON -DUSBD_USE_CDC + +# +# MKS/ZNP Robin Nano V1.3 with native USB mod +# +[env:mks_robin_nano_v1_3_f4_usbmod] +extends = mks_robin_nano_v1_3_f4_common +build_flags = ${stm32_variant.build_flags} + -DMCU_STM32F407VE -DSTM32_FLASH_SIZE=512 + -DTIMER_SERVO=TIM2 -DTIMER_TONE=TIM3 -DSS_TIMER=4 + -DHAL_SD_MODULE_ENABLED -DHAL_SRAM_MODULE_ENABLED + # # Artillery Ruby # [env:Artillery_Ruby] -extends = common_stm32 -board = marlin_Artillery_Ruby -build_flags = ${common_stm32.build_flags} - -DSTM32F401xC -DTARGET_STM32F4 -DDISABLE_GENERIC_SERIALUSB -DARDUINO_ARCH_STM32 - -DUSBD_USE_CDC_COMPOSITE -DUSE_USB_FS - -DUSB_PRODUCT=\"Artillery_3D_Printer\" - -DFLASH_DATA_SECTOR=1U -DFLASH_BASE_ADDRESS=0x08004000 -extra_scripts = ${common_stm32.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py +extends = common_stm32 +board = marlin_Artillery_Ruby +build_flags = ${common_stm32.build_flags} + -DSTM32F401xC -DTARGET_STM32F4 -DDISABLE_GENERIC_SERIALUSB -DARDUINO_ARCH_STM32 + -DUSBD_USE_CDC_COMPOSITE -DUSE_USB_FS + -DUSB_PRODUCT=\"Artillery_3D_Printer\" + -DFLASH_DATA_SECTOR=1U -DFLASH_BASE_ADDRESS=0x08004000 +extra_scripts = ${common_stm32.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/generic_create_variant.py # # Ender-3 S1 STM32F401RC_creality From a8cf886aa5d4c6a65a41b93b49ed5504b8fc4691 Mon Sep 17 00:00:00 2001 From: Lefteris Garyfalakis <46350667+lefterisgar@users.noreply.github.com> Date: Thu, 25 Aug 2022 19:48:35 +0300 Subject: [PATCH 019/243] =?UTF-8?q?=F0=9F=94=A8=20Suppressible=20Creality?= =?UTF-8?q?=204.2.2=20warning=20(#24683)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/Warnings.cpp | 5 ++--- Marlin/src/pins/stm32f1/pins_CREALITY_V422.h | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Marlin/src/inc/Warnings.cpp b/Marlin/src/inc/Warnings.cpp index e665ac5bca4e..a88b6e532a0c 100644 --- a/Marlin/src/inc/Warnings.cpp +++ b/Marlin/src/inc/Warnings.cpp @@ -707,9 +707,8 @@ #warning "Don't forget to update your TFT settings in Configuration.h." #endif -// Ender 3 Pro (but, apparently all Creality 4.2.2 boards) -#if ENABLED(EMIT_CREALITY_422_WARNING) || MB(CREALITY_V4) - #warning "Creality 4.2.2 boards come with a variety of stepper drivers. Check the board label and set the correct *_DRIVER_TYPE! (C=HR4988, E=A4988, A=TMC2208, B=TMC2209, H=TMC2225)." +#if ENABLED(EMIT_CREALITY_422_WARNING) + #warning "Creality 4.2.2 boards come with a variety of stepper drivers. Check the board label and set the correct *_DRIVER_TYPE! (C=HR4988, E=A4988, A=TMC2208, B=TMC2209, H=TMC2225). (Define EMIT_CREALITY_422_WARNING false to suppress this warning.)" #endif #if PRINTCOUNTER_SYNC diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V422.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V422.h index 5499adb07668..c6b6e84bfa36 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V422.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V422.h @@ -28,4 +28,8 @@ #define BOARD_INFO_NAME "Creality v4.2.2" #define DEFAULT_MACHINE_NAME "Creality3D" +#ifndef EMIT_CREALITY_422_WARNING + #define EMIT_CREALITY_422_WARNING +#endif + #include "pins_CREALITY_V4.h" From 68c5e97fd7574841ac32cd929b6b1e8b44d1cb61 Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Thu, 25 Aug 2022 10:08:03 -0700 Subject: [PATCH 020/243] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20Freeze=20Feature?= =?UTF-8?q?=20(#24664)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/MarlinCore.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 1e2e6c64830f..0ea55b7ef458 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -488,7 +488,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) { } #endif - #if HAS_FREEZE_PIN + #if ENABLED(FREEZE_FEATURE) stepper.frozen = READ(FREEZE_PIN) == FREEZE_STATE; #endif From f088722ae80d5ba9e032b029e1f69a12e3d4e900 Mon Sep 17 00:00:00 2001 From: DejitaruJin Date: Thu, 25 Aug 2022 13:10:43 -0400 Subject: [PATCH 021/243] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20SainSmart=20LCD=20?= =?UTF-8?q?(#24672)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/Conditionals_LCD.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index c1c174da4642..a6c9f0ae4305 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -373,6 +373,7 @@ #define LCD_I2C_TYPE_PCF8575 // I2C Character-based 12864 display #define LCD_I2C_ADDRESS 0x27 // I2C Address of the port expander + #define IS_ULTIPANEL 1 #if ENABLED(LCD_SAINSMART_I2C_2004) #define LCD_WIDTH 20 From ef1cf0d5a188fcff37c056ce8d64348c2e4e225e Mon Sep 17 00:00:00 2001 From: EvilGremlin <22657714+EvilGremlin@users.noreply.github.com> Date: Thu, 25 Aug 2022 20:16:55 +0300 Subject: [PATCH 022/243] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Display=20sleep=20?= =?UTF-8?q?minutes,=20encoder=20disable=20option=20(#24618)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/Configuration.h | 7 ++++--- Marlin/Configuration_adv.h | 4 ++-- Marlin/src/gcode/lcd/M255.cpp | 14 +++++--------- Marlin/src/inc/Conditionals_LCD.h | 2 +- Marlin/src/inc/Conditionals_adv.h | 4 ++-- Marlin/src/inc/Conditionals_post.h | 4 ++++ Marlin/src/inc/SanityCheck.h | 10 +++++++--- Marlin/src/lcd/dogm/marlinui_DOGM.cpp | 3 +-- Marlin/src/lcd/language/language_de.h | 1 - Marlin/src/lcd/language/language_en.h | 1 - Marlin/src/lcd/language/language_fr.h | 2 +- Marlin/src/lcd/language/language_it.h | 1 - Marlin/src/lcd/language/language_sk.h | 1 - Marlin/src/lcd/language/language_uk.h | 2 +- Marlin/src/lcd/marlinui.cpp | 18 +++++++++++------- Marlin/src/lcd/marlinui.h | 15 +++++++-------- Marlin/src/lcd/menu/menu_configuration.cpp | 6 +++--- Marlin/src/lcd/menu/menu_item.h | 9 +++++++-- Marlin/src/lcd/menu/menu_main.cpp | 22 +++++++++++----------- Marlin/src/lcd/tft/touch.cpp | 2 +- Marlin/src/lcd/touch/touch_buttons.cpp | 4 ++-- Marlin/src/module/settings.cpp | 18 +++++++++--------- buildroot/tests/mega2560 | 2 +- 23 files changed, 80 insertions(+), 72 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 9d82b3cc40a2..876267af7039 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -3156,10 +3156,11 @@ // //#define TOUCH_SCREEN #if ENABLED(TOUCH_SCREEN) - #define BUTTON_DELAY_EDIT 50 // (ms) Button repeat delay for edit screens - #define BUTTON_DELAY_MENU 250 // (ms) Button repeat delay for menus + #define BUTTON_DELAY_EDIT 50 // (ms) Button repeat delay for edit screens + #define BUTTON_DELAY_MENU 250 // (ms) Button repeat delay for menus - //#define TOUCH_IDLE_SLEEP 300 // (s) Turn off the TFT backlight if set (5mn) + //#define DISABLE_ENCODER // Disable the click encoder, if any + //#define TOUCH_IDLE_SLEEP_MINS 5 // (minutes) Display Sleep after a period of inactivity. Set with M255 S. #define TOUCH_SCREEN_CALIBRATION diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 6ec969474d9f..b83da5441bc5 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1321,7 +1321,7 @@ // // LCD Backlight Timeout // -//#define LCD_BACKLIGHT_TIMEOUT 30 // (s) Timeout before turning off the backlight +//#define LCD_BACKLIGHT_TIMEOUT_MINS 1 // (minutes) Timeout before turning off the backlight #if HAS_BED_PROBE && EITHER(HAS_MARLINUI_MENU, HAS_TFT_LVGL_UI) //#define PROBE_OFFSET_WIZARD // Add a Probe Z Offset calibration option to the LCD menu @@ -1739,7 +1739,7 @@ * Adds the menu item Configuration > LCD Timeout (m) to set a wait period * from 0 (disabled) to 99 minutes. */ - //#define DISPLAY_SLEEP_MINUTES 2 // (minutes) Timeout before turning off the screen + //#define DISPLAY_SLEEP_MINUTES 2 // (minutes) Timeout before turning off the screen. Set with M255 S. /** * ST7920-based LCDs can emulate a 16 x 4 character display using diff --git a/Marlin/src/gcode/lcd/M255.cpp b/Marlin/src/gcode/lcd/M255.cpp index 4a9049ab2c61..8dc8099de149 100644 --- a/Marlin/src/gcode/lcd/M255.cpp +++ b/Marlin/src/gcode/lcd/M255.cpp @@ -32,12 +32,11 @@ */ void GcodeSuite::M255() { if (parser.seenval('S')) { + const int m = parser.value_int(); #if HAS_DISPLAY_SLEEP - const int m = parser.value_int(); - ui.sleep_timeout_minutes = constrain(m, SLEEP_TIMEOUT_MIN, SLEEP_TIMEOUT_MAX); + ui.sleep_timeout_minutes = constrain(m, ui.sleep_timeout_min, ui.sleep_timeout_max); #else - const unsigned int s = parser.value_ushort() * 60; - ui.lcd_backlight_timeout = constrain(s, LCD_BKL_TIMEOUT_MIN, LCD_BKL_TIMEOUT_MAX); + ui.backlight_timeout_minutes = constrain(m, ui.backlight_timeout_min, ui.backlight_timeout_max); #endif } else @@ -47,11 +46,8 @@ void GcodeSuite::M255() { void GcodeSuite::M255_report(const bool forReplay/*=true*/) { report_heading_etc(forReplay, F(STR_DISPLAY_SLEEP)); SERIAL_ECHOLNPGM(" M255 S", - #if HAS_DISPLAY_SLEEP - ui.sleep_timeout_minutes, " ; (minutes)" - #else - ui.lcd_backlight_timeout, " ; (seconds)" - #endif + TERN(HAS_DISPLAY_SLEEP, ui.sleep_timeout_minutes, ui.backlight_timeout_minutes), + " ; (minutes)" ); } diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index a6c9f0ae4305..5e23cedc4d38 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -1599,7 +1599,7 @@ // This emulated DOGM has 'touch/xpt2046', not 'tft/xpt2046' #if ENABLED(TOUCH_SCREEN) - #if TOUCH_IDLE_SLEEP + #if TOUCH_IDLE_SLEEP_MINS #define HAS_TOUCH_SLEEP 1 #endif #if NONE(TFT_TOUCH_DEVICE_GT911, TFT_TOUCH_DEVICE_XPT2046) diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 21bc424f5940..0d79d710bcde 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -647,10 +647,10 @@ #if ALL(HAS_RESUME_CONTINUE, PRINTER_EVENT_LEDS, SDSUPPORT) #define HAS_LEDS_OFF_FLAG 1 #endif -#ifdef DISPLAY_SLEEP_MINUTES +#ifdef DISPLAY_SLEEP_MINUTES || TOUCH_IDLE_SLEEP_MINS #define HAS_DISPLAY_SLEEP 1 #endif -#if HAS_DISPLAY_SLEEP || LCD_BACKLIGHT_TIMEOUT +#if HAS_DISPLAY_SLEEP || LCD_BACKLIGHT_TIMEOUT_MINS #define HAS_GCODE_M255 1 #endif diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 650c420532ed..ea6c1f93bf8f 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -3761,6 +3761,10 @@ #define HAS_ROTARY_ENCODER 1 #endif +#if DISABLED(DISABLE_ENCODER) && ANY(HAS_ROTARY_ENCODER, HAS_ADC_BUTTONS) && ANY(TFT_CLASSIC_UI, TFT_COLOR_UI) + #define HAS_BACK_ITEM 1 +#endif + #if PIN_EXISTS(SAFE_POWER) && DISABLED(DISABLE_DRIVER_SAFE_POWER_PROTECT) #define HAS_DRIVER_SAFE_POWER_PROTECT 1 #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 7c0625dec44e..388303522cfc 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -642,6 +642,10 @@ #error "LEVEL_CORNERS_* settings have been renamed BED_TRAMMING_*." #elif defined(LEVEL_CENTER_TOO) #error "LEVEL_CENTER_TOO is now BED_TRAMMING_INCLUDE_CENTER." +#elif defined(TOUCH_IDLE_SLEEP) + #error "TOUCH_IDLE_SLEEP (seconds) is now TOUCH_IDLE_SLEEP_MINS (minutes)." +#elif defined(LCD_BACKLIGHT_TIMEOUT) + #error "LCD_BACKLIGHT_TIMEOUT (seconds) is now LCD_BACKLIGHT_TIMEOUT_MINS (minutes)." #endif // L64xx stepper drivers have been removed @@ -3030,11 +3034,11 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #endif -#if LCD_BACKLIGHT_TIMEOUT +#if LCD_BACKLIGHT_TIMEOUT_MINS #if !HAS_ENCODER_ACTION - #error "LCD_BACKLIGHT_TIMEOUT requires an LCD with encoder or keypad." + #error "LCD_BACKLIGHT_TIMEOUT_MINS requires an LCD with encoder or keypad." #elif !PIN_EXISTS(LCD_BACKLIGHT) - #error "LCD_BACKLIGHT_TIMEOUT requires LCD_BACKLIGHT_PIN." + #error "LCD_BACKLIGHT_TIMEOUT_MINS requires LCD_BACKLIGHT_PIN." #endif #endif diff --git a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp index e32715988d2f..b72a1ac9263b 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp @@ -343,8 +343,7 @@ void MarlinUI::draw_kill_screen() { void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop #if HAS_DISPLAY_SLEEP - void MarlinUI::sleep_on() { u8g.sleepOn(); } - void MarlinUI::sleep_off() { u8g.sleepOff(); } + void MarlinUI::sleep_display(const bool sleep) { sleep ? u8g.sleepOn() : u8g.sleepOff(); } #endif #if HAS_LCD_BRIGHTNESS diff --git a/Marlin/src/lcd/language/language_de.h b/Marlin/src/lcd/language/language_de.h index 5708221e9cc3..9939ea3f4429 100644 --- a/Marlin/src/lcd/language/language_de.h +++ b/Marlin/src/lcd/language/language_de.h @@ -407,7 +407,6 @@ namespace Language_de { LSTR MSG_ADVANCE_K_E = _UxGT("Vorschubfaktor *"); LSTR MSG_CONTRAST = _UxGT("LCD-Kontrast"); LSTR MSG_BRIGHTNESS = _UxGT("LCD-Helligkeit"); - LSTR MSG_LCD_TIMEOUT_SEC = _UxGT("LCD-Ruhezustand (s)"); LSTR MSG_SCREEN_TIMEOUT = _UxGT("LCD Timeout (m)"); LSTR MSG_BRIGHTNESS_OFF = _UxGT("LCD ausschalten"); LSTR MSG_STORE_EEPROM = _UxGT("Konfig. speichern"); diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 57cae3d32858..d03b455c7196 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -422,7 +422,6 @@ namespace Language_en { LSTR MSG_ADVANCE_K_E = _UxGT("Advance K *"); LSTR MSG_CONTRAST = _UxGT("LCD Contrast"); LSTR MSG_BRIGHTNESS = _UxGT("LCD Brightness"); - LSTR MSG_LCD_TIMEOUT_SEC = _UxGT("LCD Timeout (s)"); LSTR MSG_SCREEN_TIMEOUT = _UxGT("LCD Timeout (m)"); LSTR MSG_BRIGHTNESS_OFF = _UxGT("Backlight Off"); LSTR MSG_STORE_EEPROM = _UxGT("Store Settings"); diff --git a/Marlin/src/lcd/language/language_fr.h b/Marlin/src/lcd/language/language_fr.h index 55b1b4e2e9c9..0a11e862f7e1 100644 --- a/Marlin/src/lcd/language/language_fr.h +++ b/Marlin/src/lcd/language/language_fr.h @@ -321,7 +321,7 @@ namespace Language_fr { LSTR MSG_ADVANCE_K_E = _UxGT("Avance K *"); LSTR MSG_BRIGHTNESS = _UxGT("Luminosité LCD"); LSTR MSG_CONTRAST = _UxGT("Contraste LCD"); - LSTR MSG_LCD_TIMEOUT_SEC = _UxGT("Veille LCD (s)"); + LSTR MSG_SCREEN_TIMEOUT = _UxGT("Veille LCD (m)"); LSTR MSG_BRIGHTNESS_OFF = _UxGT("Éteindre l'écran LCD"); LSTR MSG_STORE_EEPROM = _UxGT("Enregistrer config."); LSTR MSG_LOAD_EEPROM = _UxGT("Charger config."); diff --git a/Marlin/src/lcd/language/language_it.h b/Marlin/src/lcd/language/language_it.h index f0c21deb96cd..0c1b3a8cee35 100644 --- a/Marlin/src/lcd/language/language_it.h +++ b/Marlin/src/lcd/language/language_it.h @@ -418,7 +418,6 @@ namespace Language_it { LSTR MSG_ADVANCE_K_E = _UxGT("K Avanzamento *"); LSTR MSG_CONTRAST = _UxGT("Contrasto LCD"); LSTR MSG_BRIGHTNESS = _UxGT("Luminosità LCD"); - LSTR MSG_LCD_TIMEOUT_SEC = _UxGT("Timeout LCD (s)"); LSTR MSG_SCREEN_TIMEOUT = _UxGT("Timeout LCD (m)"); LSTR MSG_BRIGHTNESS_OFF = _UxGT("Spegni Retroillum."); LSTR MSG_STORE_EEPROM = _UxGT("Salva impostazioni"); diff --git a/Marlin/src/lcd/language/language_sk.h b/Marlin/src/lcd/language/language_sk.h index ef1396e81ff3..bb332f4b1ff2 100644 --- a/Marlin/src/lcd/language/language_sk.h +++ b/Marlin/src/lcd/language/language_sk.h @@ -419,7 +419,6 @@ namespace Language_sk { LSTR MSG_ADVANCE_K_E = _UxGT("K pre posun *"); LSTR MSG_CONTRAST = _UxGT("Kontrast LCD"); LSTR MSG_BRIGHTNESS = _UxGT("Jas LCD"); - LSTR MSG_LCD_TIMEOUT_SEC = _UxGT("Čas. limit LCD (s)"); LSTR MSG_SCREEN_TIMEOUT = _UxGT("Čas. limit LCD (m)"); LSTR MSG_BRIGHTNESS_OFF = _UxGT("Podsviet. vyp."); LSTR MSG_STORE_EEPROM = _UxGT("Uložiť nastavenie"); diff --git a/Marlin/src/lcd/language/language_uk.h b/Marlin/src/lcd/language/language_uk.h index 6170faedaeea..ccdcb21ddf38 100644 --- a/Marlin/src/lcd/language/language_uk.h +++ b/Marlin/src/lcd/language/language_uk.h @@ -455,7 +455,7 @@ namespace Language_uk { LSTR MSG_CONTRAST = _UxGT("Контраст"); LSTR MSG_BRIGHTNESS = _UxGT("Яскравість"); #endif - LSTR MSG_LCD_TIMEOUT_SEC = _UxGT("LCD Таймаут, с"); + LSTR MSG_SCREEN_TIMEOUT = _UxGT("LCD Таймаут, x"); LSTR MSG_BRIGHTNESS_OFF = _UxGT("Підсвітка вимк."); LSTR MSG_STORE_EEPROM = _UxGT("Зберегти в EEPROM"); LSTR MSG_LOAD_EEPROM = _UxGT("Зчитати з EEPROM"); diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index e03e80ed3ce3..8b9c0e048e6b 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -174,22 +174,26 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; volatile int8_t encoderDiff; // Updated in update_buttons, added to encoderPosition every LCD update #endif -#if LCD_BACKLIGHT_TIMEOUT +#if LCD_BACKLIGHT_TIMEOUT_MINS - uint16_t MarlinUI::lcd_backlight_timeout; // Initialized by settings.load() + constexpr uint8_t MarlinUI::backlight_timeout_min, MarlinUI::backlight_timeout_max; + + uint8_t MarlinUI::backlight_timeout_minutes; // Initialized by settings.load() millis_t MarlinUI::backlight_off_ms = 0; void MarlinUI::refresh_backlight_timeout() { - backlight_off_ms = lcd_backlight_timeout ? millis() + lcd_backlight_timeout * 1000UL : 0; + backlight_off_ms = backlight_timeout_minutes ? millis() + backlight_timeout_minutes * 60UL * 1000UL : 0; WRITE(LCD_BACKLIGHT_PIN, HIGH); } #elif HAS_DISPLAY_SLEEP + constexpr uint8_t MarlinUI::sleep_timeout_min, MarlinUI::sleep_timeout_max; + uint8_t MarlinUI::sleep_timeout_minutes; // Initialized by settings.load() millis_t MarlinUI::screen_timeout_millis = 0; void MarlinUI::refresh_screen_timeout() { screen_timeout_millis = sleep_timeout_minutes ? millis() + sleep_timeout_minutes * 60UL * 1000UL : 0; - sleep_off(); + sleep_display(false); } #endif @@ -1059,7 +1063,7 @@ void MarlinUI::init() { reset_status_timeout(ms); - #if LCD_BACKLIGHT_TIMEOUT + #if LCD_BACKLIGHT_TIMEOUT_MINS refresh_backlight_timeout(); #elif HAS_DISPLAY_SLEEP refresh_screen_timeout(); @@ -1169,14 +1173,14 @@ void MarlinUI::init() { return_to_status(); #endif - #if LCD_BACKLIGHT_TIMEOUT + #if LCD_BACKLIGHT_TIMEOUT_MINS if (backlight_off_ms && ELAPSED(ms, backlight_off_ms)) { WRITE(LCD_BACKLIGHT_PIN, LOW); // Backlight off backlight_off_ms = 0; } #elif HAS_DISPLAY_SLEEP if (screen_timeout_millis && ELAPSED(ms, screen_timeout_millis)) - sleep_on(); + sleep_display(); #endif // Change state of drawing flag between screen updates diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index b2a9bb5de955..d2e370890727 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -270,20 +270,19 @@ class MarlinUI { FORCE_INLINE static void refresh_brightness() { set_brightness(brightness); } #endif - #if LCD_BACKLIGHT_TIMEOUT - #define LCD_BKL_TIMEOUT_MIN 1u - #define LCD_BKL_TIMEOUT_MAX UINT16_MAX // Slightly more than 18 hours - static uint16_t lcd_backlight_timeout; + #if LCD_BACKLIGHT_TIMEOUT_MINS + static constexpr uint8_t backlight_timeout_min = 0; + static constexpr uint8_t backlight_timeout_max = 99; + static uint8_t backlight_timeout_minutes; static millis_t backlight_off_ms; static void refresh_backlight_timeout(); #elif HAS_DISPLAY_SLEEP - #define SLEEP_TIMEOUT_MIN 0 - #define SLEEP_TIMEOUT_MAX 99 + static constexpr uint8_t sleep_timeout_min = 0; + static constexpr uint8_t sleep_timeout_max = 99; static uint8_t sleep_timeout_minutes; static millis_t screen_timeout_millis; static void refresh_screen_timeout(); - static void sleep_on(); - static void sleep_off(); + static void sleep_display(const bool sleep=true); #endif #if HAS_DWIN_E3V2_BASIC diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 1f2257a77fe3..9eef94823e33 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -547,10 +547,10 @@ void menu_configuration() { // // Set display backlight / sleep timeout // - #if LCD_BACKLIGHT_TIMEOUT && LCD_BKL_TIMEOUT_MIN < LCD_BKL_TIMEOUT_MAX - EDIT_ITEM(uint16_4, MSG_LCD_TIMEOUT_SEC, &ui.lcd_backlight_timeout, LCD_BKL_TIMEOUT_MIN, LCD_BKL_TIMEOUT_MAX, ui.refresh_backlight_timeout); + #if LCD_BACKLIGHT_TIMEOUT_MINS + EDIT_ITEM(uint8, MSG_SCREEN_TIMEOUT, &ui.backlight_timeout_minutes, ui.backlight_timeout_min, ui.backlight_timeout_max, ui.refresh_backlight_timeout); #elif HAS_DISPLAY_SLEEP - EDIT_ITEM(uint8, MSG_SCREEN_TIMEOUT, &ui.sleep_timeout_minutes, SLEEP_TIMEOUT_MIN, SLEEP_TIMEOUT_MAX, ui.refresh_screen_timeout); + EDIT_ITEM(uint8, MSG_SCREEN_TIMEOUT, &ui.sleep_timeout_minutes, ui.sleep_timeout_min, ui.sleep_timeout_max, ui.refresh_screen_timeout); #endif #if ENABLED(FWRETRACT) diff --git a/Marlin/src/lcd/menu/menu_item.h b/Marlin/src/lcd/menu/menu_item.h index b0eab65c649b..7c81e3dd39bd 100644 --- a/Marlin/src/lcd/menu/menu_item.h +++ b/Marlin/src/lcd/menu/menu_item.h @@ -402,8 +402,13 @@ class MenuItem_bool : public MenuEditItemBase { // Predefined menu item types // -#define BACK_ITEM_F(FLABEL) MENU_ITEM_F(back, FLABEL) -#define BACK_ITEM(LABEL) MENU_ITEM(back, LABEL) +#if HAS_BACK_ITEM + #define BACK_ITEM_F(FLABEL) MENU_ITEM_F(back, FLABEL) + #define BACK_ITEM(LABEL) MENU_ITEM(back, LABEL) +#else + #define BACK_ITEM_F(FLABEL) NOOP + #define BACK_ITEM(LABEL) NOOP +#endif #define ACTION_ITEM_N_S_F(N, S, FLABEL, ACTION) MENU_ITEM_N_S_F(function, N, S, FLABEL, ACTION) #define ACTION_ITEM_N_S(N, S, LABEL, ACTION) ACTION_ITEM_N_S_F(N, S, GET_TEXT_F(LABEL), ACTION) diff --git a/Marlin/src/lcd/menu/menu_main.cpp b/Marlin/src/lcd/menu/menu_main.cpp index 518f1e0f502d..bd1670388589 100644 --- a/Marlin/src/lcd/menu/menu_main.cpp +++ b/Marlin/src/lcd/menu/menu_main.cpp @@ -325,6 +325,17 @@ void menu_main() { SUBMENU(MSG_TEMPERATURE, menu_temperature); #endif + #if ENABLED(ADVANCED_PAUSE_FEATURE) + #if E_STEPPERS == 1 && DISABLED(FILAMENT_LOAD_UNLOAD_GCODES) + YESNO_ITEM(MSG_FILAMENTCHANGE, + menu_change_filament, nullptr, + GET_TEXT_F(MSG_FILAMENTCHANGE), (const char *)nullptr, F("?") + ); + #else + SUBMENU(MSG_FILAMENTCHANGE, menu_change_filament); + #endif + #endif + #if HAS_POWER_MONITOR SUBMENU(MSG_POWER_MONITOR, menu_power_monitor); #endif @@ -349,17 +360,6 @@ void menu_main() { } #endif - #if ENABLED(ADVANCED_PAUSE_FEATURE) - #if E_STEPPERS == 1 && DISABLED(FILAMENT_LOAD_UNLOAD_GCODES) - YESNO_ITEM(MSG_FILAMENTCHANGE, - menu_change_filament, nullptr, - GET_TEXT_F(MSG_FILAMENTCHANGE), (const char *)nullptr, F("?") - ); - #else - SUBMENU(MSG_FILAMENTCHANGE, menu_change_filament); - #endif - #endif - #if ENABLED(LCD_INFO_MENU) SUBMENU(MSG_INFO_MENU, menu_info); #endif diff --git a/Marlin/src/lcd/tft/touch.cpp b/Marlin/src/lcd/tft/touch.cpp index 050b59f39f90..824b2699247b 100644 --- a/Marlin/src/lcd/tft/touch.cpp +++ b/Marlin/src/lcd/tft/touch.cpp @@ -302,7 +302,7 @@ bool Touch::get_point(int16_t *x, int16_t *y) { WRITE(TFT_BACKLIGHT_PIN, HIGH); #endif } - next_sleep_ms = millis() + SEC_TO_MS(TOUCH_IDLE_SLEEP); + next_sleep_ms = millis() + SEC_TO_MS(ui.sleep_timeout_minutes * 60); } #endif // HAS_TOUCH_SLEEP diff --git a/Marlin/src/lcd/touch/touch_buttons.cpp b/Marlin/src/lcd/touch/touch_buttons.cpp index 604f366ed4f2..d641dd3b1c92 100644 --- a/Marlin/src/lcd/touch/touch_buttons.cpp +++ b/Marlin/src/lcd/touch/touch_buttons.cpp @@ -61,7 +61,7 @@ TouchButtons touchBt; void TouchButtons::init() { touchIO.Init(); - TERN_(HAS_TOUCH_SLEEP, next_sleep_ms = millis() + SEC_TO_MS(TOUCH_IDLE_SLEEP)); + TERN_(HAS_TOUCH_SLEEP, next_sleep_ms = millis() + SEC_TO_MS(ui.sleep_timeout_minutes * 60)); } uint8_t TouchButtons::read_buttons() { @@ -135,7 +135,7 @@ uint8_t TouchButtons::read_buttons() { WRITE(TFT_BACKLIGHT_PIN, HIGH); #endif } - next_sleep_ms = millis() + SEC_TO_MS(TOUCH_IDLE_SLEEP); + next_sleep_ms = millis() + SEC_TO_MS(ui.sleep_timeout_minutes * 60); } #endif // HAS_TOUCH_SLEEP diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index b40690e22c6a..aa6f48d763df 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -402,8 +402,8 @@ typedef struct SettingsDataStruct { // // Display Sleep // - #if LCD_BACKLIGHT_TIMEOUT - uint16_t lcd_backlight_timeout; // M255 S + #if LCD_BACKLIGHT_TIMEOUT_MINS + uint8_t backlight_timeout_minutes; // M255 S #elif HAS_DISPLAY_SLEEP uint8_t sleep_timeout_minutes; // M255 S #endif @@ -640,7 +640,7 @@ void MarlinSettings::postprocess() { TERN_(HAS_LCD_CONTRAST, ui.refresh_contrast()); TERN_(HAS_LCD_BRIGHTNESS, ui.refresh_brightness()); - #if LCD_BACKLIGHT_TIMEOUT + #if LCD_BACKLIGHT_TIMEOUT_MINS ui.refresh_backlight_timeout(); #elif HAS_DISPLAY_SLEEP ui.refresh_screen_timeout(); @@ -1157,8 +1157,8 @@ void MarlinSettings::postprocess() { // // LCD Backlight / Sleep Timeout // - #if LCD_BACKLIGHT_TIMEOUT - EEPROM_WRITE(ui.lcd_backlight_timeout); + #if LCD_BACKLIGHT_TIMEOUT_MINS + EEPROM_WRITE(ui.backlight_timeout_minutes); #elif HAS_DISPLAY_SLEEP EEPROM_WRITE(ui.sleep_timeout_minutes); #endif @@ -2108,8 +2108,8 @@ void MarlinSettings::postprocess() { // // LCD Backlight / Sleep Timeout // - #if LCD_BACKLIGHT_TIMEOUT - EEPROM_READ(ui.lcd_backlight_timeout); + #if LCD_BACKLIGHT_TIMEOUT_MINS + EEPROM_READ(ui.backlight_timeout_minutes); #elif HAS_DISPLAY_SLEEP EEPROM_READ(ui.sleep_timeout_minutes); #endif @@ -3198,8 +3198,8 @@ void MarlinSettings::reset() { // // LCD Backlight / Sleep Timeout // - #if LCD_BACKLIGHT_TIMEOUT - ui.lcd_backlight_timeout = LCD_BACKLIGHT_TIMEOUT; + #if LCD_BACKLIGHT_TIMEOUT_MINS + ui.backlight_timeout_minutes = LCD_BACKLIGHT_TIMEOUT_MINS; #elif HAS_DISPLAY_SLEEP ui.sleep_timeout_minutes = DISPLAY_SLEEP_MINUTES; #endif diff --git a/buildroot/tests/mega2560 b/buildroot/tests/mega2560 index 536f723b73b7..9cb50688cdea 100755 --- a/buildroot/tests/mega2560 +++ b/buildroot/tests/mega2560 @@ -213,7 +213,7 @@ opt_set MOTHERBOARD BOARD_RAMPS_14_EFB EXTRUDERS 1 \ TEMP_SENSOR_0 -2 TEMP_SENSOR_REDUNDANT -2 \ TEMP_SENSOR_REDUNDANT_SOURCE E1 TEMP_SENSOR_REDUNDANT_TARGET E0 \ TEMP_0_CS_PIN 11 TEMP_1_CS_PIN 12 \ - LCD_BACKLIGHT_TIMEOUT 30 + LCD_BACKLIGHT_TIMEOUT_MINS 2 opt_enable MPCTEMP MINIPANEL opt_disable PIDTEMP exec_test $1 $2 "MEGA2560 RAMPS | Redundant temperature sensor | 2x MAX6675 | BL Timeout" "$3" From e24d5f931518fd6644d5d50dcce908e903550963 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arkadiusz=20Mi=C5=9Bkiewicz?= Date: Fri, 26 Aug 2022 00:14:54 +0200 Subject: [PATCH 023/243] =?UTF-8?q?=E2=9C=A8=20M20=5FTIMESTAMP=5FSUPPORT?= =?UTF-8?q?=20(#24679)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/Configuration_adv.h | 1 + Marlin/src/gcode/sd/M20.cpp | 21 ++++++----- Marlin/src/inc/Conditionals_adv.h | 2 +- Marlin/src/sd/cardreader.cpp | 50 +++++++++++++++----------- Marlin/src/sd/cardreader.h | 15 +++----- buildroot/tests/SAMD51_grandcentral_m4 | 3 +- 6 files changed, 50 insertions(+), 42 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index b83da5441bc5..68cf81627f08 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1578,6 +1578,7 @@ //#define LONG_FILENAME_HOST_SUPPORT // Get the long filename of a file/folder with 'M33 ' and list long filenames with 'M20 L' //#define LONG_FILENAME_WRITE_SUPPORT // Create / delete files with long filenames via M28, M30, and Binary Transfer Protocol + //#define M20_TIMESTAMP_SUPPORT // Include timestamps by adding the 'T' flag to M20 commands //#define SCROLL_LONG_FILENAMES // Scroll long filenames in the SD card menu diff --git a/Marlin/src/gcode/sd/M20.cpp b/Marlin/src/gcode/sd/M20.cpp index c640309be8c8..2a7e0d08df71 100644 --- a/Marlin/src/gcode/sd/M20.cpp +++ b/Marlin/src/gcode/sd/M20.cpp @@ -28,18 +28,23 @@ #include "../../sd/cardreader.h" /** - * M20: List SD card to serial output + * M20: List SD card to serial output in [name] [size] format. + * + * With CUSTOM_FIRMWARE_UPLOAD: + * F - List BIN files only, for use with firmware upload + * + * With LONG_FILENAME_HOST_SUPPORT: + * L - List long filenames (instead of DOS8.3 names) + * + * With M20_TIMESTAMP_SUPPORT: + * T - Include timestamps */ void GcodeSuite::M20() { if (card.flag.mounted) { SERIAL_ECHOLNPGM(STR_BEGIN_FILE_LIST); - card.ls( - TERN_(CUSTOM_FIRMWARE_UPLOAD, parser.boolval('F')) - #if BOTH(CUSTOM_FIRMWARE_UPLOAD, LONG_FILENAME_HOST_SUPPORT) - , - #endif - TERN_(LONG_FILENAME_HOST_SUPPORT, parser.boolval('L')) - ); + card.ls(TERN0(CUSTOM_FIRMWARE_UPLOAD, parser.boolval('F') << LS_ONLY_BIN) + | TERN0(LONG_FILENAME_HOST_SUPPORT, parser.boolval('L') << LS_LONG_FILENAME) + | TERN0(M20_TIMESTAMP_SUPPORT, parser.boolval('T') << LS_TIMESTAMP)); SERIAL_ECHOLNPGM(STR_END_FILE_LIST); } else diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 0d79d710bcde..49b6652587cb 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -1003,7 +1003,7 @@ #endif // Flag whether hex_print.cpp is used -#if ANY(AUTO_BED_LEVELING_UBL, M100_FREE_MEMORY_WATCHER, DEBUG_GCODE_PARSER, TMC_DEBUG, MARLIN_DEV_MODE, DEBUG_CARDREADER) +#if ANY(AUTO_BED_LEVELING_UBL, M100_FREE_MEMORY_WATCHER, DEBUG_GCODE_PARSER, TMC_DEBUG, MARLIN_DEV_MODE, DEBUG_CARDREADER, M20_TIMESTAMP_SUPPORT) #define NEED_HEX_PRINT 1 #endif diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 3fff79653933..3057bf68af09 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -29,6 +29,7 @@ #include "cardreader.h" #include "../MarlinCore.h" +#include "../libs/hex_print.h" #include "../lcd/marlinui.h" #if ENABLED(DWIN_CREALITY_LCD) @@ -197,7 +198,7 @@ char *createFilename(char * const buffer, const dir_t &p) { // // Return 'true' if the item is a folder, G-code file or Binary file // -bool CardReader::is_visible_entity(const dir_t &p OPTARG(CUSTOM_FIRMWARE_UPLOAD, bool onlyBin/*=false*/)) { +bool CardReader::is_visible_entity(const dir_t &p OPTARG(CUSTOM_FIRMWARE_UPLOAD, const bool onlyBin/*=false*/)) { //uint8_t pn0 = p.name[0]; #if DISABLED(CUSTOM_FIRMWARE_UPLOAD) @@ -279,12 +280,17 @@ void CardReader::selectByName(SdFile dir, const char * const match) { * this can blow up the stack, so a 'depth' parameter would be a * good addition. */ -void CardReader::printListing( - SdFile parent, const char * const prepend - OPTARG(CUSTOM_FIRMWARE_UPLOAD, bool onlyBin/*=false*/) - OPTARG(LONG_FILENAME_HOST_SUPPORT, const bool includeLongNames/*=false*/) +void CardReader::printListing(SdFile parent, const char * const prepend, const uint8_t lsflags OPTARG(LONG_FILENAME_HOST_SUPPORT, const char * const prependLong/*=nullptr*/) ) { + const bool includeTime = TERN0(M20_TIMESTAMP_SUPPORT, TEST(lsflags, LS_TIMESTAMP)); + #if ENABLED(LONG_FILENAME_HOST_SUPPORT) + const bool includeLong = TEST(lsflags, LS_LONG_FILENAME); + #endif + #if ENABLED(CUSTOM_FIRMWARE_UPLOAD) + const bool onlyBin = TEST(lsflags, LS_ONLY_BIN); + #endif + UNUSED(lsflags); dir_t p; while (parent.readDir(&p, longFilename) > 0) { if (DIR_IS_SUBDIR(&p)) { @@ -301,19 +307,17 @@ void CardReader::printListing( SdFile child; // child.close() in destructor if (child.open(&parent, dosFilename, O_READ)) { #if ENABLED(LONG_FILENAME_HOST_SUPPORT) - if (includeLongNames) { - size_t lenPrependLong = prependLong ? strlen(prependLong) + 1 : 0; + if (includeLong) { + const size_t lenPrependLong = prependLong ? strlen(prependLong) + 1 : 0; // Allocate enough stack space for the full long path including / separator char pathLong[lenPrependLong + strlen(longFilename) + 1]; if (prependLong) { strcpy(pathLong, prependLong); pathLong[lenPrependLong - 1] = '/'; } strcpy(pathLong + lenPrependLong, longFilename); - printListing(child, path OPTARG(CUSTOM_FIRMWARE_UPLOAD, onlyBin), true, pathLong); + printListing(child, path, lsflags, pathLong); + continue; } - else - printListing(child, path OPTARG(CUSTOM_FIRMWARE_UPLOAD, onlyBin)); - #else - printListing(child, path OPTARG(CUSTOM_FIRMWARE_UPLOAD, onlyBin)); #endif + printListing(child, path, lsflags); } else { SERIAL_ECHO_MSG(STR_SD_CANT_OPEN_SUBDIR, dosFilename); @@ -325,8 +329,18 @@ void CardReader::printListing( SERIAL_ECHO(createFilename(filename, p)); SERIAL_CHAR(' '); SERIAL_ECHO(p.fileSize); + if (includeTime) { + SERIAL_CHAR(' '); + uint16_t crmodDate = p.lastWriteDate, crmodTime = p.lastWriteTime; + if (crmodDate < p.creationDate || (crmodDate == p.creationDate && crmodTime < p.creationTime)) { + crmodDate = p.creationDate; + crmodTime = p.creationTime; + } + SERIAL_ECHOPGM("0x", hex_word(crmodDate)); + print_hex_word(crmodTime); + } #if ENABLED(LONG_FILENAME_HOST_SUPPORT) - if (includeLongNames) { + if (includeLong) { SERIAL_CHAR(' '); if (prependLong) { SERIAL_ECHO(prependLong); SERIAL_CHAR('/'); } SERIAL_ECHO(longFilename[0] ? longFilename : filename); @@ -340,16 +354,10 @@ void CardReader::printListing( // // List all files on the SD card // -void CardReader::ls( - TERN_(CUSTOM_FIRMWARE_UPLOAD, const bool onlyBin/*=false*/) - #if BOTH(CUSTOM_FIRMWARE_UPLOAD, LONG_FILENAME_HOST_SUPPORT) - , - #endif - TERN_(LONG_FILENAME_HOST_SUPPORT, const bool includeLongNames/*=false*/) -) { +void CardReader::ls(const uint8_t lsflags) { if (flag.mounted) { root.rewind(); - printListing(root, nullptr OPTARG(CUSTOM_FIRMWARE_UPLOAD, onlyBin) OPTARG(LONG_FILENAME_HOST_SUPPORT, includeLongNames)); + printListing(root, nullptr, lsflags); } } diff --git a/Marlin/src/sd/cardreader.h b/Marlin/src/sd/cardreader.h index d2f462c2a777..6fe75f760e2d 100644 --- a/Marlin/src/sd/cardreader.h +++ b/Marlin/src/sd/cardreader.h @@ -89,6 +89,8 @@ typedef struct { ; } card_flags_t; +enum ListingFlags : uint8_t { LS_LONG_FILENAME, LS_ONLY_BIN, LS_TIMESTAMP }; + #if ENABLED(AUTO_REPORT_SD_STATUS) #include "../libs/autoreport.h" #endif @@ -207,13 +209,7 @@ class CardReader { FORCE_INLINE static void getfilename_sorted(const uint16_t nr) { selectFileByIndex(nr); } #endif - static void ls( - TERN_(CUSTOM_FIRMWARE_UPLOAD, const bool onlyBin=false) - #if BOTH(CUSTOM_FIRMWARE_UPLOAD, LONG_FILENAME_HOST_SUPPORT) - , - #endif - TERN_(LONG_FILENAME_HOST_SUPPORT, const bool includeLongNames=false) - ); + static void ls(const uint8_t lsflags); #if ENABLED(POWER_LOSS_RECOVERY) static bool jobRecoverFileExists(); @@ -348,10 +344,7 @@ class CardReader { static int countItems(SdFile dir); static void selectByIndex(SdFile dir, const uint8_t index); static void selectByName(SdFile dir, const char * const match); - static void printListing( - SdFile parent, const char * const prepend - OPTARG(CUSTOM_FIRMWARE_UPLOAD, const bool onlyBin=false) - OPTARG(LONG_FILENAME_HOST_SUPPORT, const bool includeLongNames=false) + static void printListing(SdFile parent, const char * const prepend, const uint8_t lsflags OPTARG(LONG_FILENAME_HOST_SUPPORT, const char * const prependLong=nullptr) ); diff --git a/buildroot/tests/SAMD51_grandcentral_m4 b/buildroot/tests/SAMD51_grandcentral_m4 index e6e27d8cb8c9..c8e08c19e6b8 100755 --- a/buildroot/tests/SAMD51_grandcentral_m4 +++ b/buildroot/tests/SAMD51_grandcentral_m4 @@ -22,7 +22,8 @@ opt_enable ENDSTOP_INTERRUPTS_FEATURE S_CURVE_ACCELERATION BLTOUCH Z_MIN_PROBE_R EEPROM_SETTINGS NOZZLE_PARK_FEATURE SDSUPPORT SD_CHECK_AND_RETRY \ REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER Z_STEPPER_AUTO_ALIGN ADAPTIVE_STEP_SMOOTHING \ STATUS_MESSAGE_SCROLLING LCD_SET_PROGRESS_MANUALLY SHOW_REMAINING_TIME USE_M73_REMAINING_TIME \ - LONG_FILENAME_HOST_SUPPORT SCROLL_LONG_FILENAMES BABYSTEPPING DOUBLECLICK_FOR_Z_BABYSTEPPING \ + LONG_FILENAME_HOST_SUPPORT CUSTOM_FIRMWARE_UPLOAD M20_TIMESTAMP_SUPPORT \ + SCROLL_LONG_FILENAMES BABYSTEPPING DOUBLECLICK_FOR_Z_BABYSTEPPING \ MOVE_Z_WHEN_IDLE BABYSTEP_ZPROBE_OFFSET BABYSTEP_ZPROBE_GFX_OVERLAY \ LIN_ADVANCE ADVANCED_PAUSE_FEATURE PARK_HEAD_ON_PAUSE MONITOR_DRIVER_STATUS SENSORLESS_HOMING \ SQUARE_WAVE_STEPPING TMC_DEBUG EXPERIMENTAL_SCURVE From e8394c391ef7bcdf62d268d7ab453e8ad7a1e743 Mon Sep 17 00:00:00 2001 From: Mark Date: Fri, 26 Aug 2022 06:50:03 +0800 Subject: [PATCH 024/243] =?UTF-8?q?=F0=9F=90=9B=20Fix=20Bed=20Distance=20S?= =?UTF-8?q?ensor=20reading=20(#24649)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/bedlevel/bdl/bdl.cpp | 33 +++++++++++++------------ Marlin/src/module/probe.cpp | 4 ++- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/Marlin/src/feature/bedlevel/bdl/bdl.cpp b/Marlin/src/feature/bedlevel/bdl/bdl.cpp index 0668eb705c5b..1a27011a4b8f 100644 --- a/Marlin/src/feature/bedlevel/bdl/bdl.cpp +++ b/Marlin/src/feature/bedlevel/bdl/bdl.cpp @@ -96,22 +96,23 @@ void BDS_Leveling::process() { const float z_sensor = (tmp & 0x3FF) / 100.0f; if (cur_z < 0) config_state = 0; //float abs_z = current_position.z > cur_z ? (current_position.z - cur_z) : (cur_z - current_position.z); - if ( cur_z < config_state * 0.1f - && config_state > 0 - && old_cur_z == cur_z - && old_buf_z == current_position.z - && z_sensor < (MAX_BD_HEIGHT) - ) { - babystep.set_mm(Z_AXIS, cur_z - z_sensor); - #if ENABLED(DEBUG_OUT_BD) - SERIAL_ECHOLNPGM("BD:", z_sensor, ", Z:", cur_z, "|", current_position.z); - #endif - } - else { - babystep.set_mm(Z_AXIS, 0); - //if (old_cur_z <= cur_z) Z_DIR_WRITE(!INVERT_Z_DIR); - stepper.set_directions(); - } + #if ENABLED(BABYSTEPPING) + if (cur_z < config_state * 0.1f + && config_state > 0 + && old_cur_z == cur_z + && old_buf_z == current_position.z + && z_sensor < (MAX_BD_HEIGHT) + ) { + babystep.set_mm(Z_AXIS, cur_z - z_sensor); + #if ENABLED(DEBUG_OUT_BD) + SERIAL_ECHOLNPGM("BD:", z_sensor, ", Z:", cur_z, "|", current_position.z); + #endif + } + else { + babystep.set_mm(Z_AXIS, 0); //if (old_cur_z <= cur_z) Z_DIR_WRITE(!INVERT_Z_DIR); + stepper.set_directions(); + } + #endif old_cur_z = cur_z; old_buf_z = current_position.z; endstops.bdp_state_update(z_sensor <= 0.01f); diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 3baef31479ca..fa92ae1fb597 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -882,7 +882,9 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai // Move the probe to the starting XYZ do_blocking_move_to(npos, feedRate_t(XY_PROBE_FEEDRATE_MM_S)); - TERN_(BD_SENSOR, return bdl.read()); + #if ENABLED(BD_SENSOR) + return current_position.z - bdl.read(); // Difference between Z-home-relative Z and sensor reading + #endif float measured_z = NAN; if (!deploy()) { From 98ee3fc2b5b3bfef9a29aaccddcefb7dae60daa1 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Fri, 26 Aug 2022 10:51:11 +1200 Subject: [PATCH 025/243] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20PID=20debug=20outp?= =?UTF-8?q?ut=20(#24647)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/module/temperature.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index ecd95b5e8f3c..c8e69e701078 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -1374,13 +1374,13 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { FORCE_INLINE void debug(const_celsius_float_t c, const_float_t pid_out, FSTR_P const name=nullptr, const int8_t index=-1) { if (TERN0(HAS_PID_DEBUG, thermalManager.pid_debug_flag)) { SERIAL_ECHO_START(); - if (name) SERIAL_ECHOLNF(name); + if (name) SERIAL_ECHOF(name); if (index >= 0) SERIAL_ECHO(index); SERIAL_ECHOLNPGM( STR_PID_DEBUG_INPUT, c, STR_PID_DEBUG_OUTPUT, pid_out #if DISABLED(PID_OPENLOOP) - , "pTerm", work_pid.Kp, "iTerm", work_pid.Ki, "dTerm", work_pid.Kd + , " pTerm ", work_pid.Kp, " iTerm ", work_pid.Ki, " dTerm ", work_pid.Kd #endif ); } From 27bea5602588c51862b788344c264f10a2486345 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Fri, 26 Aug 2022 11:07:41 +1200 Subject: [PATCH 026/243] =?UTF-8?q?=F0=9F=94=A7=20Fix=20Auto-Fan=20/=20Con?= =?UTF-8?q?troller-Fan=20pin=20conflict=20check=20(#24648)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/SanityCheck.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 388303522cfc..ea39aa1b7020 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2197,14 +2197,22 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #if ENABLED(USE_CONTROLLER_FAN) #if !HAS_CONTROLLER_FAN #error "USE_CONTROLLER_FAN requires a CONTROLLER_FAN_PIN. Define in Configuration_adv.h." - #elif E0_AUTO_FAN_PIN == CONTROLLER_FAN_PIN + #elif PIN_EXISTS(E0_AUTO_FAN) && E0_AUTO_FAN_PIN == CONTROLLER_FAN_PIN #error "You cannot set E0_AUTO_FAN_PIN equal to CONTROLLER_FAN_PIN." - #elif E1_AUTO_FAN_PIN == CONTROLLER_FAN_PIN + #elif PIN_EXISTS(E1_AUTO_FAN) && E1_AUTO_FAN_PIN == CONTROLLER_FAN_PIN #error "You cannot set E1_AUTO_FAN_PIN equal to CONTROLLER_FAN_PIN." - #elif E2_AUTO_FAN_PIN == CONTROLLER_FAN_PIN + #elif PIN_EXISTS(E2_AUTO_FAN) && E2_AUTO_FAN_PIN == CONTROLLER_FAN_PIN #error "You cannot set E2_AUTO_FAN_PIN equal to CONTROLLER_FAN_PIN." - #elif E3_AUTO_FAN_PIN == CONTROLLER_FAN_PIN + #elif PIN_EXISTS(E3_AUTO_FAN) && E3_AUTO_FAN_PIN == CONTROLLER_FAN_PIN #error "You cannot set E3_AUTO_FAN_PIN equal to CONTROLLER_FAN_PIN." + #elif PIN_EXISTS(E4_AUTO_FAN) && E4_AUTO_FAN_PIN == CONTROLLER_FAN_PIN + #error "You cannot set E4_AUTO_FAN_PIN equal to CONTROLLER_FAN_PIN." + #elif PIN_EXISTS(E5_AUTO_FAN) && E5_AUTO_FAN_PIN == CONTROLLER_FAN_PIN + #error "You cannot set E5_AUTO_FAN_PIN equal to CONTROLLER_FAN_PIN." + #elif PIN_EXISTS(E6_AUTO_FAN) && E6_AUTO_FAN_PIN == CONTROLLER_FAN_PIN + #error "You cannot set E6_AUTO_FAN_PIN equal to CONTROLLER_FAN_PIN." + #elif PIN_EXISTS(E7_AUTO_FAN) && E7_AUTO_FAN_PIN == CONTROLLER_FAN_PIN + #error "You cannot set E7_AUTO_FAN_PIN equal to CONTROLLER_FAN_PIN." #endif #endif From d140be0281b9903e4759e3bfadecaa0979cdbc09 Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Thu, 25 Aug 2022 16:14:50 -0700 Subject: [PATCH 027/243] =?UTF-8?q?=F0=9F=9A=B8=20Up=20to=2010=20Preheat?= =?UTF-8?q?=20Constants=20(#24636)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration.h | 2 +- Marlin/src/inc/Conditionals_post.h | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 876267af7039..69ce84944046 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -2205,7 +2205,7 @@ // @section temperature // -// Preheat Constants - Up to 6 are supported without changes +// Preheat Constants - Up to 10 are supported without changes // #define PREHEAT_1_LABEL "PLA" #define PREHEAT_1_TEMP_HOTEND 180 diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index ea6c1f93bf8f..8375ac661c45 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -3306,7 +3306,15 @@ #endif #if HAS_TEMPERATURE && ANY(HAS_MARLINUI_MENU, HAS_DWIN_E3V2, HAS_DGUS_LCD_CLASSIC) - #ifdef PREHEAT_6_LABEL + #ifdef PREHEAT_10_LABEL + #define PREHEAT_COUNT 10 + #elif defined(PREHEAT_9_LABEL) + #define PREHEAT_COUNT 9 + #elif defined(PREHEAT_8_LABEL) + #define PREHEAT_COUNT 8 + #elif defined(PREHEAT_7_LABEL) + #define PREHEAT_COUNT 7 + #elif defined(PREHEAT_6_LABEL) #define PREHEAT_COUNT 6 #elif defined(PREHEAT_5_LABEL) #define PREHEAT_COUNT 5 From d244389998863aa2d37b0c903aebfcda80930a01 Mon Sep 17 00:00:00 2001 From: Miguel Risco-Castillo Date: Thu, 25 Aug 2022 23:23:54 -0500 Subject: [PATCH 028/243] =?UTF-8?q?=F0=9F=A9=B9=20Constrain=20UBL=20within?= =?UTF-8?q?=20mesh=20bounds=20(#24631)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #24630 --- Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp index 18110c67fa8e..56c48650f1eb 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp @@ -423,10 +423,12 @@ LIMIT(icell.x, 0, GRID_MAX_CELLS_X); LIMIT(icell.y, 0, GRID_MAX_CELLS_Y); - float z_x0y0 = z_values[icell.x ][icell.y ], // z at lower left corner - z_x1y0 = z_values[icell.x+1][icell.y ], // z at upper left corner - z_x0y1 = z_values[icell.x ][icell.y+1], // z at lower right corner - z_x1y1 = z_values[icell.x+1][icell.y+1]; // z at upper right corner + const int8_t ncellx = _MIN(icell.x+1, GRID_MAX_CELLS_X), + ncelly = _MIN(icell.y+1, GRID_MAX_CELLS_Y); + float z_x0y0 = z_values[icell.x][icell.y], // z at lower left corner + z_x1y0 = z_values[ncellx ][icell.y], // z at upper left corner + z_x0y1 = z_values[icell.x][ncelly ], // z at lower right corner + z_x1y1 = z_values[ncellx ][ncelly ]; // z at upper right corner if (isnan(z_x0y0)) z_x0y0 = 0; // ideally activating planner.leveling_active (G29 A) if (isnan(z_x1y0)) z_x1y0 = 0; // should refuse if any invalid mesh points From d8a280bf53a163d08a99e2c518ecd68f6b0be601 Mon Sep 17 00:00:00 2001 From: Lefteris Garyfalakis <46350667+lefterisgar@users.noreply.github.com> Date: Fri, 26 Aug 2022 07:40:31 +0300 Subject: [PATCH 029/243] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20Fix=20LCD=20sleep?= =?UTF-8?q?=20conditional=20(#24685)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/Conditionals_adv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 49b6652587cb..7d3306ffb892 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -647,7 +647,7 @@ #if ALL(HAS_RESUME_CONTINUE, PRINTER_EVENT_LEDS, SDSUPPORT) #define HAS_LEDS_OFF_FLAG 1 #endif -#ifdef DISPLAY_SLEEP_MINUTES || TOUCH_IDLE_SLEEP_MINS +#if DISPLAY_SLEEP_MINUTES || TOUCH_IDLE_SLEEP_MINS #define HAS_DISPLAY_SLEEP 1 #endif #if HAS_DISPLAY_SLEEP || LCD_BACKLIGHT_TIMEOUT_MINS From 9313c2fd18ef6255437e7ae3b0d68d0349242d00 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 25 Aug 2022 23:45:07 -0500 Subject: [PATCH 030/243] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20Fix=20http://=20li?= =?UTF-8?q?nks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/NATIVE_SIM/fastio.h | 2 +- Marlin/src/module/thermistor/thermistor_504.h | 2 +- Marlin/src/module/thermistor/thermistor_505.h | 2 +- Marlin/src/pins/sanguino/pins_ZMIB_V2.h | 2 +- Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h | 2 +- Marlin/src/pins/stm32f4/pins_ARTILLERY_RUBY.h | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Marlin/src/HAL/NATIVE_SIM/fastio.h b/Marlin/src/HAL/NATIVE_SIM/fastio.h index de8013b1e542..f501afdbaa4e 100644 --- a/Marlin/src/HAL/NATIVE_SIM/fastio.h +++ b/Marlin/src/HAL/NATIVE_SIM/fastio.h @@ -44,7 +44,7 @@ * * Now you can simply SET_OUTPUT(STEP); WRITE(STEP, HIGH); WRITE(STEP, LOW); * - * Why double up on these macros? see http://gcc.gnu.org/onlinedocs/cpp/Stringification.html + * Why double up on these macros? see https://gcc.gnu.org/onlinedocs/cpp/Stringification.html */ /// Read a pin diff --git a/Marlin/src/module/thermistor/thermistor_504.h b/Marlin/src/module/thermistor/thermistor_504.h index 61ce3ae1358c..0724e49b9d74 100644 --- a/Marlin/src/module/thermistor/thermistor_504.h +++ b/Marlin/src/module/thermistor/thermistor_504.h @@ -16,7 +16,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . * */ #pragma once diff --git a/Marlin/src/module/thermistor/thermistor_505.h b/Marlin/src/module/thermistor/thermistor_505.h index 6c94b0e1b456..1377b43d2401 100644 --- a/Marlin/src/module/thermistor/thermistor_505.h +++ b/Marlin/src/module/thermistor/thermistor_505.h @@ -16,7 +16,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . * */ #pragma once diff --git a/Marlin/src/pins/sanguino/pins_ZMIB_V2.h b/Marlin/src/pins/sanguino/pins_ZMIB_V2.h index 4e8731c1cbf9..aa3ce556d16e 100644 --- a/Marlin/src/pins/sanguino/pins_ZMIB_V2.h +++ b/Marlin/src/pins/sanguino/pins_ZMIB_V2.h @@ -36,7 +36,7 @@ * If you don't have a chip programmer you can use a spare Arduino plus a few * electronic components to write the bootloader. * - * See http://www.instructables.com/id/Burn-Arduino-Bootloader-with-Arduino-MEGA/ + * See https://www.instructables.com/Burn-Arduino-Bootloader-with-Arduino-MEGA/ */ /** diff --git a/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h b/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h index 4b5d38e8c544..646638dae2f5 100644 --- a/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h +++ b/Marlin/src/pins/stm32f1/pins_GTM32_PRO_VB.h @@ -23,7 +23,7 @@ /** * Geeetech GTM32 Pro VB board pin assignments - * http://www.geeetech.com/wiki/index.php/File:Hardware_GTM32_PRO_VB.pdf + * https://www.geeetech.com/wiki/index.php/File:Hardware_GTM32_PRO_VB.pdf * * Also applies to GTM32 Pro VD */ diff --git a/Marlin/src/pins/stm32f4/pins_ARTILLERY_RUBY.h b/Marlin/src/pins/stm32f4/pins_ARTILLERY_RUBY.h index 47d009c5a61e..7413b9b0645a 100644 --- a/Marlin/src/pins/stm32f4/pins_ARTILLERY_RUBY.h +++ b/Marlin/src/pins/stm32f4/pins_ARTILLERY_RUBY.h @@ -16,7 +16,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . * */ #pragma once From d5e9b25a3121724556ce231967c3e1069afa126b Mon Sep 17 00:00:00 2001 From: EvilGremlin <22657714+EvilGremlin@users.noreply.github.com> Date: Tue, 30 Aug 2022 02:52:02 +0300 Subject: [PATCH 031/243] =?UTF-8?q?=F0=9F=90=9B=20Fix=20back=20button=20(#?= =?UTF-8?q?24694)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/Conditionals_post.h | 4 ---- Marlin/src/lcd/menu/menu_item.h | 2 +- Marlin/src/lcd/menu/menu_main.cpp | 29 ++++++++++++++++++----------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 8375ac661c45..010cb7933021 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -3769,10 +3769,6 @@ #define HAS_ROTARY_ENCODER 1 #endif -#if DISABLED(DISABLE_ENCODER) && ANY(HAS_ROTARY_ENCODER, HAS_ADC_BUTTONS) && ANY(TFT_CLASSIC_UI, TFT_COLOR_UI) - #define HAS_BACK_ITEM 1 -#endif - #if PIN_EXISTS(SAFE_POWER) && DISABLED(DISABLE_DRIVER_SAFE_POWER_PROTECT) #define HAS_DRIVER_SAFE_POWER_PROTECT 1 #endif diff --git a/Marlin/src/lcd/menu/menu_item.h b/Marlin/src/lcd/menu/menu_item.h index 7c81e3dd39bd..f6b406a15d21 100644 --- a/Marlin/src/lcd/menu/menu_item.h +++ b/Marlin/src/lcd/menu/menu_item.h @@ -402,7 +402,7 @@ class MenuItem_bool : public MenuEditItemBase { // Predefined menu item types // -#if HAS_BACK_ITEM +#if DISABLED(DISABLE_ENCODER) #define BACK_ITEM_F(FLABEL) MENU_ITEM_F(back, FLABEL) #define BACK_ITEM(LABEL) MENU_ITEM(back, LABEL) #else diff --git a/Marlin/src/lcd/menu/menu_main.cpp b/Marlin/src/lcd/menu/menu_main.cpp index bd1670388589..8c8c4758b73d 100644 --- a/Marlin/src/lcd/menu/menu_main.cpp +++ b/Marlin/src/lcd/menu/menu_main.cpp @@ -222,6 +222,16 @@ void menu_configuration(); #endif // CUSTOM_MENU_MAIN +#if ENABLED(ADVANCED_PAUSE_FEATURE) + // This menu item is last with an encoder. Otherwise, somewhere in the middle. + #if E_STEPPERS == 1 && DISABLED(FILAMENT_LOAD_UNLOAD_GCODES) + #define FILAMENT_CHANGE_ITEM() YESNO_ITEM(MSG_FILAMENTCHANGE, menu_change_filament, nullptr, \ + GET_TEXT_F(MSG_FILAMENTCHANGE), (const char *)nullptr, F("?")) + #else + #define FILAMENT_CHANGE_ITEM() SUBMENU(MSG_FILAMENTCHANGE, menu_change_filament) + #endif +#endif + void menu_main() { const bool busy = printingIsActive() #if ENABLED(SDSUPPORT) @@ -317,6 +327,10 @@ void menu_main() { SUBMENU(MSG_MOTION, menu_motion); } + #if BOTH(ADVANCED_PAUSE_FEATURE, DISABLE_ENCODER) + FILAMENT_CHANGE_ITEM(); + #endif + #if HAS_CUTTER SUBMENU(MSG_CUTTER(MENU), STICKY_SCREEN(menu_spindle_laser)); #endif @@ -325,17 +339,6 @@ void menu_main() { SUBMENU(MSG_TEMPERATURE, menu_temperature); #endif - #if ENABLED(ADVANCED_PAUSE_FEATURE) - #if E_STEPPERS == 1 && DISABLED(FILAMENT_LOAD_UNLOAD_GCODES) - YESNO_ITEM(MSG_FILAMENTCHANGE, - menu_change_filament, nullptr, - GET_TEXT_F(MSG_FILAMENTCHANGE), (const char *)nullptr, F("?") - ); - #else - SUBMENU(MSG_FILAMENTCHANGE, menu_change_filament); - #endif - #endif - #if HAS_POWER_MONITOR SUBMENU(MSG_POWER_MONITOR, menu_power_monitor); #endif @@ -458,6 +461,10 @@ void menu_main() { }); #endif + #if ENABLED(ADVANCED_PAUSE_FEATURE) && DISABLED(DISABLE_ENCODER) + FILAMENT_CHANGE_ITEM(); + #endif + END_MENU(); } From 3c6b3e5af41202be8781645bb07cc8cee9206b49 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 29 Aug 2022 19:23:53 -0500 Subject: [PATCH 032/243] =?UTF-8?q?=F0=9F=94=96=20=20Config=20version=2002?= =?UTF-8?q?010200?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration.h | 2 +- Marlin/Configuration_adv.h | 2 +- Marlin/src/inc/Version.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 69ce84944046..0b8691f8551f 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -35,7 +35,7 @@ * * Advanced settings can be found in Configuration_adv.h */ -#define CONFIGURATION_H_VERSION 02010100 +#define CONFIGURATION_H_VERSION 02010200 //=========================================================================== //============================= Getting Started ============================= diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 68cf81627f08..55512e64fbf0 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -30,7 +30,7 @@ * * Basic settings can be found in Configuration.h */ -#define CONFIGURATION_ADV_H_VERSION 02010100 +#define CONFIGURATION_ADV_H_VERSION 02010200 // @section develop diff --git a/Marlin/src/inc/Version.h b/Marlin/src/inc/Version.h index 7fcaee1345f6..5c4f8ec31631 100644 --- a/Marlin/src/inc/Version.h +++ b/Marlin/src/inc/Version.h @@ -52,7 +52,7 @@ * to alert users to major changes. */ -#define MARLIN_HEX_VERSION 02010100 +#define MARLIN_HEX_VERSION 02010200 #ifndef REQUIRED_CONFIGURATION_H_VERSION #define REQUIRED_CONFIGURATION_H_VERSION MARLIN_HEX_VERSION #endif From 7d8d2e2c587e951c944eb7e399767dbc8432e62d Mon Sep 17 00:00:00 2001 From: Ruedi Steinmann Date: Fri, 9 Sep 2022 22:33:54 +0200 Subject: [PATCH 033/243] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20a=20BUZZ=20(#24740?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/spindle_laser.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Marlin/src/feature/spindle_laser.h b/Marlin/src/feature/spindle_laser.h index 0a99585bc099..a49e5611a4a9 100644 --- a/Marlin/src/feature/spindle_laser.h +++ b/Marlin/src/feature/spindle_laser.h @@ -30,9 +30,7 @@ #include "spindle_laser_types.h" -#if HAS_BEEPER - #include "../libs/buzzer.h" -#endif +#include "../libs/buzzer.h" // Inline laser power #include "../module/planner.h" From e350acb360a7d6645bf2b3938ac82720c1475de2 Mon Sep 17 00:00:00 2001 From: Bob Kuhn Date: Thu, 22 Sep 2022 12:54:49 -0500 Subject: [PATCH 034/243] =?UTF-8?q?=F0=9F=90=9B=20Fix=20UBL=20regression?= =?UTF-8?q?=20(#24622)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix regression from #24188 --- Marlin/src/feature/bedlevel/bedlevel.cpp | 6 +++--- Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Marlin/src/feature/bedlevel/bedlevel.cpp b/Marlin/src/feature/bedlevel/bedlevel.cpp index 2207884c3637..1658b536d3ec 100644 --- a/Marlin/src/feature/bedlevel/bedlevel.cpp +++ b/Marlin/src/feature/bedlevel/bedlevel.cpp @@ -75,9 +75,9 @@ void set_bed_leveling_enabled(const bool enable/*=true*/) { planner.synchronize(); // Get the corrected leveled / unleveled position - planner.apply_modifiers(current_position); // Physical position with all modifiers - planner.leveling_active ^= true; // Toggle leveling between apply and unapply - planner.unapply_modifiers(current_position); // Logical position with modifiers removed + planner.apply_modifiers(current_position, true); // Physical position with all modifiers + planner.leveling_active ^= true; // Toggle leveling between apply and unapply + planner.unapply_modifiers(current_position, true); // Logical position with modifiers removed sync_plan_position(); _report_leveling(); diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp index f1e88006ff82..d6cb0b762ff2 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp @@ -407,7 +407,7 @@ void unified_bed_leveling::G29() { z_values[x][x2] += 9.999f; // We want the altered line several mesh points thick #if ENABLED(EXTENSIBLE_UI) ExtUI::onMeshUpdate(x, x, z_values[x][x]); - ExtUI::onMeshUpdate(x, (x2), z_values[x][x2]); + ExtUI::onMeshUpdate(x, x2, z_values[x][x2]); #endif } break; From 033bca17737964ebb95c76a69e7e2005738f9c35 Mon Sep 17 00:00:00 2001 From: EvilGremlin <22657714+EvilGremlin@users.noreply.github.com> Date: Fri, 2 Sep 2022 05:47:37 +0300 Subject: [PATCH 035/243] =?UTF-8?q?=F0=9F=94=A8=20Native=20USB=20modified?= =?UTF-8?q?=20env=20followup=20(#24669)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to #24619 --- Marlin/src/pins/pins.h | 2 +- buildroot/tests/mks_robin_nano_v1_3_f4_usbmod | 6 +++--- ...ks_robin_nano_v1_2_usbmod => mks_robin_nano_v1v2_usbmod} | 6 +++--- ini/stm32f1.ini | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) rename buildroot/tests/{mks_robin_nano_v1_2_usbmod => mks_robin_nano_v1v2_usbmod} (51%) diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 1bd58487e75a..14d16c5415ec 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -512,7 +512,7 @@ #elif MB(MKS_ROBIN_MINI) #include "stm32f1/pins_MKS_ROBIN_MINI.h" // STM32F1 env:mks_robin_mini env:mks_robin_mini_maple #elif MB(MKS_ROBIN_NANO) - #include "stm32f1/pins_MKS_ROBIN_NANO.h" // STM32F1 env:mks_robin_nano_v1v2 env:mks_robin_nano_v1v2_maple env:mks_robin_nano_v1_2_usbmod + #include "stm32f1/pins_MKS_ROBIN_NANO.h" // STM32F1 env:mks_robin_nano_v1v2 env:mks_robin_nano_v1v2_maple env:mks_robin_nano_v1v2_usbmod #elif MB(MKS_ROBIN_NANO_V2) #include "stm32f1/pins_MKS_ROBIN_NANO_V2.h" // STM32F1 env:mks_robin_nano_v1v2 env:mks_robin_nano3_v1v2_maple #elif MB(MKS_ROBIN_LITE) diff --git a/buildroot/tests/mks_robin_nano_v1_3_f4_usbmod b/buildroot/tests/mks_robin_nano_v1_3_f4_usbmod index 5213eb84f796..01a47525d12d 100755 --- a/buildroot/tests/mks_robin_nano_v1_3_f4_usbmod +++ b/buildroot/tests/mks_robin_nano_v1_3_f4_usbmod @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Build tests for MKS Robin nano +# Build tests for MKS Robin nano v1.3 with native USB modification # (STM32F4 genericSTM32F407VE) # @@ -8,12 +8,12 @@ set -e # -# MKS/ZNP Robin nano v1.3 Emulated DOGM FSMC and native USB mod +# MKS/ZNP Robin nano v1.3 with Emulated DOGM FSMC and native USB mod # use_example_configs Mks/Robin opt_add USB_MOD opt_set MOTHERBOARD BOARD_MKS_ROBIN_NANO_V1_3_F4 SERIAL_PORT -1 -exec_test $1 $2 "MKS/ZNP Robin nano v1.3 Emulated DOGM FSMC and native USB mod" "$3" +exec_test $1 $2 "MKS/ZNP Robin nano v1.3 with Emulated DOGM FSMC (native USB mod)" "$3" # cleanup restore_configs diff --git a/buildroot/tests/mks_robin_nano_v1_2_usbmod b/buildroot/tests/mks_robin_nano_v1v2_usbmod similarity index 51% rename from buildroot/tests/mks_robin_nano_v1_2_usbmod rename to buildroot/tests/mks_robin_nano_v1v2_usbmod index a3ec1d4075d9..31f04c9a947a 100755 --- a/buildroot/tests/mks_robin_nano_v1_2_usbmod +++ b/buildroot/tests/mks_robin_nano_v1v2_usbmod @@ -1,6 +1,6 @@ #!/usr/bin/env bash # -# Build tests for MKS Robin nano +# Build tests for MKS Robin nano V1.2 and V2 with native USB modification # (STM32F1 genericSTM32F103VE) # @@ -8,12 +8,12 @@ set -e # -# MKS/ZNP Robin nano v1.2 Emulated DOGM FSMC and native USB mod +# MKS/ZNP Robin nano v1.2 with Emulated DOGM FSMC # use_example_configs Mks/Robin opt_add USB_MOD opt_set MOTHERBOARD BOARD_MKS_ROBIN_NANO SERIAL_PORT -1 -exec_test $1 $2 "MKS/ZNP Robin nano v1.2 Emulated DOGM FSMC and native USB mod" "$3" +exec_test $1 $2 "MKS/ZNP Robin nano v1.2 with Emulated DOGM FSMC (native USB mod)" "$3" # cleanup restore_configs diff --git a/ini/stm32f1.ini b/ini/stm32f1.ini index f06eef459472..49dac9e47664 100644 --- a/ini/stm32f1.ini +++ b/ini/stm32f1.ini @@ -238,9 +238,9 @@ build_unflags = ${stm32_variant.build_unflags} -DUSBCON -DUSBD_USE_CDC # -# MKS/ZNP Robin Nano v1.2 with native USB modification +# MKS/ZNP Robin Nano V1.2 and V2 with native USB modification # -[env:mks_robin_nano_v1_2_usbmod] +[env:mks_robin_nano_v1v2_usbmod] extends = mks_robin_nano_v1v2_common build_flags = ${common_stm32.build_flags} -DMCU_STM32F103VE -DSS_TIMER=4 From dc65e299fa2860c254b113a160f7c41c1220558d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 3 Sep 2022 18:21:23 -0500 Subject: [PATCH 036/243] =?UTF-8?q?=F0=9F=93=9D=20Format=20some=20comments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 55512e64fbf0..21d0bbd3d721 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -481,18 +481,22 @@ // before a min_temp_error is triggered. (Shouldn't be more than 10.) //#define MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED 0 -// The number of milliseconds a hotend will preheat before starting to check -// the temperature. This value should NOT be set to the time it takes the -// hot end to reach the target temperature, but the time it takes to reach -// the minimum temperature your thermistor can read. The lower the better/safer. -// This shouldn't need to be more than 30 seconds (30000) +/** + * The number of milliseconds a hotend will preheat before starting to check + * the temperature. This value should NOT be set to the time it takes the + * hot end to reach the target temperature, but the time it takes to reach + * the minimum temperature your thermistor can read. The lower the better/safer. + * This shouldn't need to be more than 30 seconds (30000) + */ //#define MILLISECONDS_PREHEAT_TIME 0 // @section extruder -// Extruder runout prevention. -// If the machine is idle and the temperature over MINTEMP -// then extrude some filament every couple of SECONDS. +/** + * Extruder runout prevention. + * If the machine is idle and the temperature over MINTEMP + * then extrude some filament every couple of SECONDS. + */ //#define EXTRUDER_RUNOUT_PREVENT #if ENABLED(EXTRUDER_RUNOUT_PREVENT) #define EXTRUDER_RUNOUT_MINTEMP 190 From 1a2e591d03ff3648a5913e1a0a6a672cfd4bba81 Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Sat, 3 Sep 2022 16:48:21 -0700 Subject: [PATCH 037/243] =?UTF-8?q?=F0=9F=94=A8=20Update=20SKR=203=20env?= =?UTF-8?q?=20(#24711)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ini/stm32h7.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ini/stm32h7.ini b/ini/stm32h7.ini index fb898d1b72b1..9b43200ff0bf 100644 --- a/ini/stm32h7.ini +++ b/ini/stm32h7.ini @@ -44,8 +44,8 @@ debug_tool = cmsis-dap # [env:STM32H743Vx_btt] extends = stm32_variant -platform = ststm32@~14.1.0 -platform_packages = framework-arduinoststm32@https://github.com/stm32duino/Arduino_Core_STM32/archive/main.zip +platform = ststm32@~15.4.1 +platform_packages = framework-arduinoststm32@~4.20200.220530 board = marlin_STM32H743Vx board_build.offset = 0x20000 board_upload.offset_address = 0x08020000 From 2f1b89bd1f4ae88e9b1b9e62ea567ac3a4d1178a Mon Sep 17 00:00:00 2001 From: Stephen Hawes Date: Sat, 3 Sep 2022 21:55:37 -0400 Subject: [PATCH 038/243] =?UTF-8?q?=E2=9C=A8=20Opulo=20LumenPnP=20REV04=20?= =?UTF-8?q?(#24718)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/boards.h | 1 + Marlin/src/pins/pins.h | 2 + .../src/pins/stm32f4/pins_OPULO_LUMEN_REV4.h | 206 ++++++++++++++++++ .../boards/marlin_opulo_lumen_rev4.json | 51 +++++ ini/stm32f4.ini | 11 + 5 files changed, 271 insertions(+) create mode 100644 Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV4.h create mode 100644 buildroot/share/PlatformIO/boards/marlin_opulo_lumen_rev4.json diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index 4e3227ba58a3..272a82f3b766 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -421,6 +421,7 @@ #define BOARD_ARTILLERY_RUBY 4238 // Artillery Ruby (STM32F401RC) #define BOARD_FYSETC_SPIDER_V2_2 4239 // FYSETC Spider V2.2 (STM32F446VE) #define BOARD_CREALITY_V24S1_301F4 4240 // Creality v2.4.S1_301F4 (STM32F401RC) as found in the Ender-3 S1 F4 +#define BOARD_OPULO_LUMEN_REV4 4241 // Opulo Lumen PnP Controller REV4 (STM32F407VE / STM32F407VG) // // ARM Cortex M7 diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 14d16c5415ec..e2f6ea292476 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -701,6 +701,8 @@ #include "stm32f4/pins_ARTILLERY_RUBY.h" // STM32F4 env:Artillery_Ruby #elif MB(CREALITY_V24S1_301F4) #include "stm32f4/pins_CREALITY_V24S1_301F4.h" // STM32F4 env:STM32F401RC_creality env:STM32F401RC_creality_jlink env:STM32F401RC_creality_stlink +#elif MB(OPULO_LUMEN_REV4) + #include "stm32f4/pins_OPULO_LUMEN_REV4.h" // STM32F4 env:Opulo_Lumen_REV4 // // ARM Cortex M7 diff --git a/Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV4.h b/Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV4.h new file mode 100644 index 000000000000..d16d7b200bd6 --- /dev/null +++ b/Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV4.h @@ -0,0 +1,206 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * STM32F407VET6 on Opulo Lumen PnP Rev3 + * Website - https://opulo.io/ + */ + +#define ALLOW_STM32DUINO +#include "env_validate.h" + +#define BOARD_INFO_NAME "LumenPnP Motherboard REV04" +#define DEFAULT_MACHINE_NAME "LumenPnP" + +/** + * By default, the extra stepper motor configuration is: + * I = Left Head + * J = Right Head + * K = Auxiliary (Conveyor belt) + */ + +#define SRAM_EEPROM_EMULATION +#define MARLIN_EEPROM_SIZE 0x2000 // 8K + +// I2C MCP3426 (16-Bit, 240SPS, dual-channel ADC) +#define HAS_MCP3426_ADC + +// +// Servos +// +#define SERVO0_PIN PB10 +#define SERVO1_PIN PB11 + +// +// Limit Switches +// +#define X_STOP_PIN PC6 +#define Y_STOP_PIN PD15 +#define Z_STOP_PIN PD14 + +// None of these require limit switches by default, so we leave these commented +// here for your reference. +//#define I_MIN_PIN PA8 +//#define I_MAX_PIN PA8 +//#define J_MIN_PIN PD13 +//#define J_MAX_PIN PD13 +//#define K_MIN_PIN PC9 +//#define K_MAX_PIN PC9 + +// +// Steppers +// +#define X_STEP_PIN PB15 +#define X_DIR_PIN PB14 +#define X_ENABLE_PIN PD9 + +#define Y_STEP_PIN PE15 +#define Y_DIR_PIN PE14 +#define Y_ENABLE_PIN PB13 + +#define Z_STEP_PIN PE7 +#define Z_DIR_PIN PB1 +#define Z_ENABLE_PIN PE9 + +#define I_STEP_PIN PC4 +#define I_DIR_PIN PA4 +#define I_ENABLE_PIN PB0 + +#define J_STEP_PIN PE11 +#define J_DIR_PIN PE10 +#define J_ENABLE_PIN PE13 + +#define K_STEP_PIN PD6 +#define K_DIR_PIN PD7 +#define K_ENABLE_PIN PA3 + +#if HAS_TMC_SPI + /** + * Make sure to configure the jumpers on the back side of the Mobo according to + * this diagram: https://github.com/MarlinFirmware/Marlin/pull/23851 + */ + #error "SPI drivers require a custom jumper configuration, see comment above! Comment out this line to continue." + + #if AXIS_HAS_SPI(X) + #define X_CS_PIN PD8 + #endif + #if AXIS_HAS_SPI(Y) + #define Y_CS_PIN PB12 + #endif + #if AXIS_HAS_SPI(Z) + #define Z_CS_PIN PE8 + #endif + #if AXIS_HAS_SPI(I) + #define I_CS_PIN PC5 + #endif + #if AXIS_HAS_SPI(J) + #define J_CS_PIN PE12 + #endif + #if AXIS_HAS_SPI(K) + #define K_CS_PIN PA2 + #endif + +#elif HAS_TMC_UART + + #define X_SERIAL_TX_PIN PD8 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PB12 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PE8 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define I_SERIAL_TX_PIN PC5 + #define I_SERIAL_RX_PIN I_SERIAL_TX_PIN + + #define J_SERIAL_TX_PIN PE12 + #define J_SERIAL_RX_PIN J_SERIAL_TX_PIN + + #define K_SERIAL_TX_PIN PA2 + #define K_SERIAL_RX_PIN K_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 + +#endif + +// +// Heaters / Fans +// +#define FAN_PIN PE2 +#define FAN1_PIN PE3 +#define FAN2_PIN PE4 +#define FAN3_PIN PE5 + +#define FAN_SOFT_PWM_REQUIRED + +// +// Neopixel +// +#define NEOPIXEL_PIN PC7 +#define NEOPIXEL2_PIN PC8 + +// +// SPI +// +#define MISO_PIN PB4 +#define MOSI_PIN PB5 +#define SCK_PIN PB3 + +#define TMC_SW_MISO MISO_PIN +#define TMC_SW_MOSI MOSI_PIN +#define TMC_SW_SCK SCK_PIN + +// +// I2C +// +#define I2C_SDA_PIN PB7 +#define I2C_SCL_PIN PB6 + +/** + * The index mobo rev03 has 3 aux ports. We define them here so they may be used + * in other places and to make sure someone doesn't have to go look up the pinout + * in the board files. Each 12 pin aux port has this pinout: + * + * VDC 1 2 GND + * 3.3V 3 4 SCL (I2C_SCL_PIN) + * PWM1 5 6 SDA (I2C_SDA_PIN) + * PWM2 7 8 CIPO (MISO_PIN) + * A1 9 10 COPI (MOSI_PIN) + * A2 11 12 SCK (SCK_PIN) + */ +#define LUMEN_AUX1_PWM1 PA15 +#define LUMEN_AUX1_PWM2 PA5 +#define LUMEN_AUX1_A1 PC0 +#define LUMEN_AUX1_A2 PC1 + +#define LUMEN_AUX2_PWM1 PA6 +#define LUMEN_AUX2_PWM2 PA7 +#define LUMEN_AUX2_A1 PC2 +#define LUMEN_AUX2_A2 PC3 + +#define LUMEN_AUX3_PWM1 PB8 +#define LUMEN_AUX3_PWM2 PB9 +#define LUMEN_AUX3_A1 PA0 +#define LUMEN_AUX3_A2 PA1 diff --git a/buildroot/share/PlatformIO/boards/marlin_opulo_lumen_rev4.json b/buildroot/share/PlatformIO/boards/marlin_opulo_lumen_rev4.json new file mode 100644 index 000000000000..ef5ebfa56066 --- /dev/null +++ b/buildroot/share/PlatformIO/boards/marlin_opulo_lumen_rev4.json @@ -0,0 +1,51 @@ +{ + "build": { + "core": "stm32", + "cpu": "cortex-m4", + "extra_flags": "-DSTM32F407xx", + "f_cpu": "168000000L", + "hwids": [ + [ + "0x0483", + "0xdf11" + ], + [ + "0x1EAF", + "0x0003" + ], + [ + "0x0483", + "0x3748" + ] + ], + "mcu": "stm32f407vet6", + "variant": "MARLIN_F407VE" + }, + "debug": { + "jlink_device": "STM32F407VE", + "openocd_target": "stm32f4x", + "svd_path": "STM32F40x.svd" + }, + "frameworks": [ + "arduino", + "stm32cube" + ], + "name": "STM32F407VE (192k RAM. 512k Flash)", + "upload": { + "disable_flushing": false, + "maximum_ram_size": 131072, + "maximum_size": 524288, + "protocol": "dfu", + "protocols": [ + "stlink", + "dfu", + "jlink", + "blackmagic" + ], + "require_upload_port": true, + "use_1200bps_touch": false, + "wait_for_upload_port": false + }, + "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32f407ve.html", + "vendor": "Generic" +} diff --git a/ini/stm32f4.ini b/ini/stm32f4.ini index 0857dec39819..2c5aedbfe004 100644 --- a/ini/stm32f4.ini +++ b/ini/stm32f4.ini @@ -93,6 +93,17 @@ build_flags = ${stm32_variant.build_flags} -DUSBD_USE_CDC_COMPOSITE -DUSE_USB_FS extra_scripts = ${stm32_variant.extra_scripts} +# +# STM32F407VET6 Opulo Lumen REV4 +# +[env:Opulo_Lumen_REV4] +extends = stm32_variant +board = marlin_opulo_lumen_rev4 +build_flags = ${stm32_variant.build_flags} + -DARDUINO_BLACK_F407VE + -DUSBD_USE_CDC_COMPOSITE -DUSE_USB_FS +extra_scripts = ${stm32_variant.extra_scripts} + # # Anet ET4-MB_V1.x/ET4P-MB_V1.x (STM32F407VGT6 ARM Cortex-M4) # From b676b43874c9f851902a0f80a2013bf19d9b0820 Mon Sep 17 00:00:00 2001 From: ButchMonkey Date: Sun, 4 Sep 2022 21:10:22 +0100 Subject: [PATCH 039/243] =?UTF-8?q?=F0=9F=94=A8=20Fix=20configuration.py?= =?UTF-8?q?=20with=20encoding=20UTF-8=20(#24719)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Opening files with Windows-1252 encoding. --- buildroot/share/PlatformIO/scripts/configuration.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/buildroot/share/PlatformIO/scripts/configuration.py b/buildroot/share/PlatformIO/scripts/configuration.py index 93ed12fae66f..64f73d0dcf00 100644 --- a/buildroot/share/PlatformIO/scripts/configuration.py +++ b/buildroot/share/PlatformIO/scripts/configuration.py @@ -10,7 +10,7 @@ def blab(str,level=1): if verbose >= level: print(f"[config] {str}") def config_path(cpath): - return Path("Marlin", cpath) + return Path("Marlin", cpath, encoding='utf-8') # Apply a single name = on/off ; name = value ; etc. # TODO: Limit to the given (optional) configuration @@ -23,7 +23,7 @@ def apply_opt(name, val, conf=None): # Find and enable and/or update all matches for file in ("Configuration.h", "Configuration_adv.h"): fullpath = config_path(file) - lines = fullpath.read_text().split('\n') + lines = fullpath.read_text(encoding='utf-8').split('\n') found = False for i in range(len(lines)): line = lines[i] @@ -46,7 +46,7 @@ def apply_opt(name, val, conf=None): # If the option was found, write the modified lines if found: - fullpath.write_text('\n'.join(lines)) + fullpath.write_text('\n'.join(lines), encoding='utf-8') break # If the option didn't appear in either config file, add it @@ -67,7 +67,7 @@ def apply_opt(name, val, conf=None): # Prepend the new option after the first set of #define lines fullpath = config_path("Configuration.h") - with fullpath.open() as f: + with fullpath.open(encoding='utf-8') as f: lines = f.readlines() linenum = 0 gotdef = False @@ -79,7 +79,7 @@ def apply_opt(name, val, conf=None): break linenum += 1 lines.insert(linenum, f"{prefix}#define {added} // Added by config.ini\n") - fullpath.write_text('\n'.join(lines)) + fullpath.write_text('\n'.join(lines), encoding='utf-8') # Fetch configuration files from GitHub given the path. # Return True if any files were fetched. From cc2cc7d08170e4778f1aa76eb38172e1b7dc8978 Mon Sep 17 00:00:00 2001 From: ButchMonkey Date: Mon, 5 Sep 2022 05:48:58 +0100 Subject: [PATCH 040/243] =?UTF-8?q?=F0=9F=94=A8=20Fix=20config.ini=20custo?= =?UTF-8?q?m=20items,=20and=20'all'=20(#24720)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../share/PlatformIO/scripts/configuration.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/buildroot/share/PlatformIO/scripts/configuration.py b/buildroot/share/PlatformIO/scripts/configuration.py index 64f73d0dcf00..aed9fc2f3d02 100644 --- a/buildroot/share/PlatformIO/scripts/configuration.py +++ b/buildroot/share/PlatformIO/scripts/configuration.py @@ -78,8 +78,8 @@ def apply_opt(name, val, conf=None): elif not isdef: break linenum += 1 - lines.insert(linenum, f"{prefix}#define {added} // Added by config.ini\n") - fullpath.write_text('\n'.join(lines), encoding='utf-8') + lines.insert(linenum, f"{prefix}#define {added:30} // Added by config.ini\n") + fullpath.write_text(''.join(lines), encoding='utf-8') # Fetch configuration files from GitHub given the path. # Return True if any files were fetched. @@ -127,7 +127,7 @@ def apply_ini_by_name(cp, sect): iniok = False items = section_items(cp, 'config:base') + section_items(cp, 'config:root') else: - items = cp.items(sect) + items = section_items(cp, sect) for item in items: if iniok or not item[0].startswith('ini_'): @@ -195,8 +195,12 @@ def apply_config_ini(cp): fetch_example(ckey) ckey = 'base' - # Apply keyed sections after external files are done - apply_sections(cp, 'config:' + ckey) + elif ckey == 'all': + apply_sections(cp) + + else: + # Apply keyed sections after external files are done + apply_sections(cp, 'config:' + ckey) if __name__ == "__main__": # From 63507acf98e94ceffa4e82d588d6ec369f2b7646 Mon Sep 17 00:00:00 2001 From: dmitrygribenchuk Date: Mon, 5 Sep 2022 21:19:19 +0300 Subject: [PATCH 041/243] =?UTF-8?q?=F0=9F=94=A8=20Clean=20up=20Python=20im?= =?UTF-8?q?ports=20(#24736)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py | 1 - buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py | 1 - buildroot/share/PlatformIO/scripts/mc-apply.py | 1 - buildroot/share/PlatformIO/scripts/offset_and_rename.py | 2 +- buildroot/share/PlatformIO/scripts/openblt.py | 1 - buildroot/share/PlatformIO/scripts/preflight-checks.py | 2 +- buildroot/share/PlatformIO/scripts/preprocessor.py | 2 +- buildroot/share/dwin/bin/makeIco.py | 1 - buildroot/share/dwin/bin/splitIco.py | 1 - buildroot/share/scripts/gen-tft-image.py | 4 ++-- buildroot/share/vscode/create_custom_upload_command_CDC.py | 2 +- buildroot/share/vscode/create_custom_upload_command_DFU.py | 2 +- 12 files changed, 7 insertions(+), 13 deletions(-) diff --git a/buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py b/buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py index 551f4c63160b..a69520f46d9c 100644 --- a/buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py +++ b/buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py @@ -4,7 +4,6 @@ import pioutil if pioutil.is_pio_build(): - import os Import("env", "projenv") flash_size = 0 diff --git a/buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py b/buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py index c9794702c34a..2cab2ce5c136 100644 --- a/buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py +++ b/buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py @@ -3,7 +3,6 @@ # import pioutil if pioutil.is_pio_build(): - import os from os.path import join from os.path import expandvars Import("env") diff --git a/buildroot/share/PlatformIO/scripts/mc-apply.py b/buildroot/share/PlatformIO/scripts/mc-apply.py index ed0ed795c6b1..b42ba12f7adf 100755 --- a/buildroot/share/PlatformIO/scripts/mc-apply.py +++ b/buildroot/share/PlatformIO/scripts/mc-apply.py @@ -5,7 +5,6 @@ import json import sys import shutil -import re opt_output = '--opt' in sys.argv output_suffix = '.sh' if opt_output else '' if '--bare-output' in sys.argv else '.gen' diff --git a/buildroot/share/PlatformIO/scripts/offset_and_rename.py b/buildroot/share/PlatformIO/scripts/offset_and_rename.py index 6a095210ece3..de14ccbbbf5f 100644 --- a/buildroot/share/PlatformIO/scripts/offset_and_rename.py +++ b/buildroot/share/PlatformIO/scripts/offset_and_rename.py @@ -10,7 +10,7 @@ # import pioutil if pioutil.is_pio_build(): - import sys,marlin + import marlin env = marlin.env board = env.BoardConfig() diff --git a/buildroot/share/PlatformIO/scripts/openblt.py b/buildroot/share/PlatformIO/scripts/openblt.py index 104bd142cac9..6db8727ce4eb 100644 --- a/buildroot/share/PlatformIO/scripts/openblt.py +++ b/buildroot/share/PlatformIO/scripts/openblt.py @@ -3,7 +3,6 @@ # import pioutil if pioutil.is_pio_build(): - import os,sys from os.path import join Import("env") diff --git a/buildroot/share/PlatformIO/scripts/preflight-checks.py b/buildroot/share/PlatformIO/scripts/preflight-checks.py index 56394e17aaa0..16f39368b654 100644 --- a/buildroot/share/PlatformIO/scripts/preflight-checks.py +++ b/buildroot/share/PlatformIO/scripts/preflight-checks.py @@ -5,7 +5,7 @@ import pioutil if pioutil.is_pio_build(): - import os,re,sys + import re,sys from pathlib import Path Import("env") diff --git a/buildroot/share/PlatformIO/scripts/preprocessor.py b/buildroot/share/PlatformIO/scripts/preprocessor.py index ad24ed7be430..b0fec52bfa10 100644 --- a/buildroot/share/PlatformIO/scripts/preprocessor.py +++ b/buildroot/share/PlatformIO/scripts/preprocessor.py @@ -1,7 +1,7 @@ # # preprocessor.py # -import subprocess,re +import subprocess nocache = 1 verbose = 0 diff --git a/buildroot/share/dwin/bin/makeIco.py b/buildroot/share/dwin/bin/makeIco.py index 274082acee87..65e7eb53a58b 100755 --- a/buildroot/share/dwin/bin/makeIco.py +++ b/buildroot/share/dwin/bin/makeIco.py @@ -18,7 +18,6 @@ # along with this program. If not, see . #---------------------------------------------------------------- -import os import os.path import argparse import DWIN_ICO diff --git a/buildroot/share/dwin/bin/splitIco.py b/buildroot/share/dwin/bin/splitIco.py index ce6ba89749c9..a96d1823d22e 100755 --- a/buildroot/share/dwin/bin/splitIco.py +++ b/buildroot/share/dwin/bin/splitIco.py @@ -18,7 +18,6 @@ # along with this program. If not, see . #---------------------------------------------------------------- -import os import os.path import argparse import DWIN_ICO diff --git a/buildroot/share/scripts/gen-tft-image.py b/buildroot/share/scripts/gen-tft-image.py index d89245fea41d..9b7d19493eca 100644 --- a/buildroot/share/scripts/gen-tft-image.py +++ b/buildroot/share/scripts/gen-tft-image.py @@ -22,8 +22,8 @@ # Generate Marlin TFT Images from bitmaps/PNG/JPG -import sys,re,struct -from PIL import Image,ImageDraw +import sys,struct +from PIL import Image def image2bin(image, output_file): if output_file.endswith(('.c', '.cpp')): diff --git a/buildroot/share/vscode/create_custom_upload_command_CDC.py b/buildroot/share/vscode/create_custom_upload_command_CDC.py index 4662dd26cb49..4926faf06a68 100644 --- a/buildroot/share/vscode/create_custom_upload_command_CDC.py +++ b/buildroot/share/vscode/create_custom_upload_command_CDC.py @@ -13,7 +13,7 @@ from __future__ import print_function from __future__ import division -import subprocess,os,sys,platform +import subprocess,os,platform from SCons.Script import DefaultEnvironment current_OS = platform.system() diff --git a/buildroot/share/vscode/create_custom_upload_command_DFU.py b/buildroot/share/vscode/create_custom_upload_command_DFU.py index 562e284e63c2..27c5a34802f8 100644 --- a/buildroot/share/vscode/create_custom_upload_command_DFU.py +++ b/buildroot/share/vscode/create_custom_upload_command_DFU.py @@ -9,7 +9,7 @@ # Will continue on if a COM port isn't found so that the compilation can be done. # -import os,sys +import os from SCons.Script import DefaultEnvironment import platform current_OS = platform.system() From 2828f1d1dbddf908968951af3b09586369dc4135 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 27 Aug 2022 20:12:52 -0500 Subject: [PATCH 042/243] =?UTF-8?q?=F0=9F=94=A8=20Outdent=20py=20string?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildroot/share/PlatformIO/scripts/signature.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildroot/share/PlatformIO/scripts/signature.py b/buildroot/share/PlatformIO/scripts/signature.py index ea878d9a6752..4fc0084e575b 100644 --- a/buildroot/share/PlatformIO/scripts/signature.py +++ b/buildroot/share/PlatformIO/scripts/signature.py @@ -260,7 +260,7 @@ def tryint(key): # Generate a C source file for storing this array with open('Marlin/src/mczip.h','wb') as result_file: result_file.write( - b'#ifndef NO_CONFIGURATION_EMBEDDING_WARNING\n' + b'#ifndef NO_CONFIGURATION_EMBEDDING_WARNING\n' + b' #warning "Generated file \'mc.zip\' is embedded (Define NO_CONFIGURATION_EMBEDDING_WARNING to suppress this warning.)"\n' + b'#endif\n' + b'const unsigned char mc_zip[] PROGMEM = {\n ' From 3a18ba04125dad983d232ef02d045c28a27c5c36 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 13 Sep 2022 13:29:50 -0500 Subject: [PATCH 043/243] =?UTF-8?q?=F0=9F=94=A8=20Fix=20config-labels.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildroot/share/scripts/config-labels.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buildroot/share/scripts/config-labels.py b/buildroot/share/scripts/config-labels.py index 519f7b67ca6d..b721baf441fb 100755 --- a/buildroot/share/scripts/config-labels.py +++ b/buildroot/share/scripts/config-labels.py @@ -130,7 +130,7 @@ def process_file(subdir: str, filename: str): # Note: no need to create output dirs, as the initial copy_tree # will do that. - print(' writing ' + outfilepath) + print(' writing ' + str(outfilepath)) try: # Preserve unicode chars; Avoid CR-LF on Windows. with outfilepath.open("w", encoding="utf-8", newline='\n') as outfile: @@ -140,7 +140,7 @@ def process_file(subdir: str, filename: str): print('Failed to write file: ' + str(e) ) raise Exception else: - print(' no change for ' + outfilepath) + print(' no change for ' + str(outfilepath)) #---------- def main(): From 8a8218a8f22f3942bbec3f22f43529b3c489603a Mon Sep 17 00:00:00 2001 From: JoaquinBerrios Date: Tue, 6 Sep 2022 01:39:02 -0500 Subject: [PATCH 044/243] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20BTT=20SKR=20V3.0?= =?UTF-8?q?=20/=20EZ=20=3D=20480MHz=20(#24721)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlatformIO/boards/marlin_STM32H743Vx.json | 2 +- ini/stm32h7.ini | 30 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/buildroot/share/PlatformIO/boards/marlin_STM32H743Vx.json b/buildroot/share/PlatformIO/boards/marlin_STM32H743Vx.json index 3b8fa73060b7..4ec34e5b3502 100644 --- a/buildroot/share/PlatformIO/boards/marlin_STM32H743Vx.json +++ b/buildroot/share/PlatformIO/boards/marlin_STM32H743Vx.json @@ -3,7 +3,7 @@ "core": "stm32", "cpu": "cortex-m7", "extra_flags": "-DSTM32H7xx -DSTM32H743xx", - "f_cpu": "400000000L", + "f_cpu": "480000000L", "mcu": "stm32h743vit6", "product_line": "STM32H743xx", "variant": "MARLIN_H743Vx" diff --git a/ini/stm32h7.ini b/ini/stm32h7.ini index 9b43200ff0bf..d00d374c61ed 100644 --- a/ini/stm32h7.ini +++ b/ini/stm32h7.ini @@ -28,14 +28,14 @@ platform_packages = framework-arduinoststm32@https://github.com/thisiskeithb/Ar board = marlin_BTT_SKR_SE_BX board_build.offset = 0x20000 build_flags = ${stm32_variant.build_flags} ${stm_flash_drive.build_flags} - -DUSE_USBHOST_HS - -DUSE_USB_HS_IN_FS - -DHAL_DMA2D_MODULE_ENABLED - -DHAL_LTDC_MODULE_ENABLED - -DHAL_SDRAM_MODULE_ENABLED - -DHAL_QSPI_MODULE_ENABLED - -DHAL_MDMA_MODULE_ENABLED - -DHAL_SD_MODULE_ENABLED + -DUSE_USBHOST_HS + -DUSE_USB_HS_IN_FS + -DHAL_DMA2D_MODULE_ENABLED + -DHAL_LTDC_MODULE_ENABLED + -DHAL_SDRAM_MODULE_ENABLED + -DHAL_QSPI_MODULE_ENABLED + -DHAL_MDMA_MODULE_ENABLED + -DHAL_SD_MODULE_ENABLED upload_protocol = cmsis-dap debug_tool = cmsis-dap @@ -50,12 +50,12 @@ board = marlin_STM32H743Vx board_build.offset = 0x20000 board_upload.offset_address = 0x08020000 build_flags = ${stm32_variant.build_flags} - -DPIN_SERIAL1_RX=PA_10 -DPIN_SERIAL1_TX=PA_9 - -DPIN_SERIAL3_RX=PD_9 -DPIN_SERIAL3_TX=PD_8 - -DPIN_SERIAL4_RX=PA_1 -DPIN_SERIAL4_TX=PA_0 - -DSERIAL_RX_BUFFER_SIZE=1024 -DSERIAL_TX_BUFFER_SIZE=1024 - -DTIMER_SERVO=TIM5 -DTIMER_TONE=TIM2 - -DSTEP_TIMER_IRQ_PRIO=0 - -DD_CACHE_DISABLED + -DPIN_SERIAL1_RX=PA_10 -DPIN_SERIAL1_TX=PA_9 + -DPIN_SERIAL3_RX=PD_9 -DPIN_SERIAL3_TX=PD_8 + -DPIN_SERIAL4_RX=PA_1 -DPIN_SERIAL4_TX=PA_0 + -DSERIAL_RX_BUFFER_SIZE=1024 -DSERIAL_TX_BUFFER_SIZE=1024 + -DTIMER_SERVO=TIM5 -DTIMER_TONE=TIM2 + -DSTEP_TIMER_IRQ_PRIO=0 + -DD_CACHE_DISABLED upload_protocol = cmsis-dap debug_tool = cmsis-dap From 0eb6a8d12e1f73eab7cef4090137f6e0cf7c7031 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 6 Sep 2022 22:06:13 -0500 Subject: [PATCH 045/243] =?UTF-8?q?=F0=9F=93=9D=20Fix=20comment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 21d0bbd3d721..ba3064722f11 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -4147,7 +4147,7 @@ /** * WiFi Support (Espressif ESP32 WiFi) */ -//#define WIFISUPPORT // Marlin embedded WiFi managenent +//#define WIFISUPPORT // Marlin embedded WiFi management //#define ESP3D_WIFISUPPORT // ESP3D Library WiFi management (https://github.com/luc-github/ESP3DLib) #if EITHER(WIFISUPPORT, ESP3D_WIFISUPPORT) From b29cd4c510632fd43fb0ff59cf69e9979ef94d25 Mon Sep 17 00:00:00 2001 From: hartmannathan <59230071+hartmannathan@users.noreply.github.com> Date: Fri, 9 Sep 2022 16:35:16 -0400 Subject: [PATCH 046/243] =?UTF-8?q?=F0=9F=93=9D=20Fix=20example=20comment?= =?UTF-8?q?=20(#24744)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/Bresenham.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Bresenham.md b/docs/Bresenham.md index 59a215096490..2d57a1cdab53 100644 --- a/docs/Bresenham.md +++ b/docs/Bresenham.md @@ -233,7 +233,7 @@ Error update equations: ε'[new] = ε' + 2.ΔY - 2.ΔX.r [7] ``` -This can be implemented in C as: +This can be implemented in C++ as: ```cpp class OversampledBresenham { From 78577b13cbe5d5aaca5a3eb58b7aeb472077f00d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 6 Sep 2022 23:03:15 -0500 Subject: [PATCH 047/243] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Mic?= =?UTF-8?q?rosteps=20to=20stepper.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/Conditionals_post.h | 67 ------------------------- Marlin/src/module/stepper.cpp | 39 +++++++++++--- Marlin/src/pins/sam/pins_ALLIGATOR_R2.h | 7 +++ 3 files changed, 38 insertions(+), 75 deletions(-) diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 010cb7933021..c208466dd01f 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -3124,73 +3124,6 @@ #define HAS_MICROSTEPS 1 #endif -#if HAS_MICROSTEPS - - // MS1 MS2 MS3 Stepper Driver Microstepping mode table - #ifndef MICROSTEP1 - #define MICROSTEP1 LOW,LOW,LOW - #endif - #if ENABLED(HEROIC_STEPPER_DRIVERS) - #ifndef MICROSTEP128 - #define MICROSTEP128 LOW,HIGH,LOW - #endif - #else - #ifndef MICROSTEP2 - #define MICROSTEP2 HIGH,LOW,LOW - #endif - #ifndef MICROSTEP4 - #define MICROSTEP4 LOW,HIGH,LOW - #endif - #endif - #ifndef MICROSTEP8 - #define MICROSTEP8 HIGH,HIGH,LOW - #endif - #ifdef __SAM3X8E__ - #if MB(ALLIGATOR) - #ifndef MICROSTEP16 - #define MICROSTEP16 LOW,LOW,LOW - #endif - #ifndef MICROSTEP32 - #define MICROSTEP32 HIGH,HIGH,LOW - #endif - #else - #ifndef MICROSTEP16 - #define MICROSTEP16 HIGH,HIGH,LOW - #endif - #endif - #else - #ifndef MICROSTEP16 - #define MICROSTEP16 HIGH,HIGH,LOW - #endif - #endif - - #ifdef MICROSTEP1 - #define HAS_MICROSTEP1 1 - #endif - #ifdef MICROSTEP2 - #define HAS_MICROSTEP2 1 - #endif - #ifdef MICROSTEP4 - #define HAS_MICROSTEP4 1 - #endif - #ifdef MICROSTEP8 - #define HAS_MICROSTEP8 1 - #endif - #ifdef MICROSTEP16 - #define HAS_MICROSTEP16 1 - #endif - #ifdef MICROSTEP32 - #define HAS_MICROSTEP32 1 - #endif - #ifdef MICROSTEP64 - #define HAS_MICROSTEP64 1 - #endif - #ifdef MICROSTEP128 - #define HAS_MICROSTEP128 1 - #endif - -#endif // HAS_MICROSTEPS - /** * Heater signal inversion defaults */ diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index beea674ced80..78c09fadefbd 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -3865,30 +3865,53 @@ void Stepper::report_positions() { } } + // MS1 MS2 MS3 Stepper Driver Microstepping mode table + #ifndef MICROSTEP1 + #define MICROSTEP1 LOW,LOW,LOW + #endif + #if ENABLED(HEROIC_STEPPER_DRIVERS) + #ifndef MICROSTEP128 + #define MICROSTEP128 LOW,HIGH,LOW + #endif + #else + #ifndef MICROSTEP2 + #define MICROSTEP2 HIGH,LOW,LOW + #endif + #ifndef MICROSTEP4 + #define MICROSTEP4 LOW,HIGH,LOW + #endif + #endif + #ifndef MICROSTEP8 + #define MICROSTEP8 HIGH,HIGH,LOW + #endif + #ifndef MICROSTEP16 + #define MICROSTEP16 HIGH,HIGH,LOW + #endif + void Stepper::microstep_mode(const uint8_t driver, const uint8_t stepping_mode) { switch (stepping_mode) { - #if HAS_MICROSTEP1 + #ifdef MICROSTEP1 case 1: microstep_ms(driver, MICROSTEP1); break; #endif - #if HAS_MICROSTEP2 + #ifdef MICROSTEP2 case 2: microstep_ms(driver, MICROSTEP2); break; #endif - #if HAS_MICROSTEP4 + #ifdef MICROSTEP4 case 4: microstep_ms(driver, MICROSTEP4); break; #endif - #if HAS_MICROSTEP8 + #ifdef MICROSTEP8 case 8: microstep_ms(driver, MICROSTEP8); break; #endif - #if HAS_MICROSTEP16 + #ifdef MICROSTEP16 case 16: microstep_ms(driver, MICROSTEP16); break; #endif - #if HAS_MICROSTEP32 + #ifdef MICROSTEP32 case 32: microstep_ms(driver, MICROSTEP32); break; #endif - #if HAS_MICROSTEP64 + #ifdef MICROSTEP64 case 64: microstep_ms(driver, MICROSTEP64); break; #endif - #if HAS_MICROSTEP128 + #ifdef MICROSTEP128 case 128: microstep_ms(driver, MICROSTEP128); break; #endif diff --git a/Marlin/src/pins/sam/pins_ALLIGATOR_R2.h b/Marlin/src/pins/sam/pins_ALLIGATOR_R2.h index 70c3853dc941..76431937a712 100644 --- a/Marlin/src/pins/sam/pins_ALLIGATOR_R2.h +++ b/Marlin/src/pins/sam/pins_ALLIGATOR_R2.h @@ -85,6 +85,13 @@ #define Z_MS1_PIN 44 // PC19 #define E0_MS1_PIN 45 // PC18 +#ifndef MICROSTEP16 + #define MICROSTEP16 LOW,LOW,LOW +#endif +#ifndef MICROSTEP32 + #define MICROSTEP32 HIGH,HIGH,LOW +#endif + //#define MOTOR_FAULT_PIN 22 // PB26 , motor X-Y-Z-E0 motor FAULT // From 85a47d61e62713c00f2512415701631e3c53b78f Mon Sep 17 00:00:00 2001 From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Date: Fri, 9 Sep 2022 20:54:29 +0200 Subject: [PATCH 048/243] =?UTF-8?q?=F0=9F=90=9B=20Fix=20heater=20timeout?= =?UTF-8?q?=20PID=20output=20(#24682)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/module/temperature.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index c8e69e701078..b97824c30585 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -1394,6 +1394,8 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { float Temperature::get_pid_output_hotend(const uint8_t E_NAME) { const uint8_t ee = HOTEND_INDEX; + const bool is_idling = TERN0(HEATER_IDLE_HANDLER, heater_idle[ee].timed_out); + #if ENABLED(PIDTEMP) typedef PIDRunner PIDRunnerHotend; @@ -1403,7 +1405,7 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { REPEAT(HOTENDS, _HOTENDPID) }; - const float pid_output = hotend_pid[ee].get_pid_output(); + const float pid_output = is_idling ? 0 : hotend_pid[ee].get_pid_output(); #if ENABLED(PID_DEBUG) if (ee == active_extruder) @@ -1466,7 +1468,7 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { hotend.modeled_ambient_temp += delta_to_apply > 0.f ? _MAX(delta_to_apply, MPC_MIN_AMBIENT_CHANGE * MPC_dT) : _MIN(delta_to_apply, -MPC_MIN_AMBIENT_CHANGE * MPC_dT); float power = 0.0; - if (hotend.target != 0 && TERN1(HEATER_IDLE_HANDLER, !heater_idle[ee].timed_out)) { + if (hotend.target != 0 && !is_idling) { // Plan power level to get to target temperature in 2 seconds power = (hotend.target - hotend.modeled_block_temp) * constants.block_heat_capacity / 2.0f; power -= (hotend.modeled_ambient_temp - hotend.modeled_block_temp) * ambient_xfer_coeff; @@ -1492,7 +1494,6 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { #else // No PID or MPC enabled - const bool is_idling = TERN0(HEATER_IDLE_HANDLER, heater_idle[ee].timed_out); const float pid_output = (!is_idling && temp_hotend[ee].is_below_target()) ? BANG_MAX : 0; #endif From 03aba439f67410e73101f83010c07387ab0ef828 Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Fri, 9 Sep 2022 12:22:52 -0700 Subject: [PATCH 049/243] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Only=20Sync=20Emul?= =?UTF-8?q?ated=20EEPROM=20Print=20Counter=20(#24731)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/LPC1768/inc/Conditionals_post.h | 2 +- Marlin/src/HAL/STM32/inc/Conditionals_post.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/HAL/LPC1768/inc/Conditionals_post.h b/Marlin/src/HAL/LPC1768/inc/Conditionals_post.h index be574a96e4ed..35499500081a 100644 --- a/Marlin/src/HAL/LPC1768/inc/Conditionals_post.h +++ b/Marlin/src/HAL/LPC1768/inc/Conditionals_post.h @@ -29,6 +29,6 @@ // LPC1768 boards seem to lose steps when saving to EEPROM during print (issue #20785) // TODO: Which other boards are incompatible? -#if defined(MCU_LPC1768) && PRINTCOUNTER_SAVE_INTERVAL > 0 +#if defined(MCU_LPC1768) && ENABLED(FLASH_EEPROM_EMULATION) && PRINTCOUNTER_SAVE_INTERVAL > 0 #define PRINTCOUNTER_SYNC 1 #endif diff --git a/Marlin/src/HAL/STM32/inc/Conditionals_post.h b/Marlin/src/HAL/STM32/inc/Conditionals_post.h index 5ac476618292..c5ce66a26f54 100644 --- a/Marlin/src/HAL/STM32/inc/Conditionals_post.h +++ b/Marlin/src/HAL/STM32/inc/Conditionals_post.h @@ -29,6 +29,6 @@ #endif // Some STM32F4 boards may lose steps when saving to EEPROM during print (PR #17946) -#if defined(STM32F4xx) && PRINTCOUNTER_SAVE_INTERVAL > 0 +#if defined(STM32F4xx) && ENABLED(FLASH_EEPROM_EMULATION) && PRINTCOUNTER_SAVE_INTERVAL > 0 #define PRINTCOUNTER_SYNC 1 #endif From d2b1467ab36974b65a3cb50ea7b6ca626c60a327 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 9 Sep 2022 19:31:47 -0500 Subject: [PATCH 050/243] =?UTF-8?q?=F0=9F=8C=90=20Some=20short=20menu=20st?= =?UTF-8?q?rings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/language/language_en.h | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index d03b455c7196..2ababe292726 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -471,15 +471,27 @@ namespace Language_en { LSTR MSG_PAUSE_PRINT = _UxGT("Pause Print"); LSTR MSG_ADVANCED_PAUSE = _UxGT("Advanced Pause"); LSTR MSG_RESUME_PRINT = _UxGT("Resume Print"); - LSTR MSG_HOST_START_PRINT = _UxGT("Start Host Print"); LSTR MSG_STOP_PRINT = _UxGT("Stop Print"); - LSTR MSG_END_LOOPS = _UxGT("End Repeat Loops"); - LSTR MSG_PRINTING_OBJECT = _UxGT("Printing Object"); - LSTR MSG_CANCEL_OBJECT = _UxGT("Cancel Object"); - LSTR MSG_CANCEL_OBJECT_N = _UxGT("Cancel Object ="); LSTR MSG_OUTAGE_RECOVERY = _UxGT("Power Outage"); - LSTR MSG_CONTINUE_PRINT_JOB = _UxGT("Continue Print Job"); - LSTR MSG_MEDIA_MENU = _UxGT("Print from ") MEDIA_TYPE_EN; + #if LCD_WIDTH >= 20 || HAS_DWIN_E3V2 + LSTR MSG_HOST_START_PRINT = _UxGT("Start Host Print"); + LSTR MSG_PRINTING_OBJECT = _UxGT("Printing Object"); + LSTR MSG_CANCEL_OBJECT = _UxGT("Cancel Object"); + LSTR MSG_CANCEL_OBJECT_N = _UxGT("Cancel Object ="); + LSTR MSG_CONTINUE_PRINT_JOB = _UxGT("Continue Print Job"); + LSTR MSG_MEDIA_MENU = _UxGT("Print from ") MEDIA_TYPE_EN; + LSTR MSG_TURN_OFF = _UxGT("Turn off the printer"); + LSTR MSG_END_LOOPS = _UxGT("End Repeat Loops"); + #else + LSTR MSG_HOST_START_PRINT = _UxGT("Host Start"); + LSTR MSG_PRINTING_OBJECT = _UxGT("Print Obj"); + LSTR MSG_CANCEL_OBJECT = _UxGT("Cancel Obj"); + LSTR MSG_CANCEL_OBJECT_N = _UxGT("Cancel Obj ="); + LSTR MSG_CONTINUE_PRINT_JOB = _UxGT("Continue Job"); + LSTR MSG_MEDIA_MENU = MEDIA_TYPE_EN _UxGT(" Print"); + LSTR MSG_TURN_OFF = _UxGT("Turn off now"); + LSTR MSG_END_LOOPS = _UxGT("End Loops"); + #endif LSTR MSG_NO_MEDIA = _UxGT("No ") MEDIA_TYPE_EN; LSTR MSG_DWELL = _UxGT("Sleep..."); LSTR MSG_USERWAIT = _UxGT("Click to Resume..."); @@ -490,7 +502,6 @@ namespace Language_en { LSTR MSG_PRINT_ABORTED = _UxGT("Print Aborted"); LSTR MSG_PRINT_DONE = _UxGT("Print Done"); LSTR MSG_PRINTER_KILLED = _UxGT("Printer killed!"); - LSTR MSG_TURN_OFF = _UxGT("Turn off the printer"); LSTR MSG_NO_MOVE = _UxGT("No Move."); LSTR MSG_KILLED = _UxGT("KILLED. "); LSTR MSG_STOPPED = _UxGT("STOPPED. "); From 0642cd8a8352cd8a34d9d9354162a4478515554c Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Thu, 22 Sep 2022 18:54:26 +0200 Subject: [PATCH 051/243] =?UTF-8?q?=F0=9F=91=B7=20Array=20macros=20to=20?= =?UTF-8?q?=E2=80=A626=20elements=20(#24789)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/macros.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index 8dfcb875ac4e..cfeb9db33c52 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -338,6 +338,12 @@ #define GANG_N_1(N,K) _GANG_N(N,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K) // Macros for initializing arrays +#define LIST_26(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z +#define LIST_25(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y +#define LIST_24(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X +#define LIST_23(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W +#define LIST_22(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V +#define LIST_21(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U #define LIST_20(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T #define LIST_19(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S #define LIST_18(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R From b9428bf0876944e163bc83a00f6dabbb48e8b472 Mon Sep 17 00:00:00 2001 From: FBN <62633887+fBn0523@users.noreply.github.com> Date: Fri, 16 Sep 2022 07:02:08 +0800 Subject: [PATCH 052/243] =?UTF-8?q?=F0=9F=9A=B8=20More=20automatic=20MMU2?= =?UTF-8?q?=20load=20(#24750,=20#24770)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/mmu/mmu2.cpp | 31 ++++++++++++++++++++++++++----- Marlin/src/feature/mmu/mmu2.h | 1 + 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/Marlin/src/feature/mmu/mmu2.cpp b/Marlin/src/feature/mmu/mmu2.cpp index a4718b53d9d8..54553a4f2d4b 100644 --- a/Marlin/src/feature/mmu/mmu2.cpp +++ b/Marlin/src/feature/mmu/mmu2.cpp @@ -585,7 +585,7 @@ static void mmu2_not_responding() { command(MMU_CMD_T0 + index); manage_response(true, true); mmu_continue_loading(); - command(MMU_CMD_C0); + //command(MMU_CMD_C0); extruder = index; active_extruder = 0; @@ -653,13 +653,34 @@ static void mmu2_not_responding() { } void MMU2::mmu_continue_loading() { + // Try to load the filament a limited number of times + bool fil_present = 0; for (uint8_t i = 0; i < MMU_LOADING_ATTEMPTS_NR; i++) { - DEBUG_ECHOLNPGM("Additional load attempt #", i); - if (FILAMENT_PRESENT()) break; + DEBUG_ECHOLNPGM("Load attempt #", i + 1); + + // Done as soon as filament is present + fil_present = FILAMENT_PRESENT(); + if (fil_present) break; + + // Attempt to load the filament, 1mm at a time, for 3s command(MMU_CMD_C0); + stepper.enable_extruder(); + const millis_t expire_ms = millis() + 3000; + do { + current_position.e += 1; + line_to_current_position(MMU_LOAD_FEEDRATE); + planner.synchronize(); + // When (T0 rx->ok) load is ready, but in fact it did not load + // successfully or an overload created pressure in the extruder. + // Send (C0) to load more and move E_AXIS a little to release pressure. + if ((fil_present = FILAMENT_PRESENT())) MMU2_COMMAND("A"); + } while (!fil_present && PENDING(millis(), expire_ms)); + stepper.disable_extruder(); manage_response(true, true); } - if (!FILAMENT_PRESENT()) { + + // Was the filament still missing in the last check? + if (!fil_present) { DEBUG_ECHOLNPGM("Filament never reached sensor, runout"); filament_runout(); } @@ -682,7 +703,7 @@ static void mmu2_not_responding() { command(MMU_CMD_T0 + index); manage_response(true, true); command(MMU_CMD_C0); - extruder = index; //filament change is finished + extruder = index; // Filament change is finished active_extruder = 0; stepper.enable_extruder(); SERIAL_ECHO_MSG(STR_ACTIVE_EXTRUDER, extruder); diff --git a/Marlin/src/feature/mmu/mmu2.h b/Marlin/src/feature/mmu/mmu2.h index 7d3d9ec4df38..18d6d38a359d 100644 --- a/Marlin/src/feature/mmu/mmu2.h +++ b/Marlin/src/feature/mmu/mmu2.h @@ -86,6 +86,7 @@ class MMU2 { #endif #if ENABLED(MMU_EXTRUDER_SENSOR) + #define MMU_LOAD_FEEDRATE 19.02f // (mm/s) static void mmu_continue_loading(); #endif From 9d9f303c5eb4be828a9ddc0a26fc7a5a726521da Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Fri, 23 Sep 2022 05:20:17 +1200 Subject: [PATCH 053/243] =?UTF-8?q?=F0=9F=93=BA=20FYSETC=20Mini=2012864=20?= =?UTF-8?q?2.1=20pins=20for=20Creality=20V4=20(#24624)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/pins/stm32f1/pins_CREALITY_V4.h | 70 +++++++++++++++++++--- 1 file changed, 62 insertions(+), 8 deletions(-) diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h index 5a3e7337adac..56caa7d35ee5 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h @@ -161,7 +161,7 @@ #define SDIO_SUPPORT #define NO_SD_HOST_DRIVE // This board's SD is only seen by the printer -#if ENABLED(CR10_STOCKDISPLAY) +#if EITHER(CR10_STOCKDISPLAY, FYSETC_MINI_12864_2_1) #if ENABLED(RET6_12864_LCD) @@ -169,7 +169,7 @@ * RET6 12864 LCD * ------ * PC6 | 1 2 | PB2 - * PB10 | 3 4 | PE8 + * PB10 | 3 4 | PB11 * PB14 5 6 | PB13 * PB12 | 7 8 | PB15 * GND | 9 10 | 5V @@ -179,16 +179,12 @@ #define EXP1_01_PIN PC6 #define EXP1_02_PIN PB2 #define EXP1_03_PIN PB10 - #define EXP1_04_PIN PE8 + #define EXP1_04_PIN PB11 #define EXP1_05_PIN PB14 #define EXP1_06_PIN PB13 #define EXP1_07_PIN PB12 #define EXP1_08_PIN PB15 - #ifndef HAS_PIN_27_BOARD - #define BEEPER_PIN EXP1_01_PIN - #endif - #elif ENABLED(VET6_12864_LCD) /** @@ -212,8 +208,11 @@ #define EXP1_08_PIN PA7 #else - #error "Define RET6_12864_LCD or VET6_12864_LCD to select pins for CR10_STOCKDISPLAY with the Creality V4 controller." + #error "Define RET6_12864_LCD or VET6_12864_LCD to select pins for the LCD with the Creality V4 controller." #endif +#endif + +#if ENABLED(CR10_STOCKDISPLAY) #define LCD_PINS_RS EXP1_07_PIN #define LCD_PINS_ENABLE EXP1_08_PIN @@ -223,6 +222,10 @@ #define BTN_EN1 EXP1_03_PIN #define BTN_EN2 EXP1_05_PIN + #ifndef HAS_PIN_27_BOARD + #define BEEPER_PIN EXP1_01_PIN + #endif + #elif ANY(HAS_DWIN_E3V2, IS_DWIN_MARLINUI, DWIN_VET6_CREALITY_LCD) #if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI @@ -248,4 +251,55 @@ #define BEEPER_PIN EXP1_06_PIN #endif +#elif ENABLED(FYSETC_MINI_12864_2_1) + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! FYSETC_MINI_12864_2_1 and clones require wiring modifications. See 'pins_CREALITY_V4.h' for details. Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning" + #endif + + #if SD_CONNECTION_IS(LCD) + #error "The LCD sdcard is not connected with this configuration" + #endif + + /** + * + * Board (RET6 12864 LCD) Display + * ------ ------ + * (EN1) PC6 | 1 2 | PB2 (BTN_ENC) 5V |10 9 | GND + * (LCD_CS) PB10 | 3 4 | PB11 (LCD RESET) -- | 8 7 | -- + * (LCD_A0) PB14 5 6 | PB13 (EN2) (DIN) | 6 5 (LCD RESET) + * (LCD_SCK)PB12 | 7 8 | PB15 (MOSI) (LCD_A0) | 4 3 | (LCD_CS) + * GND | 9 10 | 5V (BTN_ENC) | 2 1 | -- + * ------ ------ + * EXP1 EXP1 + * + * ------ + * ----- -- |10 9 | -- + * | 1 | VCC (RESET) | 8 7 | -- + * | 2 | PA13 (DIN) (MOSI) | 6 5 (EN2) + * | 3 | PA14 -- | 4 3 | (EN1) + * | 4 | GND (LCD_SCK)| 2 1 | -- + * ----- ------ + * Debug port EXP2 + * + * Needs custom cable. Connect EN2-EN2, LCD_CS-LCD_CS and so on. + * Debug port is just above EXP1, You need to add pins + * + */ + + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP1_01_PIN + #define BTN_EN2 EXP1_06_PIN + #define BEEPER_PIN -1 + + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_05_PIN + #define DOGLCD_SCK EXP1_07_PIN + #define DOGLCD_MOSI EXP1_08_PIN + #define LCD_RESET_PIN EXP1_04_PIN + + #define FORCE_SOFT_SPI + #define LCD_BACKLIGHT_PIN -1 + #define NEOPIXEL_PIN PA13 + #endif From 53564fb6f3d1c1cf4421329a2f729dab22f3f8e1 Mon Sep 17 00:00:00 2001 From: Gurmeet Athwal Date: Sat, 10 Sep 2022 00:51:19 +0530 Subject: [PATCH 054/243] =?UTF-8?q?=F0=9F=9A=B8=20M115=20spindle/laser=20(?= =?UTF-8?q?#24681,=20#24747)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/host/M115.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Marlin/src/gcode/host/M115.cpp b/Marlin/src/gcode/host/M115.cpp index d38bd6612d9c..7f17617b63f6 100644 --- a/Marlin/src/gcode/host/M115.cpp +++ b/Marlin/src/gcode/host/M115.cpp @@ -130,6 +130,13 @@ void GcodeSuite::M115() { cap_line(F("TOGGLE_LIGHTS"), ENABLED(CASE_LIGHT_ENABLE)); cap_line(F("CASE_LIGHT_BRIGHTNESS"), TERN0(CASE_LIGHT_ENABLE, caselight.has_brightness())); + // SPINDLE AND LASER CONTROL (M3, M4, M5) + #if ENABLED(SPINDLE_FEATURE) + cap_line(F("SPINDLE"), true); + #elif ENABLED(LASER_FEATURE) + cap_line(F("LASER"), true); + #endif + // EMERGENCY_PARSER (M108, M112, M410, M876) cap_line(F("EMERGENCY_PARSER"), ENABLED(EMERGENCY_PARSER)); From 7daff755f2899d4cbe24aa038b1e32d9369692c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arkadiusz=20Mi=C5=9Bkiewicz?= Date: Thu, 1 Sep 2022 20:48:24 +0200 Subject: [PATCH 055/243] =?UTF-8?q?=F0=9F=A9=B9=20Report=20M22=20/=20M23?= =?UTF-8?q?=20success=20/=20fail=20(#24706)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/language.h | 1 + Marlin/src/sd/cardreader.cpp | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Marlin/src/core/language.h b/Marlin/src/core/language.h index 157bd6918515..545f9df6410b 100644 --- a/Marlin/src/core/language.h +++ b/Marlin/src/core/language.h @@ -174,6 +174,7 @@ #define STR_SD_VOL_INIT_FAIL "volume.init failed" #define STR_SD_OPENROOT_FAIL "openRoot failed" #define STR_SD_CARD_OK "SD card ok" +#define STR_SD_CARD_RELEASED "SD card released" #define STR_SD_WORKDIR_FAIL "workDir open failed" #define STR_SD_OPEN_FILE_FAIL "open failed, File: " #define STR_SD_FILE_OPENED "File opened: " diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 3057bf68af09..6a55f7efbf74 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -547,6 +547,7 @@ void CardReader::release() { #if ALL(SDCARD_SORT_ALPHA, SDSORT_USES_RAM, SDSORT_CACHE_NAMES) nrFiles = 0; #endif + SERIAL_ECHO_MSG(STR_SD_CARD_RELEASED); } /** @@ -642,7 +643,7 @@ void announceOpen(const uint8_t doing, const char * const path) { // - 2 : Resuming from a sub-procedure // void CardReader::openFileRead(const char * const path, const uint8_t subcall_type/*=0*/) { - if (!isMounted()) return; + if (!isMounted()) return openFailed(path); switch (subcall_type) { case 0: // Starting a new print. "Now fresh file: ..." @@ -684,7 +685,7 @@ void CardReader::openFileRead(const char * const path, const uint8_t subcall_typ SdFile *diveDir; const char * const fname = diveToFile(true, diveDir, path); - if (!fname) return; + if (!fname) return openFailed(path); if (file.open(diveDir, fname, O_READ)) { filesize = file.fileSize(); @@ -720,21 +721,20 @@ void CardReader::openFileWrite(const char * const path) { SdFile *diveDir; const char * const fname = diveToFile(false, diveDir, path); - if (!fname) return; + if (!fname) return openFailed(path); - #if ENABLED(SDCARD_READONLY) - openFailed(fname); - #else + #if DISABLED(SDCARD_READONLY) if (file.open(diveDir, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC)) { flag.saving = true; selectFileByName(fname); TERN_(EMERGENCY_PARSER, emergency_parser.disable()); echo_write_to_file(fname); ui.set_status(fname); + return; } - else - openFailed(fname); #endif + + openFailed(fname); } // From 02810616cc08ea14c6257578061d61c492fb8673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arkadiusz=20Mi=C5=9Bkiewicz?= Date: Tue, 6 Sep 2022 08:48:42 +0200 Subject: [PATCH 056/243] =?UTF-8?q?=F0=9F=9A=B8=20On=20pause=20report=20"S?= =?UTF-8?q?D=20printing=20byte=20X/Y"=20(#24709)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/sd/cardreader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 6a55f7efbf74..085ae9541c9c 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -789,7 +789,7 @@ void CardReader::removeFile(const char * const name) { } void CardReader::report_status() { - if (isPrinting()) { + if (isPrinting() || isPaused()) { SERIAL_ECHOPGM(STR_SD_PRINTING_BYTE, sdpos); SERIAL_CHAR('/'); SERIAL_ECHOLN(filesize); From 38b31059003110ae0cb2dcc3270620e69954a3d7 Mon Sep 17 00:00:00 2001 From: XDA-Bam <1209896+XDA-Bam@users.noreply.github.com> Date: Fri, 9 Sep 2022 22:51:11 +0200 Subject: [PATCH 057/243] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Minor=20planner=20?= =?UTF-8?q?optimization=20(#24737)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/module/planner.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 1c9601632df8..6ef1ed6c2848 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -793,19 +793,21 @@ void Planner::calculate_trapezoid_for_block(block_t * const block, const_float_t uint32_t cruise_rate = block->nominal_rate; #endif - const int32_t accel = block->acceleration_steps_per_s2; - // Steps for acceleration, plateau and deceleration int32_t plateau_steps = block->step_event_count; uint32_t accelerate_steps = 0, decelerate_steps = 0; + const int32_t accel = block->acceleration_steps_per_s2; + float inverse_accel = 0.0f; if (accel != 0) { - // Steps required for acceleration, deceleration to/from nominal rate - const float nominal_rate_sq = sq(float(block->nominal_rate)); - float accelerate_steps_float = (nominal_rate_sq - sq(float(initial_rate))) * (0.5f / accel); + inverse_accel = 1.0f / accel; + const float half_inverse_accel = 0.5f * inverse_accel, + nominal_rate_sq = sq(float(block->nominal_rate)), + // Steps required for acceleration, deceleration to/from nominal rate + decelerate_steps_float = half_inverse_accel * (nominal_rate_sq - sq(float(final_rate))); + float accelerate_steps_float = half_inverse_accel * (nominal_rate_sq - sq(float(initial_rate))); accelerate_steps = CEIL(accelerate_steps_float); - const float decelerate_steps_float = (nominal_rate_sq - sq(float(final_rate))) * (0.5f / accel); decelerate_steps = FLOOR(decelerate_steps_float); // Steps between acceleration and deceleration, if any @@ -828,9 +830,10 @@ void Planner::calculate_trapezoid_for_block(block_t * const block, const_float_t } #if ENABLED(S_CURVE_ACCELERATION) + const float rate_factor = inverse_accel * (STEPPER_TIMER_RATE); // Jerk controlled speed requires to express speed versus time, NOT steps - uint32_t acceleration_time = (float(cruise_rate - initial_rate) / accel) * (STEPPER_TIMER_RATE), - deceleration_time = (float(cruise_rate - final_rate) / accel) * (STEPPER_TIMER_RATE), + uint32_t acceleration_time = rate_factor * float(cruise_rate - initial_rate), + deceleration_time = rate_factor * float(cruise_rate - final_rate), // And to offload calculations from the ISR, we also calculate the inverse of those times here acceleration_time_inverse = get_period_inverse(acceleration_time), deceleration_time_inverse = get_period_inverse(deceleration_time); From aabd3e9e196ccbe04f94a26cd25e4d3508c262f9 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Wed, 14 Sep 2022 05:27:16 +1200 Subject: [PATCH 058/243] =?UTF-8?q?=E2=9C=A8=20BTT=20SKR=20Mini=20E3=20V3.?= =?UTF-8?q?0.1=20(#24722)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/boards.h | 79 ++-- Marlin/src/pins/pins.h | 2 + .../stm32f1/pins_BTT_SKR_MINI_E3_common.h | 62 ++-- Marlin/src/pins/stm32f4/pins_ARMED.h | 5 +- .../stm32f4/pins_BTT_SKR_MINI_E3_V3_0_1.h | 350 ++++++++++++++++++ .../PlatformIO/boards/marlin_STM32F401RC.json | 38 ++ .../variants/MARLIN_F401RC/PeripheralPins.c | 256 +++++++++++++ .../variants/MARLIN_F401RC/PinNamesVar.h | 52 +++ .../variants/MARLIN_F401RC/ldscript.ld | 177 +++++++++ .../variant_MARLIN_STM32F401RC.cpp | 223 +++++++++++ .../variant_MARLIN_STM32F401RC.h | 186 ++++++++++ ini/stm32f4.ini | 18 + 12 files changed, 1378 insertions(+), 70 deletions(-) create mode 100644 Marlin/src/pins/stm32f4/pins_BTT_SKR_MINI_E3_V3_0_1.h create mode 100644 buildroot/share/PlatformIO/boards/marlin_STM32F401RC.json create mode 100644 buildroot/share/PlatformIO/variants/MARLIN_F401RC/PeripheralPins.c create mode 100644 buildroot/share/PlatformIO/variants/MARLIN_F401RC/PinNamesVar.h create mode 100644 buildroot/share/PlatformIO/variants/MARLIN_F401RC/ldscript.ld create mode 100644 buildroot/share/PlatformIO/variants/MARLIN_F401RC/variant_MARLIN_STM32F401RC.cpp create mode 100644 buildroot/share/PlatformIO/variants/MARLIN_F401RC/variant_MARLIN_STM32F401RC.h diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index 272a82f3b766..f3f5c01d2de3 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -329,45 +329,46 @@ #define BOARD_BTT_SKR_MINI_E3_V1_2 4025 // BigTreeTech SKR Mini E3 V1.2 (STM32F103RC) #define BOARD_BTT_SKR_MINI_E3_V2_0 4026 // BigTreeTech SKR Mini E3 V2.0 (STM32F103RC / STM32F103RE) #define BOARD_BTT_SKR_MINI_E3_V3_0 4027 // BigTreeTech SKR Mini E3 V3.0 (STM32G0B1RE) -#define BOARD_BTT_SKR_MINI_MZ_V1_0 4028 // BigTreeTech SKR Mini MZ V1.0 (STM32F103RC) -#define BOARD_BTT_SKR_E3_DIP 4029 // BigTreeTech SKR E3 DIP V1.0 (STM32F103RC / STM32F103RE) -#define BOARD_BTT_SKR_CR6 4030 // BigTreeTech SKR CR6 v1.0 (STM32F103RE) -#define BOARD_JGAURORA_A5S_A1 4031 // JGAurora A5S A1 (STM32F103ZE) -#define BOARD_FYSETC_AIO_II 4032 // FYSETC AIO_II (STM32F103RC) -#define BOARD_FYSETC_CHEETAH 4033 // FYSETC Cheetah (STM32F103RC) -#define BOARD_FYSETC_CHEETAH_V12 4034 // FYSETC Cheetah V1.2 (STM32F103RC) -#define BOARD_LONGER3D_LK 4035 // Longer3D LK1/2 - Alfawise U20/U20+/U30 (STM32F103VE) -#define BOARD_CCROBOT_MEEB_3DP 4036 // ccrobot-online.com MEEB_3DP (STM32F103RC) -#define BOARD_CHITU3D_V5 4037 // Chitu3D TronXY X5SA V5 Board (STM32F103ZE) -#define BOARD_CHITU3D_V6 4038 // Chitu3D TronXY X5SA V6 Board (STM32F103ZE) -#define BOARD_CHITU3D_V9 4039 // Chitu3D TronXY X5SA V9 Board (STM32F103ZE) -#define BOARD_CREALITY_V4 4040 // Creality v4.x (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V422 4041 // Creality v4.2.2 (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V423 4042 // Creality v4.2.3 (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V425 4043 // Creality v4.2.5 (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V427 4044 // Creality v4.2.7 (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V4210 4045 // Creality v4.2.10 (STM32F103RC / STM32F103RE) as found in the CR-30 -#define BOARD_CREALITY_V431 4046 // Creality v4.3.1 (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V431_A 4047 // Creality v4.3.1a (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V431_B 4048 // Creality v4.3.1b (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V431_C 4049 // Creality v4.3.1c (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V431_D 4050 // Creality v4.3.1d (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V452 4051 // Creality v4.5.2 (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V453 4052 // Creality v4.5.3 (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V24S1 4053 // Creality v2.4.S1 (STM32F103RC / STM32F103RE) v101 as found in the Ender-7 -#define BOARD_CREALITY_V24S1_301 4054 // Creality v2.4.S1_301 (STM32F103RC / STM32F103RE) v301 as found in the Ender-3 S1 -#define BOARD_CREALITY_V25S1 4055 // Creality v2.5.S1 (STM32F103RE) as found in the CR-10 Smart Pro -#define BOARD_TRIGORILLA_PRO 4056 // Trigorilla Pro (STM32F103ZE) -#define BOARD_FLY_MINI 4057 // FLYmaker FLY MINI (STM32F103RC) -#define BOARD_FLSUN_HISPEED 4058 // FLSUN HiSpeedV1 (STM32F103VE) -#define BOARD_BEAST 4059 // STM32F103RE Libmaple-based controller -#define BOARD_MINGDA_MPX_ARM_MINI 4060 // STM32F103ZE Mingda MD-16 -#define BOARD_GTM32_PRO_VD 4061 // STM32F103VE controller -#define BOARD_ZONESTAR_ZM3E2 4062 // Zonestar ZM3E2 (STM32F103RC) -#define BOARD_ZONESTAR_ZM3E4 4063 // Zonestar ZM3E4 V1 (STM32F103VC) -#define BOARD_ZONESTAR_ZM3E4V2 4064 // Zonestar ZM3E4 V2 (STM32F103VC) -#define BOARD_ERYONE_ERY32_MINI 4065 // Eryone Ery32 mini (STM32F103VE) -#define BOARD_PANDA_PI_V29 4066 // Panda Pi V2.9 - Standalone (STM32F103RC) +#define BOARD_BTT_SKR_MINI_E3_V3_0_1 4028 // BigTreeTech SKR Mini E3 V3.0.1 (STM32F401RC) +#define BOARD_BTT_SKR_MINI_MZ_V1_0 4029 // BigTreeTech SKR Mini MZ V1.0 (STM32F103RC) +#define BOARD_BTT_SKR_E3_DIP 4030 // BigTreeTech SKR E3 DIP V1.0 (STM32F103RC / STM32F103RE) +#define BOARD_BTT_SKR_CR6 4031 // BigTreeTech SKR CR6 v1.0 (STM32F103RE) +#define BOARD_JGAURORA_A5S_A1 4032 // JGAurora A5S A1 (STM32F103ZE) +#define BOARD_FYSETC_AIO_II 4033 // FYSETC AIO_II (STM32F103RC) +#define BOARD_FYSETC_CHEETAH 4034 // FYSETC Cheetah (STM32F103RC) +#define BOARD_FYSETC_CHEETAH_V12 4035 // FYSETC Cheetah V1.2 (STM32F103RC) +#define BOARD_LONGER3D_LK 4036 // Longer3D LK1/2 - Alfawise U20/U20+/U30 (STM32F103VE) +#define BOARD_CCROBOT_MEEB_3DP 4037 // ccrobot-online.com MEEB_3DP (STM32F103RC) +#define BOARD_CHITU3D_V5 4038 // Chitu3D TronXY X5SA V5 Board (STM32F103ZE) +#define BOARD_CHITU3D_V6 4039 // Chitu3D TronXY X5SA V6 Board (STM32F103ZE) +#define BOARD_CHITU3D_V9 4040 // Chitu3D TronXY X5SA V9 Board (STM32F103ZE) +#define BOARD_CREALITY_V4 4041 // Creality v4.x (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V422 4042 // Creality v4.2.2 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V423 4043 // Creality v4.2.3 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V425 4044 // Creality v4.2.5 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V427 4045 // Creality v4.2.7 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V4210 4046 // Creality v4.2.10 (STM32F103RC / STM32F103RE) as found in the CR-30 +#define BOARD_CREALITY_V431 4047 // Creality v4.3.1 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V431_A 4048 // Creality v4.3.1a (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V431_B 4049 // Creality v4.3.1b (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V431_C 4050 // Creality v4.3.1c (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V431_D 4051 // Creality v4.3.1d (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V452 4052 // Creality v4.5.2 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V453 4053 // Creality v4.5.3 (STM32F103RC / STM32F103RE) +#define BOARD_CREALITY_V24S1 4054 // Creality v2.4.S1 (STM32F103RC / STM32F103RE) v101 as found in the Ender-7 +#define BOARD_CREALITY_V24S1_301 4055 // Creality v2.4.S1_301 (STM32F103RC / STM32F103RE) v301 as found in the Ender-3 S1 +#define BOARD_CREALITY_V25S1 4056 // Creality v2.5.S1 (STM32F103RE) as found in the CR-10 Smart Pro +#define BOARD_TRIGORILLA_PRO 4057 // Trigorilla Pro (STM32F103ZE) +#define BOARD_FLY_MINI 4058 // FLYmaker FLY MINI (STM32F103RC) +#define BOARD_FLSUN_HISPEED 4059 // FLSUN HiSpeedV1 (STM32F103VE) +#define BOARD_BEAST 4060 // STM32F103RE Libmaple-based controller +#define BOARD_MINGDA_MPX_ARM_MINI 4061 // STM32F103ZE Mingda MD-16 +#define BOARD_GTM32_PRO_VD 4062 // STM32F103VE controller +#define BOARD_ZONESTAR_ZM3E2 4063 // Zonestar ZM3E2 (STM32F103RC) +#define BOARD_ZONESTAR_ZM3E4 4064 // Zonestar ZM3E4 V1 (STM32F103VC) +#define BOARD_ZONESTAR_ZM3E4V2 4065 // Zonestar ZM3E4 V2 (STM32F103VC) +#define BOARD_ERYONE_ERY32_MINI 4066 // Eryone Ery32 mini (STM32F103VE) +#define BOARD_PANDA_PI_V29 4067 // Panda Pi V2.9 - Standalone (STM32F103RC) // // ARM Cortex-M4F diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index e2f6ea292476..384f06ecfd23 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -541,6 +541,8 @@ #include "stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h" // STM32F1 env:STM32F103RC_btt env:STM32F103RC_btt_USB env:STM32F103RE_btt env:STM32F103RE_btt_USB env:STM32F103RC_btt_maple env:STM32F103RC_btt_USB_maple env:STM32F103RE_btt_maple env:STM32F103RE_btt_USB_maple #elif MB(BTT_SKR_MINI_E3_V3_0) #include "stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h" // STM32G0 env:STM32G0B1RE_btt env:STM32G0B1RE_btt_xfer +#elif MB(BTT_SKR_MINI_E3_V3_0_1) + #include "stm32f4/pins_BTT_SKR_MINI_E3_V3_0_1.h"// STM32F4 env:STM32F401RC_btt #elif MB(BTT_SKR_MINI_MZ_V1_0) #include "stm32f1/pins_BTT_SKR_MINI_MZ_V1_0.h" // STM32F1 env:STM32F103RC_btt env:STM32F103RC_btt_USB env:STM32F103RC_btt_maple env:STM32F103RC_btt_USB_maple #elif MB(BTT_SKR_E3_DIP) diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h index 537e905e2152..c4a89712652e 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h @@ -135,6 +135,12 @@ #define EXP1_02_PIN PB6 #define EXP1_08_PIN PB7 #endif +#define EXP1_01_PIN PB5 +#define EXP1_03_PIN PA9 +#define EXP1_04_PIN -1 // RESET +#define EXP1_05_PIN PA10 +#define EXP1_06_PIN PB9 +#define EXP1_07_PIN PB8 #if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI /** @@ -156,22 +162,22 @@ #define BEEPER_PIN EXP1_02_PIN #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 PB8 - #define BTN_ENC PB5 + #define BTN_EN2 EXP1_07_PIN + #define BTN_ENC EXP1_01_PIN #elif HAS_WIRED_LCD #if ENABLED(CR10_STOCKDISPLAY) - #define BEEPER_PIN PB5 + #define BEEPER_PIN EXP1_01_PIN #define BTN_ENC EXP1_02_PIN - #define BTN_EN1 PA9 - #define BTN_EN2 PA10 + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN - #define LCD_PINS_RS PB8 + #define LCD_PINS_RS EXP1_07_PIN #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 PB9 + #define LCD_PINS_D4 EXP1_06_PIN #elif ENABLED(ZONESTAR_LCD) // ANET A8 LCD Controller - Must convert to 3.3V - CONNECTING TO 5V WILL DAMAGE THE BOARD! @@ -179,23 +185,23 @@ #error "CAUTION! ZONESTAR_LCD requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" #endif - #define LCD_PINS_RS PB9 + #define LCD_PINS_RS EXP1_06_PIN #define LCD_PINS_ENABLE EXP1_02_PIN - #define LCD_PINS_D4 PB8 - #define LCD_PINS_D5 PA10 - #define LCD_PINS_D6 PA9 - #define LCD_PINS_D7 PB5 + #define LCD_PINS_D4 EXP1_07_PIN + #define LCD_PINS_D5 EXP1_05_PIN + #define LCD_PINS_D6 EXP1_03_PIN + #define LCD_PINS_D7 EXP1_01_PIN #define ADC_KEYPAD_PIN PA1 // Repurpose servo pin for ADC - CONNECTING TO 5V WILL DAMAGE THE BOARD! #elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY) #define BTN_ENC EXP1_02_PIN - #define BTN_EN1 PA9 - #define BTN_EN2 PA10 + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN - #define DOGLCD_CS PB8 - #define DOGLCD_A0 PB9 - #define DOGLCD_SCK PB5 + #define DOGLCD_CS EXP1_07_PIN + #define DOGLCD_A0 EXP1_06_PIN + #define DOGLCD_SCK EXP1_01_PIN #define DOGLCD_MOSI EXP1_08_PIN #define FORCE_SOFT_SPI @@ -238,7 +244,7 @@ * EXP1-1 ----------- EXP1-7 SD_DET */ - #define TFTGLCD_CS PA9 + #define TFTGLCD_CS EXP1_03_PIN #endif @@ -291,20 +297,20 @@ * for backlight configuration see steps 2 (V2.1) and 3 in https://wiki.fysetc.com/Mini12864_Panel/ */ - #define LCD_PINS_RS PA9 // CS + #define LCD_PINS_RS EXP1_03_PIN // CS #define LCD_PINS_ENABLE PA3 // MOSI #define LCD_BACKLIGHT_PIN -1 - #define NEOPIXEL_PIN PB8 + #define NEOPIXEL_PIN EXP1_07_PIN #define LCD_CONTRAST 255 - #define LCD_RESET_PIN PA10 + #define LCD_RESET_PIN EXP1_05_PIN - #define DOGLCD_CS PA9 - #define DOGLCD_A0 PB5 + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_01_PIN #define DOGLCD_SCK PA2 #define DOGLCD_MOSI PA3 #define BTN_ENC PA15 - #define BTN_EN1 PB9 + #define BTN_EN1 EXP1_06_PIN #define BTN_EN2 PB15 #define FORCE_SOFT_SPI @@ -354,8 +360,8 @@ #define BEEPER_PIN EXP1_02_PIN - #define CLCD_MOD_RESET PA9 - #define CLCD_SPI_CS PB8 + #define CLCD_MOD_RESET EXP1_03_PIN + #define CLCD_SPI_CS EXP1_07_PIN #endif // TOUCH_UI_FTDI_EVE && LCD_FYSETC_TFT81050 @@ -370,8 +376,8 @@ #if SD_CONNECTION_IS(ONBOARD) #define SD_DETECT_PIN PC4 #elif SD_CONNECTION_IS(LCD) && (BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) || IS_TFTGLCD_PANEL) - #define SD_DETECT_PIN PB5 - #define SD_SS_PIN PA10 + #define SD_DETECT_PIN EXP1_01_PIN + #define SD_SS_PIN EXP1_05_PIN #elif SD_CONNECTION_IS(CUSTOM_CABLE) #error "SD CUSTOM_CABLE is not compatible with SKR Mini E3." #endif diff --git a/Marlin/src/pins/stm32f4/pins_ARMED.h b/Marlin/src/pins/stm32f4/pins_ARMED.h index d08d3fb66c0a..2abcc21da5a4 100644 --- a/Marlin/src/pins/stm32f4/pins_ARMED.h +++ b/Marlin/src/pins/stm32f4/pins_ARMED.h @@ -19,11 +19,10 @@ * along with this program. If not, see . * */ - -// https://github.com/ktand/Armed - #pragma once +// https://github.com/ktand/Armed + #include "env_validate.h" #if HOTENDS > 2 || E_STEPPERS > 2 diff --git a/Marlin/src/pins/stm32f4/pins_BTT_SKR_MINI_E3_V3_0_1.h b/Marlin/src/pins/stm32f4/pins_BTT_SKR_MINI_E3_V3_0_1.h new file mode 100644 index 000000000000..1e278cd4ba30 --- /dev/null +++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_MINI_E3_V3_0_1.h @@ -0,0 +1,350 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +//#define BOARD_CUSTOM_BUILD_FLAGS -DTONE_CHANNEL=4 -DTONE_TIMER=4 -DTIMER_TONE=4 + +#include "env_validate.h" + +#if HOTENDS > 1 || E_STEPPERS > 1 + #error "BTT SKR Mini E3 V3.0.1 supports up to 1 hotend / E stepper." +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "BTT SKR Mini E3 V3.0.1" +#endif + +#define USES_DIAG_JUMPERS + +// Ignore temp readings during development. +//#define BOGUS_TEMPERATURE_GRACE_PERIOD 2000 + +#ifndef NEOPIXEL_LED + #define LED_PIN PA14 +#endif + +// Onboard I2C EEPROM +#if EITHER(NO_EEPROM_SELECTED, I2C_EEPROM) + #undef NO_EEPROM_SELECTED + #define I2C_EEPROM + #define SOFT_I2C_EEPROM // Force the use of Software I2C + #define I2C_SCL_PIN PB8 + #define I2C_SDA_PIN PB9 + #define MARLIN_EEPROM_SIZE 0x1000 // 4KB +#endif + +// +// Servos +// +#define SERVO0_PIN PA0 // SERVOS + +// +// Limit Switches +// +#define X_STOP_PIN PB5 // X-STOP +#define Y_STOP_PIN PB6 // Y-STOP +#define Z_STOP_PIN PB7 // Z-STOP + +// +// Z Probe must be this pin +// +#define Z_MIN_PROBE_PIN PA1 // PROBE + +// +// Filament Runout Sensor +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PC15 // E0-STOP +#endif + +// +// Power-loss Detection +// +#ifndef POWER_LOSS_PIN + #define POWER_LOSS_PIN PC13 // Power Loss Detection: PWR-DET +#endif + +#ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN PA14 // LED driving pin +#endif + +#ifndef PS_ON_PIN + #define PS_ON_PIN PC14 // Power Supply Control +#endif + +// +// Steppers +// +#define X_ENABLE_PIN PC10 +#define X_STEP_PIN PC11 +#define X_DIR_PIN PC12 + +#define Y_ENABLE_PIN PB13 +#define Y_STEP_PIN PB12 +#define Y_DIR_PIN PB10 + +#define Z_ENABLE_PIN PB2 +#define Z_STEP_PIN PB1 +#define Z_DIR_PIN PB0 + +#define E0_ENABLE_PIN PC3 +#define E0_STEP_PIN PC2 +#define E0_DIR_PIN PC1 + +#if HAS_TMC_UART + /** + * TMC220x stepper drivers + * Hardware serial communication ports + */ + #define X_HARDWARE_SERIAL MSerial6 + #define Y_HARDWARE_SERIAL MSerial6 + #define Z_HARDWARE_SERIAL MSerial6 + #define E0_HARDWARE_SERIAL MSerial6 + + // Default TMC slave addresses + #ifndef X_SLAVE_ADDRESS + #define X_SLAVE_ADDRESS 0 + #endif + #ifndef Y_SLAVE_ADDRESS + #define Y_SLAVE_ADDRESS 2 + #endif + #ifndef Z_SLAVE_ADDRESS + #define Z_SLAVE_ADDRESS 1 + #endif + #ifndef E0_SLAVE_ADDRESS + #define E0_SLAVE_ADDRESS 3 + #endif +#endif + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC5 // Analog Input "TH0" +#define TEMP_BED_PIN PC4 // Analog Input "TB0" + +// +// Heaters / Fans +// +#define HEATER_0_PIN PA15 // "HE" +#define HEATER_BED_PIN PB3 // "HB" +#define FAN_PIN PC9 // "FAN0" +#define FAN1_PIN PA8 // "FAN1" +#define FAN2_PIN PC8 // "FAN2" + +/** + * SKR Mini E3 V3.0.1 + * ------ + * (BEEPER) PB15 | 1 2 | PB14 (BTN_ENC) + * (BTN_EN1) PA9 | 3 4 | RESET + * (BTN_EN2) PA10 5 6 | PB4 (LCD_D4) + * (LCD_RS) PD2 | 7 8 | PC0 (LCD_EN) + * GND | 9 10 | 5V + * ------ + * EXP1 + */ +#define EXP1_01_PIN PB15 +#define EXP1_02_PIN PB14 +#define EXP1_03_PIN PA9 +#define EXP1_04_PIN -1 // RESET +#define EXP1_05_PIN PA10 +#define EXP1_06_PIN PB4 +#define EXP1_07_PIN PD2 +#define EXP1_08_PIN PC0 + +#if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI + /** + * ------ ------ ------ + * (ENT) | 1 2 | (BEEP) |10 9 | |10 9 | + * (RX) | 3 4 | (RX) | 8 7 | (TX) RX | 8 7 | TX + * (TX) 5 6 | (ENT) 6 5 | (BEEP) ENT | 6 5 | BEEP + * (B) | 7 8 | (A) (B) | 4 3 | (A) B | 4 3 | A + * GND | 9 10 | (VCC) GND | 2 1 | VCC GND | 2 1 | VCC + * ------ ------ ------ + * EXP1 DWIN DWIN (plug) + * + * All pins are labeled as printed on DWIN PCB. Connect TX-TX, A-A and so on. + */ + + #error "DWIN_CREALITY_LCD requires a custom cable, see diagram above this line. Comment out this line to continue." + + #define BEEPER_PIN EXP1_02_PIN + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 EXP1_07_PIN + #define BTN_ENC EXP1_01_PIN + +#elif HAS_WIRED_LCD + + #if ENABLED(CR10_STOCKDISPLAY) + + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN + + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + + #elif ENABLED(ZONESTAR_LCD) // ANET A8 LCD Controller - Must convert to 3.3V - CONNECTING TO 5V WILL DAMAGE THE BOARD! + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! ZONESTAR_LCD requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + #define LCD_PINS_RS EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_02_PIN + #define LCD_PINS_D4 EXP1_07_PIN + #define LCD_PINS_D5 EXP1_05_PIN + #define LCD_PINS_D6 EXP1_03_PIN + #define LCD_PINS_D7 EXP1_01_PIN + #define ADC_KEYPAD_PIN PA1 // Repurpose servo pin for ADC - CONNECTING TO 5V WILL DAMAGE THE BOARD! + + #elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY) + + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + + #define DOGLCD_CS EXP1_07_PIN + #define DOGLCD_A0 EXP1_06_PIN + #define DOGLCD_SCK EXP1_01_PIN + #define DOGLCD_MOSI EXP1_08_PIN + + #define FORCE_SOFT_SPI + #define LCD_BACKLIGHT_PIN -1 + + #elif IS_TFTGLCD_PANEL + + #if ENABLED(TFTGLCD_PANEL_SPI) + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! TFTGLCD_PANEL_SPI requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + /** + * TFTGLCD_PANEL_SPI display pinout + * + * Board Display + * ------ ------ + * (BEEPER) PB6 | 1 2 | PB15 (SD_DET) 5V |10 9 | GND + * RESET | 3 4 | PA9 (MOD_RESET) -- | 8 7 | (SD_DET) + * PB4 5 6 | PA10 (SD_CS) (MOSI) | 6 5 | -- + * PB7 | 7 8 | PD2 (LCD_CS) (SD_CS) | 4 3 | (LCD_CS) + * GND | 9 10 | 5V (SCK) | 2 1 | (MISO) + * ------ ------ + * EXP1 EXP1 + * + * Needs custom cable: + * + * Board Display + * + * EXP1-10 ---------- EXP1-10 + * EXP1-9 ----------- EXP1-9 + * SPI1-4 ----------- EXP1-6 + * EXP1-7 ----------- FREE + * SPI1-3 ----------- EXP1-2 + * EXP1-5 ----------- EXP1-4 + * EXP1-4 ----------- FREE + * EXP1-3 ----------- EXP1-3 + * SPI1-1 ----------- EXP1-1 + * EXP1-1 ----------- EXP1-7 + */ + + #define TFTGLCD_CS EXP1_03_PIN + + #endif + + #else + #error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, MKS_MINI_12864, and TFTGLCD_PANEL_(SPI|I2C) are currently supported on the BIGTREE_SKR_MINI_E3." + #endif + +#endif // HAS_WIRED_LCD + +#if BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! LCD_FYSETC_TFT81050 requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_common.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + /** + * FYSETC TFT TFT81050 display pinout + * + * Board Display + * ------ ------ + * (SD_DET) PB15 | 1 2 | PB6 (BEEPER) 5V |10 9 | GND + * (MOD_RESET) PA9 | 3 4 | RESET (RESET) | 8 7 | (SD_DET) + * (SD_CS) PA10 5 6 | PB4 (FREE) (MOSI) | 6 5 | (LCD_CS) + * (LCD_CS) PD2 | 7 8 | PB7 (FREE) (SD_CS) | 4 3 | (MOD_RESET) + * 5V | 9 10 | GND (SCK) | 2 1 | (MISO) + * ------ ------ + * EXP1 EXP1 + * + * Needs custom cable: + * + * Board Adapter Display + * _________ + * EXP1-10 ---------- EXP1-10 + * EXP1-9 ----------- EXP1-9 + * SPI1-4 ----------- EXP1-6 + * EXP1-7 ----------- EXP1-5 + * SPI1-3 ----------- EXP1-2 + * EXP1-5 ----------- EXP1-4 + * EXP1-4 ----------- EXP1-8 + * EXP1-3 ----------- EXP1-3 + * SPI1-1 ----------- EXP1-1 + * EXP1-1 ----------- EXP1-7 + */ + + #define CLCD_SPI_BUS 1 // SPI1 connector + + #define BEEPER_PIN EXP1_02_PIN + + #define CLCD_MOD_RESET EXP1_03_PIN + #define CLCD_SPI_CS EXP1_07_PIN + +#endif // TOUCH_UI_FTDI_EVE && LCD_FYSETC_TFT81050 + +// +// SD Support +// + +#ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION ONBOARD +#endif + +#if SD_CONNECTION_IS(LCD) && (BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) || IS_TFTGLCD_PANEL) + #define SD_DETECT_PIN EXP1_01_PIN + #define SD_SS_PIN EXP1_05_PIN +#elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "SD CUSTOM_CABLE is not compatible with SKR Mini E3." +#endif + +#define ONBOARD_SPI_DEVICE 1 // SPI1 -> used only by HAL/STM32F1... +#define ONBOARD_SD_CS_PIN PA4 // Chip select for "System" SD card + +#define ENABLE_SPI1 +#define SDSS ONBOARD_SD_CS_PIN +#define SD_SS_PIN ONBOARD_SD_CS_PIN +#define SD_SCK_PIN PA5 +#define SD_MISO_PIN PA6 +#define SD_MOSI_PIN PA7 diff --git a/buildroot/share/PlatformIO/boards/marlin_STM32F401RC.json b/buildroot/share/PlatformIO/boards/marlin_STM32F401RC.json new file mode 100644 index 000000000000..f4242ccc00ca --- /dev/null +++ b/buildroot/share/PlatformIO/boards/marlin_STM32F401RC.json @@ -0,0 +1,38 @@ +{ + "build": { + "core": "stm32", + "cpu": "cortex-m4", + "extra_flags": "-DSTM32F401xC -DSTM32F4xx", + "f_cpu": "84000000L", + "mcu": "stm32f401rct6", + "product_line": "STM32F401xC", + "variant": "MARLIN_F401RC" + }, + "debug": { + "jlink_device": "STM32F401RC", + "openocd_target": "stm32f4x", + "svd_path": "STM32F401x.svd" + }, + "frameworks": [ + "arduino", + "cmsis", + "spl", + "stm32cube", + "libopencm3" + ], + "name": "STM32F401RC (64k RAM. 256k Flash)", + "upload": { + "maximum_ram_size": 65536, + "maximum_size": 262144, + "protocol": "serial", + "protocols": [ + "blackmagic", + "dfu", + "jlink", + "serial", + "stlink" + ] + }, + "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32f401rc.html", + "vendor": "Generic" +} diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F401RC/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_F401RC/PeripheralPins.c new file mode 100644 index 000000000000..b30ccf606b20 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F401RC/PeripheralPins.c @@ -0,0 +1,256 @@ +/* + ******************************************************************************* + * Copyright (c) 2020-2021, STMicroelectronics + * All rights reserved. + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ******************************************************************************* + */ +/* + * Automatically generated from STM32F401R(B-C)Tx.xml, STM32F401R(D-E)Tx.xml + * CubeMX DB release 6.0.30 + */ +#if !defined(CUSTOM_PERIPHERAL_PINS) +#include "Arduino.h" +#include "PeripheralPins.h" + +/* ===== + * Notes: + * - The pins mentioned Px_y_ALTz are alternative possibilities which use other + * HW peripheral instances. You can use them the same way as any other "normal" + * pin (i.e. analogWrite(PA7_ALT1, 128);). + * + * - Commented lines are alternative possibilities which are not used per default. + * If you change them, you will have to know what you do + * ===== + */ + +//*** ADC *** + +#ifdef HAL_ADC_MODULE_ENABLED +WEAK const PinMap PinMap_ADC[] = { + {PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0 + {PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 + {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 + {PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 + {PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 + {PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 + {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 + {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 + {PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 + {PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 + {PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 + {PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 + {PC_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 + {PC_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 + {PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 + {PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 + {NC, NP, 0} +}; +#endif + +//*** No DAC *** + +//*** I2C *** + +#ifdef HAL_I2C_MODULE_ENABLED +WEAK const PinMap PinMap_I2C_SDA[] = { + {PB_3, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF9_I2C2)}, + {PB_4, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF9_I2C3)}, + {PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PC_9, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_I2C_MODULE_ENABLED +WEAK const PinMap PinMap_I2C_SCL[] = { + {PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + {NC, NP, 0} +}; +#endif + +//*** TIM *** + +#ifdef HAL_TIM_MODULE_ENABLED +WEAK const PinMap PinMap_TIM[] = { + {PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + {PA_0_ALT1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 + {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + {PA_1_ALT1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 + {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 + {PA_2_ALT1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 + {PA_2_ALT2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 + {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + {PA_3_ALT1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 + {PA_3_ALT2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 + {PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + {PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + {PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + {PA_7_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 + {PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 + {PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 + {PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 + {PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + {PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + {PB_0_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 + {PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + {PB_1_ALT1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + {PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + {PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + {PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + {PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 + {PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 + {PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 + {PB_8_ALT1, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 + {PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + {PB_9_ALT1, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 + {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 + {PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + {PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + {PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + {PC_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + {PC_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + {PC_8, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 + {PC_9, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + {NC, NP, 0} +}; +#endif + +//*** UART *** + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_TX[] = { + {PA_2, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PA_11, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PC_6, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_RX[] = { + {PA_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PA_12, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PC_7, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_RTS[] = { + {PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_CTS[] = { + {PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {NC, NP, 0} +}; +#endif + +//*** SPI *** + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_MOSI[] = { + {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PB_5_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PC_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_MISO[] = { + {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PB_4_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PC_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_SCLK[] = { + {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PB_3_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {PB_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PC_10, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_SSEL[] = { + {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PA_4_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PA_15_ALT1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {PB_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {NC, NP, 0} +}; +#endif + +//*** No CAN *** + +//*** No ETHERNET *** + +//*** No QUADSPI *** + +//*** USB *** + +#if defined(HAL_PCD_MODULE_ENABLED) || defined(HAL_HCD_MODULE_ENABLED) +WEAK const PinMap PinMap_USB_OTG_FS[] = { + {PA_8, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_SOF + {PA_9, USB_OTG_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_FS_VBUS + {PA_10, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_ID + {PA_11, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DM + {PA_12, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DP + {NC, NP, 0} +}; +#endif + +//*** SD *** + +#ifdef HAL_SD_MODULE_ENABLED +WEAK const PinMap PinMap_SD[] = { + {PB_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D4 + {PB_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D5 + {PC_6, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D6 + {PC_7, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D7 + {PC_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D0 + {PC_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D1 + {PC_10, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D2 + {PC_11, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D3 + {PC_12, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO)}, // SDIO_CK + {PD_2, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO)}, // SDIO_CMD + {NC, NP, 0} +}; +#endif + +#endif /* !CUSTOM_PERIPHERAL_PINS */ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F401RC/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_F401RC/PinNamesVar.h new file mode 100644 index 000000000000..766cc2ca26c2 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F401RC/PinNamesVar.h @@ -0,0 +1,52 @@ +/* Alternate pin name */ +PA_0_ALT1 = PA_0 | ALT1, +PA_1_ALT1 = PA_1 | ALT1, +PA_2_ALT1 = PA_2 | ALT1, +PA_2_ALT2 = PA_2 | ALT2, +PA_3_ALT1 = PA_3 | ALT1, +PA_3_ALT2 = PA_3 | ALT2, +PA_4_ALT1 = PA_4 | ALT1, +PA_7_ALT1 = PA_7 | ALT1, +PA_15_ALT1 = PA_15 | ALT1, +PB_0_ALT1 = PB_0 | ALT1, +PB_1_ALT1 = PB_1 | ALT1, +PB_3_ALT1 = PB_3 | ALT1, +PB_4_ALT1 = PB_4 | ALT1, +PB_5_ALT1 = PB_5 | ALT1, +PB_8_ALT1 = PB_8 | ALT1, +PB_9_ALT1 = PB_9 | ALT1, + +/* SYS_WKUP */ +#ifdef PWR_WAKEUP_PIN1 + SYS_WKUP1 = PA_0, +#endif +#ifdef PWR_WAKEUP_PIN2 + SYS_WKUP2 = NC, +#endif +#ifdef PWR_WAKEUP_PIN3 + SYS_WKUP3 = NC, +#endif +#ifdef PWR_WAKEUP_PIN4 + SYS_WKUP4 = NC, +#endif +#ifdef PWR_WAKEUP_PIN5 + SYS_WKUP5 = NC, +#endif +#ifdef PWR_WAKEUP_PIN6 + SYS_WKUP6 = NC, +#endif +#ifdef PWR_WAKEUP_PIN7 + SYS_WKUP7 = NC, +#endif +#ifdef PWR_WAKEUP_PIN8 + SYS_WKUP8 = NC, +#endif + +/* USB */ +#ifdef USBCON + USB_OTG_FS_DM = PA_11, + USB_OTG_FS_DP = PA_12, + USB_OTG_FS_ID = PA_10, + USB_OTG_FS_SOF = PA_8, + USB_OTG_FS_VBUS = PA_9, +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F401RC/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_F401RC/ldscript.ld new file mode 100644 index 000000000000..a0ab41f631c5 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F401RC/ldscript.ld @@ -0,0 +1,177 @@ +/** + ****************************************************************************** + * @file LinkerScript.ld + * @author Auto-generated by STM32CubeIDE + * @brief Linker script for STM32F401RBTx Device from STM32F4 series + * 128Kbytes FLASH + * 64Kbytes RAM + * + * Set heap size, stack size and stack location according + * to application requirements. + * + * Set memory bank area and size if external memory is used + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Highest address of the user mode stack */ +_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */ + +_Min_Heap_Size = 0x200; /* required amount of heap */ +_Min_Stack_Size = 0x400; /* required amount of stack */ + +/* Memories definition */ +MEMORY +{ + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE + FLASH (rx) : ORIGIN = 0x8000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET +} + +/* Sections */ +SECTIONS +{ + /* The startup code into "FLASH" Rom type memory */ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + } >FLASH + + /* The program code and other data into "FLASH" Rom type memory */ + .text : + { + . = ALIGN(4); + *(.text) /* .text sections (code) */ + *(.text*) /* .text* sections (code) */ + *(.glue_7) /* glue arm to thumb code */ + *(.glue_7t) /* glue thumb to arm code */ + *(.eh_frame) + + KEEP (*(.init)) + KEEP (*(.fini)) + + . = ALIGN(4); + _etext = .; /* define a global symbols at end of code */ + } >FLASH + + /* Constant data into "FLASH" Rom type memory */ + .rodata : + { + . = ALIGN(4); + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + . = ALIGN(4); + } >FLASH + + .ARM.extab : { + . = ALIGN(4); + *(.ARM.extab* .gnu.linkonce.armextab.*) + . = ALIGN(4); + } >FLASH + + .ARM : { + . = ALIGN(4); + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + . = ALIGN(4); + } >FLASH + + .preinit_array : + { + . = ALIGN(4); + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)) + PROVIDE_HIDDEN (__preinit_array_end = .); + . = ALIGN(4); + } >FLASH + + .init_array : + { + . = ALIGN(4); + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + . = ALIGN(4); + } >FLASH + + .fini_array : + { + . = ALIGN(4); + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array*)) + PROVIDE_HIDDEN (__fini_array_end = .); + . = ALIGN(4); + } >FLASH + + /* Used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* Initialized data sections into "RAM" Ram type memory */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + *(.RamFunc) /* .RamFunc sections */ + *(.RamFunc*) /* .RamFunc* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + + } >RAM AT> FLASH + + /* Uninitialized data section into "RAM" Ram type memory */ + . = ALIGN(4); + .bss : + { + /* This is used by the startup in order to initialize the .bss section */ + _sbss = .; /* define a global symbol at bss start */ + __bss_start__ = _sbss; + *(.bss) + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end */ + __bss_end__ = _ebss; + } >RAM + + /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */ + ._user_heap_stack : + { + . = ALIGN(8); + PROVIDE ( end = . ); + PROVIDE ( _end = . ); + . = . + _Min_Heap_Size; + . = . + _Min_Stack_Size; + . = ALIGN(8); + } >RAM + + /* Remove information from the compiler libraries */ + /DISCARD/ : + { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + + .ARM.attributes 0 : { *(.ARM.attributes) } +} diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F401RC/variant_MARLIN_STM32F401RC.cpp b/buildroot/share/PlatformIO/variants/MARLIN_F401RC/variant_MARLIN_STM32F401RC.cpp new file mode 100644 index 000000000000..aac11b0b66cf --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F401RC/variant_MARLIN_STM32F401RC.cpp @@ -0,0 +1,223 @@ +/* + ******************************************************************************* + * Copyright (c) 2020-2021, STMicroelectronics + * All rights reserved. + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ******************************************************************************* + */ + +#if defined(STM32F401xC) +#include "pins_arduino.h" + +// Digital PinName array +const PinName digitalPin[] = { + PA_0, // D0/A0 + PA_1, // D1/A1 + PA_2, // D2/A2 + PA_3, // D3/A3 + PA_4, // D4/A4 + PA_5, // D5/A5 + PA_6, // D6/A6 + PA_7, // D7/A7 + PA_8, // D8 + PA_9, // D9 + PA_10, // D10 + PA_11, // D11 + PA_12, // D12 + PA_13, // D13 + PA_14, // D14 + PA_15, // D15 + PB_0, // D16/A8 + PB_1, // D17/A9 + PB_2, // D18 + PB_3, // D19 + PB_4, // D20 + PB_5, // D21 + PB_6, // D22 + PB_7, // D23 + PB_8, // D24 + PB_9, // D25 + PB_10, // D26 + PB_12, // D27 + PB_13, // D28 + PB_14, // D29 + PB_15, // D30 + PC_0, // D31/A10 + PC_1, // D32/A11 + PC_2, // D33/A12 + PC_3, // D34/A13 + PC_4, // D35/A14 + PC_5, // D36/A15 + PC_6, // D37 + PC_7, // D38 + PC_8, // D39 + PC_9, // D40 + PC_10, // D41 + PC_11, // D42 + PC_12, // D43 + PC_13, // D44 + PC_14, // D45 + PC_15, // D46 + PD_2, // D47 + PH_0, // D48 + PH_1 // D49 +}; + +// Analog (Ax) pin number array +const uint32_t analogInputPin[] = { + 0, // A0, PA0 + 1, // A1, PA1 + 2, // A2, PA2 + 3, // A3, PA3 + 4, // A4, PA4 + 5, // A5, PA5 + 6, // A6, PA6 + 7, // A7, PA7 + 16, // A8, PB0 + 17, // A9, PB1 + 31, // A10, PC0 + 32, // A11, PC1 + 33, // A12, PC2 + 34, // A13, PC3 + 35, // A14, PC4 + 36 // A15, PC5 +}; + +// ---------------------------------------------------------------------------- + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * @brief Configures the System clock source, PLL Multiplier and Divider factors, + * AHB/APBx prescalers and Flash settings + * @note This function should be called only once the RCC clock configuration + * is reset to the default reset state (done in SystemInit() function). + * @param None + * @retval None + */ + +/******************************************************************************/ +/* PLL (clocked by HSE) used as System clock source */ +/******************************************************************************/ +static uint8_t SetSysClock_PLL_HSE(uint8_t bypass) +{ + RCC_OscInitTypeDef RCC_OscInitStruct; + RCC_ClkInitTypeDef RCC_ClkInitStruct; + + /* The voltage scaling allows optimizing the power consumption when the device is + clocked below the maximum system frequency, to update the voltage scaling value + regarding system frequency refer to product datasheet. */ + __HAL_RCC_PWR_CLK_ENABLE(); + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2); + + // Enable HSE oscillator and activate PLL with HSE as source + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; + if (bypass == 0) { + RCC_OscInitStruct.HSEState = RCC_HSE_ON; // External 8 MHz xtal on OSC_IN/OSC_OUT + } else { + RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS; // External 8 MHz clock on OSC_IN + } + + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = HSE_VALUE / 1000000L; // Expects an 8 MHz external clock by default. Redefine HSE_VALUE if not + RCC_OscInitStruct.PLL.PLLN = 336; // VCO output clock = 336 MHz (1 MHz * 336) + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; // PLLCLK = 84 MHz (336 MHz / 4) + RCC_OscInitStruct.PLL.PLLQ = 7; // USB clock = 48 MHz (336 MHz / 7) --> OK for USB + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { + return 0; // FAIL + } + + // Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; // 84 MHz + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 84 MHz + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; // 42 MHz + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; // 84 MHz + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) { + return 0; // FAIL + } + + /* Output clock on MCO1 pin(PA8) for debugging purpose */ + /* + if (bypass == 0) + HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_2); // 4 MHz + else + HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_1); // 8 MHz + */ + + return 1; // OK +} + +/******************************************************************************/ +/* PLL (clocked by HSI) used as System clock source */ +/******************************************************************************/ +uint8_t SetSysClock_PLL_HSI(void) +{ + RCC_OscInitTypeDef RCC_OscInitStruct; + RCC_ClkInitTypeDef RCC_ClkInitStruct; + + /* The voltage scaling allows optimizing the power consumption when the device is + clocked below the maximum system frequency, to update the voltage scaling value + regarding system frequency refer to product datasheet. */ + __HAL_RCC_PWR_CLK_ENABLE(); + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2); + + // Enable HSI oscillator and activate PLL with HSI as source + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSIState = RCC_HSI_ON; + RCC_OscInitStruct.HSEState = RCC_HSE_OFF; + RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; + RCC_OscInitStruct.PLL.PLLM = 16; // VCO input clock = 1 MHz (16 MHz / 16) + RCC_OscInitStruct.PLL.PLLN = 336; // VCO output clock = 336 MHz (1 MHz * 336) + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; // PLLCLK = 84 MHz (336 MHz / 4) + RCC_OscInitStruct.PLL.PLLQ = 7; // USB clock = 48 MHz (336 MHz / 7) --> freq is ok but not precise enough + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { + return 0; // FAIL + } + + /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */ + RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; // 84 MHz + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 84 MHz + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; // 42 MHz + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; // 84 MHz + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) { + return 0; // FAIL + } + + /* Output clock on MCO1 pin(PA8) for debugging purpose */ + //HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSI, RCC_MCODIV_1); // 16 MHz + + return 1; // OK +} + +WEAK void SystemClock_Config(void) +{ + /* 1- If fail try to start with HSE and external xtal */ + if (SetSysClock_PLL_HSE(0) == 0) { + /* 2- Try to start with HSE and external clock */ + if (SetSysClock_PLL_HSE(1) == 0) { + /* 3- If fail start with HSI clock */ + if (SetSysClock_PLL_HSI() == 0) { + Error_Handler(); + } + } + } + /* Output clock on MCO2 pin(PC9) for debugging purpose */ + //HAL_RCC_MCOConfig(RCC_MCO2, RCC_MCO2SOURCE_SYSCLK, RCC_MCODIV_4); +} + +#ifdef __cplusplus +} +#endif +#endif /* STM32F401xC */ \ No newline at end of file diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F401RC/variant_MARLIN_STM32F401RC.h b/buildroot/share/PlatformIO/variants/MARLIN_F401RC/variant_MARLIN_STM32F401RC.h new file mode 100644 index 000000000000..37d60d93068a --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F401RC/variant_MARLIN_STM32F401RC.h @@ -0,0 +1,186 @@ +/* + ******************************************************************************* + * Copyright (c) 2020-2021, STMicroelectronics + * All rights reserved. + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ******************************************************************************* + */ +#pragma once + +/*---------------------------------------------------------------------------- + * STM32 pins number + *----------------------------------------------------------------------------*/ +#define PA0 PIN_A0 +#define PA1 PIN_A1 +#define PA2 PIN_A2 +#define PA3 PIN_A3 +#define PA4 PIN_A4 +#define PA5 PIN_A5 +#define PA6 PIN_A6 +#define PA7 PIN_A7 +#define PA8 8 +#define PA9 9 +#define PA10 10 +#define PA11 11 +#define PA12 12 +#define PA13 13 +#define PA14 14 +#define PA15 15 +#define PB0 PIN_A8 +#define PB1 PIN_A9 +#define PB2 18 +#define PB3 19 +#define PB4 20 +#define PB5 21 +#define PB6 22 +#define PB7 23 +#define PB8 24 +#define PB9 25 +#define PB10 26 +#define PB12 27 +#define PB13 28 +#define PB14 29 +#define PB15 30 +#define PC0 PIN_A10 +#define PC1 PIN_A11 +#define PC2 PIN_A12 +#define PC3 PIN_A13 +#define PC4 PIN_A14 +#define PC5 PIN_A15 +#define PC6 37 +#define PC7 38 +#define PC8 39 +#define PC9 40 +#define PC10 41 +#define PC11 42 +#define PC12 43 +#define PC13 44 +#define PC14 45 +#define PC15 46 +#define PD2 47 +#define PH0 48 +#define PH1 49 + +// Alternate pins number +#define PA0_ALT1 (PA0 | ALT1) +#define PA1_ALT1 (PA1 | ALT1) +#define PA2_ALT1 (PA2 | ALT1) +#define PA2_ALT2 (PA2 | ALT2) +#define PA3_ALT1 (PA3 | ALT1) +#define PA3_ALT2 (PA3 | ALT2) +#define PA4_ALT1 (PA4 | ALT1) +#define PA7_ALT1 (PA7 | ALT1) +#define PA15_ALT1 (PA15 | ALT1) +#define PB0_ALT1 (PB0 | ALT1) +#define PB1_ALT1 (PB1 | ALT1) +#define PB3_ALT1 (PB3 | ALT1) +#define PB4_ALT1 (PB4 | ALT1) +#define PB5_ALT1 (PB5 | ALT1) +#define PB8_ALT1 (PB8 | ALT1) +#define PB9_ALT1 (PB9 | ALT1) + +#define NUM_DIGITAL_PINS 50 +#define NUM_ANALOG_INPUTS 16 +#define NUM_ANALOG_FIRST 192 + +// On-board LED pin number +#ifndef LED_BUILTIN + #define LED_BUILTIN PNUM_NOT_DEFINED +#endif + +// On-board user button +#ifndef USER_BTN + #define USER_BTN PNUM_NOT_DEFINED +#endif + +// SPI definitions +#ifndef PIN_SPI_SS + #define PIN_SPI_SS PA4 +#endif +#ifndef PIN_SPI_SS1 + #define PIN_SPI_SS1 PA15 +#endif +#ifndef PIN_SPI_SS2 + #define PIN_SPI_SS2 PNUM_NOT_DEFINED +#endif +#ifndef PIN_SPI_SS3 + #define PIN_SPI_SS3 PNUM_NOT_DEFINED +#endif +#ifndef PIN_SPI_MOSI + #define PIN_SPI_MOSI PA7 +#endif +#ifndef PIN_SPI_MISO + #define PIN_SPI_MISO PA6 +#endif +#ifndef PIN_SPI_SCK + #define PIN_SPI_SCK PA5 +#endif + +// I2C definitions +#ifndef PIN_WIRE_SDA + #define PIN_WIRE_SDA PB3 +#endif +#ifndef PIN_WIRE_SCL + #define PIN_WIRE_SCL PB10 +#endif + +// Timer Definitions +// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin +#ifndef TIMER_TONE + #define TIMER_TONE TIM10 +#endif +#ifndef TIMER_SERVO + #define TIMER_SERVO TIM11 +#endif + +// UART Definitions +#ifndef SERIAL_UART_INSTANCE + #define SERIAL_UART_INSTANCE 2 +#endif + +// Default pin used for generic 'Serial' instance +// Mandatory for Firmata +#ifndef PIN_SERIAL_RX + #define PIN_SERIAL_RX PA3 +#endif +#ifndef PIN_SERIAL_TX + #define PIN_SERIAL_TX PA2 +#endif + +// Extra HAL modules +#if !defined(HAL_SD_MODULE_DISABLED) + #define HAL_SD_MODULE_ENABLED +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus + // These serial port names are intended to allow libraries and architecture-neutral + // sketches to automatically default to the correct port name for a particular type + // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, + // the first hardware serial port whose RX/TX pins are not dedicated to another use. + // + // SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor + // + // SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial + // + // SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library + // + // SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. + // + // SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX + // pins are NOT connected to anything by default. + #ifndef SERIAL_PORT_MONITOR + #define SERIAL_PORT_MONITOR Serial + #endif + #ifndef SERIAL_PORT_HARDWARE + #define SERIAL_PORT_HARDWARE Serial + #endif +#endif diff --git a/ini/stm32f4.ini b/ini/stm32f4.ini index 2c5aedbfe004..39ceb8079d02 100644 --- a/ini/stm32f4.ini +++ b/ini/stm32f4.ini @@ -656,3 +656,21 @@ upload_protocol = jlink extends = env:STM32F401RC_creality debug_tool = stlink upload_protocol = stlink + +# +# BigTree SKR mini E3 V3.0.1 (STM32F401RCT6 ARM Cortex-M4) +# +[env:STM32F401RC_btt] +extends = stm32_variant +platform = ststm32@~14.1.0 +platform_packages = framework-arduinoststm32@https://github.com/stm32duino/Arduino_Core_STM32/archive/main.zip +board = marlin_STM32F401RC +board_build.offset = 0x4000 +board_upload.offset_address = 0x08004000 +build_flags = ${stm32_variant.build_flags} + -DPIN_SERIAL6_RX=PC_7 -DPIN_SERIAL6_TX=PC_6 + -DSERIAL_RX_BUFFER_SIZE=1024 -DSERIAL_TX_BUFFER_SIZE=1024 + -DTIMER_SERVO=TIM3 -DTIMER_TONE=TIM4 + -DSTEP_TIMER_IRQ_PRIO=0 +upload_protocol = stlink +debug_tool = stlink From 96d050c7ba4c1f3dccf1278eb2eb6c6b4dab4a99 Mon Sep 17 00:00:00 2001 From: George Fu Date: Wed, 14 Sep 2022 01:28:38 +0800 Subject: [PATCH 059/243] =?UTF-8?q?=E2=9C=A8=20FYSETC=20SPIDER=20KING407?= =?UTF-8?q?=20(#24696)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/boards.h | 1 + Marlin/src/pins/pins.h | 2 + .../PeripheralPins.c | 399 ++++++++++++++++++ .../PinNamesVar.h | 50 +++ .../MARLIN_FYSETC_SPIDER_KING407/ldscript.ld | 204 +++++++++ .../MARLIN_FYSETC_SPIDER_KING407/variant.cpp | 212 ++++++++++ .../MARLIN_FYSETC_SPIDER_KING407/variant.h | 237 +++++++++++ ini/stm32f4.ini | 10 + 8 files changed, 1115 insertions(+) create mode 100644 buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/PeripheralPins.c create mode 100644 buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/PinNamesVar.h create mode 100644 buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/ldscript.ld create mode 100644 buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/variant.cpp create mode 100644 buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/variant.h diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index f3f5c01d2de3..42f8746aafb6 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -423,6 +423,7 @@ #define BOARD_FYSETC_SPIDER_V2_2 4239 // FYSETC Spider V2.2 (STM32F446VE) #define BOARD_CREALITY_V24S1_301F4 4240 // Creality v2.4.S1_301F4 (STM32F401RC) as found in the Ender-3 S1 F4 #define BOARD_OPULO_LUMEN_REV4 4241 // Opulo Lumen PnP Controller REV4 (STM32F407VE / STM32F407VG) +#define BOARD_FYSETC_SPIDER_KING407 4242 // FYSETC Spider King407 (STM32F407ZG) // // ARM Cortex M7 diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 384f06ecfd23..2bd5d613347a 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -705,6 +705,8 @@ #include "stm32f4/pins_CREALITY_V24S1_301F4.h" // STM32F4 env:STM32F401RC_creality env:STM32F401RC_creality_jlink env:STM32F401RC_creality_stlink #elif MB(OPULO_LUMEN_REV4) #include "stm32f4/pins_OPULO_LUMEN_REV4.h" // STM32F4 env:Opulo_Lumen_REV4 +#elif MB(FYSETC_SPIDER_KING407) + #include "stm32f4/pins_FYSETC_SPIDER_KING407.h" // STM32F4 env:FYSETC_SPIDER_KING407 // // ARM Cortex M7 diff --git a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/PeripheralPins.c new file mode 100644 index 000000000000..4205e103184f --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/PeripheralPins.c @@ -0,0 +1,399 @@ +/* + ******************************************************************************* + * Copyright (c) 2019, STMicroelectronics + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************* + * Automatically generated from STM32F407Z(E-G)Tx.xml + */ +#include +#include + +/* ===== + * Note: Commented lines are alternative possibilities which are not used per default. + * If you change them, you will have to know what you do + * ===== + */ + +//*** ADC *** + +#ifdef HAL_ADC_MODULE_ENABLED +WEAK const PinMap PinMap_ADC[] = { + //{PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0 + //{PA_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC2_IN0 + //{PA_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC3_IN0 + //{PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 + //{PA_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC2_IN1 + //{PA_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC3_IN1 + {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 LCD RX + //{PA_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC2_IN2 + //{PA_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC3_IN2 + {PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 LCD TX + //{PA_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC2_IN3 + //{PA_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC3_IN3 + //{PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 + //{PA_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC2_IN4 + //{PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 + //{PA_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC2_IN5 + //{PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 + //{PA_6, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC2_IN6 + //{PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 + //{PA_7, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC2_IN7 + //{PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 + //{PB_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC2_IN8 + //{PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 + //{PB_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC2_IN9 + {PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 + //{PC_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC2_IN10 + //{PC_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC3_IN10 + {PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 + //{PC_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC2_IN11 + //{PC_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC3_IN11 + {PC_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 + //{PC_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC2_IN12 + //{PC_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC3_IN12 + {PC_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 + //{PC_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC2_IN13 + //{PC_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC3_IN13 + //{PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 + //{PC_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC2_IN14 + //{PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 + //{PC_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC2_IN15 + //{PF_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC3_IN9 + //{PF_4, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC3_IN14 + //{PF_5, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC3_IN15 + //{PF_6, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC3_IN4 + //{PF_7, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC3_IN5 + //{PF_8, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC3_IN6 + {PF_9, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC3_IN7 + {PF_10, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC3_IN8 + {NC, NP, 0} +}; +#endif + +//*** DAC *** + +#ifdef HAL_DAC_MODULE_ENABLED +WEAK const PinMap PinMap_DAC[] = { + //{PA_4, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // DAC_OUT1 + //{PA_5, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC_OUT2 + {NC, NP, 0} +}; +#endif + +//*** I2C *** + +#ifdef HAL_I2C_MODULE_ENABLED +WEAK const PinMap PinMap_I2C_SDA[] = { + {PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_11, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + {PC_9, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + {PF_0, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_I2C_SCL[] = { + {PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + {PF_1, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + {NC, NP, 0} +}; +#endif + +//*** PWM *** + +#ifdef HAL_TIM_MODULE_ENABLED +WEAK const PinMap PinMap_PWM[] = { + //{PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + // {PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 + // {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + //{PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 + // {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 + //{PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 + // {PA_2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 + // {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + //{PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 + // {PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 + //{PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + // {PA_5, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N + // {PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + //{PA_6, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 + // {PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + // {PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + // {PA_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N + //{PA_7, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 + //{PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 + //{PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 + //{PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 + //{PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 + {PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 HEATER_4_PIN + // {PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + // {PB_0, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 + {PB_0, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N HEATER_1_PIN + // {PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + // {PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + //{PB_1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N + //{PB_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + //{PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + {PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 HEATER_0_PIN + //{PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + //{PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 + //{PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 + //{PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 + // {PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 + // {PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + //{PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 + //{PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 + //{PB_11, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + //{PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + // {PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + // {PB_14, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N + //{PB_14, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 1, 0)}, // TIM12_CH1 + // {PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + // {PB_15, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N + //{PB_15, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 2, 0)}, // TIM12_CH2 + //{PC_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + // {PC_6, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1 + // {PC_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + //{PC_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2 + // {PC_8, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 + {PC_8, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 0)}, // TIM8_CH3 HEATER_3_PIN + // {PC_9, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + //{PC_9, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 4, 0)}, // TIM8_CH4 + {PD_12, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 FAN3 + {PD_13, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 HEATER_2_PIN + {PD_14, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 FAN4 + {PD_15, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 FAN2_PIN + //{PE_5, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 + //{PE_6, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 + {PE_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N FAN_PIN + {PE_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 FAN1_PIN + {PE_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N HEATER_BED_PIN + //{PE_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 + //{PE_12, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + //{PE_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 + //{PE_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 + {NC, NP, 0} +}; +#endif + +//*** SERIAL *** + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_TX[] = { + //{PA_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {PA_2, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + //{PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + //{PB_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PC_6, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + //{PC_10, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + //{PC_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PC_12, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, + //{PD_5, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + //{PD_8, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_UART_RX[] = { + //{PA_1, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {PA_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + //{PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + //{PB_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PC_7, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + // {PC_11, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + //{PC_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PD_2, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, + //{PD_6, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + //{PD_9, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_UART_RTS[] = { + //{PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + //{PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + //{PB_14, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PD_4, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + //{PD_12, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PG_8, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + //{PG_12, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_UART_CTS[] = { + //{PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + //{PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + //{PB_13, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PD_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + //{PD_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + //{PG_13, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + //{PG_15, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + {NC, NP, 0} +}; +#endif + +//*** SPI *** + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_MOSI[] = { + {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PB_5, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PC_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_SPI_MISO[] = { + {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PB_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PC_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_SPI_SCLK[] = { + {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PB_3, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PB_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + //{PC_10, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_SPI_SSEL[] = { + {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PA_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + //{PA_15, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + //{PB_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {NC, NP, 0} +}; +#endif + +//*** CAN *** + +#ifdef HAL_CAN_MODULE_ENABLED +WEAK const PinMap PinMap_CAN_RD[] = { + //{PA_11, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + //{PB_5, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + {PB_8, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + //{PB_12, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + //{PD_0, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_CAN_TD[] = { + //{PA_12, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + //{PB_6, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + {PB_9, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + //{PB_13, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + //{PD_1, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + {NC, NP, 0} +}; +#endif + +//*** ETHERNET *** + +#ifdef HAL_ETH_MODULE_ENABLED +WEAK const PinMap PinMap_Ethernet[] = { + /* + {PA_0, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_CRS + {PA_1, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_REF_CLK|ETH_RX_CLK + {PA_2, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_MDIO + {PA_3, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_COL + {PA_7, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_CRS_DV|ETH_RX_DV + {PB_0, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RXD2 + {PB_1, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RXD3 + {PB_5, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_PPS_OUT + {PB_8, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD3 + {PB_10, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RX_ER + {PB_11, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TX_EN + {PB_12, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD0 + {PB_13, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD1 + {PC_1, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_MDC + {PC_2, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD2 + {PC_3, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TX_CLK + {PC_4, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RXD0 + {PC_5, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_RXD1 + {PE_2, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD3 + {PG_8, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_PPS_OUT + {PG_11, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TX_EN + {PG_13, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD0 + {PG_14, ETH, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF11_ETH)}, // ETH_TXD1 + {NC, NP, 0} + */ +}; +#endif + +//*** No QUADSPI *** + +//*** USB *** + +#ifdef HAL_PCD_MODULE_ENABLED +WEAK const PinMap PinMap_USB_OTG_FS[] = { + //{PA_8, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_SOF + //{PA_9, USB_OTG_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_FS_VBUS + //{PA_10, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_ID + {PA_11, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DM + {PA_12, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DP + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_USB_OTG_HS[] = { + /* + #ifdef USE_USB_HS_IN_FS + {PA_4, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_SOF + {PB_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_ID + {PB_13, USB_OTG_HS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_OTG_HS_VBUS + {PB_14, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_DM + {PB_15, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_OTG_HS_FS)}, // USB_OTG_HS_DP + #else + {PA_3, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D0 + {PA_5, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_CK + {PB_0, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D1 + {PB_1, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D2 + {PB_5, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D7 + {PB_10, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D3 + {PB_11, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D4 + {PB_12, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D5 + {PB_13, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_D6 + {PC_0, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_STP + {PC_2, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_DIR + {PC_3, USB_OTG_HS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_HS)}, // USB_OTG_HS_ULPI_NXT + #endif // USE_USB_HS_IN_FS + */ + {NC, NP, 0} +}; +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/PinNamesVar.h new file mode 100644 index 000000000000..b4bb9d45f8ac --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/PinNamesVar.h @@ -0,0 +1,50 @@ +/* SYS_WKUP */ +#ifdef PWR_WAKEUP_PIN1 + SYS_WKUP1 = PA_0, +#endif +#ifdef PWR_WAKEUP_PIN2 + SYS_WKUP2 = NC, +#endif +#ifdef PWR_WAKEUP_PIN3 + SYS_WKUP3 = NC, +#endif +#ifdef PWR_WAKEUP_PIN4 + SYS_WKUP4 = NC, +#endif +#ifdef PWR_WAKEUP_PIN5 + SYS_WKUP5 = NC, +#endif +#ifdef PWR_WAKEUP_PIN6 + SYS_WKUP6 = NC, +#endif +#ifdef PWR_WAKEUP_PIN7 + SYS_WKUP7 = NC, +#endif +#ifdef PWR_WAKEUP_PIN8 + SYS_WKUP8 = NC, +#endif +/* USB */ +#ifdef USBCON + USB_OTG_FS_SOF = PA_8, + USB_OTG_FS_VBUS = PA_9, + USB_OTG_FS_ID = PA_10, + USB_OTG_FS_DM = PA_11, + USB_OTG_FS_DP = PA_12, + USB_OTG_HS_ULPI_D0 = PA_3, + USB_OTG_HS_SOF = PA_4, + USB_OTG_HS_ULPI_CK = PA_5, + USB_OTG_HS_ULPI_D1 = PB_0, + USB_OTG_HS_ULPI_D2 = PB_1, + USB_OTG_HS_ULPI_D7 = PB_5, + USB_OTG_HS_ULPI_D3 = PB_10, + USB_OTG_HS_ULPI_D4 = PB_11, + USB_OTG_HS_ID = PB_12, + USB_OTG_HS_ULPI_D5 = PB_12, + USB_OTG_HS_ULPI_D6 = PB_13, + USB_OTG_HS_VBUS = PB_13, + USB_OTG_HS_DM = PB_14, + USB_OTG_HS_DP = PB_15, + USB_OTG_HS_ULPI_STP = PC_0, + USB_OTG_HS_ULPI_DIR = PC_2, + USB_OTG_HS_ULPI_NXT = PC_3, +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/ldscript.ld new file mode 100644 index 000000000000..6af296a521ff --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/ldscript.ld @@ -0,0 +1,204 @@ +/* +***************************************************************************** +** + +** File : LinkerScript.ld +** +** Abstract : Linker script for STM32F407ZGTx Device with +** 1024KByte FLASH, 128KByte RAM +** +** Set heap size, stack size and stack location according +** to application requirements. +** +** Set memory bank area and size if external memory is used. +** +** Target : STMicroelectronics STM32 +** +** +** Distribution: The file is distributed as is, without any warranty +** of any kind. +** +***************************************************************************** +** @attention +** +**

© COPYRIGHT(c) 2014 Ac6

+** +** Redistribution and use in source and binary forms, with or without modification, +** are permitted provided that the following conditions are met: +** 1. Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** 3. Neither the name of Ac6 nor the names of its contributors +** may be used to endorse or promote products derived from this software +** without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +***************************************************************************** +*/ + +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Highest address of the user mode stack */ +_estack = 0x20020000; /* end of RAM */ +/* Generate a link error if heap and stack don't fit into RAM */ +_Min_Heap_Size = 0x200;; /* required amount of heap */ +_Min_Stack_Size = 0x400;; /* required amount of stack */ + +/* Specify the memory areas */ +MEMORY +{ +FLASH (rx) : ORIGIN = 0x8008000, LENGTH = 1024K +RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K +CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K +} + +/* Define output sections */ +SECTIONS +{ + /* The startup code goes first into FLASH */ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + } >FLASH + + /* The program code and other data goes into FLASH */ + .text ALIGN(4): + { + . = ALIGN(4); + *(.text) /* .text sections (code) */ + *(.text*) /* .text* sections (code) */ + *(.glue_7) /* glue arm to thumb code */ + *(.glue_7t) /* glue thumb to arm code */ + *(.eh_frame) + + KEEP (*(.init)) + KEEP (*(.fini)) + + . = ALIGN(4); + _etext = .; /* define a global symbols at end of code */ + } >FLASH + + /* Constant data goes into FLASH */ + .rodata ALIGN(4): + { + . = ALIGN(4); + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + . = ALIGN(4); + } >FLASH + + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH + .ARM : { + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + } >FLASH + + .preinit_array : + { + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)) + PROVIDE_HIDDEN (__preinit_array_end = .); + } >FLASH + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + } >FLASH + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array*)) + PROVIDE_HIDDEN (__fini_array_end = .); + } >FLASH + + /* used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* Initialized data sections goes into RAM, load LMA copy after code */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + } >RAM AT> FLASH + + _siccmram = LOADADDR(.ccmram); + + /* CCM-RAM section + * + * IMPORTANT NOTE! + * If initialized variables will be placed in this section, + * the startup code needs to be modified to copy the init-values. + */ + .ccmram : + { + . = ALIGN(4); + _sccmram = .; /* create a global symbol at ccmram start */ + *(.ccmram) + *(.ccmram*) + + . = ALIGN(4); + _eccmram = .; /* create a global symbol at ccmram end */ + } >CCMRAM AT> FLASH + + + /* Uninitialized data section */ + . = ALIGN(4); + .bss : + { + /* This is used by the startup in order to initialize the .bss section */ + _sbss = .; /* define a global symbol at bss start */ + __bss_start__ = _sbss; + *(.bss) + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end */ + __bss_end__ = _ebss; + } >RAM + + /* User_heap_stack section, used to check that there is enough RAM left */ + ._user_heap_stack : + { + . = ALIGN(4); + PROVIDE ( end = . ); + PROVIDE ( _end = . ); + . = . + _Min_Heap_Size; + . = . + _Min_Stack_Size; + . = ALIGN(4); + } >RAM + + /* Remove information from the standard libraries */ + /DISCARD/ : + { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + + .ARM.attributes 0 : { *(.ARM.attributes) } +} diff --git a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/variant.cpp b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/variant.cpp new file mode 100644 index 000000000000..1c7aedd9ac9c --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/variant.cpp @@ -0,0 +1,212 @@ +/* + ******************************************************************************* + * Copyright (c) 2017, STMicroelectronics + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************* + */ + +#include "pins_arduino.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +const PinName digitalPin[] = { +PA_1, +PA_2, +PA_3, +PA_4, +PA_5, +PA_6, +PA_7, +PA_8, +PA_9, +PA_10, +PA_11, +PA_12, +PA_13, +PA_14, +PA_15, +PB_0, +PB_1, +PB_2, +PB_3, +PB_4, +PB_5, +PB_6, +PB_7, +PB_8, +PB_9, +PB_10, +PB_11, +PB_12, +PB_13, +PB_14, +PB_15, +PC_2, +PC_3, +PC_4, +PC_5, +PC_6, +PC_7, +PC_8, +PC_9, +PC_10, +PC_11, +PC_12, +PC_13, +PC_14, +PC_15, +PD_0, +PD_1, +PD_2, +PD_3, +PD_4, +PD_5, +PD_6, +PD_7, +PD_8, +PD_9, +PD_10, +PD_11, +PD_12, +PD_13, +PD_14, +PD_15, +PE_0, +PE_1, +PE_11, +PE_3, +PE_4, +PE_5, +PE_6, +PE_7, +PE_8, +PE_9, +PE_10, +PE_2, +PE_12, +PE_13, +PE_14, +PE_15, +PF_0, +PF_1, +PF_2, +PF_6, +PF_7, +PF_8, +PF_9, +PF_11, +PF_12, +PF_13, +PF_14, +PF_15, +PG_0, +PG_1, +PG_2, +PG_3, +PG_4, +PG_5, +PG_6, +PG_7, +PG_8, +PG_9, +PG_10, +PG_11, +PG_12, +PG_13, +PG_14, +PG_15, +PH_0, +PH_1, +PA_0, +PC_1, +PC_0, +PF_10, +PF_5, +PF_4, +PF_3, +}; + +#ifdef __cplusplus +} +#endif + +// ---------------------------------------------------------------------------- + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief System Clock Configuration + * @param None + * @retval None + */ +WEAK void SystemClock_Config(void) +{ + + RCC_OscInitTypeDef RCC_OscInitStruct; + RCC_ClkInitTypeDef RCC_ClkInitStruct; + + /**Configure the main internal regulator output voltage + */ + __HAL_RCC_PWR_CLK_ENABLE(); + + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); + + /**Initializes the CPU, AHB and APB busses clocks + */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = 8; + RCC_OscInitStruct.PLL.PLLN = 336; + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; + RCC_OscInitStruct.PLL.PLLQ = 7; + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { + _Error_Handler(__FILE__, __LINE__); + } + + /**Initializes the CPU, AHB and APB busses clocks + */ + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK + | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; + + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) { + _Error_Handler(__FILE__, __LINE__); + } +} + +#ifdef __cplusplus +} +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/variant.h new file mode 100644 index 000000000000..727c0d07d832 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/variant.h @@ -0,0 +1,237 @@ +/* + ******************************************************************************* + * Copyright (c) 2017, STMicroelectronics + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************* + */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + + +#define PA1 0 +#define PA2 1 +#define PA3 2 +#define PA4 3 +#define PA5 4 +#define PA6 5 +#define PA7 6 +#define PA8 7 +#define PA9 8 +#define PA10 9 +#define PA11 10 +#define PA12 11 +#define PA13 12 +#define PA14 13 +#define PA15 14 +#define PB0 15 +#define PB1 16 +#define PB2 17 +#define PB3 18 +#define PB4 19 +#define PB5 20 +#define PB6 21 +#define PB7 22 +#define PB8 23 +#define PB9 24 +#define PB10 25 +#define PB11 26 +#define PB12 27 +#define PB13 28 +#define PB14 29 +#define PB15 30 +#define PC2 31 +#define PC3 32 +#define PC4 33 +#define PC5 34 +#define PC6 35 +#define PC7 36 +#define PC8 37 +#define PC9 38 +#define PC10 39 +#define PC11 40 +#define PC12 41 +#define PC13 42 +#define PC14 43 +#define PC15 44 +#define PD0 45 +#define PD1 46 +#define PD2 47 +#define PD3 48 +#define PD4 49 +#define PD5 50 +#define PD6 51 +#define PD7 52 +#define PD8 53 +#define PD9 54 +#define PD10 55 +#define PD11 56 +#define PD12 57 +#define PD13 58 +#define PD14 59 +#define PD15 60 +#define PE0 61 +#define PE1 62 +#define PE11 63 +#define PE3 64 +#define PE4 65 +#define PE5 66 +#define PE6 67 +#define PE7 68 +#define PE8 69 +#define PE9 70 +#define PE10 71 +#define PE2 72 +#define PE12 73 +#define PE13 74 +#define PE14 75 +#define PE15 76 +#define PF0 77 +#define PF1 78 +#define PF2 79 +#define PF6 80 +#define PF7 81 +#define PF8 82 +#define PF9 83 +#define PF11 84 +#define PF12 85 +#define PF13 86 +#define PF14 87 +#define PF15 88 +#define PG0 89 +#define PG1 90 +#define PG2 91 +#define PG3 92 +#define PG4 93 +#define PG5 94 +#define PG6 95 +#define PG7 96 +#define PG8 97 +#define PG9 98 +#define PG10 99 +#define PG11 100 +#define PG12 101 +#define PG13 102 +#define PG14 103 +#define PG15 104 +#define PH0 105 +#define PH1 106 +#define PA0 107 +#define PC1 108 +#define PC0 109 +#define PF10 110 +#define PF5 111 +#define PF4 112 +#define PF3 113 + +// This must be a literal +#define NUM_DIGITAL_PINS 114 +// This must be a literal with a value less than or equal to MAX_ANALOG_INPUTS +#define NUM_ANALOG_INPUTS 7 +#define NUM_ANALOG_FIRST 107 + + +// Below SPI and I2C definitions already done in the core +// Could be redefined here if differs from the default one +// SPI Definitions +#define PIN_SPI_SS PA4 +#define PIN_SPI_MOSI PA7 +#define PIN_SPI_MISO PA6 +#define PIN_SPI_SCK PA5 + +// I2C Definitions +#define PIN_WIRE_SDA PF0 +#define PIN_WIRE_SCL PF1 + +// Timer Definitions +// Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c +#define TIMER_TONE TIM2 +#define TIMER_SERVO TIM5 +#define TIMER_SERIAL TIM7 + +// UART Definitions +#define ENABLE_HWSERIAL1 +#define ENABLE_HWSERIAL2 +// Define here Serial instance number to map on Serial generic name +//#define SERIAL_UART_INSTANCE 1 //1 for Serial = Serial1 (USART1) +// DEBUG_UART could be redefined to print on another instance than 'Serial' +//#define DEBUG_UART ((USART_TypeDef *) U(S)ARTX) // ex: USART3 +// DEBUG_UART baudrate, default: 9600 if not defined +//#define DEBUG_UART_BAUDRATE x +// DEBUG_UART Tx pin name, default: the first one found in PinMap_UART_TX for DEBUG_UART +//#define DEBUG_PINNAME_TX PX_n // PinName used for TX + +// Default pin used for 'Serial' instance (ex: ST-Link) +// Mandatory for Firmata +#define PIN_SERIAL_RX PA10 +#define PIN_SERIAL_TX PA9 + +// Optional PIN_SERIALn_RX and PIN_SERIALn_TX where 'n' is the U(S)ART number +// Used when user instantiate a hardware Serial using its peripheral name. +// Example: HardwareSerial mySerial(USART3); +// will use PIN_SERIAL3_RX and PIN_SERIAL3_TX if defined. +#define PIN_SERIAL1_RX PA10 +#define PIN_SERIAL1_TX PA9 +#define PIN_SERIAL2_RX PA3 +#define PIN_SERIAL2_TX PA2 + +/* HAL configuration */ +#define HSE_VALUE 8000000U + +#ifdef __cplusplus +} // extern "C" +#endif +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +// These serial port names are intended to allow libraries and architecture-neutral +// sketches to automatically default to the correct port name for a particular type +// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, +// the first hardware serial port whose RX/TX pins are not dedicated to another use. +// +// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor +// +// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial +// +// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library +// +// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. +// +// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX +// pins are NOT connected to anything by default. +#define SERIAL_PORT_MONITOR Serial +#define SERIAL_PORT_HARDWARE Serial1 +#define SERIAL_PORT_HARDWARE_OPEN Serial2 +#endif + diff --git a/ini/stm32f4.ini b/ini/stm32f4.ini index 39ceb8079d02..b0d2a5600c3d 100644 --- a/ini/stm32f4.ini +++ b/ini/stm32f4.ini @@ -71,6 +71,16 @@ board_build.offset = 0x8000 board_upload.offset_address = 0x08008000 upload_command = dfu-util -a 0 -s 0x08008000:leave -D "$SOURCE" +# +# FYSETC SPIDER KING407 (STM32F407ZGT6 ARM Cortex-M4) +# +[env:FYSETC_SPIDER_KING407] +extends = stm32_variant +board = marlin_STM32F407ZGT6 +board_build.variant = MARLIN_FYSETC_SPIDER_KING407 +board_build.offset = 0x8000 +upload_protocol = dfu + # # STM32F407VET6 with RAMPS-like shield # 'Black' STM32F407VET6 board - https://wiki.stm32duino.com/index.php?title=STM32F407 From 2f24c3145458b60e091714e18629253eac3d7d1f Mon Sep 17 00:00:00 2001 From: Eduard Sukharev Date: Tue, 13 Sep 2022 20:29:59 +0300 Subject: [PATCH 060/243] =?UTF-8?q?=F0=9F=9A=B8=20Sanity=20check=20Integra?= =?UTF-8?q?ted=20Babystepping=20+=20I2S=20stream=20+=20ESP32=20(#24691)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/ESP32/inc/SanityCheck.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Marlin/src/HAL/ESP32/inc/SanityCheck.h b/Marlin/src/HAL/ESP32/inc/SanityCheck.h index 3ccb15989f33..4486a0a6ee7c 100644 --- a/Marlin/src/HAL/ESP32/inc/SanityCheck.h +++ b/Marlin/src/HAL/ESP32/inc/SanityCheck.h @@ -45,6 +45,10 @@ #error "FAST_PWM_FAN is not available on TinyBee." #endif +#if BOTH(I2S_STEPPER_STREAM, BABYSTEPPING) && DISABLED(INTEGRATED_BABYSTEPPING) + #error "BABYSTEPPING on I2S stream requires INTEGRATED_BABYSTEPPING." +#endif + #if USING_PULLDOWNS #error "PULLDOWN pin mode is not available on ESP32 boards." #endif From bdb7f3af3f4008c2a6d209d4cb3d679863718ad7 Mon Sep 17 00:00:00 2001 From: Eduard Sukharev Date: Tue, 13 Sep 2022 20:31:59 +0300 Subject: [PATCH 061/243] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20MKS=20TinyBee=20+?= =?UTF-8?q?=20MKS=20MINI=2012864=20SD=20blank=20on=20write=20(#24670)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp | 12 ++++++++++++ Marlin/src/pins/esp32/pins_MKS_TINYBEE.h | 7 +++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp b/Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp index a445035b2b43..bd7ecdc9f217 100644 --- a/Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp +++ b/Marlin/src/HAL/ESP32/u8g_esp32_spi.cpp @@ -32,6 +32,13 @@ #include "HAL.h" #include "SPI.h" +#if ENABLED(SDSUPPORT) + #include "../../sd/cardreader.h" + #if ENABLED(ESP3D_WIFISUPPORT) + #include "sd_ESP32.h" + #endif +#endif + static SPISettings spiConfig; @@ -45,6 +52,11 @@ static SPISettings spiConfig; uint8_t u8g_eps_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) { static uint8_t msgInitCount = 2; // Ignore all messages until 2nd U8G_COM_MSG_INIT + + #if ENABLED(PAUSE_LCD_FOR_BUSY_SD) + if (card.flag.saving || card.flag.logging || TERN0(ESP3D_WIFISUPPORT, sd_busy_lock == true)) return 0; + #endif + if (msgInitCount) { if (msg == U8G_COM_MSG_INIT) msgInitCount--; if (msgInitCount) return -1; diff --git a/Marlin/src/pins/esp32/pins_MKS_TINYBEE.h b/Marlin/src/pins/esp32/pins_MKS_TINYBEE.h index 04210bb23440..37ce4ee94e56 100644 --- a/Marlin/src/pins/esp32/pins_MKS_TINYBEE.h +++ b/Marlin/src/pins/esp32/pins_MKS_TINYBEE.h @@ -166,12 +166,12 @@ #define LCD_BACKLIGHT_PIN -1 #if ENABLED(MKS_MINI_12864) - // MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor) + // MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor) #define DOGLCD_CS EXP1_06_PIN #define DOGLCD_A0 EXP1_07_PIN #define LCD_RESET_PIN -1 #elif ENABLED(FYSETC_MINI_12864_2_1) - // MKS_MINI_12864_V3, BTT_MINI_12864_V1, FYSETC_MINI_12864_2_1 + // MKS_MINI_12864_V3, BTT_MINI_12864_V1, FYSETC_MINI_12864_2_1 #define DOGLCD_CS EXP1_03_PIN #define DOGLCD_A0 EXP1_04_PIN #define LCD_RESET_PIN EXP1_05_PIN @@ -179,6 +179,9 @@ #if SD_CONNECTION_IS(ONBOARD) #define FORCE_SOFT_SPI #endif + #if BOTH(MKS_MINI_12864_V3, SDSUPPORT) + #define PAUSE_LCD_FOR_BUSY_SD + #endif #else #define LCD_PINS_D4 EXP1_05_PIN #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) From e04e18a5902958c9a200ff67b3fba6c730524bf3 Mon Sep 17 00:00:00 2001 From: Chris Bagwell Date: Fri, 16 Sep 2022 13:30:04 -0500 Subject: [PATCH 062/243] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20STM?= =?UTF-8?q?32G0B1RE=20Pins=20Debugging=20(#24748)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/DUE/pinsDebug.h | 2 +- Marlin/src/HAL/SAMD51/pinsDebug.h | 2 +- Marlin/src/HAL/STM32/pinsDebug.h | 18 +++++++++++------- Marlin/src/HAL/TEENSY40_41/pinsDebug.h | 2 +- Marlin/src/gcode/config/M43.cpp | 2 +- .../MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.h | 1 + 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Marlin/src/HAL/DUE/pinsDebug.h b/Marlin/src/HAL/DUE/pinsDebug.h index df1ba415e918..2aafe9be0c56 100644 --- a/Marlin/src/HAL/DUE/pinsDebug.h +++ b/Marlin/src/HAL/DUE/pinsDebug.h @@ -70,7 +70,7 @@ #define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0) #define GET_ARRAY_PIN(p) pin_array[p].pin #define GET_ARRAY_IS_DIGITAL(p) pin_array[p].is_digital -#define VALID_PIN(pin) (pin >= 0 && pin < (int8_t)NUMBER_PINS_TOTAL ? 1 : 0) +#define VALID_PIN(pin) (pin >= 0 && pin < int8_t(NUMBER_PINS_TOTAL)) #define DIGITAL_PIN_TO_ANALOG_PIN(p) int(p - analogInputToDigitalPin(0)) #define IS_ANALOG(P) WITHIN(P, char(analogInputToDigitalPin(0)), char(analogInputToDigitalPin(NUM_ANALOG_INPUTS - 1))) #define pwm_status(pin) (((g_pinStatus[pin] & 0xF) == PIN_STATUS_PWM) && \ diff --git a/Marlin/src/HAL/SAMD51/pinsDebug.h b/Marlin/src/HAL/SAMD51/pinsDebug.h index f0a46fd7c567..639c4cd66eb9 100644 --- a/Marlin/src/HAL/SAMD51/pinsDebug.h +++ b/Marlin/src/HAL/SAMD51/pinsDebug.h @@ -29,7 +29,7 @@ #define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0) #define GET_ARRAY_PIN(p) pin_array[p].pin #define GET_ARRAY_IS_DIGITAL(p) pin_array[p].is_digital -#define VALID_PIN(pin) (pin >= 0 && pin < (int8_t)NUMBER_PINS_TOTAL) +#define VALID_PIN(pin) (pin >= 0 && pin < int8_t(NUMBER_PINS_TOTAL)) #define DIGITAL_PIN_TO_ANALOG_PIN(p) digitalPinToAnalogInput(p) #define IS_ANALOG(P) (DIGITAL_PIN_TO_ANALOG_PIN(P)!=-1) #define pwm_status(pin) digitalPinHasPWM(pin) diff --git a/Marlin/src/HAL/STM32/pinsDebug.h b/Marlin/src/HAL/STM32/pinsDebug.h index 55c64c868192..29a4e003f98a 100644 --- a/Marlin/src/HAL/STM32/pinsDebug.h +++ b/Marlin/src/HAL/STM32/pinsDebug.h @@ -102,17 +102,18 @@ const XrefInfo pin_xref[] PROGMEM = { #define PIN_NUM_ALPHA_LEFT(P) (((P & 0x000F) < 10) ? ('0' + (P & 0x000F)) : '1') #define PIN_NUM_ALPHA_RIGHT(P) (((P & 0x000F) > 9) ? ('0' + (P & 0x000F) - 10) : 0 ) #define PORT_NUM(P) ((P >> 4) & 0x0007) -#define PORT_ALPHA(P) ('A' + (P >> 4)) +#define PORT_ALPHA(P) ('A' + (P >> 4)) /** * Translation of routines & variables used by pinsDebug.h */ -#if PA0 >= NUM_DIGITAL_PINS +#if NUM_ANALOG_FIRST >= NUM_DIGITAL_PINS #define HAS_HIGH_ANALOG_PINS 1 #endif -#define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS + TERN0(HAS_HIGH_ANALOG_PINS, NUM_ANALOG_INPUTS) -#define VALID_PIN(ANUM) ((ANUM) >= 0 && (ANUM) < NUMBER_PINS_TOTAL) +#define NUM_ANALOG_LAST ((NUM_ANALOG_FIRST) + (NUM_ANALOG_INPUTS) - 1) +#define NUMBER_PINS_TOTAL ((NUM_DIGITAL_PINS) + TERN0(HAS_HIGH_ANALOG_PINS, NUM_ANALOG_INPUTS)) +#define VALID_PIN(P) (WITHIN(P, 0, (NUM_DIGITAL_PINS) - 1) || TERN0(HAS_HIGH_ANALOG_PINS, WITHIN(P, NUM_ANALOG_FIRST, NUM_ANALOG_LAST))) #define digitalRead_mod(Ard_num) extDigitalRead(Ard_num) // must use Arduino pin numbers when doing reads #define PRINT_PIN(Q) #define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0) @@ -168,7 +169,7 @@ bool GET_PINMODE(const pin_t Ard_num) { } int8_t digital_pin_to_analog_pin(const pin_t Ard_num) { - if (WITHIN(Ard_num, NUM_ANALOG_FIRST, NUM_ANALOG_FIRST + NUM_ANALOG_INPUTS - 1)) + if (WITHIN(Ard_num, NUM_ANALOG_FIRST, NUM_ANALOG_LAST)) return Ard_num - NUM_ANALOG_FIRST; const uint32_t ind = digitalPinToAnalogInput(Ard_num); @@ -206,8 +207,11 @@ void port_print(const pin_t Ard_num) { SERIAL_ECHO_SP(7); // Print number to be used with M42 - int calc_p = Ard_num % (NUM_DIGITAL_PINS + 1); - if (Ard_num > NUM_DIGITAL_PINS && calc_p > 7) calc_p += 8; + int calc_p = Ard_num; + if (Ard_num > NUM_DIGITAL_PINS) { + calc_p -= NUM_ANALOG_FIRST; + if (calc_p > 7) calc_p += 8; + } SERIAL_ECHOPGM(" M42 P", calc_p); SERIAL_CHAR(' '); if (calc_p < 100) { diff --git a/Marlin/src/HAL/TEENSY40_41/pinsDebug.h b/Marlin/src/HAL/TEENSY40_41/pinsDebug.h index 94b85ea56861..fc90f671cffe 100644 --- a/Marlin/src/HAL/TEENSY40_41/pinsDebug.h +++ b/Marlin/src/HAL/TEENSY40_41/pinsDebug.h @@ -36,7 +36,7 @@ #define PRINT_PIN_ANALOG(p) do{ sprintf_P(buffer, PSTR(" (A%2d) "), DIGITAL_PIN_TO_ANALOG_PIN(pin)); SERIAL_ECHO(buffer); }while(0) #define GET_ARRAY_PIN(p) pin_array[p].pin #define GET_ARRAY_IS_DIGITAL(p) pin_array[p].is_digital -#define VALID_PIN(pin) (pin >= 0 && pin < (int8_t)NUMBER_PINS_TOTAL ? 1 : 0) +#define VALID_PIN(pin) (pin >= 0 && pin < int8_t(NUMBER_PINS_TOTAL)) #define DIGITAL_PIN_TO_ANALOG_PIN(p) int(p - analogInputToDigitalPin(0)) #define IS_ANALOG(P) ((P) >= analogInputToDigitalPin(0) && (P) <= analogInputToDigitalPin(13)) || ((P) >= analogInputToDigitalPin(14) && (P) <= analogInputToDigitalPin(17)) #define pwm_status(pin) HAL_pwm_status(pin) diff --git a/Marlin/src/gcode/config/M43.cpp b/Marlin/src/gcode/config/M43.cpp index 688b94c9bf39..cff143d5711a 100644 --- a/Marlin/src/gcode/config/M43.cpp +++ b/Marlin/src/gcode/config/M43.cpp @@ -313,7 +313,7 @@ void GcodeSuite::M43() { // 'P' Get the range of pins to test or watch uint8_t first_pin = PARSED_PIN_INDEX('P', 0), - last_pin = parser.seenval('P') ? first_pin : TERN(HAS_HIGH_ANALOG_PINS, NUM_DIGITAL_PINS, NUMBER_PINS_TOTAL) - 1; + last_pin = parser.seenval('P') ? first_pin : (NUMBER_PINS_TOTAL) - 1; if (first_pin > last_pin) return; diff --git a/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.h b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.h index 9cb3d45a0d95..6a26baff45db 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/variant_MARLIN_STM32G0B1RE.h @@ -124,6 +124,7 @@ #define NUM_DIGITAL_PINS 62 #define NUM_REMAP_PINS 2 #define NUM_ANALOG_INPUTS 16 +#define NUM_ANALOG_FIRST PA0 // SPI definitions #ifndef PIN_SPI_SS From aa283582677fbbcb7ffe5f3183ac0bf5028747c3 Mon Sep 17 00:00:00 2001 From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Date: Sun, 4 Sep 2022 02:51:53 +0200 Subject: [PATCH 063/243] =?UTF-8?q?=F0=9F=90=9B=20Fix=20/=20refactor=20sha?= =?UTF-8?q?red=20PID=20(#24673)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/src/gcode/config/M301.cpp | 22 +-- Marlin/src/gcode/config/M304.cpp | 14 +- Marlin/src/gcode/config/M309.cpp | 14 +- Marlin/src/lcd/e3v2/jyersui/dwin.cpp | 12 +- Marlin/src/lcd/e3v2/proui/dwin.cpp | 20 +- Marlin/src/lcd/e3v2/proui/dwin.h | 6 +- .../lcd/extui/dgus_reloaded/DGUSTxHandler.cpp | 18 +- Marlin/src/lcd/extui/nextion/nextion_tft.cpp | 6 +- Marlin/src/lcd/extui/ui_api.cpp | 32 ++-- Marlin/src/lcd/extui/ui_api.h | 16 +- Marlin/src/lcd/menu/menu_advanced.cpp | 72 ++++--- Marlin/src/module/settings.cpp | 132 +++++-------- Marlin/src/module/temperature.cpp | 47 +++-- Marlin/src/module/temperature.h | 180 ++++++++++++------ buildroot/tests/rambo | 2 +- 15 files changed, 325 insertions(+), 268 deletions(-) diff --git a/Marlin/src/gcode/config/M301.cpp b/Marlin/src/gcode/config/M301.cpp index fc9f1883d616..a3938acb1157 100644 --- a/Marlin/src/gcode/config/M301.cpp +++ b/Marlin/src/gcode/config/M301.cpp @@ -57,19 +57,18 @@ void GcodeSuite::M301() { if (e < HOTENDS) { // catch bad input value - if (parser.seenval('P')) PID_PARAM(Kp, e) = parser.value_float(); - if (parser.seenval('I')) PID_PARAM(Ki, e) = scalePID_i(parser.value_float()); - if (parser.seenval('D')) PID_PARAM(Kd, e) = scalePID_d(parser.value_float()); + if (parser.seenval('P')) SET_HOTEND_PID(Kp, e, parser.value_float()); + if (parser.seenval('I')) SET_HOTEND_PID(Ki, e, parser.value_float()); + if (parser.seenval('D')) SET_HOTEND_PID(Kd, e, parser.value_float()); #if ENABLED(PID_EXTRUSION_SCALING) - if (parser.seenval('C')) PID_PARAM(Kc, e) = parser.value_float(); + if (parser.seenval('C')) SET_HOTEND_PID(Kc, e, parser.value_float()); if (parser.seenval('L')) thermalManager.lpq_len = parser.value_int(); - NOMORE(thermalManager.lpq_len, LPQ_MAX_LEN); - NOLESS(thermalManager.lpq_len, 0); + LIMIT(thermalManager.lpq_len, 0, LPQ_MAX_LEN); #endif #if ENABLED(PID_FAN_SCALING) - if (parser.seenval('F')) PID_PARAM(Kf, e) = parser.value_float(); + if (parser.seenval('F')) SET_HOTEND_PID(Kf, e, parser.value_float()); #endif thermalManager.updatePID(); @@ -83,6 +82,7 @@ void GcodeSuite::M301_report(const bool forReplay/*=true*/ E_OPTARG(const int8_t IF_DISABLED(HAS_MULTI_EXTRUDER, constexpr int8_t eindex = -1); HOTEND_LOOP() { if (e == eindex || eindex == -1) { + const hotend_pid_t &pid = thermalManager.temp_hotend[e].pid; report_echo_start(forReplay); SERIAL_ECHOPGM_P( #if ENABLED(PID_PARAMS_PER_HOTEND) @@ -90,16 +90,14 @@ void GcodeSuite::M301_report(const bool forReplay/*=true*/ E_OPTARG(const int8_t #else PSTR(" M301 P") #endif - , PID_PARAM(Kp, e) - , PSTR(" I"), unscalePID_i(PID_PARAM(Ki, e)) - , PSTR(" D"), unscalePID_d(PID_PARAM(Kd, e)) + , pid.p(), PSTR(" I"), pid.i(), PSTR(" D"), pid.d() ); #if ENABLED(PID_EXTRUSION_SCALING) - SERIAL_ECHOPGM_P(SP_C_STR, PID_PARAM(Kc, e)); + SERIAL_ECHOPGM_P(SP_C_STR, pid.c()); if (e == 0) SERIAL_ECHOPGM(" L", thermalManager.lpq_len); #endif #if ENABLED(PID_FAN_SCALING) - SERIAL_ECHOPGM(" F", PID_PARAM(Kf, e)); + SERIAL_ECHOPGM(" F", pid.f()); #endif SERIAL_EOL(); } diff --git a/Marlin/src/gcode/config/M304.cpp b/Marlin/src/gcode/config/M304.cpp index c970288238f5..a71a34c6de42 100644 --- a/Marlin/src/gcode/config/M304.cpp +++ b/Marlin/src/gcode/config/M304.cpp @@ -36,17 +36,17 @@ */ void GcodeSuite::M304() { if (!parser.seen("PID")) return M304_report(); - if (parser.seenval('P')) thermalManager.temp_bed.pid.Kp = parser.value_float(); - if (parser.seenval('I')) thermalManager.temp_bed.pid.Ki = scalePID_i(parser.value_float()); - if (parser.seenval('D')) thermalManager.temp_bed.pid.Kd = scalePID_d(parser.value_float()); + if (parser.seenval('P')) thermalManager.temp_bed.pid.set_Kp(parser.value_float()); + if (parser.seenval('I')) thermalManager.temp_bed.pid.set_Ki(parser.value_float()); + if (parser.seenval('D')) thermalManager.temp_bed.pid.set_Kd(parser.value_float()); } void GcodeSuite::M304_report(const bool forReplay/*=true*/) { report_heading_etc(forReplay, F(STR_BED_PID)); - SERIAL_ECHOLNPGM( - " M304 P", thermalManager.temp_bed.pid.Kp - , " I", unscalePID_i(thermalManager.temp_bed.pid.Ki) - , " D", unscalePID_d(thermalManager.temp_bed.pid.Kd) + SERIAL_ECHOLNPGM(" M304" + " P", thermalManager.temp_bed.pid.p() + , " I", thermalManager.temp_bed.pid.i() + , " D", thermalManager.temp_bed.pid.d() ); } diff --git a/Marlin/src/gcode/config/M309.cpp b/Marlin/src/gcode/config/M309.cpp index 577023292e2d..4953113041d7 100644 --- a/Marlin/src/gcode/config/M309.cpp +++ b/Marlin/src/gcode/config/M309.cpp @@ -36,17 +36,17 @@ */ void GcodeSuite::M309() { if (!parser.seen("PID")) return M309_report(); - if (parser.seen('P')) thermalManager.temp_chamber.pid.Kp = parser.value_float(); - if (parser.seen('I')) thermalManager.temp_chamber.pid.Ki = scalePID_i(parser.value_float()); - if (parser.seen('D')) thermalManager.temp_chamber.pid.Kd = scalePID_d(parser.value_float()); + if (parser.seenval('P')) thermalManager.temp_chamber.pid.set_Kp(parser.value_float()); + if (parser.seenval('I')) thermalManager.temp_chamber.pid.set_Ki(parser.value_float()); + if (parser.seenval('D')) thermalManager.temp_chamber.pid.set_Kd(parser.value_float()); } void GcodeSuite::M309_report(const bool forReplay/*=true*/) { report_heading_etc(forReplay, F(STR_CHAMBER_PID)); - SERIAL_ECHOLNPGM( - " M309 P", thermalManager.temp_chamber.pid.Kp - , " I", unscalePID_i(thermalManager.temp_chamber.pid.Ki) - , " D", unscalePID_d(thermalManager.temp_chamber.pid.Kd) + SERIAL_ECHOLNPGM(" M309" + " P", thermalManager.temp_chamber.pid.p() + , " I", thermalManager.temp_chamber.pid.i() + , " D", thermalManager.temp_chamber.pid.d() ); } diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index b29ad9e63abe..df758da61786 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -2140,7 +2140,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case HOTENDPID_KP: if (draw) { Draw_Menu_Item(row, ICON_Version, F("Kp Value")); - Draw_Float(thermalManager.temp_hotend[0].pid.Kp, row, false, 100); + Draw_Float(thermalManager.temp_hotend[0].pid.p(), row, false, 100); } else Modify_Value(thermalManager.temp_hotend[0].pid.Kp, 0, 5000, 100, thermalManager.updatePID); @@ -2148,7 +2148,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case HOTENDPID_KI: if (draw) { Draw_Menu_Item(row, ICON_Version, F("Ki Value")); - Draw_Float(unscalePID_i(thermalManager.temp_hotend[0].pid.Ki), row, false, 100); + Draw_Float(thermalManager.temp_hotend[0].pid.i(), row, false, 100); } else Modify_Value(thermalManager.temp_hotend[0].pid.Ki, 0, 5000, 100, thermalManager.updatePID); @@ -2156,7 +2156,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case HOTENDPID_KD: if (draw) { Draw_Menu_Item(row, ICON_Version, F("Kd Value")); - Draw_Float(unscalePID_d(thermalManager.temp_hotend[0].pid.Kd), row, false, 100); + Draw_Float(thermalManager.temp_hotend[0].pid.d(), row, false, 100); } else Modify_Value(thermalManager.temp_hotend[0].pid.Kd, 0, 5000, 100, thermalManager.updatePID); @@ -2207,7 +2207,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case BEDPID_KP: if (draw) { Draw_Menu_Item(row, ICON_Version, F("Kp Value")); - Draw_Float(thermalManager.temp_bed.pid.Kp, row, false, 100); + Draw_Float(thermalManager.temp_bed.pid.p(), row, false, 100); } else { Modify_Value(thermalManager.temp_bed.pid.Kp, 0, 5000, 100, thermalManager.updatePID); @@ -2216,7 +2216,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case BEDPID_KI: if (draw) { Draw_Menu_Item(row, ICON_Version, F("Ki Value")); - Draw_Float(unscalePID_i(thermalManager.temp_bed.pid.Ki), row, false, 100); + Draw_Float(thermalManager.temp_bed.pid.i(), row, false, 100); } else Modify_Value(thermalManager.temp_bed.pid.Ki, 0, 5000, 100, thermalManager.updatePID); @@ -2224,7 +2224,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case BEDPID_KD: if (draw) { Draw_Menu_Item(row, ICON_Version, F("Kd Value")); - Draw_Float(unscalePID_d(thermalManager.temp_bed.pid.Kd), row, false, 100); + Draw_Float(thermalManager.temp_bed.pid.d(), row, false, 100); } else Modify_Value(thermalManager.temp_bed.pid.Kd, 0, 5000, 100, thermalManager.updatePID); diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp index f51da4cf5a71..09c3ca9ab8df 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -2667,13 +2667,15 @@ void SetStepsY() { HMI_value.axis = Y_AXIS, SetPFloatOnClick( MIN_STEP, MAX_STEP void SetStepsZ() { HMI_value.axis = Z_AXIS, SetPFloatOnClick( MIN_STEP, MAX_STEP, UNITFDIGITS); } #if HAS_HOTEND void SetStepsE() { HMI_value.axis = E_AXIS; SetPFloatOnClick( MIN_STEP, MAX_STEP, UNITFDIGITS); } - void SetHotendPidT() { SetPIntOnClick(MIN_ETEMP, MAX_ETEMP); } + #if ENABLED(PIDTEMP) + void SetHotendPidT() { SetPIntOnClick(MIN_ETEMP, MAX_ETEMP); } + #endif #endif -#if HAS_HEATED_BED +#if ENABLED(PIDTEMPBED) void SetBedPidT() { SetPIntOnClick(MIN_BEDTEMP, MAX_BEDTEMP); } #endif -#if HAS_HOTEND || HAS_HEATED_BED +#if EITHER(PIDTEMP, PIDTEMPBED) void SetPidCycles() { SetPIntOnClick(3, 50); } void SetKp() { SetPFloatOnClick(0, 1000, 2); } void ApplyPIDi() { @@ -3222,10 +3224,10 @@ void Draw_AdvancedSettings_Menu() { #if HAS_HOME_OFFSET MENU_ITEM_F(ICON_HomeOffset, MSG_SET_HOME_OFFSETS, onDrawSubMenu, Draw_HomeOffset_Menu); #endif - #if HAS_HOTEND + #if ENABLED(PIDTEMP) MENU_ITEM(ICON_PIDNozzle, F(STR_HOTEND_PID " Settings"), onDrawSubMenu, Draw_HotendPID_Menu); #endif - #if HAS_HEATED_BED + #if ENABLED(PIDTEMPBED) MENU_ITEM(ICON_PIDbed, F(STR_BED_PID " Settings"), onDrawSubMenu, Draw_BedPID_Menu); #endif MENU_ITEM_F(ICON_FilSet, MSG_FILAMENT_SET, onDrawSubMenu, Draw_FilSet_Menu); @@ -3668,10 +3670,10 @@ void Draw_Steps_Menu() { CurrentMenu->draw(); } -#if HAS_HOTEND +#if ENABLED(PIDTEMP) void Draw_HotendPID_Menu() { checkkey = Menu; - if (SetMenu(HotendPIDMenu, F(STR_HOTEND_PID " Settings"),8)) { + if (SetMenu(HotendPIDMenu, F(STR_HOTEND_PID " Settings"), 8)) { BACK_ITEM(Draw_AdvancedSettings_Menu); MENU_ITEM(ICON_PIDNozzle, F(STR_HOTEND_PID), onDrawMenuItem, HotendPID); EDIT_ITEM(ICON_PIDValue, F("Set" STR_KP), onDrawPFloat2Menu, SetKp, &thermalManager.temp_hotend[0].pid.Kp); @@ -3687,10 +3689,10 @@ void Draw_Steps_Menu() { } #endif -#if HAS_HEATED_BED +#if ENABLED(PIDTEMPBED) void Draw_BedPID_Menu() { checkkey = Menu; - if (SetMenu(BedPIDMenu, F(STR_BED_PID " Settings"),8)) { + if (SetMenu(BedPIDMenu, F(STR_BED_PID " Settings"), 8)) { BACK_ITEM(Draw_AdvancedSettings_Menu); MENU_ITEM(ICON_PIDNozzle, F(STR_BED_PID), onDrawMenuItem,BedPID); EDIT_ITEM(ICON_PIDValue, F("Set" STR_KP), onDrawPFloat2Menu, SetKp, &thermalManager.temp_bed.pid.Kp); diff --git a/Marlin/src/lcd/e3v2/proui/dwin.h b/Marlin/src/lcd/e3v2/proui/dwin.h index 6d36cca92af7..f4c06186916d 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.h +++ b/Marlin/src/lcd/e3v2/proui/dwin.h @@ -264,7 +264,9 @@ void Draw_Motion_Menu(); void Draw_Preheat1_Menu(); void Draw_Preheat2_Menu(); void Draw_Preheat3_Menu(); - void Draw_HotendPID_Menu(); + #if ENABLED(PIDTEMP) + void Draw_HotendPID_Menu(); + #endif #endif void Draw_Temperature_Menu(); void Draw_MaxSpeed_Menu(); @@ -273,7 +275,7 @@ void Draw_MaxAccel_Menu(); void Draw_MaxJerk_Menu(); #endif void Draw_Steps_Menu(); -#if HAS_HEATED_BED +#if ENABLED(PIDTEMPBED) void Draw_BedPID_Menu(); #endif #if EITHER(HAS_BED_PROBE, BABYSTEPPING) diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.cpp b/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.cpp index 62df84e53d8f..1837a0c93ab2 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.cpp +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSTxHandler.cpp @@ -421,16 +421,16 @@ void DGUSTxHandler::PIDKp(DGUS_VP &vp) { default: return; #if ENABLED(PIDTEMPBED) case DGUS_Data::Heater::BED: - value = ExtUI::getBedPIDValues_Kp(); + value = ExtUI::getBedPID_Kp(); break; #endif #if ENABLED(PIDTEMP) case DGUS_Data::Heater::H0: - value = ExtUI::getPIDValues_Kp(ExtUI::E0); + value = ExtUI::getPID_Kp(ExtUI::E0); break; #if HAS_MULTI_HOTEND case DGUS_Data::Heater::H1: - value = ExtUI::getPIDValues_Kp(ExtUI::E1); + value = ExtUI::getPID_Kp(ExtUI::E1); break; #endif #endif @@ -447,16 +447,16 @@ void DGUSTxHandler::PIDKi(DGUS_VP &vp) { default: return; #if ENABLED(PIDTEMPBED) case DGUS_Data::Heater::BED: - value = ExtUI::getBedPIDValues_Ki(); + value = ExtUI::getBedPID_Ki(); break; #endif #if ENABLED(PIDTEMP) case DGUS_Data::Heater::H0: - value = ExtUI::getPIDValues_Ki(ExtUI::E0); + value = ExtUI::getPID_Ki(ExtUI::E0); break; #if HAS_MULTI_HOTEND case DGUS_Data::Heater::H1: - value = ExtUI::getPIDValues_Ki(ExtUI::E1); + value = ExtUI::getPID_Ki(ExtUI::E1); break; #endif #endif @@ -473,16 +473,16 @@ void DGUSTxHandler::PIDKd(DGUS_VP &vp) { default: return; #if ENABLED(PIDTEMPBED) case DGUS_Data::Heater::BED: - value = ExtUI::getBedPIDValues_Kd(); + value = ExtUI::getBedPID_Kd(); break; #endif #if ENABLED(PIDTEMP) case DGUS_Data::Heater::H0: - value = ExtUI::getPIDValues_Kd(ExtUI::E0); + value = ExtUI::getPID_Kd(ExtUI::E0); break; #if HAS_MULTI_HOTEND case DGUS_Data::Heater::H1: - value = ExtUI::getPIDValues_Kd(ExtUI::E1); + value = ExtUI::getPID_Kd(ExtUI::E1); break; #endif #endif diff --git a/Marlin/src/lcd/extui/nextion/nextion_tft.cpp b/Marlin/src/lcd/extui/nextion/nextion_tft.cpp index 92349659eb3d..63c25177a679 100644 --- a/Marlin/src/lcd/extui/nextion/nextion_tft.cpp +++ b/Marlin/src/lcd/extui/nextion/nextion_tft.cpp @@ -459,17 +459,17 @@ void NextionTFT::PanelInfo(uint8_t req) { case 37: // PID #if ENABLED(PIDTEMP) - #define SEND_PID_INFO_0(A, B) SEND_VALasTXT(A, getPIDValues_K##B(E0)) + #define SEND_PID_INFO_0(A, B) SEND_VALasTXT(A, getPID_K##B(E0)) #else #define SEND_PID_INFO_0(A, B) SEND_NA(A) #endif #if BOTH(PIDTEMP, HAS_MULTI_EXTRUDER) - #define SEND_PID_INFO_1(A, B) SEND_VALasTXT(A, getPIDValues_K##B(E1)) + #define SEND_PID_INFO_1(A, B) SEND_VALasTXT(A, getPID_K##B(E1)) #else #define SEND_PID_INFO_1(A, B) SEND_NA(A) #endif #if ENABLED(PIDTEMPBED) - #define SEND_PID_INFO_BED(A, B) SEND_VALasTXT(A, getBedPIDValues_K##B()) + #define SEND_PID_INFO_BED(A, B) SEND_VALasTXT(A, getBedPID_K##B()) #else #define SEND_PID_INFO_BED(A, B) SEND_NA(A) #endif diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index a711e6dd5726..f4d02d8cca4a 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -976,32 +976,26 @@ namespace ExtUI { float getFeedrate_percent() { return feedrate_percentage; } #if ENABLED(PIDTEMP) - float getPIDValues_Kp(const extruder_t tool) { return PID_PARAM(Kp, tool); } - float getPIDValues_Ki(const extruder_t tool) { return unscalePID_i(PID_PARAM(Ki, tool)); } - float getPIDValues_Kd(const extruder_t tool) { return unscalePID_d(PID_PARAM(Kd, tool)); } - - void setPIDValues(const_float_t p, const_float_t i, const_float_t d, extruder_t tool) { - thermalManager.temp_hotend[tool].pid.Kp = p; - thermalManager.temp_hotend[tool].pid.Ki = scalePID_i(i); - thermalManager.temp_hotend[tool].pid.Kd = scalePID_d(d); - thermalManager.updatePID(); + float getPID_Kp(const extruder_t tool) { return thermalManager.temp_hotend[tool].pid.p(); } + float getPID_Ki(const extruder_t tool) { return thermalManager.temp_hotend[tool].pid.i(); } + float getPID_Kd(const extruder_t tool) { return thermalManager.temp_hotend[tool].pid.d(); } + + void setPID(const_float_t p, const_float_t i, const_float_t d, extruder_t tool) { + thermalManager.setPID(uint8_t(tool), p, i, d); } void startPIDTune(const celsius_t temp, extruder_t tool) { - thermalManager.PID_autotune(temp, (heater_id_t)tool, 8, true); + thermalManager.PID_autotune(temp, heater_id_t(tool), 8, true); } #endif #if ENABLED(PIDTEMPBED) - float getBedPIDValues_Kp() { return thermalManager.temp_bed.pid.Kp; } - float getBedPIDValues_Ki() { return unscalePID_i(thermalManager.temp_bed.pid.Ki); } - float getBedPIDValues_Kd() { return unscalePID_d(thermalManager.temp_bed.pid.Kd); } - - void setBedPIDValues(const_float_t p, const_float_t i, const_float_t d) { - thermalManager.temp_bed.pid.Kp = p; - thermalManager.temp_bed.pid.Ki = scalePID_i(i); - thermalManager.temp_bed.pid.Kd = scalePID_d(d); - thermalManager.updatePID(); + float getBedPID_Kp() { return thermalManager.temp_bed.pid.p(); } + float getBedPID_Ki() { return thermalManager.temp_bed.pid.i(); } + float getBedPID_Kd() { return thermalManager.temp_bed.pid.d(); } + + void setBedPID(const_float_t p, const_float_t i, const_float_t d) { + thermalManager.temp_bed.pid.set(p, i, d); } void startBedPIDTune(const celsius_t temp) { diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index 84555187677a..bf32c5703e36 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -324,18 +324,18 @@ namespace ExtUI { #endif #if ENABLED(PIDTEMP) - float getPIDValues_Kp(const extruder_t); - float getPIDValues_Ki(const extruder_t); - float getPIDValues_Kd(const extruder_t); - void setPIDValues(const_float_t, const_float_t , const_float_t , extruder_t); + float getPID_Kp(const extruder_t); + float getPID_Ki(const extruder_t); + float getPID_Kd(const extruder_t); + void setPID(const_float_t, const_float_t , const_float_t , extruder_t); void startPIDTune(const celsius_t, extruder_t); #endif #if ENABLED(PIDTEMPBED) - float getBedPIDValues_Kp(); - float getBedPIDValues_Ki(); - float getBedPIDValues_Kd(); - void setBedPIDValues(const_float_t, const_float_t , const_float_t); + float getBedPID_Kp(); + float getBedPID_Ki(); + float getBedPID_Kd(); + void setBedPID(const_float_t, const_float_t , const_float_t); void startBedPIDTune(const celsius_t); #endif diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index f9f4116bc3a0..e79fe55938e3 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -209,37 +209,59 @@ void menu_backlash(); #if ENABLED(PID_EDIT_MENU) - float raw_Ki, raw_Kd; // place-holders for Ki and Kd edits + // Placeholders for PID editing + float raw_Kp, raw_Ki, raw_Kd; + #if ENABLED(PID_EXTRUSION_SCALING) + float raw_Kc; + #endif + #if ENABLED(PID_FAN_SCALING) + float raw_Kf; + #endif - // Helpers for editing PID Ki & Kd values - // grab the PID value out of the temp variable; scale it; then update the PID driver - void copy_and_scalePID_i(const int8_t e) { + // Helpers for editing PID Kp, Ki and Kd values + void apply_PID_p(const int8_t e) { + switch (e) { + #if ENABLED(PIDTEMPBED) + case H_BED: thermalManager.temp_bed.pid.set_Ki(raw_Ki); break; + #endif + #if ENABLED(PIDTEMPCHAMBER) + case H_CHAMBER: thermalManager.temp_chamber.pid.set_Ki(raw_Ki); break; + #endif + default: + #if ENABLED(PIDTEMP) + SET_HOTEND_PID(Kp, e, raw_Kp); + thermalManager.updatePID(); + #endif + break; + } + } + void apply_PID_i(const int8_t e) { switch (e) { #if ENABLED(PIDTEMPBED) - case H_BED: thermalManager.temp_bed.pid.Ki = scalePID_i(raw_Ki); break; + case H_BED: thermalManager.temp_bed.pid.set_Ki(raw_Ki); break; #endif #if ENABLED(PIDTEMPCHAMBER) - case H_CHAMBER: thermalManager.temp_chamber.pid.Ki = scalePID_i(raw_Ki); break; + case H_CHAMBER: thermalManager.temp_chamber.pid.set_Ki(raw_Ki); break; #endif default: #if ENABLED(PIDTEMP) - PID_PARAM(Ki, e) = scalePID_i(raw_Ki); + SET_HOTEND_PID(Ki, e, raw_Ki); thermalManager.updatePID(); #endif break; } } - void copy_and_scalePID_d(const int8_t e) { + void apply_PID_d(const int8_t e) { switch (e) { #if ENABLED(PIDTEMPBED) - case H_BED: thermalManager.temp_bed.pid.Kd = scalePID_d(raw_Kd); break; + case H_BED: thermalManager.temp_bed.pid.set_Kd(raw_Kd); break; #endif #if ENABLED(PIDTEMPCHAMBER) - case H_CHAMBER: thermalManager.temp_chamber.pid.Kd = scalePID_d(raw_Kd); break; + case H_CHAMBER: thermalManager.temp_chamber.pid.set_Kd(raw_Kd); break; #endif default: #if ENABLED(PIDTEMP) - PID_PARAM(Kd, e) = scalePID_d(raw_Kd); + SET_HOTEND_PID(Kd, e, raw_Kd); thermalManager.updatePID(); #endif break; @@ -291,16 +313,18 @@ void menu_backlash(); #if BOTH(PIDTEMP, PID_EDIT_MENU) #define __PID_HOTEND_MENU_ITEMS(N) \ - raw_Ki = unscalePID_i(PID_PARAM(Ki, N)); \ - raw_Kd = unscalePID_d(PID_PARAM(Kd, N)); \ - EDIT_ITEM_FAST_N(float41sign, N, MSG_PID_P_E, &PID_PARAM(Kp, N), 1, 9990); \ - EDIT_ITEM_FAST_N(float52sign, N, MSG_PID_I_E, &raw_Ki, 0.01f, 9990, []{ copy_and_scalePID_i(N); }); \ - EDIT_ITEM_FAST_N(float41sign, N, MSG_PID_D_E, &raw_Kd, 1, 9990, []{ copy_and_scalePID_d(N); }) + raw_Kp = thermalManager.temp_hotend[N].pid.p(); \ + raw_Ki = thermalManager.temp_hotend[N].pid.i(); \ + raw_Kd = thermalManager.temp_hotend[N].pid.d(); \ + EDIT_ITEM_FAST_N(float41sign, N, MSG_PID_P_E, &raw_Kp, 1, 9990, []{ apply_PID_p(N); }); \ + EDIT_ITEM_FAST_N(float52sign, N, MSG_PID_I_E, &raw_Ki, 0.01f, 9990, []{ apply_PID_i(N); }); \ + EDIT_ITEM_FAST_N(float41sign, N, MSG_PID_D_E, &raw_Kd, 1, 9990, []{ apply_PID_d(N); }) #if ENABLED(PID_EXTRUSION_SCALING) #define _PID_HOTEND_MENU_ITEMS(N) \ __PID_HOTEND_MENU_ITEMS(N); \ - EDIT_ITEM_N(float4, N, MSG_PID_C_E, &PID_PARAM(Kc, N), 1, 9990) + raw_Kc = thermalManager.temp_hotend[N].pid.c(); \ + EDIT_ITEM_N(float4, N, MSG_PID_C_E, &raw_Kc, 1, 9990, []{ SET_HOTEND_PID(Kc, N, raw_Kc); thermalManager.updatePID(); }); #else #define _PID_HOTEND_MENU_ITEMS(N) __PID_HOTEND_MENU_ITEMS(N) #endif @@ -308,7 +332,8 @@ void menu_backlash(); #if ENABLED(PID_FAN_SCALING) #define _HOTEND_PID_EDIT_MENU_ITEMS(N) \ _PID_HOTEND_MENU_ITEMS(N); \ - EDIT_ITEM_N(float4, N, MSG_PID_F_E, &PID_PARAM(Kf, N), 1, 9990) + raw_Kf = thermalManager.temp_hotend[N].pid.f(); \ + EDIT_ITEM_N(float4, N, MSG_PID_F_E, &raw_Kf, 1, 9990, []{ SET_HOTEND_PID(Kf, N, raw_Kf); thermalManager.updatePID(); }); #else #define _HOTEND_PID_EDIT_MENU_ITEMS(N) _PID_HOTEND_MENU_ITEMS(N) #endif @@ -321,11 +346,12 @@ void menu_backlash(); #if ENABLED(PID_EDIT_MENU) && EITHER(PIDTEMPBED, PIDTEMPCHAMBER) #define _PID_EDIT_ITEMS_TMPL(N,T) \ - raw_Ki = unscalePID_i(T.pid.Ki); \ - raw_Kd = unscalePID_d(T.pid.Kd); \ - EDIT_ITEM_FAST_N(float41sign, N, MSG_PID_P_E, &T.pid.Kp, 1, 9990); \ - EDIT_ITEM_FAST_N(float52sign, N, MSG_PID_I_E, &raw_Ki, 0.01f, 9990, []{ copy_and_scalePID_i(N); }); \ - EDIT_ITEM_FAST_N(float41sign, N, MSG_PID_D_E, &raw_Kd, 1, 9990, []{ copy_and_scalePID_d(N); }) + raw_Kp = T.pid.p(); \ + raw_Ki = T.pid.i(); \ + raw_Kd = T.pid.d(); \ + EDIT_ITEM_FAST_N(float41sign, N, MSG_PID_P_E, &raw_Kp, 1, 9990, []{ apply_PID_p(N); }); \ + EDIT_ITEM_FAST_N(float52sign, N, MSG_PID_I_E, &raw_Ki, 0.01f, 9990, []{ apply_PID_i(N); }); \ + EDIT_ITEM_FAST_N(float41sign, N, MSG_PID_D_E, &raw_Kd, 1, 9990, []{ apply_PID_d(N); }) #endif #if ENABLED(PIDTEMP) diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index aa6f48d763df..179fea057d9b 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -364,18 +364,18 @@ typedef struct SettingsDataStruct { // // PIDTEMP // - PIDCF_t hotendPID[HOTENDS]; // M301 En PIDCF / M303 En U + raw_pidcf_t hotendPID[HOTENDS]; // M301 En PIDCF / M303 En U int16_t lpq_len; // M301 L // // PIDTEMPBED // - PID_t bedPID; // M304 PID / M303 E-1 U + raw_pid_t bedPID; // M304 PID / M303 E-1 U // // PIDTEMPCHAMBER // - PID_t chamberPID; // M309 PID / M303 E-2 U + raw_pid_t chamberPID; // M309 PID / M303 E-2 U // // User-defined Thermistors @@ -1052,27 +1052,20 @@ void MarlinSettings::postprocess() { // { _FIELD_TEST(hotendPID); + #if DISABLED(PIDTEMP) + raw_pidcf_t pidcf = { NAN, NAN, NAN, NAN, NAN }; + #endif HOTEND_LOOP() { - PIDCF_t pidcf = { - #if DISABLED(PIDTEMP) - NAN, NAN, NAN, - NAN, NAN - #else - PID_PARAM(Kp, e), - unscalePID_i(PID_PARAM(Ki, e)), - unscalePID_d(PID_PARAM(Kd, e)), - PID_PARAM(Kc, e), - PID_PARAM(Kf, e) - #endif - }; + #if ENABLED(PIDTEMP) + const hotend_pid_t &pid = thermalManager.temp_hotend[e].pid; + raw_pidcf_t pidcf = { pid.p(), pid.i(), pid.d(), pid.c(), pid.f() }; + #endif EEPROM_WRITE(pidcf); } _FIELD_TEST(lpq_len); - #if DISABLED(PID_EXTRUSION_SCALING) - const int16_t lpq_len = 20; - #endif - EEPROM_WRITE(TERN(PID_EXTRUSION_SCALING, thermalManager.lpq_len, lpq_len)); + const int16_t lpq_len = TERN(PID_EXTRUSION_SCALING, thermalManager.lpq_len, 20); + EEPROM_WRITE(lpq_len); } // @@ -1080,17 +1073,12 @@ void MarlinSettings::postprocess() { // { _FIELD_TEST(bedPID); - - const PID_t bed_pid = { - #if DISABLED(PIDTEMPBED) - NAN, NAN, NAN - #else - // Store the unscaled PID values - thermalManager.temp_bed.pid.Kp, - unscalePID_i(thermalManager.temp_bed.pid.Ki), - unscalePID_d(thermalManager.temp_bed.pid.Kd) - #endif - }; + #if ENABLED(PIDTEMPBED) + const PID_t &pid = thermalManager.temp_bed.pid; + const raw_pid_t bed_pid = { pid.p(), pid.i(), pid.d() }; + #else + const raw_pid_t bed_pid = { NAN, NAN, NAN }; + #endif EEPROM_WRITE(bed_pid); } @@ -1099,17 +1087,12 @@ void MarlinSettings::postprocess() { // { _FIELD_TEST(chamberPID); - - const PID_t chamber_pid = { - #if DISABLED(PIDTEMPCHAMBER) - NAN, NAN, NAN - #else - // Store the unscaled PID values - thermalManager.temp_chamber.pid.Kp, - unscalePID_i(thermalManager.temp_chamber.pid.Ki), - unscalePID_d(thermalManager.temp_chamber.pid.Kd) - #endif - }; + #if ENABLED(PIDTEMPCHAMBER) + const PID_t &pid = thermalManager.temp_chamber.pid; + const raw_pid_t chamber_pid = { pid.p(), pid.i(), pid.d() }; + #else + const raw_pid_t chamber_pid = { NAN, NAN, NAN }; + #endif EEPROM_WRITE(chamber_pid); } @@ -1117,10 +1100,8 @@ void MarlinSettings::postprocess() { // User-defined Thermistors // #if HAS_USER_THERMISTORS - { _FIELD_TEST(user_thermistor); EEPROM_WRITE(thermalManager.user_thermistor); - } #endif // @@ -2003,17 +1984,11 @@ void MarlinSettings::postprocess() { // { HOTEND_LOOP() { - PIDCF_t pidcf; + raw_pidcf_t pidcf; EEPROM_READ(pidcf); #if ENABLED(PIDTEMP) - if (!validating && !isnan(pidcf.Kp)) { - // Scale PID values since EEPROM values are unscaled - PID_PARAM(Kp, e) = pidcf.Kp; - PID_PARAM(Ki, e) = scalePID_i(pidcf.Ki); - PID_PARAM(Kd, e) = scalePID_d(pidcf.Kd); - TERN_(PID_EXTRUSION_SCALING, PID_PARAM(Kc, e) = pidcf.Kc); - TERN_(PID_FAN_SCALING, PID_PARAM(Kf, e) = pidcf.Kf); - } + if (!validating && !isnan(pidcf.p)) + thermalManager.temp_hotend[e].pid.set(pidcf); #endif } } @@ -2035,15 +2010,11 @@ void MarlinSettings::postprocess() { // Heated Bed PID // { - PID_t pid; + raw_pid_t pid; EEPROM_READ(pid); #if ENABLED(PIDTEMPBED) - if (!validating && !isnan(pid.Kp)) { - // Scale PID values since EEPROM values are unscaled - thermalManager.temp_bed.pid.Kp = pid.Kp; - thermalManager.temp_bed.pid.Ki = scalePID_i(pid.Ki); - thermalManager.temp_bed.pid.Kd = scalePID_d(pid.Kd); - } + if (!validating && !isnan(pid.p)) + thermalManager.temp_bed.pid.set(pid); #endif } @@ -2051,15 +2022,11 @@ void MarlinSettings::postprocess() { // Heated Chamber PID // { - PID_t pid; + raw_pid_t pid; EEPROM_READ(pid); #if ENABLED(PIDTEMPCHAMBER) - if (!validating && !isnan(pid.Kp)) { - // Scale PID values since EEPROM values are unscaled - thermalManager.temp_chamber.pid.Kp = pid.Kp; - thermalManager.temp_chamber.pid.Ki = scalePID_i(pid.Ki); - thermalManager.temp_chamber.pid.Kd = scalePID_d(pid.Kd); - } + if (!validating && !isnan(pid.p)) + thermalManager.temp_chamber.pid.set(pid); #endif } @@ -3142,11 +3109,13 @@ void MarlinSettings::reset() { #define PID_DEFAULT(N,E) DEFAULT_##N #endif HOTEND_LOOP() { - PID_PARAM(Kp, e) = float(PID_DEFAULT(Kp, ALIM(e, defKp))); - PID_PARAM(Ki, e) = scalePID_i(PID_DEFAULT(Ki, ALIM(e, defKi))); - PID_PARAM(Kd, e) = scalePID_d(PID_DEFAULT(Kd, ALIM(e, defKd))); - TERN_(PID_EXTRUSION_SCALING, PID_PARAM(Kc, e) = float(PID_DEFAULT(Kc, ALIM(e, defKc)))); - TERN_(PID_FAN_SCALING, PID_PARAM(Kf, e) = float(PID_DEFAULT(Kf, ALIM(e, defKf)))); + thermalManager.temp_hotend[e].pid.set( + PID_DEFAULT(Kp, ALIM(e, defKp)), + PID_DEFAULT(Ki, ALIM(e, defKi)), + PID_DEFAULT(Kd, ALIM(e, defKd)) + OPTARG(PID_EXTRUSION_SCALING, PID_DEFAULT(Kc, ALIM(e, defKc))) + OPTARG(PID_FAN_SCALING, PID_DEFAULT(Kf, ALIM(e, defKf))) + ); } #endif @@ -3160,9 +3129,7 @@ void MarlinSettings::reset() { // #if ENABLED(PIDTEMPBED) - thermalManager.temp_bed.pid.Kp = DEFAULT_bedKp; - thermalManager.temp_bed.pid.Ki = scalePID_i(DEFAULT_bedKi); - thermalManager.temp_bed.pid.Kd = scalePID_d(DEFAULT_bedKd); + thermalManager.temp_bed.pid.set(DEFAULT_bedKp, DEFAULT_bedKi, DEFAULT_bedKd); #endif // @@ -3170,9 +3137,7 @@ void MarlinSettings::reset() { // #if ENABLED(PIDTEMPCHAMBER) - thermalManager.temp_chamber.pid.Kp = DEFAULT_chamberKp; - thermalManager.temp_chamber.pid.Ki = scalePID_i(DEFAULT_chamberKi); - thermalManager.temp_chamber.pid.Kd = scalePID_d(DEFAULT_chamberKd); + thermalManager.temp_chamber.pid.set(DEFAULT_chamberKp, DEFAULT_chamberKi, DEFAULT_chamberKd); #endif // @@ -3342,14 +3307,15 @@ void MarlinSettings::reset() { static_assert(COUNT(_filament_heat_capacity_permm) == HOTENDS, "FILAMENT_HEAT_CAPACITY_PERMM must have HOTENDS items."); HOTEND_LOOP() { - thermalManager.temp_hotend[e].constants.heater_power = _mpc_heater_power[e]; - thermalManager.temp_hotend[e].constants.block_heat_capacity = _mpc_block_heat_capacity[e]; - thermalManager.temp_hotend[e].constants.sensor_responsiveness = _mpc_sensor_responsiveness[e]; - thermalManager.temp_hotend[e].constants.ambient_xfer_coeff_fan0 = _mpc_ambient_xfer_coeff[e]; + MPC_t &constants = thermalManager.temp_hotend[e].constants; + constants.heater_power = _mpc_heater_power[e]; + constants.block_heat_capacity = _mpc_block_heat_capacity[e]; + constants.sensor_responsiveness = _mpc_sensor_responsiveness[e]; + constants.ambient_xfer_coeff_fan0 = _mpc_ambient_xfer_coeff[e]; #if ENABLED(MPC_INCLUDE_FAN) - thermalManager.temp_hotend[e].constants.fan255_adjustment = _mpc_ambient_xfer_coeff_fan255[e] - _mpc_ambient_xfer_coeff[e]; + constants.fan255_adjustment = _mpc_ambient_xfer_coeff_fan255[e] - _mpc_ambient_xfer_coeff[e]; #endif - thermalManager.temp_hotend[e].constants.filament_heat_capacity_permm = _filament_heat_capacity_permm[e]; + constants.filament_heat_capacity_permm = _filament_heat_capacity_permm[e]; } #endif diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index b97824c30585..dd5712e1b0af 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -597,7 +597,7 @@ volatile bool Temperature::raw_temps_ready = false; millis_t next_temp_ms = millis(), t1 = next_temp_ms, t2 = next_temp_ms; long t_high = 0, t_low = 0; - PID_t tune_pid = { 0, 0, 0 }; + raw_pid_t tune_pid = { 0, 0, 0 }; celsius_float_t maxT = 0, minT = 10000; const bool isbed = (heater_id == H_BED), @@ -716,16 +716,16 @@ volatile bool Temperature::raw_temps_ready = false; pf = (ischamber || isbed) ? 0.2f : 0.6f, df = (ischamber || isbed) ? 1.0f / 3.0f : 1.0f / 8.0f; - tune_pid.Kp = Ku * pf; - tune_pid.Ki = tune_pid.Kp * 2.0f / Tu; - tune_pid.Kd = tune_pid.Kp * Tu * df; + tune_pid.p = Ku * pf; + tune_pid.i = tune_pid.p * 2.0f / Tu; + tune_pid.d = tune_pid.p * Tu * df; SERIAL_ECHOLNPGM(STR_KU, Ku, STR_TU, Tu); if (ischamber || isbed) SERIAL_ECHOLNPGM(" No overshoot"); else SERIAL_ECHOLNPGM(STR_CLASSIC_PID); - SERIAL_ECHOLNPGM(STR_KP, tune_pid.Kp, STR_KI, tune_pid.Ki, STR_KD, tune_pid.Kd); + SERIAL_ECHOLNPGM(STR_KP, tune_pid.p, STR_KI, tune_pid.i, STR_KD, tune_pid.d); } } SHV((bias + d) >> 1); @@ -795,39 +795,36 @@ volatile bool Temperature::raw_temps_ready = false; #if EITHER(PIDTEMPBED, PIDTEMPCHAMBER) FSTR_P const estring = GHV(F("chamber"), F("bed"), FPSTR(NUL_STR)); - say_default_(); SERIAL_ECHOF(estring); SERIAL_ECHOLNPGM("Kp ", tune_pid.Kp); - say_default_(); SERIAL_ECHOF(estring); SERIAL_ECHOLNPGM("Ki ", tune_pid.Ki); - say_default_(); SERIAL_ECHOF(estring); SERIAL_ECHOLNPGM("Kd ", tune_pid.Kd); + say_default_(); SERIAL_ECHOF(estring); SERIAL_ECHOLNPGM("Kp ", tune_pid.p); + say_default_(); SERIAL_ECHOF(estring); SERIAL_ECHOLNPGM("Ki ", tune_pid.i); + say_default_(); SERIAL_ECHOF(estring); SERIAL_ECHOLNPGM("Kd ", tune_pid.d); #else - say_default_(); SERIAL_ECHOLNPGM("Kp ", tune_pid.Kp); - say_default_(); SERIAL_ECHOLNPGM("Ki ", tune_pid.Ki); - say_default_(); SERIAL_ECHOLNPGM("Kd ", tune_pid.Kd); + say_default_(); SERIAL_ECHOLNPGM("Kp ", tune_pid.p); + say_default_(); SERIAL_ECHOLNPGM("Ki ", tune_pid.i); + say_default_(); SERIAL_ECHOLNPGM("Kd ", tune_pid.d); #endif - auto _set_hotend_pid = [](const uint8_t e, const PID_t &in_pid) { + auto _set_hotend_pid = [](const uint8_t tool, const raw_pid_t &in_pid) { #if ENABLED(PIDTEMP) - PID_PARAM(Kp, e) = in_pid.Kp; - PID_PARAM(Ki, e) = scalePID_i(in_pid.Ki); - PID_PARAM(Kd, e) = scalePID_d(in_pid.Kd); + #if ENABLED(PID_PARAMS_PER_HOTEND) + thermalManager.temp_hotend[tool].pid.set(in_pid); + #else + HOTEND_LOOP() thermalManager.temp_hotend[e].pid.set(in_pid); + #endif updatePID(); - #else - UNUSED(e); UNUSED(in_pid); #endif + UNUSED(tool); UNUSED(in_pid); }; #if ENABLED(PIDTEMPBED) - auto _set_bed_pid = [](const PID_t &in_pid) { - temp_bed.pid.Kp = in_pid.Kp; - temp_bed.pid.Ki = scalePID_i(in_pid.Ki); - temp_bed.pid.Kd = scalePID_d(in_pid.Kd); + auto _set_bed_pid = [](const raw_pid_t &in_pid) { + temp_bed.pid.set(in_pid); }; #endif #if ENABLED(PIDTEMPCHAMBER) - auto _set_chamber_pid = [](const PID_t &in_pid) { - temp_chamber.pid.Kp = in_pid.Kp; - temp_chamber.pid.Ki = scalePID_i(in_pid.Ki); - temp_chamber.pid.Kd = scalePID_d(in_pid.Kd); + auto _set_chamber_pid = [](const raw_pid_t &in_pid) { + temp_chamber.pid.set(in_pid); }; #endif diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index f6cf81b8a966..d0f7d2dda774 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -60,53 +60,6 @@ typedef enum : int8_t { H_NONE = -128 } heater_id_t; -// PID storage -typedef struct { float Kp, Ki, Kd; } PID_t; -typedef struct { float Kp, Ki, Kd, Kc; } PIDC_t; -typedef struct { float Kp, Ki, Kd, Kf; } PIDF_t; -typedef struct { float Kp, Ki, Kd, Kc, Kf; } PIDCF_t; - -typedef - #if BOTH(PID_EXTRUSION_SCALING, PID_FAN_SCALING) - PIDCF_t - #elif ENABLED(PID_EXTRUSION_SCALING) - PIDC_t - #elif ENABLED(PID_FAN_SCALING) - PIDF_t - #else - PID_t - #endif -hotend_pid_t; - -#if ENABLED(PID_EXTRUSION_SCALING) - typedef IF<(LPQ_MAX_LEN > 255), uint16_t, uint8_t>::type lpq_ptr_t; -#endif - -#define PID_PARAM(F,H) _PID_##F(TERN(PID_PARAMS_PER_HOTEND, H, 0 & H)) // Always use 'H' to suppress warning -#define _PID_Kp(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Kp, NAN) -#define _PID_Ki(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Ki, NAN) -#define _PID_Kd(H) TERN(PIDTEMP, Temperature::temp_hotend[H].pid.Kd, NAN) -#if ENABLED(PIDTEMP) - #define _PID_Kc(H) TERN(PID_EXTRUSION_SCALING, Temperature::temp_hotend[H].pid.Kc, 1) - #define _PID_Kf(H) TERN(PID_FAN_SCALING, Temperature::temp_hotend[H].pid.Kf, 0) -#else - #define _PID_Kc(H) 1 - #define _PID_Kf(H) 0 -#endif - -#if ENABLED(MPCTEMP) - typedef struct { - float heater_power; // M306 P - float block_heat_capacity; // M306 C - float sensor_responsiveness; // M306 R - float ambient_xfer_coeff_fan0; // M306 A - #if ENABLED(MPC_INCLUDE_FAN) - float fan255_adjustment; // M306 F - #endif - float filament_heat_capacity_permm; // M306 H - } MPC_t; -#endif - /** * States for ADC reading in the ISR */ @@ -188,7 +141,15 @@ enum ADCSensorState : char { #define ACTUAL_ADC_SAMPLES _MAX(int(MIN_ADC_ISR_LOOPS), int(SensorsReady)) +// +// PID +// + +typedef struct { float p, i, d; } raw_pid_t; +typedef struct { float p, i, d, c, f; } raw_pidcf_t; + #if HAS_PID_HEATING + #define PID_K2 (1-float(PID_K1)) #define PID_dT ((OVERSAMPLENR * float(ACTUAL_ADC_SAMPLES)) / (TEMP_TIMER_FREQUENCY)) @@ -197,10 +158,116 @@ enum ADCSensorState : char { #define unscalePID_i(i) ( float(i) / PID_dT ) #define scalePID_d(d) ( float(d) / PID_dT ) #define unscalePID_d(d) ( float(d) * PID_dT ) + + typedef struct { + float Kp, Ki, Kd; + float p() const { return Kp; } + float i() const { return unscalePID_i(Ki); } + float d() const { return unscalePID_d(Kd); } + float c() const { return 1; } + float f() const { return 0; } + void set_Kp(float p) { Kp = p; } + void set_Ki(float i) { Ki = scalePID_i(i); } + void set_Kd(float d) { Kd = scalePID_d(d); } + void set_Kc(float) {} + void set_Kf(float) {} + void set(float p, float i, float d, float c=1, float f=0) { set_Kp(p); set_Ki(i); set_Kd(d); UNUSED(c); UNUSED(f); } + void set(const raw_pid_t &raw) { set(raw.p, raw.i, raw.d); } + void set(const raw_pidcf_t &raw) { set(raw.p, raw.i, raw.d); } + } PID_t; + #endif -#if ENABLED(MPCTEMP) +#if ENABLED(PIDTEMP) + + typedef struct { + float Kp, Ki, Kd, Kc; + float p() const { return Kp; } + float i() const { return unscalePID_i(Ki); } + float d() const { return unscalePID_d(Kd); } + float c() const { return Kc; } + float f() const { return 0; } + void set_Kp(float p) { Kp = p; } + void set_Ki(float i) { Ki = scalePID_i(i); } + void set_Kd(float d) { Kd = scalePID_d(d); } + void set_Kc(float c) { Kc = c; } + void set_Kf(float) {} + void set(float p, float i, float d, float c=1, float f=0) { set_Kp(p); set_Ki(i); set_Kd(d); set_Kc(c); set_Kf(f); } + void set(const raw_pid_t &raw) { set(raw.p, raw.i, raw.d); } + void set(const raw_pidcf_t &raw) { set(raw.p, raw.i, raw.d, raw.c); } + } PIDC_t; + + typedef struct { + float Kp, Ki, Kd, Kf; + float p() const { return Kp; } + float i() const { return unscalePID_i(Ki); } + float d() const { return unscalePID_d(Kd); } + float c() const { return 1; } + float f() const { return Kf; } + void set_Kp(float p) { Kp = p; } + void set_Ki(float i) { Ki = scalePID_i(i); } + void set_Kd(float d) { Kd = scalePID_d(d); } + void set_Kc(float) {} + void set_Kf(float f) { Kf = f; } + void set(float p, float i, float d, float c=1, float f=0) { set_Kp(p); set_Ki(i); set_Kd(d); set_Kf(f); } + void set(const raw_pid_t &raw) { set(raw.p, raw.i, raw.d); } + void set(const raw_pidcf_t &raw) { set(raw.p, raw.i, raw.d, raw.f); } + } PIDF_t; + + typedef struct { + float Kp, Ki, Kd, Kc, Kf; + float p() const { return Kp; } + float i() const { return unscalePID_i(Ki); } + float d() const { return unscalePID_d(Kd); } + float c() const { return Kc; } + float f() const { return Kf; } + void set_Kp(float p) { Kp = p; } + void set_Ki(float i) { Ki = scalePID_i(i); } + void set_Kd(float d) { Kd = scalePID_d(d); } + void set_Kc(float c) { Kc = c; } + void set_Kf(float f) { Kf = f; } + void set(float p, float i, float d, float c=1, float f=0) { set_Kp(p); set_Ki(i); set_Kd(d); set_Kc(c); set_Kf(f); } + void set(const raw_pid_t &raw) { set(raw.p, raw.i, raw.d); } + void set(const raw_pidcf_t &raw) { set(raw.p, raw.i, raw.d, raw.c, raw.f); } + } PIDCF_t; + + typedef + #if BOTH(PID_EXTRUSION_SCALING, PID_FAN_SCALING) + PIDCF_t + #elif ENABLED(PID_EXTRUSION_SCALING) + PIDC_t + #elif ENABLED(PID_FAN_SCALING) + PIDF_t + #else + PID_t + #endif + hotend_pid_t; + + #if ENABLED(PID_EXTRUSION_SCALING) + typedef IF<(LPQ_MAX_LEN > 255), uint16_t, uint8_t>::type lpq_ptr_t; + #endif + + #if ENABLED(PID_PARAMS_PER_HOTEND) + #define SET_HOTEND_PID(F,H,V) thermalManager.temp_hotend[H].pid.set_##F(V) + #else + #define SET_HOTEND_PID(F,_,V) do{ HOTEND_LOOP() thermalManager.temp_hotend[e].pid.set_##F(V); }while(0) + #endif + +#elif ENABLED(MPCTEMP) + + typedef struct { + float heater_power; // M306 P + float block_heat_capacity; // M306 C + float sensor_responsiveness; // M306 R + float ambient_xfer_coeff_fan0; // M306 A + #if ENABLED(MPC_INCLUDE_FAN) + float fan255_adjustment; // M306 F + #endif + float filament_heat_capacity_permm; // M306 H + } MPC_t; + #define MPC_dT ((OVERSAMPLENR * float(ACTUAL_ADC_SAMPLES)) / (TEMP_TIMER_FREQUENCY)) + #endif #if ENABLED(G26_MESH_VALIDATION) && EITHER(HAS_MARLINUI_MENU, EXTENSIBLE_UI) @@ -218,7 +285,7 @@ typedef struct TempInfo { inline void sample(const raw_adc_t s) { acc += s; } inline void update() { raw = acc; } void setraw(const raw_adc_t r) { raw = r; } - raw_adc_t getraw() { return raw; } + raw_adc_t getraw() const { return raw; } } temp_info_t; #if HAS_TEMP_REDUNDANT @@ -393,6 +460,7 @@ class Temperature { static const celsius_t hotend_maxtemp[HOTENDS]; static celsius_t hotend_max_target(const uint8_t e) { return hotend_maxtemp[e] - (HOTEND_OVERSHOOT); } #endif + #if HAS_HEATED_BED static bed_info_t temp_bed; #endif @@ -965,12 +1033,16 @@ class Temperature { static constexpr bool adaptive_fan_slowing = true; #endif - /** - * Update the temp manager when PID values change - */ + // Update the temp manager when PID values change #if ENABLED(PIDTEMP) - static void updatePID() { - TERN_(PID_EXTRUSION_SCALING, pes_e_position = 0); + static void updatePID() { TERN_(PID_EXTRUSION_SCALING, pes_e_position = 0); } + static void setPID(const uint8_t hotend, const_float_t p, const_float_t i, const_float_t d) { + #if ENABLED(PID_PARAMS_PER_HOTEND) + temp_hotend[hotend].pid.set(p, i, d); + #else + HOTEND_LOOP() temp_hotend[e].pid.set(p, i, d); + #endif + updatePID(); } #endif diff --git a/buildroot/tests/rambo b/buildroot/tests/rambo index 167f6d89aae2..b5d6491d2870 100755 --- a/buildroot/tests/rambo +++ b/buildroot/tests/rambo @@ -23,7 +23,7 @@ opt_enable USE_ZMAX_PLUG REPRAP_DISCOUNT_SMART_CONTROLLER LCD_PROGRESS_BAR LCD_P EEPROM_SETTINGS SDSUPPORT SD_REPRINT_LAST_SELECTED_FILE BINARY_FILE_TRANSFER \ BLINKM PCA9533 PCA9632 RGB_LED RGB_LED_R_PIN RGB_LED_G_PIN RGB_LED_B_PIN LED_CONTROL_MENU \ NEOPIXEL_LED NEOPIXEL_PIN CASE_LIGHT_ENABLE CASE_LIGHT_USE_NEOPIXEL CASE_LIGHT_MENU \ - PID_PARAMS_PER_HOTEND PID_AUTOTUNE_MENU PID_EDIT_MENU LCD_SHOW_E_TOTAL \ + PID_PARAMS_PER_HOTEND PID_AUTOTUNE_MENU PID_EDIT_MENU PID_EXTRUSION_SCALING LCD_SHOW_E_TOTAL \ PRINTCOUNTER SERVICE_NAME_1 SERVICE_INTERVAL_1 LCD_BED_TRAMMING BED_TRAMMING_INCLUDE_CENTER \ NOZZLE_PARK_FEATURE FILAMENT_RUNOUT_SENSOR FILAMENT_RUNOUT_DISTANCE_MM \ ADVANCED_PAUSE_FEATURE FILAMENT_LOAD_UNLOAD_GCODES FILAMENT_UNLOAD_ALL_EXTRUDERS \ From 2fc97aa240f17c9c2429e65c0110ceddb7af4132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arkadiusz=20Mi=C5=9Bkiewicz?= Date: Sun, 18 Sep 2022 03:51:37 +0200 Subject: [PATCH 064/243] =?UTF-8?q?=F0=9F=9A=B8=20Emergency=20Parse=20M524?= =?UTF-8?q?=20(#24761)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/e_parser.cpp | 3 +++ Marlin/src/feature/e_parser.h | 20 +++++++++++++++++++- Marlin/src/module/temperature.cpp | 6 ++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Marlin/src/feature/e_parser.cpp b/Marlin/src/feature/e_parser.cpp index d98afcfee71b..cfe0956aa789 100644 --- a/Marlin/src/feature/e_parser.cpp +++ b/Marlin/src/feature/e_parser.cpp @@ -33,6 +33,9 @@ // Static data members bool EmergencyParser::killed_by_M112, // = false EmergencyParser::quickstop_by_M410, + #if ENABLED(SDSUPPORT) + EmergencyParser::sd_abort_by_M524, + #endif EmergencyParser::enabled; #if ENABLED(HOST_PROMPT_SUPPORT) diff --git a/Marlin/src/feature/e_parser.h b/Marlin/src/feature/e_parser.h index fda1ba144bc4..3a15a7ffa0f9 100644 --- a/Marlin/src/feature/e_parser.h +++ b/Marlin/src/feature/e_parser.h @@ -49,7 +49,7 @@ class EmergencyParser { public: - // Currently looking for: M108, M112, M410, M876 S[0-9], S000, P000, R000 + // Currently looking for: M108, M112, M410, M524, M876 S[0-9], S000, P000, R000 enum State : uint8_t { EP_RESET, EP_N, @@ -58,6 +58,9 @@ class EmergencyParser { EP_M10, EP_M108, EP_M11, EP_M112, EP_M4, EP_M41, EP_M410, + #if ENABLED(SDSUPPORT) + EP_M5, EP_M52, EP_M524, + #endif #if ENABLED(HOST_PROMPT_SUPPORT) EP_M8, EP_M87, EP_M876, EP_M876S, EP_M876SN, #endif @@ -76,6 +79,10 @@ class EmergencyParser { static bool killed_by_M112; static bool quickstop_by_M410; + #if ENABLED(SDSUPPORT) + static bool sd_abort_by_M524; + #endif + #if ENABLED(HOST_PROMPT_SUPPORT) static uint8_t M876_reason; #endif @@ -145,6 +152,9 @@ class EmergencyParser { case ' ': break; case '1': state = EP_M1; break; case '4': state = EP_M4; break; + #if ENABLED(SDSUPPORT) + case '5': state = EP_M5; break; + #endif #if ENABLED(HOST_PROMPT_SUPPORT) case '8': state = EP_M8; break; #endif @@ -165,6 +175,11 @@ class EmergencyParser { case EP_M4: state = (c == '1') ? EP_M41 : EP_IGNORE; break; case EP_M41: state = (c == '0') ? EP_M410 : EP_IGNORE; break; + #if ENABLED(SDSUPPORT) + case EP_M5: state = (c == '2') ? EP_M52 : EP_IGNORE; break; + case EP_M52: state = (c == '4') ? EP_M524 : EP_IGNORE; break; + #endif + #if ENABLED(HOST_PROMPT_SUPPORT) case EP_M8: state = (c == '7') ? EP_M87 : EP_IGNORE; break; @@ -200,6 +215,9 @@ class EmergencyParser { case EP_M108: wait_for_user = wait_for_heatup = false; break; case EP_M112: killed_by_M112 = true; break; case EP_M410: quickstop_by_M410 = true; break; + #if ENABLED(SDSUPPORT) + case EP_M524: sd_abort_by_M524 = true; break; + #endif #if ENABLED(HOST_PROMPT_SUPPORT) case EP_M876SN: hostui.handle_response(M876_reason); break; #endif diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index dd5712e1b0af..cb9043f3473d 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -1848,6 +1848,12 @@ void Temperature::task() { emergency_parser.quickstop_by_M410 = false; // quickstop_stepper may call idle so clear this now! quickstop_stepper(); } + + if (emergency_parser.sd_abort_by_M524) { // abort SD print immediately + emergency_parser.sd_abort_by_M524 = false; + card.flag.abort_sd_printing = true; + gcode.process_subcommands_now(F("M524")); + } #endif if (!updateTemperaturesIfReady()) return; // Will also reset the watchdog if temperatures are ready From 5fe1f6647875b2f325db52b74f356bdaec19dce5 Mon Sep 17 00:00:00 2001 From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Date: Thu, 1 Sep 2022 21:16:52 +0200 Subject: [PATCH 065/243] =?UTF-8?q?=F0=9F=9A=B8=20Strict=20index=202=20for?= =?UTF-8?q?=20M913=20/=20M914=20XY=20(#24680)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/feature/trinamic/M911-M914.cpp | 9 ++++----- Marlin/src/inc/SanityCheck.h | 6 ++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp index 0a9d1760e91e..0fbf1def6777 100644 --- a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp +++ b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp @@ -294,14 +294,14 @@ #if X_HAS_STEALTHCHOP || X2_HAS_STEALTHCHOP case X_AXIS: TERN_(X_HAS_STEALTHCHOP, if (index < 2) TMC_SET_PWMTHRS(X,X)); - TERN_(X2_HAS_STEALTHCHOP, if (!(index & 1)) TMC_SET_PWMTHRS(X,X2)); + TERN_(X2_HAS_STEALTHCHOP, if (!index || index == 2) TMC_SET_PWMTHRS(X,X2)); break; #endif #if Y_HAS_STEALTHCHOP || Y2_HAS_STEALTHCHOP case Y_AXIS: TERN_(Y_HAS_STEALTHCHOP, if (index < 2) TMC_SET_PWMTHRS(Y,Y)); - TERN_(Y2_HAS_STEALTHCHOP, if (!(index & 1)) TMC_SET_PWMTHRS(Y,Y2)); + TERN_(Y2_HAS_STEALTHCHOP, if (!index || index == 2) TMC_SET_PWMTHRS(Y,Y2)); break; #endif @@ -499,7 +499,6 @@ * M914: Set StallGuard sensitivity. */ void GcodeSuite::M914() { - bool report = true; const uint8_t index = parser.byteval('I'); LOOP_NUM_AXES(i) if (parser.seen(AXIS_CHAR(i))) { @@ -509,13 +508,13 @@ #if X_SENSORLESS case X_AXIS: if (index < 2) stepperX.homing_threshold(value); - TERN_(X2_SENSORLESS, if (!(index & 1)) stepperX2.homing_threshold(value)); + TERN_(X2_SENSORLESS, if (!index || index == 2) stepperX2.homing_threshold(value)); break; #endif #if Y_SENSORLESS case Y_AXIS: if (index < 2) stepperY.homing_threshold(value); - TERN_(Y2_SENSORLESS, if (!(index & 1)) stepperY2.homing_threshold(value)); + TERN_(Y2_SENSORLESS, if (!index || index == 2) stepperY2.homing_threshold(value)); break; #endif #if Z_SENSORLESS diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index ea39aa1b7020..e9675feaf1d4 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2044,6 +2044,12 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS ); #endif +#define COUNT_SENSORLESS COUNT_ENABLED(Z_SENSORLESS, Z2_SENSORLESS, Z3_SENSORLESS, Z4_SENSORLESS) +#if COUNT_SENSORLESS && COUNT_SENSORLESS != NUM_Z_STEPPERS + #error "All Z steppers must have *_STALL_SENSITIVITY defined to use Z sensorless homing." +#endif +#undef COUNT_SENSORLESS + #ifdef SENSORLESS_BACKOFF_MM constexpr float sbm[] = SENSORLESS_BACKOFF_MM; static_assert(COUNT(sbm) == NUM_AXES, "SENSORLESS_BACKOFF_MM must have " _NUM_AXES_STR "elements (and no others)."); From eff60964da6e1b5d74f342de84f47344f96f201d Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Fri, 23 Sep 2022 17:16:01 +1200 Subject: [PATCH 066/243] =?UTF-8?q?=F0=9F=90=9B=20Fix=20VW=20axis=20fields?= =?UTF-8?q?=20in=20types.h=20(#24780)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/types.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index f0ddc871a556..de6bc2486d02 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -494,10 +494,10 @@ struct XYZval { FI void set(const T px, const T py, const T pz, const T pi, const T pj, const T pk) { x = px; y = py; z = pz; i = pi; j = pj; k = pk; } #endif #if HAS_V_AXIS - FI void set(const T px, const T py, const T pz, const T pi, const T pj, const T pk, const T pm) { x = px; y = py; z = pz; i = pi; j = pj; k = pk; u = pu; } + FI void set(const T px, const T py, const T pz, const T pi, const T pj, const T pk, const T pu) { x = px; y = py; z = pz; i = pi; j = pj; k = pk; u = pu; } #endif #if HAS_W_AXIS - FI void set(const T px, const T py, const T pz, const T pi, const T pj, const T pk, const T pm, const T po) { x = px; y = py; z = pz; i = pi; j = pj; k = pk; u = pu; v = pv; } + FI void set(const T px, const T py, const T pz, const T pi, const T pj, const T pk, const T pu, const T pv) { x = px; y = py; z = pz; i = pi; j = pj; k = pk; u = pu; v = pv; } #endif // Length reduced to one dimension @@ -634,10 +634,10 @@ struct XYZEval { FI void set(const T px, const T py, const T pz, const T pi, const T pj, const T pk) { x = px; y = py; z = pz; i = pi; j = pj; k = pk; } #endif #if HAS_V_AXIS - FI void set(const T px, const T py, const T pz, const T pi, const T pj, const T pk, const T pm) { x = px; y = py; z = pz; i = pi; j = pj; k = pk; u = pu; } + FI void set(const T px, const T py, const T pz, const T pi, const T pj, const T pk, const T pu) { x = px; y = py; z = pz; i = pi; j = pj; k = pk; u = pu; } #endif #if HAS_W_AXIS - FI void set(const T px, const T py, const T pz, const T pi, const T pj, const T pk, const T pm, const T po) { x = px; y = py; z = pz; i = pi; j = pj; k = pk; u = pm; v = pv; } + FI void set(const T px, const T py, const T pz, const T pi, const T pj, const T pk, const T pu, const T pv) { x = px; y = py; z = pz; i = pi; j = pj; k = pk; u = pu; v = pv; } #endif // Setters taking struct types and arrays From 29156ffe5d16afeb78fac434197155e8a04f0629 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 9 Nov 2022 20:54:17 -0600 Subject: [PATCH 067/243] =?UTF-8?q?=F0=9F=90=9B=20Fix=20recalculate=5Fmax?= =?UTF-8?q?=5Fe=5Fjerk?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/module/planner.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index 09afee7db1b5..974dcd2ad371 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -988,7 +988,7 @@ class Planner { FORCE_INLINE static void recalculate_max_e_jerk() { const float prop = junction_deviation_mm * SQRT(0.5) / (1.0f - SQRT(0.5)); EXTRUDER_LOOP() - max_e_jerk[E_INDEX_N(e)] = SQRT(prop * settings.max_acceleration_mm_per_s2[E_INDEX_N(e)]); + max_e_jerk[E_INDEX_N(e)] = SQRT(prop * settings.max_acceleration_mm_per_s2[E_AXIS_N(e)]); } #endif From 647d459a158afaf9f1ea0374ab6aaee2d39e9330 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 24 Aug 2022 10:15:57 -0500 Subject: [PATCH 068/243] =?UTF-8?q?=E2=9C=A8=20Robin=20Nano=20v1=20CDC=20(?= =?UTF-8?q?USB=20mod)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to #24619 --- .../{mks_robin_nano_v1v2_usbmod => mks_robin_nano_v1_2_usbmod} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename buildroot/tests/{mks_robin_nano_v1v2_usbmod => mks_robin_nano_v1_2_usbmod} (100%) diff --git a/buildroot/tests/mks_robin_nano_v1v2_usbmod b/buildroot/tests/mks_robin_nano_v1_2_usbmod similarity index 100% rename from buildroot/tests/mks_robin_nano_v1v2_usbmod rename to buildroot/tests/mks_robin_nano_v1_2_usbmod From c996bfddb7775f9160e33443df8c103de003339f Mon Sep 17 00:00:00 2001 From: tombrazier <68918209+tombrazier@users.noreply.github.com> Date: Fri, 2 Sep 2022 03:04:46 +0100 Subject: [PATCH 069/243] =?UTF-8?q?=E2=9C=A8=20Permit=20Linear=20Advance?= =?UTF-8?q?=20with=20I2S=20Streaming=20(#24684)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 7 +++--- Marlin/src/HAL/ESP32/i2s.cpp | 32 ++++++++++++++++++++------ Marlin/src/HAL/ESP32/inc/SanityCheck.h | 2 +- Marlin/src/inc/Warnings.cpp | 4 ++++ Marlin/src/module/stepper.cpp | 32 +++++++++++--------------- Marlin/src/module/stepper.h | 1 + 6 files changed, 48 insertions(+), 30 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index ba3064722f11..85a69cc48322 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -2063,11 +2063,12 @@ */ //#define LIN_ADVANCE #if ENABLED(LIN_ADVANCE) - //#define EXTRA_LIN_ADVANCE_K // Enable for second linear advance constants + //#define EXTRA_LIN_ADVANCE_K // Add a second linear advance constant, configurable with M900. #define LIN_ADVANCE_K 0.22 // Unit: mm compression per 1mm/s extruder speed - //#define LA_DEBUG // If enabled, this will generate debug information output over USB. - //#define EXPERIMENTAL_SCURVE // Enable this option to permit S-Curve Acceleration + //#define LA_DEBUG // Print debug information to serial during operation. Disable for production use. + //#define EXPERIMENTAL_SCURVE // Allow S-Curve Acceleration to be used with LA. //#define ALLOW_LOW_EJERK // Allow a DEFAULT_EJERK value of <10. Recommended for direct drive hotends. + //#define EXPERIMENTAL_I2S_LA // Allow I2S_STEPPER_STREAM to be used with LA. Performance degrades as the LA step rate reaches ~20kHz. #endif // @section leveling diff --git a/Marlin/src/HAL/ESP32/i2s.cpp b/Marlin/src/HAL/ESP32/i2s.cpp index cf337eeb4622..d9bad4ec2d12 100644 --- a/Marlin/src/HAL/ESP32/i2s.cpp +++ b/Marlin/src/HAL/ESP32/i2s.cpp @@ -139,22 +139,40 @@ static void IRAM_ATTR i2s_intr_handler_default(void *arg) { } void stepperTask(void *parameter) { - uint32_t remaining = 0; + uint32_t nextMainISR = 0; + #if ENABLED(LIN_ADVANCE) + uint32_t nextAdvanceISR = Stepper::LA_ADV_NEVER; + #endif - while (1) { + for (;;) { xQueueReceive(dma.queue, &dma.current, portMAX_DELAY); dma.rw_pos = 0; while (dma.rw_pos < DMA_SAMPLE_COUNT) { // Fill with the port data post pulse_phase until the next step - if (remaining) { + if (nextMainISR && TERN1(LIN_ADVANCE, nextAdvanceISR)) i2s_push_sample(); - remaining--; - } - else { + + // i2s_push_sample() is also called from Stepper::pulse_phase_isr() and Stepper::advance_isr() + // in a rare case where both are called, we need to double decrement the counters + const uint8_t push_count = 1 + (!nextMainISR && TERN0(LIN_ADVANCE, !nextAdvanceISR)); + + #if ENABLED(LIN_ADVANCE) + if (!nextAdvanceISR) { + Stepper::advance_isr(); + nextAdvanceISR = Stepper::la_interval; + } + else if (nextAdvanceISR == Stepper::LA_ADV_NEVER) + nextAdvanceISR = Stepper::la_interval; + #endif + + if (!nextMainISR) { Stepper::pulse_phase_isr(); - remaining = Stepper::block_phase_isr(); + nextMainISR = Stepper::block_phase_isr(); } + + nextMainISR -= push_count; + TERN_(LIN_ADVANCE, nextAdvanceISR -= push_count); } } } diff --git a/Marlin/src/HAL/ESP32/inc/SanityCheck.h b/Marlin/src/HAL/ESP32/inc/SanityCheck.h index 4486a0a6ee7c..8c5621f10c02 100644 --- a/Marlin/src/HAL/ESP32/inc/SanityCheck.h +++ b/Marlin/src/HAL/ESP32/inc/SanityCheck.h @@ -53,6 +53,6 @@ #error "PULLDOWN pin mode is not available on ESP32 boards." #endif -#if BOTH(I2S_STEPPER_STREAM, LIN_ADVANCE) +#if BOTH(I2S_STEPPER_STREAM, LIN_ADVANCE) && DISABLED(EXPERIMENTAL_I2S_LA) #error "I2S stream is currently incompatible with LIN_ADVANCE." #endif diff --git a/Marlin/src/inc/Warnings.cpp b/Marlin/src/inc/Warnings.cpp index a88b6e532a0c..65174593fb5d 100644 --- a/Marlin/src/inc/Warnings.cpp +++ b/Marlin/src/inc/Warnings.cpp @@ -35,6 +35,10 @@ #warning "WARNING! Disable MARLIN_DEV_MODE for the final build!" #endif +#if ENABLED(LA_DEBUG) + #warning "WARNING! Disable LA_DEBUG for the final build!" +#endif + #if NUM_AXES_WARNING #warning "Note: NUM_AXES is now based on the *_DRIVER_TYPE settings so you can remove NUM_AXES from Configuration.h." #endif diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 78c09fadefbd..4ee4c1d1a790 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -137,6 +137,10 @@ Stepper stepper; // Singleton #include "../lcd/extui/ui_api.h" #endif +#if ENABLED(I2S_STEPPER_STREAM) + #include "../HAL/ESP32/i2s.h" +#endif + // public: #if EITHER(HAS_EXTRA_ENDSTOPS, Z_STEPPER_AUTO_ALIGN) @@ -1558,14 +1562,7 @@ void Stepper::isr() { * On AVR the ISR epilogue+prologue is estimated at 100 instructions - Give 8µs as margin * On ARM the ISR epilogue+prologue is estimated at 20 instructions - Give 1µs as margin */ - min_ticks = HAL_timer_get_count(MF_TIMER_STEP) + hal_timer_t( - #ifdef __AVR__ - 8 - #else - 1 - #endif - * (STEPPER_TIMER_TICKS_PER_US) - ); + min_ticks = HAL_timer_get_count(MF_TIMER_STEP) + hal_timer_t(TERN(__AVR__, 8, 1) * (STEPPER_TIMER_TICKS_PER_US)); /** * NB: If for some reason the stepper monopolizes the MPU, eventually the @@ -2472,18 +2469,19 @@ uint32_t Stepper::block_phase_isr() { // the acceleration and speed values calculated in block_phase_isr(). // This helps keep LA in sync with, for example, S_CURVE_ACCELERATION. la_delta_error += la_dividend; - if (la_delta_error >= 0) { + const bool step_needed = la_delta_error >= 0; + if (step_needed) { count_position.e += count_direction.e; la_advance_steps += count_direction.e; la_delta_error -= advance_divisor; // Set the STEP pulse ON - #if ENABLED(MIXING_EXTRUDER) - E_STEP_WRITE(mixer.get_next_stepper(), !INVERT_E_STEP_PIN); - #else - E_STEP_WRITE(stepper_extruder, !INVERT_E_STEP_PIN); - #endif + E_STEP_WRITE(TERN(MIXING_EXTRUDER, mixer.get_next_stepper(), stepper_extruder), !INVERT_E_STEP_PIN); + } + + TERN_(I2S_STEPPER_STREAM, i2s_push_sample()); + if (step_needed) { // Enforce a minimum duration for STEP pulse ON #if ISR_PULSE_CONTROL USING_TIMED_PULSE(); @@ -2492,11 +2490,7 @@ uint32_t Stepper::block_phase_isr() { #endif // Set the STEP pulse OFF - #if ENABLED(MIXING_EXTRUDER) - E_STEP_WRITE(mixer.get_stepper(), INVERT_E_STEP_PIN); - #else - E_STEP_WRITE(stepper_extruder, INVERT_E_STEP_PIN); - #endif + E_STEP_WRITE(TERN(MIXING_EXTRUDER, mixer.get_stepper(), stepper_extruder), INVERT_E_STEP_PIN); } } diff --git a/Marlin/src/module/stepper.h b/Marlin/src/module/stepper.h index ccf342b573e7..729ab83266b1 100644 --- a/Marlin/src/module/stepper.h +++ b/Marlin/src/module/stepper.h @@ -318,6 +318,7 @@ constexpr ena_mask_t enable_overlap[] = { class Stepper { friend class KinematicSystem; friend class DeltaKinematicSystem; + friend void stepperTask(void *); public: From 3d03f96205cac22d9061293b8703e5a3271ed420 Mon Sep 17 00:00:00 2001 From: studiodyne Date: Sun, 28 Aug 2022 00:43:32 +0200 Subject: [PATCH 070/243] =?UTF-8?q?=E2=9C=A8=20RGB=5FSTARTUP=5FTEST?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration.h | 13 ++++++++--- Marlin/src/feature/leds/leds.cpp | 38 ++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 0b8691f8551f..59285af763cd 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -3251,16 +3251,19 @@ * luminance values can be set from 0 to 255. * For NeoPixel LED an overall brightness parameter is also available. * - * *** CAUTION *** + * === CAUTION === * LED Strips require a MOSFET Chip between PWM lines and LEDs, * as the Arduino cannot handle the current the LEDs will require. * Failure to follow this precaution can destroy your Arduino! + * * NOTE: A separate 5V power supply is required! The NeoPixel LED needs * more current than the Arduino 5V linear regulator can produce. - * *** CAUTION *** * - * LED Type. Enable only one of the following two options. + * Requires PWM frequency between 50 <> 100Hz (Check HAL or variant) + * Use FAST_PWM_FAN, if possible, to reduce fan noise. */ + +// LED Type. Enable only one of the following two options: //#define RGB_LED //#define RGBW_LED @@ -3269,6 +3272,10 @@ //#define RGB_LED_G_PIN 43 //#define RGB_LED_B_PIN 35 //#define RGB_LED_W_PIN -1 + //#define RGB_STARTUP_TEST // For PWM pins, fade between all colors + #if ENABLED(RGB_STARTUP_TEST) + #define RGB_STARTUP_TEST_INNER_MS 10 // (ms) Reduce or increase fading speed + #endif #endif // Support for Adafruit NeoPixel LED driver diff --git a/Marlin/src/feature/leds/leds.cpp b/Marlin/src/feature/leds/leds.cpp index 2a53a7c884e6..1c6d9ab09044 100644 --- a/Marlin/src/feature/leds/leds.cpp +++ b/Marlin/src/feature/leds/leds.cpp @@ -69,6 +69,44 @@ void LEDLights::setup() { #if ENABLED(RGBW_LED) if (PWM_PIN(RGB_LED_W_PIN)) SET_PWM(RGB_LED_W_PIN); else SET_OUTPUT(RGB_LED_W_PIN); #endif + + #if ENABLED(RGB_STARTUP_TEST) + int8_t led_pin_count = 0; + if (PWM_PIN(RGB_LED_R_PIN) && PWM_PIN(RGB_LED_G_PIN) && PWM_PIN(RGB_LED_B_PIN)) led_pin_count = 3; + #if ENABLED(RGBW_LED) + if (PWM_PIN(RGB_LED_W_PIN) && led_pin_count) led_pin_count++; + #endif + // Startup animation + if (led_pin_count) { + // blackout + if (PWM_PIN(RGB_LED_R_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_R_PIN), 0); else WRITE(RGB_LED_R_PIN, LOW); + if (PWM_PIN(RGB_LED_G_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_G_PIN), 0); else WRITE(RGB_LED_G_PIN, LOW); + if (PWM_PIN(RGB_LED_B_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_B_PIN), 0); else WRITE(RGB_LED_B_PIN, LOW); + #if ENABLED(RGBW_LED) + if (PWM_PIN(RGB_LED_W_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_W_PIN), 0); + else WRITE(RGB_LED_W_PIN, LOW); + #endif + delay(200); + + LOOP_L_N(i, led_pin_count) { + LOOP_LE_N(b, 200) { + const uint16_t led_pwm = b <= 100 ? b : 200 - b; + if (i == 0 && PWM_PIN(RGB_LED_R_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_R_PIN), led_pwm); else WRITE(RGB_LED_R_PIN, b < 100 ? HIGH : LOW); + if (i == 1 && PWM_PIN(RGB_LED_G_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_G_PIN), led_pwm); else WRITE(RGB_LED_G_PIN, b < 100 ? HIGH : LOW); + if (i == 2 && PWM_PIN(RGB_LED_B_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_B_PIN), led_pwm); else WRITE(RGB_LED_B_PIN, b < 100 ? HIGH : LOW); + #if ENABLED(RGBW_LED) + if (i == 3){ + if (PWM_PIN(RGB_LED_W_PIN)) hal.set_pwm_duty(pin_t(RGB_LED_W_PIN), led_pwm); + else WRITE(RGB_LED_W_PIN, b < 100 ? HIGH : LOW); + delay(RGB_STARTUP_TEST_INNER_MS);//More slowing for ending + } + #endif + delay(RGB_STARTUP_TEST_INNER_MS); + } + } + delay(500); + } + #endif // RGB_STARTUP_TEST #endif TERN_(NEOPIXEL_LED, neo.init()); TERN_(PCA9533, PCA9533_init()); From 1f72c8341f33a6ea7e086ad4f94b0bc903ad2ba3 Mon Sep 17 00:00:00 2001 From: studiodyne Date: Sun, 28 Aug 2022 00:43:32 +0200 Subject: [PATCH 071/243] =?UTF-8?q?=E2=9C=A8=20XY=5FCOUNTERPART=5FBACKOFF?= =?UTF-8?q?=5FMM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 1 + Marlin/src/module/motion.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 85a69cc48322..df1c1d245f28 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -874,6 +874,7 @@ #define HOMING_BUMP_DIVISOR { 2, 2, 4 } // Re-Bump Speed Divisor (Divides the Homing Feedrate) //#define HOMING_BACKOFF_POST_MM { 2, 2, 2 } // (linear=mm, rotational=°) Backoff from endstops after homing +//#define XY_COUNTERPART_BACKOFF_MM 0 // (mm) Backoff X after homing Y, and vice-versa //#define QUICK_HOME // If G28 contains XY do a diagonal move first //#define HOME_Y_BEFORE_X // If G28 contains XY home Y before X diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 6101022fd49d..c0503c621dfb 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -1994,6 +1994,17 @@ void prepare_line_to_destination() { } #endif + // + // Back away to prevent opposite endstop damage + // + #if !defined(SENSORLESS_BACKOFF_MM) && XY_COUNTERPART_BACKOFF_MM + if (!(axis_was_homed(X_AXIS) || axis_was_homed(Y_AXIS)) && (axis == X_AXIS || axis == Y_AXIS)) { + const AxisEnum opposite_axis = axis == X_AXIS ? Y_AXIS : X_AXIS; + const float backoff_length = -ABS(XY_COUNTERPART_BACKOFF_MM) * home_dir(opposite_axis); + do_homing_move(opposite_axis, backoff_length, homing_feedrate(opposite_axis)); + } + #endif + // Determine if a homing bump will be done and the bumps distance // When homing Z with probe respect probe clearance const bool use_probe_bump = TERN0(HOMING_Z_WITH_PROBE, axis == Z_AXIS && home_bump_mm(axis)); From be149336f0192777e835396a856bd836c10aea35 Mon Sep 17 00:00:00 2001 From: studiodyne Date: Sun, 28 Aug 2022 00:43:32 +0200 Subject: [PATCH 072/243] =?UTF-8?q?=E2=9C=A8=20M217=20G=20wipe=20retract?= =?UTF-8?q?=20length?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 2 +- Marlin/src/gcode/config/M217.cpp | 30 +++++++++++++--------- Marlin/src/lcd/language/language_en.h | 1 + Marlin/src/lcd/language/language_fr.h | 1 + Marlin/src/lcd/menu/menu_configuration.cpp | 1 + Marlin/src/module/settings.cpp | 3 ++- Marlin/src/module/tool_change.cpp | 30 +++++++++++----------- Marlin/src/module/tool_change.h | 1 + 8 files changed, 40 insertions(+), 29 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index df1c1d245f28..cb327e9b730d 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -2527,7 +2527,7 @@ // Longer prime to clean out a SINGLENOZZLE #define TOOLCHANGE_FS_EXTRA_PRIME 0 // (mm) Extra priming length #define TOOLCHANGE_FS_PRIME_SPEED (4.6*60) // (mm/min) Extra priming feedrate - #define TOOLCHANGE_FS_WIPE_RETRACT 0 // (mm) Retract before cooling for less stringing, better wipe, etc. + #define TOOLCHANGE_FS_WIPE_RETRACT 0 // (mm) Cutting retraction out of park, for less stringing, better wipe, etc. Adjust with LCD or M217 G. // Cool after prime to reduce stringing #define TOOLCHANGE_FS_FAN -1 // Fan index or -1 to skip diff --git a/Marlin/src/gcode/config/M217.cpp b/Marlin/src/gcode/config/M217.cpp index 989e4d0870a4..b360739e210a 100644 --- a/Marlin/src/gcode/config/M217.cpp +++ b/Marlin/src/gcode/config/M217.cpp @@ -43,13 +43,14 @@ * S[linear] Swap length * B[linear] Extra Swap resume length * E[linear] Extra Prime length (as used by M217 Q) - * P[linear/min] Prime speed + * G[linear] Cutting wipe retract length (<=100mm) * R[linear/min] Retract speed * U[linear/min] UnRetract speed + * P[linear/min] Prime speed * V[linear] 0/1 Enable auto prime first extruder used * W[linear] 0/1 Enable park & Z Raise * X[linear] Park X (Requires TOOLCHANGE_PARK) - * Y[linear] Park Y (Requires TOOLCHANGE_PARK) + * Y[linear] Park Y (Requires TOOLCHANGE_PARK and NUM_AXES >= 2) * I[linear] Park I (Requires TOOLCHANGE_PARK and NUM_AXES >= 4) * J[linear] Park J (Requires TOOLCHANGE_PARK and NUM_AXES >= 5) * K[linear] Park K (Requires TOOLCHANGE_PARK and NUM_AXES >= 6) @@ -79,6 +80,7 @@ void GcodeSuite::M217() { if (parser.seenval('B')) { const float v = parser.value_linear_units(); toolchange_settings.extra_resume = constrain(v, -10, 10); } if (parser.seenval('E')) { const float v = parser.value_linear_units(); toolchange_settings.extra_prime = constrain(v, 0, max_extrude); } if (parser.seenval('P')) { const int16_t v = parser.value_linear_units(); toolchange_settings.prime_speed = constrain(v, 10, 5400); } + if (parser.seenval('G')) { const int16_t v = parser.value_linear_units(); toolchange_settings.wipe_retract = constrain(v, 0, 100); } if (parser.seenval('R')) { const int16_t v = parser.value_linear_units(); toolchange_settings.retract_speed = constrain(v, 10, 5400); } if (parser.seenval('U')) { const int16_t v = parser.value_linear_units(); toolchange_settings.unretract_speed = constrain(v, 10, 5400); } #if TOOLCHANGE_FS_FAN >= 0 && HAS_FAN @@ -164,21 +166,24 @@ void GcodeSuite::M217_report(const bool forReplay/*=true*/) { SERIAL_ECHOPGM(" M217"); #if ENABLED(TOOLCHANGE_FILAMENT_SWAP) - SERIAL_ECHOPGM(" S", LINEAR_UNIT(toolchange_settings.swap_length)); - SERIAL_ECHOPGM_P(SP_B_STR, LINEAR_UNIT(toolchange_settings.extra_resume), - SP_E_STR, LINEAR_UNIT(toolchange_settings.extra_prime), - SP_P_STR, LINEAR_UNIT(toolchange_settings.prime_speed)); - SERIAL_ECHOPGM(" R", LINEAR_UNIT(toolchange_settings.retract_speed), - " U", LINEAR_UNIT(toolchange_settings.unretract_speed), - " F", toolchange_settings.fan_speed, - " D", toolchange_settings.fan_time); + SERIAL_ECHOPGM_P( + PSTR(" S"), LINEAR_UNIT(toolchange_settings.swap_length), + SP_B_STR, LINEAR_UNIT(toolchange_settings.extra_resume), + SP_E_STR, LINEAR_UNIT(toolchange_settings.extra_prime), + SP_P_STR, LINEAR_UNIT(toolchange_settings.prime_speed), + PSTR(" G"), LINEAR_UNIT(toolchange_settings.wipe_retract), + PSTR(" R"), LINEAR_UNIT(toolchange_settings.retract_speed), + PSTR(" U"), LINEAR_UNIT(toolchange_settings.unretract_speed), + PSTR(" F"), toolchange_settings.fan_speed, + PSTR(" D"), toolchange_settings.fan_time + ); #if ENABLED(TOOLCHANGE_MIGRATION_FEATURE) - SERIAL_ECHOPGM(" A", migration.automode); - SERIAL_ECHOPGM(" L", LINEAR_UNIT(migration.last)); + SERIAL_ECHOPGM(" A", migration.automode, " L", LINEAR_UNIT(migration.last)); #endif #if ENABLED(TOOLCHANGE_PARK) + { SERIAL_ECHOPGM(" W", LINEAR_UNIT(toolchange_settings.enable_park)); SERIAL_ECHOPGM_P( SP_X_STR, LINEAR_UNIT(toolchange_settings.change_point.x) @@ -196,6 +201,7 @@ void GcodeSuite::M217_report(const bool forReplay/*=true*/) { ) #endif ); + } #endif #if ENABLED(TOOLCHANGE_FS_PRIME_FIRST_USED) diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 2ababe292726..6b1ca2a30d3c 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -521,6 +521,7 @@ namespace Language_en { LSTR MSG_TOOL_CHANGE = _UxGT("Tool Change"); LSTR MSG_TOOL_CHANGE_ZLIFT = _UxGT("Z Raise"); LSTR MSG_SINGLENOZZLE_PRIME_SPEED = _UxGT("Prime Speed"); + LSTR MSG_SINGLENOZZLE_WIPE_RETRACT = _UxGT("Wipe Retract"); LSTR MSG_SINGLENOZZLE_RETRACT_SPEED = _UxGT("Retract Speed"); LSTR MSG_FILAMENT_PARK_ENABLED = _UxGT("Park Head"); LSTR MSG_SINGLENOZZLE_UNRETRACT_SPEED = _UxGT("Recover Speed"); diff --git a/Marlin/src/lcd/language/language_fr.h b/Marlin/src/lcd/language/language_fr.h index 0a11e862f7e1..05e69a583ff5 100644 --- a/Marlin/src/lcd/language/language_fr.h +++ b/Marlin/src/lcd/language/language_fr.h @@ -376,6 +376,7 @@ namespace Language_fr { LSTR MSG_TOOL_CHANGE = _UxGT("Changement outil"); LSTR MSG_TOOL_CHANGE_ZLIFT = _UxGT("Augmenter Z"); LSTR MSG_SINGLENOZZLE_PRIME_SPEED = _UxGT("Vitesse primaire"); + LSTR MSG_SINGLENOZZLE_WIPE_RETRACT = _UxGT("Purge Retract"); LSTR MSG_SINGLENOZZLE_RETRACT_SPEED = _UxGT("Vitesse rétract°"); LSTR MSG_FILAMENT_PARK_ENABLED = _UxGT("Garer Extrudeur"); LSTR MSG_SINGLENOZZLE_UNRETRACT_SPEED = _UxGT("Vitesse reprise"); diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 9eef94823e33..7ae199dfd6e9 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -124,6 +124,7 @@ void menu_advanced_settings(); EDIT_ITEM_FAST(int4, MSG_SINGLENOZZLE_UNRETRACT_SPEED, &toolchange_settings.unretract_speed, 10, 5400); EDIT_ITEM(float3, MSG_FILAMENT_PURGE_LENGTH, &toolchange_settings.extra_prime, 0, max_extrude); EDIT_ITEM_FAST(int4, MSG_SINGLENOZZLE_PRIME_SPEED, &toolchange_settings.prime_speed, 10, 5400); + EDIT_ITEM_FAST(int4, MSG_SINGLENOZZLE_WIPE_RETRACT, &toolchange_settings.wipe_retract, 0, 100); EDIT_ITEM_FAST(uint8, MSG_SINGLENOZZLE_FAN_SPEED, &toolchange_settings.fan_speed, 0, 255); EDIT_ITEM_FAST(uint8, MSG_SINGLENOZZLE_FAN_TIME, &toolchange_settings.fan_time, 1, 30); #endif diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 179fea057d9b..2b6a98b0452f 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -36,7 +36,7 @@ */ // Change EEPROM version if the structure changes -#define EEPROM_VERSION "V86" +#define EEPROM_VERSION "V87" #define EEPROM_OFFSET 100 // Check the integrity of data offsets. @@ -2876,6 +2876,7 @@ void MarlinSettings::reset() { toolchange_settings.unretract_speed = TOOLCHANGE_FS_UNRETRACT_SPEED; toolchange_settings.extra_prime = TOOLCHANGE_FS_EXTRA_PRIME; toolchange_settings.prime_speed = TOOLCHANGE_FS_PRIME_SPEED; + toolchange_settings.wipe_retract = TOOLCHANGE_FS_WIPE_RETRACT; toolchange_settings.fan_speed = TOOLCHANGE_FS_FAN_SPEED; toolchange_settings.fan_time = TOOLCHANGE_FS_FAN_TIME; #endif diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index dbd95121dce0..0ff0856ddd1f 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -940,13 +940,13 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. * Cutting recovery -- Recover from cutting retraction that occurs at the end of nozzle priming * * If the active_extruder is up to temp (!too_cold): - * Extrude filament distance = toolchange_settings.extra_resume + TOOLCHANGE_FS_WIPE_RETRACT + * Extrude filament distance = toolchange_settings.extra_resume + toolchange_settings.wipe_retract * current_position.e = e; * sync_plan_position_e(); */ void extruder_cutting_recover(const_float_t e) { if (!too_cold(active_extruder)) { - const float dist = toolchange_settings.extra_resume + (TOOLCHANGE_FS_WIPE_RETRACT); + const float dist = toolchange_settings.extra_resume + toolchange_settings.wipe_retract; FS_DEBUG("Performing Cutting Recover | Distance: ", dist, " | Speed: ", MMM_TO_MMS(toolchange_settings.unretract_speed), "mm/s"); unscaled_e_move(dist, MMM_TO_MMS(toolchange_settings.unretract_speed)); planner.synchronize(); @@ -973,17 +973,17 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. float fr = toolchange_settings.unretract_speed; // Set default speed for unretract #if ENABLED(TOOLCHANGE_FS_SLOW_FIRST_PRIME) - /* - * Perform first unretract movement at the slower Prime_Speed to avoid breakage on first prime - */ - static Flags extruder_did_first_prime; // Extruders first priming status - if (!extruder_did_first_prime[active_extruder]) { - extruder_did_first_prime.set(active_extruder); // Log first prime complete - // new nozzle - prime at user-specified speed. - FS_DEBUG("First time priming T", active_extruder, ", reducing speed from ", MMM_TO_MMS(fr), " to ", MMM_TO_MMS(toolchange_settings.prime_speed), "mm/s"); - fr = toolchange_settings.prime_speed; - unscaled_e_move(0, MMM_TO_MMS(fr)); // Init planner with 0 length move - } + /** + * Perform first unretract movement at the slower Prime_Speed to avoid breakage on first prime + */ + static Flags extruder_did_first_prime; // Extruders first priming status + if (!extruder_did_first_prime[active_extruder]) { + extruder_did_first_prime.set(active_extruder); // Log first prime complete + // new nozzle - prime at user-specified speed. + FS_DEBUG("First time priming T", active_extruder, ", reducing speed from ", MMM_TO_MMS(fr), " to ", MMM_TO_MMS(toolchange_settings.prime_speed), "mm/s"); + fr = toolchange_settings.prime_speed; + unscaled_e_move(0, MMM_TO_MMS(fr)); // Init planner with 0 length move + } #endif //Calculate and perform the priming distance @@ -1011,8 +1011,8 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. // Cutting retraction #if TOOLCHANGE_FS_WIPE_RETRACT - FS_DEBUG("Performing Cutting Retraction | Distance: ", -(TOOLCHANGE_FS_WIPE_RETRACT), " | Speed: ", MMM_TO_MMS(toolchange_settings.retract_speed), "mm/s"); - unscaled_e_move(-(TOOLCHANGE_FS_WIPE_RETRACT), MMM_TO_MMS(toolchange_settings.retract_speed)); + FS_DEBUG("Performing Cutting Retraction | Distance: ", -toolchange_settings.wipe_retract, " | Speed: ", MMM_TO_MMS(toolchange_settings.retract_speed), "mm/s"); + unscaled_e_move(-toolchange_settings.wipe_retract, MMM_TO_MMS(toolchange_settings.retract_speed)); #endif // Cool down with fan diff --git a/Marlin/src/module/tool_change.h b/Marlin/src/module/tool_change.h index 864062f572e3..ff456485e23d 100644 --- a/Marlin/src/module/tool_change.h +++ b/Marlin/src/module/tool_change.h @@ -33,6 +33,7 @@ float extra_prime; // M217 E float extra_resume; // M217 B int16_t prime_speed; // M217 P + int16_t wipe_retract; // M217 G int16_t retract_speed; // M217 R int16_t unretract_speed; // M217 U uint8_t fan_speed; // M217 F From 5ee74668cf48a72736ffa8a1dfd6ca1fa6644eeb Mon Sep 17 00:00:00 2001 From: Stefan Kalscheuer Date: Fri, 16 Sep 2022 21:21:13 +0200 Subject: [PATCH 073/243] =?UTF-8?q?=E2=9C=A8=20Anycubic=20i3=20Mega=20LCD?= =?UTF-8?q?=20file=20menu=20fix=20(#24752)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration.h | 1 + .../anycubic_i3mega/anycubic_i3mega_lcd.cpp | 94 ++++++++++--------- 2 files changed, 51 insertions(+), 44 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 59285af763cd..a2370d99d083 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -2989,6 +2989,7 @@ //#define ANYCUBIC_LCD_CHIRON #if EITHER(ANYCUBIC_LCD_I3MEGA, ANYCUBIC_LCD_CHIRON) //#define ANYCUBIC_LCD_DEBUG + //#define ANYCUBIC_LCD_GCODE_EXT // Add ".gcode" to menu entries for DGUS clone compatibility #endif // diff --git a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp index 0da8bb36a780..03997fa95bea 100644 --- a/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp +++ b/Marlin/src/lcd/extui/anycubic_i3mega/anycubic_i3mega_lcd.cpp @@ -46,6 +46,12 @@ #define SENDLINE_DBG_PGM_VAL(x,y,z) sendLine_P(PSTR(x)) #endif +// Append ".gcode" to filename, if requested. Used for some DGUS-clone displays with built-in filter. +// Filenames are limited to 26 characters, so the actual name for the FILENAME can be 20 characters at most. +// If a longer string is desired without "extension, use the ALTNAME macro to provide a (longer) alternative. +#define SPECIAL_MENU_FILENAME(A) A TERN_(ANYCUBIC_LCD_GCODE_EXT, ".gcode") +#define SPECIAL_MENU_ALTNAME(A, B) TERN(ANYCUBIC_LCD_GCODE_EXT, A ".gcode", B) + AnycubicTFTClass AnycubicTFT; char AnycubicTFTClass::TFTcmdbuffer[TFTBUFSIZE][TFT_MAX_CMD_SIZE]; @@ -383,8 +389,8 @@ void AnycubicTFTClass::RenderCurrentFileList() { if (!isMediaInserted() && !SpecialMenu) { SENDLINE_DBG_PGM("J02", "TFT Serial Debug: No SD Card mounted to render Current File List... J02"); - SENDLINE_PGM(""); - SENDLINE_PGM(""); + SENDLINE_PGM("")); } else { if (CodeSeen('S')) @@ -403,58 +409,58 @@ void AnycubicTFTClass::RenderSpecialMenu(uint16_t selectedNumber) { switch (selectedNumber) { #if ENABLED(PROBE_MANUALLY) case 0: // First Page - SENDLINE_PGM("<01ZUp0.1>"); - SENDLINE_PGM(""); - SENDLINE_PGM("<02ZUp0.02>"); - SENDLINE_PGM(""); - SENDLINE_PGM("<03ZDn0.02>"); - SENDLINE_PGM(""); - SENDLINE_PGM("<04ZDn0.1>"); - SENDLINE_PGM(""); + SENDLINE_PGM("<01ZUP~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_FILENAME("")); + SENDLINE_PGM("<02ZUP~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_FILENAME("")); + SENDLINE_PGM("<03ZDO~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_FILENAME("")); + SENDLINE_PGM("<04ZDO~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_FILENAME("")); break; case 4: // Second Page - SENDLINE_PGM("<05PrehtBed>"); - SENDLINE_PGM(""); - SENDLINE_PGM("<06SMeshLvl>"); - SENDLINE_PGM(""); - SENDLINE_PGM("<07MeshNPnt>"); - SENDLINE_PGM(""); - SENDLINE_PGM("<08HtEndPID>"); - SENDLINE_PGM(""); + SENDLINE_PGM("<05PRE~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_FILENAME("")); + SENDLINE_PGM("<06MES~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_ALTNAME("", "")); + SENDLINE_PGM("<07NEX~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_FILENAME("")); + SENDLINE_PGM("<08PID~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_FILENAME("")); break; case 8: // Third Page - SENDLINE_PGM("<09HtBedPID>"); - SENDLINE_PGM(""); - SENDLINE_PGM("<10FWDeflts>"); - SENDLINE_PGM(""); - SENDLINE_PGM("<11SvEEPROM>"); - SENDLINE_PGM(""); - SENDLINE_PGM(""); - SENDLINE_PGM(""); + SENDLINE_PGM("<09PID~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_FILENAME("")); + SENDLINE_PGM("<10FWD~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_FILENAME("")); + SENDLINE_PGM("<11SAV~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_FILENAME("")); + SENDLINE_PGM("")); break; #else case 0: // First Page - SENDLINE_PGM("<01PrehtBed>"); - SENDLINE_PGM(""); - SENDLINE_PGM("<02ABL>"); - SENDLINE_PGM(""); - SENDLINE_PGM("<03HtEndPID>"); - SENDLINE_PGM(""); - SENDLINE_PGM("<04HtBedPID>"); - SENDLINE_PGM(""); + SENDLINE_PGM("<01PRE~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_FILENAME("")); + SENDLINE_PGM("<02ABL~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_FILENAME("")); + SENDLINE_PGM("<03PID~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_ALTNAME("", "")); + SENDLINE_PGM("<04PID~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_ALTNAME("", "")); break; case 4: // Second Page - SENDLINE_PGM("<05FWDeflts>"); - SENDLINE_PGM(""); - SENDLINE_PGM("<06SvEEPROM>"); - SENDLINE_PGM(""); - SENDLINE_PGM("<07SendM108>"); - SENDLINE_PGM(""); - SENDLINE_PGM(""); - SENDLINE_PGM(""); + SENDLINE_PGM("<05FWD~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_FILENAME("")); + SENDLINE_PGM("<06SAV~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_FILENAME("")); + SENDLINE_PGM("<06SEN~1.GCO"); + SENDLINE_PGM(SPECIAL_MENU_ALTNAME("", "")); + SENDLINE_PGM("")); break; #endif // PROBE_MANUALLY @@ -478,8 +484,8 @@ void AnycubicTFTClass::RenderCurrentFolder(uint16_t selectedNumber) { for (cnt = selectedNumber; cnt <= max_files; cnt++) { if (cnt == 0) { // Special Entry if (currentFileList.isAtRootDir()) { - SENDLINE_PGM(""); - SENDLINE_PGM(""); + SENDLINE_PGM("")); } else { SENDLINE_PGM("/.."); From d9967f5395e3f223bd2cf99249f2f6058d907620 Mon Sep 17 00:00:00 2001 From: Renaud11232 Date: Fri, 23 Sep 2022 07:20:44 +0200 Subject: [PATCH 074/243] =?UTF-8?q?=F0=9F=94=A8=20Fix=20LPC1768=20autodete?= =?UTF-8?q?ct=20path=20on=20Linux=20(#24773)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/LPC1768/upload_extra_script.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/HAL/LPC1768/upload_extra_script.py b/Marlin/src/HAL/LPC1768/upload_extra_script.py index 52c9a8e2ecee..efd46fdd6309 100755 --- a/Marlin/src/HAL/LPC1768/upload_extra_script.py +++ b/Marlin/src/HAL/LPC1768/upload_extra_script.py @@ -73,7 +73,7 @@ def before_upload(source, target, env): # import getpass user = getpass.getuser() - mpath = Path('media', user) + mpath = Path('/media', user) drives = [ x for x in mpath.iterdir() if x.is_dir() ] if target_drive in drives: # If target drive is found, use it. target_drive_found = True From a7a493d795fcb9d77cbbe284aea1f5aa3978845a Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Mon, 26 Sep 2022 14:15:14 -0700 Subject: [PATCH 075/243] =?UTF-8?q?=F0=9F=93=8C=20Specify=20MarlinFirmware?= =?UTF-8?q?/U8glib=20(#24792)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ini/features.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ini/features.ini b/ini/features.ini index 2f26aa25236e..d3d863ccd406 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -37,7 +37,7 @@ USES_LIQUIDCRYSTAL_I2C = marcoschwartz/LiquidCrystal_I2C@1.1.4 USES_LIQUIDTWI2 = LiquidTWI2@1.2.7 HAS_LCDPRINT = src_filter=+ HAS_MARLINUI_HD44780 = src_filter=+ -HAS_MARLINUI_U8GLIB = U8glib-HAL@~0.5.2 +HAS_MARLINUI_U8GLIB = marlinfirmware/U8glib-HAL@~0.5.2 src_filter=+ HAS_(FSMC|SPI|LTDC)_TFT = src_filter=+ + + HAS_FSMC_TFT = src_filter=+ + From f1a05d19b0886921cbe3529a22bcf796c174bc4a Mon Sep 17 00:00:00 2001 From: Stuart Pittaway <1201909+stuartpittaway@users.noreply.github.com> Date: Mon, 26 Sep 2022 22:18:15 +0100 Subject: [PATCH 076/243] =?UTF-8?q?=F0=9F=9A=B8=20UUID=20fallback=20to=20S?= =?UTF-8?q?TM32=20device=20SN=20(#24759)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/src/gcode/host/M115.cpp | 37 +++++++++++++++---- .../src/pins/stm32f4/pins_OPULO_LUMEN_REV3.h | 3 ++ 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/Marlin/src/gcode/host/M115.cpp b/Marlin/src/gcode/host/M115.cpp index 7f17617b63f6..a244e9802f77 100644 --- a/Marlin/src/gcode/host/M115.cpp +++ b/Marlin/src/gcode/host/M115.cpp @@ -32,6 +32,10 @@ #include "../../feature/caselight.h" #endif +#if ENABLED(HAS_STM32_UID) && !defined(MACHINE_UUID) + #include "../../libs/hex_print.h" +#endif + //#define MINIMAL_CAP_LINES // Don't even mention the disabled capabilities #if ENABLED(EXTENDED_CAPABILITIES_REPORT) @@ -59,20 +63,37 @@ * the capability is not present. */ void GcodeSuite::M115() { - SERIAL_ECHOLNPGM( - "FIRMWARE_NAME:Marlin " DETAILED_BUILD_VERSION " (" __DATE__ " " __TIME__ ") " - "SOURCE_CODE_URL:" SOURCE_CODE_URL " " - "PROTOCOL_VERSION:" PROTOCOL_VERSION " " - "MACHINE_TYPE:" MACHINE_NAME " " - "EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " " + SERIAL_ECHOPGM("FIRMWARE_NAME:Marlin" + " " DETAILED_BUILD_VERSION " (" __DATE__ " " __TIME__ ")" + " SOURCE_CODE_URL:" SOURCE_CODE_URL + " PROTOCOL_VERSION:" PROTOCOL_VERSION + " MACHINE_TYPE:" MACHINE_NAME + " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) #if NUM_AXES != XYZ - "AXIS_COUNT:" STRINGIFY(NUM_AXES) " " + " AXIS_COUNT:" STRINGIFY(NUM_AXES) #endif #ifdef MACHINE_UUID - "UUID:" MACHINE_UUID + " UUID:" MACHINE_UUID #endif ); + // STM32UID:111122223333 + #if ENABLED(HAS_STM32_UID) && !defined(MACHINE_UUID) + // STM32 based devices output the CPU device serial number + // Used by LumenPnP / OpenPNP to keep track of unique hardware/configurations + // https://github.com/opulo-inc/lumenpnp + // Although this code should work on all STM32 based boards + SERIAL_ECHOPGM(" UUID:"); + uint32_t *uid_address = (uint32_t*)UID_BASE; + LOOP_L_N(i, 3) { + const uint32_t UID = uint32_t(READ_REG(*(uid_address))); + uid_address += 4U; + for (int B = 24; B >= 0; B -= 8) print_hex_byte(UID >> B); + } + #endif + + SERIAL_EOL(); + #if ENABLED(EXTENDED_CAPABILITIES_REPORT) // The port that sent M115 diff --git a/Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV3.h b/Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV3.h index 36dde8810525..06bf09402c06 100644 --- a/Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV3.h +++ b/Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV3.h @@ -44,6 +44,9 @@ // I2C MCP3426 (16-Bit, 240SPS, dual-channel ADC) #define HAS_MCP3426_ADC +#ifdef STM32F4 + #define HAS_STM32_UID +#endif // // Servos From e44f1565356b1a93020292721ee39ed9416d762f Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Tue, 27 Sep 2022 10:25:54 +1300 Subject: [PATCH 077/243] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20Followup=20for=20M?= =?UTF-8?q?524=20(#24775)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to #24761 --- Marlin/src/module/temperature.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index cb9043f3473d..8c662948bc54 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -1849,11 +1849,13 @@ void Temperature::task() { quickstop_stepper(); } - if (emergency_parser.sd_abort_by_M524) { // abort SD print immediately - emergency_parser.sd_abort_by_M524 = false; - card.flag.abort_sd_printing = true; - gcode.process_subcommands_now(F("M524")); - } + #if ENABLED(SDSUPPORT) + if (emergency_parser.sd_abort_by_M524) { // abort SD print immediately + emergency_parser.sd_abort_by_M524 = false; + card.flag.abort_sd_printing = true; + gcode.process_subcommands_now(F("M524")); + } + #endif #endif if (!updateTemperaturesIfReady()) return; // Will also reset the watchdog if temperatures are ready From 827f9ae7923cb80ffa0bb480b53a85e016e4b789 Mon Sep 17 00:00:00 2001 From: discip <53649486+discip@users.noreply.github.com> Date: Mon, 26 Sep 2022 23:42:52 +0200 Subject: [PATCH 078/243] =?UTF-8?q?=E2=9C=A8=20Pt1000=20with=202k2=20pullu?= =?UTF-8?q?p=20(SKR=203=20/=20EZ)=20(#24790)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration.h | 1 + Marlin/src/lcd/thermistornames.h | 2 + .../src/module/thermistor/thermistor_1022.h | 45 +++++++++++++++++++ Marlin/src/module/thermistor/thermistors.h | 3 ++ 4 files changed, 51 insertions(+) create mode 100644 Marlin/src/module/thermistor/thermistor_1022.h diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index a2370d99d083..1d2542e26628 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -518,6 +518,7 @@ * 110 : Pt100 with 1kΩ pullup (atypical) * 147 : Pt100 with 4.7kΩ pullup * 1010 : Pt1000 with 1kΩ pullup (atypical) + * 1022 : Pt1000 with 2.2kΩ pullup * 1047 : Pt1000 with 4.7kΩ pullup (E3D) * 20 : Pt100 with circuit in the Ultimainboard V2.x with mainboard ADC reference voltage = INA826 amplifier-board supply voltage. * NOTE: (1) Must use an ADC input with no pullup. (2) Some INA826 amplifiers are unreliable at 3.3V so consider using sensor 147, 110, or 21. diff --git a/Marlin/src/lcd/thermistornames.h b/Marlin/src/lcd/thermistornames.h index 2571efe0759c..1b40a8c7d49a 100644 --- a/Marlin/src/lcd/thermistornames.h +++ b/Marlin/src/lcd/thermistornames.h @@ -124,6 +124,8 @@ #define THERMISTOR_NAME "ATC104GT-2 1K" #elif THERMISTOR_ID == 1047 #define THERMISTOR_NAME "PT1000 4K7" +#elif THERMISTOR_ID == 1022 + #define THERMISTOR_NAME "PT1000 2K2" #elif THERMISTOR_ID == 1010 #define THERMISTOR_NAME "PT1000 1K" #elif THERMISTOR_ID == 147 diff --git a/Marlin/src/module/thermistor/thermistor_1022.h b/Marlin/src/module/thermistor/thermistor_1022.h new file mode 100644 index 000000000000..1db928fbb86b --- /dev/null +++ b/Marlin/src/module/thermistor/thermistor_1022.h @@ -0,0 +1,45 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#define REVERSE_TEMP_SENSOR_RANGE_1022 1 + +// Pt1000 with 1k0 pullup +constexpr temp_entry_t temptable_1022[] PROGMEM = { + PtLine( 0, 1000, 2200), + PtLine( 25, 1000, 2200), + PtLine( 50, 1000, 2200), + PtLine( 75, 1000, 2200), + PtLine(100, 1000, 2200), + PtLine(125, 1000, 2200), + PtLine(150, 1000, 2200), + PtLine(175, 1000, 2200), + PtLine(200, 1000, 2200), + PtLine(225, 1000, 2200), + PtLine(250, 1000, 2200), + PtLine(275, 1000, 2200), + PtLine(300, 1000, 2200), + PtLine(350, 1000, 2200), + PtLine(400, 1000, 2200), + PtLine(450, 1000, 2200), + PtLine(500, 1000, 2200) +}; diff --git a/Marlin/src/module/thermistor/thermistors.h b/Marlin/src/module/thermistor/thermistors.h index a38b7f381feb..5d89dd3aa901 100644 --- a/Marlin/src/module/thermistor/thermistors.h +++ b/Marlin/src/module/thermistor/thermistors.h @@ -193,6 +193,9 @@ typedef struct { raw_adc_t value; celsius_t celsius; } temp_entry_t; #if ANY_THERMISTOR_IS(1010) // Pt1000 with 1k0 pullup #include "thermistor_1010.h" #endif +#if ANY_THERMISTOR_IS(1022) // Pt1000 with 2k2 pullup + #include "thermistor_1022.h" +#endif #if ANY_THERMISTOR_IS(1047) // Pt1000 with 4k7 pullup #include "thermistor_1047.h" #endif From 215fcefc1b0c8c626efa7f74b78f0a03b5f1280f Mon Sep 17 00:00:00 2001 From: Plynix / Ben Hartiwch <77836725+Plyn1x@users.noreply.github.com> Date: Wed, 28 Sep 2022 16:46:50 +0200 Subject: [PATCH 079/243] =?UTF-8?q?=E2=9C=A8=20Creality=20v5.2.1=20board?= =?UTF-8?q?=20(#24760)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/boards.h | 29 +-- Marlin/src/module/thermistor/thermistor_504.h | 4 +- Marlin/src/module/thermistor/thermistor_505.h | 4 +- Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h | 1 + Marlin/src/pins/pins.h | 2 + Marlin/src/pins/stm32f1/pins_CREALITY_V4.h | 150 +++++------- Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h | 136 +++++------ Marlin/src/pins/stm32f1/pins_CREALITY_V425.h | 4 +- Marlin/src/pins/stm32f1/pins_CREALITY_V521.h | 226 ++++++++++++++++++ ini/stm32f1.ini | 21 ++ 10 files changed, 399 insertions(+), 178 deletions(-) create mode 100644 Marlin/src/pins/stm32f1/pins_CREALITY_V521.h diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index 42f8746aafb6..17051b484cc9 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -355,20 +355,21 @@ #define BOARD_CREALITY_V431_D 4051 // Creality v4.3.1d (STM32F103RC / STM32F103RE) #define BOARD_CREALITY_V452 4052 // Creality v4.5.2 (STM32F103RC / STM32F103RE) #define BOARD_CREALITY_V453 4053 // Creality v4.5.3 (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V24S1 4054 // Creality v2.4.S1 (STM32F103RC / STM32F103RE) v101 as found in the Ender-7 -#define BOARD_CREALITY_V24S1_301 4055 // Creality v2.4.S1_301 (STM32F103RC / STM32F103RE) v301 as found in the Ender-3 S1 -#define BOARD_CREALITY_V25S1 4056 // Creality v2.5.S1 (STM32F103RE) as found in the CR-10 Smart Pro -#define BOARD_TRIGORILLA_PRO 4057 // Trigorilla Pro (STM32F103ZE) -#define BOARD_FLY_MINI 4058 // FLYmaker FLY MINI (STM32F103RC) -#define BOARD_FLSUN_HISPEED 4059 // FLSUN HiSpeedV1 (STM32F103VE) -#define BOARD_BEAST 4060 // STM32F103RE Libmaple-based controller -#define BOARD_MINGDA_MPX_ARM_MINI 4061 // STM32F103ZE Mingda MD-16 -#define BOARD_GTM32_PRO_VD 4062 // STM32F103VE controller -#define BOARD_ZONESTAR_ZM3E2 4063 // Zonestar ZM3E2 (STM32F103RC) -#define BOARD_ZONESTAR_ZM3E4 4064 // Zonestar ZM3E4 V1 (STM32F103VC) -#define BOARD_ZONESTAR_ZM3E4V2 4065 // Zonestar ZM3E4 V2 (STM32F103VC) -#define BOARD_ERYONE_ERY32_MINI 4066 // Eryone Ery32 mini (STM32F103VE) -#define BOARD_PANDA_PI_V29 4067 // Panda Pi V2.9 - Standalone (STM32F103RC) +#define BOARD_CREALITY_V521 4054 // SV04 Board +#define BOARD_CREALITY_V24S1 4055 // Creality v2.4.S1 (STM32F103RC / STM32F103RE) v101 as found in the Ender-7 +#define BOARD_CREALITY_V24S1_301 4056 // Creality v2.4.S1_301 (STM32F103RC / STM32F103RE) v301 as found in the Ender-3 S1 +#define BOARD_CREALITY_V25S1 4057 // Creality v2.5.S1 (STM32F103RE) as found in the CR-10 Smart Pro +#define BOARD_TRIGORILLA_PRO 4058 // Trigorilla Pro (STM32F103ZE) +#define BOARD_FLY_MINI 4059 // FLYmaker FLY MINI (STM32F103RC) +#define BOARD_FLSUN_HISPEED 4060 // FLSUN HiSpeedV1 (STM32F103VE) +#define BOARD_BEAST 4061 // STM32F103RE Libmaple-based controller +#define BOARD_MINGDA_MPX_ARM_MINI 4062 // STM32F103ZE Mingda MD-16 +#define BOARD_GTM32_PRO_VD 4063 // STM32F103VE controller +#define BOARD_ZONESTAR_ZM3E2 4064 // Zonestar ZM3E2 (STM32F103RC) +#define BOARD_ZONESTAR_ZM3E4 4065 // Zonestar ZM3E4 V1 (STM32F103VC) +#define BOARD_ZONESTAR_ZM3E4V2 4066 // Zonestar ZM3E4 V2 (STM32F103VC) +#define BOARD_ERYONE_ERY32_MINI 4067 // Eryone Ery32 mini (STM32F103VE) +#define BOARD_PANDA_PI_V29 4068 // Panda Pi V2.9 - Standalone (STM32F103RC) // // ARM Cortex-M4F diff --git a/Marlin/src/module/thermistor/thermistor_504.h b/Marlin/src/module/thermistor/thermistor_504.h index 0724e49b9d74..751bea233e44 100644 --- a/Marlin/src/module/thermistor/thermistor_504.h +++ b/Marlin/src/module/thermistor/thermistor_504.h @@ -1,9 +1,9 @@ /** * Marlin 3D Printer Firmware - * Copyright (C) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] * * Based on Sprinter and grbl. - * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/Marlin/src/module/thermistor/thermistor_505.h b/Marlin/src/module/thermistor/thermistor_505.h index 1377b43d2401..12600f63ae9c 100644 --- a/Marlin/src/module/thermistor/thermistor_505.h +++ b/Marlin/src/module/thermistor/thermistor_505.h @@ -1,9 +1,9 @@ /** * Marlin 3D Printer Firmware - * Copyright (C) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] * * Based on Sprinter and grbl. - * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h index 209529cbe1ce..aac839808119 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h @@ -43,6 +43,7 @@ #if NO_EEPROM_SELECTED //#define I2C_EEPROM // EEPROM on I2C-0 //#define SDCARD_EEPROM_EMULATION + //#undef NO_EEPROM_SELECTED #endif #if ENABLED(I2C_EEPROM) diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 2bd5d613347a..1e7f5ec3981a 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -611,6 +611,8 @@ #include "stm32f1/pins_ERYONE_ERY32_MINI.h" // STM32F103VET6 env:ERYONE_ERY32_MINI_maple #elif MB(PANDA_PI_V29) #include "stm32f1/pins_PANDA_PI_V29.h" // STM32F103RCT6 env:PANDA_PI_V29 +#elif MB(CREALITY_V521) + #include "stm32f1/pins_CREALITY_V521.h" // STM32F103RET6 env:STM32F103RET6_creality // // ARM Cortex-M4F diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h index 56caa7d35ee5..ea2cc52f03d1 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h @@ -161,94 +161,74 @@ #define SDIO_SUPPORT #define NO_SD_HOST_DRIVE // This board's SD is only seen by the printer -#if EITHER(CR10_STOCKDISPLAY, FYSETC_MINI_12864_2_1) - - #if ENABLED(RET6_12864_LCD) - - /** - * RET6 12864 LCD - * ------ - * PC6 | 1 2 | PB2 - * PB10 | 3 4 | PB11 - * PB14 5 6 | PB13 - * PB12 | 7 8 | PB15 - * GND | 9 10 | 5V - * ------ - * EXP1 - */ - #define EXP1_01_PIN PC6 - #define EXP1_02_PIN PB2 - #define EXP1_03_PIN PB10 - #define EXP1_04_PIN PB11 - #define EXP1_05_PIN PB14 - #define EXP1_06_PIN PB13 - #define EXP1_07_PIN PB12 - #define EXP1_08_PIN PB15 - - #elif ENABLED(VET6_12864_LCD) - - /** - * VET6 12864 LCD - * ------ - * ? | 1 2 | PC5 - * PB10 | 3 4 | ? - * PA6 5 6 | PA5 - * PA4 | 7 8 | PA7 - * GND | 9 10 | 5V - * ------ - * EXP1 - */ - #define EXP1_01_PIN -1 - #define EXP1_02_PIN PC5 - #define EXP1_03_PIN PB10 - #define EXP1_04_PIN -1 - #define EXP1_05_PIN PA6 - #define EXP1_06_PIN PA5 - #define EXP1_07_PIN PA4 - #define EXP1_08_PIN PA7 +#if ANY(RET6_12864_LCD, HAS_DWIN_E3V2, IS_DWIN_MARLINUI) - #else - #error "Define RET6_12864_LCD or VET6_12864_LCD to select pins for the LCD with the Creality V4 controller." - #endif + /** + * RET6 12864 LCD + * ------ + * PC6 | 1 2 | PB2 + * PB10 | 3 4 | PB11 + * PB14 5 6 | PB13 + * PB12 | 7 8 | PB15 + * GND | 9 10 | 5V + * ------ + */ + #define EXP3_01_PIN PC6 + #define EXP3_02_PIN PB2 + #define EXP3_03_PIN PB10 + #define EXP3_04_PIN PB11 + #define EXP3_05_PIN PB14 + #define EXP3_06_PIN PB13 + #define EXP3_07_PIN PB12 + #define EXP3_08_PIN PB15 + +#elif EITHER(VET6_12864_LCD, DWIN_VET6_CREALITY_LCD) + + /** + * VET6 12864 LCD + * ------ + * ? | 1 2 | PC5 + * PB10 | 3 4 | ? + * PA6 5 6 | PA5 + * PA4 | 7 8 | PA7 + * GND | 9 10 | 5V + * ------ + */ + #define EXP3_01_PIN -1 + #define EXP3_02_PIN PC5 + #define EXP3_03_PIN PB10 + #define EXP3_04_PIN -1 + #define EXP3_05_PIN PA6 + #define EXP3_06_PIN PA5 + #define EXP3_07_PIN PA4 + #define EXP3_08_PIN PA7 + +#elif EITHER(CR10_STOCKDISPLAY, FYSETC_MINI_12864_2_1) + #error "Define RET6_12864_LCD or VET6_12864_LCD to select pins for the LCD with the Creality V4 controller." #endif #if ENABLED(CR10_STOCKDISPLAY) - #define LCD_PINS_RS EXP1_07_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_RS EXP3_07_PIN + #define LCD_PINS_ENABLE EXP3_08_PIN + #define LCD_PINS_D4 EXP3_06_PIN - #define BTN_ENC EXP1_02_PIN - #define BTN_EN1 EXP1_03_PIN - #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP3_02_PIN + #define BTN_EN1 EXP3_03_PIN + #define BTN_EN2 EXP3_05_PIN #ifndef HAS_PIN_27_BOARD - #define BEEPER_PIN EXP1_01_PIN + #define BEEPER_PIN EXP3_01_PIN #endif #elif ANY(HAS_DWIN_E3V2, IS_DWIN_MARLINUI, DWIN_VET6_CREALITY_LCD) - #if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI - // RET6 DWIN ENCODER LCD - #define EXP1_05_PIN PB14 - #define EXP1_06_PIN PB13 - #define EXP1_07_PIN PB12 - #define EXP1_08_PIN PB15 - //#define LCD_LED_PIN PB2 - #else - // VET6 DWIN ENCODER LCD - #define EXP1_05_PIN PA6 - #define EXP1_06_PIN PA5 - #define EXP1_07_PIN PA4 - #define EXP1_08_PIN PA7 - #endif - - #define BTN_ENC EXP1_05_PIN - #define BTN_EN1 EXP1_08_PIN - #define BTN_EN2 EXP1_07_PIN + #define BTN_ENC EXP3_05_PIN + #define BTN_EN1 EXP3_08_PIN + #define BTN_EN2 EXP3_07_PIN #ifndef BEEPER_PIN - #define BEEPER_PIN EXP1_06_PIN + #define BEEPER_PIN EXP3_06_PIN #endif #elif ENABLED(FYSETC_MINI_12864_2_1) @@ -257,8 +237,8 @@ #error "CAUTION! FYSETC_MINI_12864_2_1 and clones require wiring modifications. See 'pins_CREALITY_V4.h' for details. Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning" #endif - #if SD_CONNECTION_IS(LCD) - #error "The LCD sdcard is not connected with this configuration" + #if SD_CONNECTION_IS(LCD) + #error "The LCD SD Card is not connected with this configuration." #endif /** @@ -283,20 +263,20 @@ * Debug port EXP2 * * Needs custom cable. Connect EN2-EN2, LCD_CS-LCD_CS and so on. - * Debug port is just above EXP1, You need to add pins + * Debug port is just above EXP1. You need to add pins. * */ - #define BTN_ENC EXP1_02_PIN - #define BTN_EN1 EXP1_01_PIN - #define BTN_EN2 EXP1_06_PIN + #define BTN_ENC EXP3_02_PIN + #define BTN_EN1 EXP3_01_PIN + #define BTN_EN2 EXP3_06_PIN #define BEEPER_PIN -1 - #define DOGLCD_CS EXP1_03_PIN - #define DOGLCD_A0 EXP1_05_PIN - #define DOGLCD_SCK EXP1_07_PIN - #define DOGLCD_MOSI EXP1_08_PIN - #define LCD_RESET_PIN EXP1_04_PIN + #define DOGLCD_CS EXP3_03_PIN + #define DOGLCD_A0 EXP3_05_PIN + #define DOGLCD_SCK EXP3_07_PIN + #define DOGLCD_MOSI EXP3_08_PIN + #define LCD_RESET_PIN EXP3_04_PIN #define FORCE_SOFT_SPI #define LCD_BACKLIGHT_PIN -1 diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h index 86ede843be57..f3b7e4f308b9 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V4210.h @@ -1,9 +1,9 @@ /** * Marlin 3D Printer Firmware - * Copyright (C) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] * * Based on Sprinter and grbl. - * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +22,7 @@ #pragma once /** - * CREALITY 4.2.10 (STM32F103RE / STM32F103RC) board pin assignments + * Creality 4.2.10 (STM32F103RE / STM32F103RC) board pin assignments */ #include "env_validate.h" @@ -143,85 +143,75 @@ #define SDIO_SUPPORT #define NO_SD_HOST_DRIVE // This board's SD is only seen by the printer -#if ENABLED(CR10_STOCKDISPLAY) +#if ANY(RET6_12864_LCD, HAS_DWIN_E3V2, IS_DWIN_MARLINUI) + + /** + * RET6 12864 LCD + * ------ + * PC6 | 1 2 | PB2 + * PB10 | 3 4 | PE8 + * PB14 5 6 | PB13 + * PB12 | 7 8 | PB15 + * GND | 9 10 | 5V + * ------ + */ + #define EXP3_01_PIN PC6 + #define EXP3_02_PIN PB2 + #define EXP3_03_PIN PB10 + #define EXP3_04_PIN PE8 + #define EXP3_05_PIN PB14 + #define EXP3_06_PIN PB13 + #define EXP3_07_PIN PB12 + #define EXP3_08_PIN PB15 + +#elif EITHER(VET6_12864_LCD, DWIN_VET6_CREALITY_LCD) + + /** + * VET6 12864 LCD + * ------ + * ? | 1 2 | PC5 + * PB10 | 3 4 | ? + * PA6 5 6 | PA5 + * PA4 | 7 8 | PA7 + * GND | 9 10 | 5V + * ------ + */ + #define EXP3_01_PIN -1 + #define EXP3_02_PIN PC5 + #define EXP3_03_PIN PB10 + #define EXP3_04_PIN -1 + #define EXP3_05_PIN PA6 + #define EXP3_06_PIN PA5 + #define EXP3_07_PIN PA4 + #define EXP3_08_PIN PA7 + +#endif - #if ENABLED(RET6_12864_LCD) - - /** - * RET6 12864 LCD - * ------ - * PC6 | 1 2 | PB2 - * PB10 | 3 4 | PE8 - * PB14 5 6 | PB13 - * PB12 | 7 8 | PB15 - * GND | 9 10 | 5V - * ------ - * EXP1 - */ - #define EXP1_01_PIN PC6 - #define EXP1_02_PIN PB2 - #define EXP1_03_PIN PB10 - #define EXP1_04_PIN PE8 - #define EXP1_05_PIN PB14 - #define EXP1_06_PIN PB13 - #define EXP1_07_PIN PB12 - #define EXP1_08_PIN PB15 - - #define BEEPER_PIN EXP1_01_PIN - - #elif ENABLED(VET6_12864_LCD) - - /** - * VET6 12864 LCD - * ------ - * ? | 1 2 | PC5 - * PB10 | 3 4 | ? - * PA6 5 6 | PA5 - * PA4 | 7 8 | PA7 - * GND | 9 10 | 5V - * ------ - * EXP1 - */ - #define EXP1_01_PIN -1 - #define EXP1_02_PIN PC5 - #define EXP1_03_PIN PB10 - #define EXP1_04_PIN -1 - #define EXP1_05_PIN PA6 - #define EXP1_06_PIN PA5 - #define EXP1_07_PIN PA4 - #define EXP1_08_PIN PA7 - - #else +#if ENABLED(CR10_STOCKDISPLAY) + #if NONE(RET6_12864_LCD, VET6_12864_LCD) #error "Define RET6_12864_LCD or VET6_12864_LCD to select pins for CR10_STOCKDISPLAY with the Creality V4 controller." #endif - #define LCD_PINS_RS EXP1_07_PIN - #define LCD_PINS_ENABLE EXP1_08_PIN - #define LCD_PINS_D4 EXP1_06_PIN + #define LCD_PINS_RS EXP3_07_PIN + #define LCD_PINS_ENABLE EXP3_08_PIN + #define LCD_PINS_D4 EXP3_06_PIN - #define BTN_ENC EXP1_02_PIN - #define BTN_EN1 EXP1_03_PIN - #define BTN_EN2 EXP1_05_PIN + #define BTN_ENC EXP3_02_PIN + #define BTN_EN1 EXP3_03_PIN + #define BTN_EN2 EXP3_05_PIN -#elif HAS_DWIN_E3V2 || IS_DWIN_MARLINUI + #define BEEPER_PIN EXP3_01_PIN - // RET6 DWIN ENCODER LCD - #define BTN_ENC PB14 - #define BTN_EN1 PB15 - #define BTN_EN2 PB12 +#elif ANY(DWIN_VET6_CREALITY_LCD, HAS_DWIN_E3V2, IS_DWIN_MARLINUI) - //#define LCD_LED_PIN PB2 + // RET6 / VET6 DWIN ENCODER LCD + #define BTN_ENC EXP3_05_PIN + #define BTN_EN1 EXP3_08_PIN + #define BTN_EN2 EXP3_07_PIN + + //#define LCD_LED_PIN EXP3_02_PIN #ifndef BEEPER_PIN - #define BEEPER_PIN PB13 + #define BEEPER_PIN EXP3_06_PIN #endif -#elif ENABLED(DWIN_VET6_CREALITY_LCD) - - // VET6 DWIN ENCODER LCD - #define BTN_ENC PA6 - #define BTN_EN1 PA7 - #define BTN_EN2 PA4 - - #define BEEPER_PIN PA5 - #endif diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V425.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V425.h index 46f437ecafb2..1c62d19a99e4 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V425.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V425.h @@ -1,9 +1,9 @@ /** * Marlin 3D Printer Firmware - * Copyright (C) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] * * Based on Sprinter and grbl. - * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V521.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V521.h new file mode 100644 index 000000000000..d3d3685531dc --- /dev/null +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V521.h @@ -0,0 +1,226 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * Creality 5.2.1 (STM32F103RE) board pin assignments + */ + +#include "env_validate.h" + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "Creality v5.2.1 supports up to 2 hotends / E steppers." +#endif + +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "Creality V521" +#endif +#ifndef DEFAULT_MACHINE_NAME + #define DEFAULT_MACHINE_NAME "Creality V5.2.1" +#endif + +// +// EEPROM +// +#if NO_EEPROM_SELECTED + // FLASH + //#define FLASH_EEPROM_EMULATION + + // I2C + #define IIC_BL24CXX_EEPROM // EEPROM on I2C-0 used only for display settings + #if ENABLED(IIC_BL24CXX_EEPROM) + #define IIC_EEPROM_SDA PC2 + #define IIC_EEPROM_SCL PC3 + #define MARLIN_EEPROM_SIZE 0x800 // 2K (24C16) + #else + #define SDCARD_EEPROM_EMULATION // SD EEPROM until all EEPROM is BL24CXX + #define MARLIN_EEPROM_SIZE 0x800 // 2K + #endif + + #undef NO_EEPROM_SELECTED +#endif + +// +// Servos +// +#define SERVO0_PIN PD13 // BLTouch OUT + +// +// Limit Switches +// +#define X_STOP_PIN PD10 // X +#define X2_STOP_PIN PE15 // X2 +#define Y_STOP_PIN PE0 // Y +#define Z_STOP_PIN PE1 // Z +#define Z2_STOP_PIN PE2 // Z2 + +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PD12 // BLTouch IN +#endif + +// +// Filament Runout Sensor +// +#define FIL_RUNOUT_PIN PE5 // "Pulled-high" +#define FIL_RUNOUT2_PIN PE6 // "Pulled-high" + +// +// Steppers +// +#define X_ENABLE_PIN PC7 +#define X_STEP_PIN PD15 +#define X_DIR_PIN PD14 + +#define Y_ENABLE_PIN PB9 +#define Y_STEP_PIN PB7 +#define Y_DIR_PIN PB6 + +#define Z_ENABLE_PIN PB5 +#define Z_STEP_PIN PB3 +#define Z_DIR_PIN PD7 + +#define E0_ENABLE_PIN PD4 +#define E0_STEP_PIN PD1 +#define E0_DIR_PIN PD0 + +#define E1_ENABLE_PIN PE7 +#define E1_STEP_PIN PB1 +#define E1_DIR_PIN PB0 + +#define X2_ENABLE_PIN PE11 +#define X2_STEP_PIN PE9 +#define X2_DIR_PIN PE8 + +#define Z2_ENABLE_PIN PC5 +#define Z2_STEP_PIN PA7 +#define Z2_DIR_PIN PA6 + +// +// Release PB4 (Y_ENABLE_PIN) from JTAG NRST role +// +#define DISABLE_JTAG + +// +// Temperature Sensors +// +#define TEMP_0_PIN PA4 // TH0 +#define TEMP_1_PIN PA5 // TH1 +#define TEMP_BED_PIN PA3 // TB1 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PA1 // HEATER0 +#define HEATER_1_PIN PA0 // HEATER1 +#define HEATER_BED_PIN PA2 // HOT BED + +#define FAN_PIN PB14 // FAN +#define FAN1_PIN PB12 // FAN +#define FAN_SOFT_PWM + +// +// SD Card +// +#define SD_DETECT_PIN PA8 +#define SDCARD_CONNECTION ONBOARD +#define ONBOARD_SPI_DEVICE 1 +#define ONBOARD_SD_CS_PIN PC11 // SDSS +#define SDIO_SUPPORT +#define NO_SD_HOST_DRIVE // This board's SD is only seen by the printer + +#if ANY(RET6_12864_LCD, HAS_DWIN_E3V2, IS_DWIN_MARLINUI) + + /** + * RET6 12864 LCD + * ------ + * PC6 | 1 2 | PB2 + * PB10 | 3 4 | PE8 + * PB14 5 6 | PB13 + * PB12 | 7 8 | PB15 + * GND | 9 10 | 5V + * ------ + */ + #define EXP3_01_PIN PC6 + #define EXP3_02_PIN PB2 + #define EXP3_03_PIN PB10 + #define EXP3_04_PIN PE8 + #define EXP3_05_PIN PB14 + #define EXP3_06_PIN PB13 + #define EXP3_07_PIN PB12 + #define EXP3_08_PIN PB15 + +#elif EITHER(VET6_12864_LCD, DWIN_VET6_CREALITY_LCD) + + /** + * VET6 12864 LCD + * ------ + * ? | 1 2 | PC5 + * PB10 | 3 4 | ? + * PA6 5 6 | PA5 + * PA4 | 7 8 | PA7 + * GND | 9 10 | 5V + * ------ + */ + #define EXP3_01_PIN -1 + #define EXP3_02_PIN PC5 + #define EXP3_03_PIN PB10 + #define EXP3_04_PIN -1 + #define EXP3_05_PIN PA6 + #define EXP3_06_PIN PA5 + #define EXP3_07_PIN PA4 + #define EXP3_08_PIN PA7 + +#endif + +#if ENABLED(CR10_STOCKDISPLAY) + #if NONE(RET6_12864_LCD, VET6_12864_LCD) + #error "Define RET6_12864_LCD or VET6_12864_LCD to select pins for CR10_STOCKDISPLAY with the Creality V4 controller." + #endif + + #define LCD_PINS_RS EXP3_07_PIN + #define LCD_PINS_ENABLE EXP3_08_PIN + #define LCD_PINS_D4 EXP3_06_PIN + + #define BTN_ENC EXP3_02_PIN + #define BTN_EN1 EXP3_03_PIN + #define BTN_EN2 EXP3_05_PIN + + #define BEEPER_PIN EXP3_01_PIN + +#elif ANY(DWIN_VET6_CREALITY_LCD, HAS_DWIN_E3V2, IS_DWIN_MARLINUI) + + // RET6 / VET6 DWIN ENCODER LCD + #define BTN_ENC EXP3_05_PIN + #define BTN_EN1 EXP3_08_PIN + #define BTN_EN2 EXP3_07_PIN + + //#define LCD_LED_PIN EXP3_02_PIN + #ifndef BEEPER_PIN + #define BEEPER_PIN EXP3_06_PIN + #endif + +#endif + +// DGUS LCDs +#if HAS_DGUS_LCD + #define LCD_SERIAL_PORT 3 +#endif diff --git a/ini/stm32f1.ini b/ini/stm32f1.ini index 49dac9e47664..ecdf554328e4 100644 --- a/ini/stm32f1.ini +++ b/ini/stm32f1.ini @@ -467,3 +467,24 @@ board = genericSTM32F103VE board_build.variant = MARLIN_F103Vx build_flags = ${ZONESTAR_ZM3E.build_flags} -DTIMER_TONE=TIM1 board_upload.maximum_size = 499712 + +# +# Creality (STM32F103RET6) +# +[env:STM32F103RET6_creality] +platform = ${common_stm32f1.platform} +extends = stm32_variant +board = genericSTM32F103VE +board_build.variant = MARLIN_F103Vx +board_build.offset = 0x7000 +board_upload.offset_address = 0x08007000 +build_flags = ${stm32_variant.build_flags} + -DSS_TIMER=4 -DTIMER_SERVO=TIM5 + -DENABLE_HWSERIAL3 -DTRANSFER_CLOCK_DIV=8 +build_unflags = ${stm32_variant.build_unflags} + -DUSBCON -DUSBD_USE_CDC +extra_scripts = ${stm32_variant.extra_scripts} + pre:buildroot/share/PlatformIO/scripts/random-bin.py +monitor_speed = 115200 +debug_tool = jlink +upload_protocol = jlink From 44e4a9c7b1deb0c5633068180a59aceaea3bcbe7 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Wed, 28 Sep 2022 16:49:30 +0200 Subject: [PATCH 080/243] =?UTF-8?q?=F0=9F=8E=A8=20Remove=20non-const=20com?= =?UTF-8?q?pare=20operators=20(#24810)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/types.h | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index de6bc2486d02..3ef1eb788111 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -436,15 +436,9 @@ struct XYval { FI XYval& operator<<=(const int &v) { _LS(x); _LS(y); return *this; } // Exact comparisons. For floats a "NEAR" operation may be better. - FI bool operator==(const XYval &rs) { return x == rs.x && y == rs.y; } - FI bool operator==(const XYZval &rs) { return x == rs.x && y == rs.y; } - FI bool operator==(const XYZEval &rs) { return x == rs.x && y == rs.y; } FI bool operator==(const XYval &rs) const { return x == rs.x && y == rs.y; } FI bool operator==(const XYZval &rs) const { return x == rs.x && y == rs.y; } FI bool operator==(const XYZEval &rs) const { return x == rs.x && y == rs.y; } - FI bool operator!=(const XYval &rs) { return !operator==(rs); } - FI bool operator!=(const XYZval &rs) { return !operator==(rs); } - FI bool operator!=(const XYZEval &rs) { return !operator==(rs); } FI bool operator!=(const XYval &rs) const { return !operator==(rs); } FI bool operator!=(const XYZval &rs) const { return !operator==(rs); } FI bool operator!=(const XYZEval &rs) const { return !operator==(rs); } @@ -599,9 +593,7 @@ struct XYZval { FI XYZval& operator<<=(const int &v) { NUM_AXIS_CODE(_LS(x), _LS(y), _LS(z), _LS(i), _LS(j), _LS(k), _LS(u), _LS(v), _LS(w)); return *this; } // Exact comparisons. For floats a "NEAR" operation may be better. - FI bool operator==(const XYZEval &rs) { return true NUM_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k, && u == rs.u, && v == rs.v, && w == rs.w); } FI bool operator==(const XYZEval &rs) const { return true NUM_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k, && u == rs.u, && v == rs.v, && w == rs.w); } - FI bool operator!=(const XYZEval &rs) { return !operator==(rs); } FI bool operator!=(const XYZEval &rs) const { return !operator==(rs); } }; @@ -750,13 +742,9 @@ struct XYZEval { FI XYZEval& operator<<=(const int &v) { LOGICAL_AXIS_CODE(_LS(e), _LS(x), _LS(y), _LS(z), _LS(i), _LS(j), _LS(k), _LS(u), _LS(v), _LS(w)); return *this; } // Exact comparisons. For floats a "NEAR" operation may be better. - FI bool operator==(const XYZval &rs) { return true NUM_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k, && u == rs.u, && v == rs.v, && w == rs.w); } FI bool operator==(const XYZval &rs) const { return true NUM_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k, && u == rs.u, && v == rs.v, && w == rs.w); } - FI bool operator==(const XYZEval &rs) { return true LOGICAL_AXIS_GANG(&& e == rs.e, && x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k, && u == rs.u, && v == rs.v, && w == rs.w); } FI bool operator==(const XYZEval &rs) const { return true LOGICAL_AXIS_GANG(&& e == rs.e, && x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k, && u == rs.u, && v == rs.v, && w == rs.w); } - FI bool operator!=(const XYZval &rs) { return !operator==(rs); } FI bool operator!=(const XYZval &rs) const { return !operator==(rs); } - FI bool operator!=(const XYZEval &rs) { return !operator==(rs); } FI bool operator!=(const XYZEval &rs) const { return !operator==(rs); } }; From 6ae07088400dcb259993afb58f5e06c651c3beb2 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Thu, 29 Sep 2022 04:03:40 +1300 Subject: [PATCH 081/243] =?UTF-8?q?=F0=9F=A9=B9=20Disable=20DEBUG=5FDGUSLC?= =?UTF-8?q?D=20(#24798)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.h b/Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.h index d115f7c02ba5..c4e3645f28c9 100644 --- a/Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.h +++ b/Marlin/src/lcd/extui/dgus_reloaded/DGUSDisplay.h @@ -33,7 +33,7 @@ #include "../../../inc/MarlinConfigPre.h" #include "../../../MarlinCore.h" -#define DEBUG_DGUSLCD // Uncomment for debug messages +//#define DEBUG_DGUSLCD // Uncomment for debug messages #define DEBUG_OUT ENABLED(DEBUG_DGUSLCD) #include "../../../core/debug_out.h" From 7b000966f06a258eef229334d9ffe9e74463c45c Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Wed, 28 Sep 2022 08:05:06 -0700 Subject: [PATCH 082/243] =?UTF-8?q?=F0=9F=94=A7=20Update=20Creality=204.2.?= =?UTF-8?q?2=20Driver=20Warning=20(#24806)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/Warnings.cpp | 4 ++-- Marlin/src/pins/stm32f1/pins_CREALITY_V422.h | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Marlin/src/inc/Warnings.cpp b/Marlin/src/inc/Warnings.cpp index 65174593fb5d..1228db336c6a 100644 --- a/Marlin/src/inc/Warnings.cpp +++ b/Marlin/src/inc/Warnings.cpp @@ -711,8 +711,8 @@ #warning "Don't forget to update your TFT settings in Configuration.h." #endif -#if ENABLED(EMIT_CREALITY_422_WARNING) - #warning "Creality 4.2.2 boards come with a variety of stepper drivers. Check the board label and set the correct *_DRIVER_TYPE! (C=HR4988, E=A4988, A=TMC2208, B=TMC2209, H=TMC2225). (Define EMIT_CREALITY_422_WARNING false to suppress this warning.)" +#if ENABLED(EMIT_CREALITY_422_WARNING) && DISABLED(NO_CREALITY_422_DRIVER_WARNING) + #warning "Creality 4.2.2 boards come with a variety of stepper drivers. Check the board label and set the correct *_DRIVER_TYPE! (C=HR4988, E=A4988, A=TMC2208, B=TMC2209, H=TMC2225). (Define NO_CREALITY_422_DRIVER_WARNING to suppress this warning.)" #endif #if PRINTCOUNTER_SYNC diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V422.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V422.h index c6b6e84bfa36..9e26b37de0d3 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V422.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V422.h @@ -28,8 +28,6 @@ #define BOARD_INFO_NAME "Creality v4.2.2" #define DEFAULT_MACHINE_NAME "Creality3D" -#ifndef EMIT_CREALITY_422_WARNING - #define EMIT_CREALITY_422_WARNING -#endif +#define EMIT_CREALITY_422_WARNING #include "pins_CREALITY_V4.h" From 5aca6ff4f2816d8e55281ebe7e7cbcbe49777572 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 29 Sep 2022 17:30:53 -0500 Subject: [PATCH 083/243] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20some=20vector=5F3?= =?UTF-8?q?=20cast=20operators?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/libs/vector_3.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/libs/vector_3.h b/Marlin/src/libs/vector_3.h index f515333cc768..58bdb43c7b41 100644 --- a/Marlin/src/libs/vector_3.h +++ b/Marlin/src/libs/vector_3.h @@ -75,8 +75,8 @@ struct vector_3 { vector_3 operator-(const vector_3 &v) { return vector_3(x - v.x, y - v.y, z - v.z); } vector_3 operator*(const float &v) { return vector_3(x * v, y * v, z * v); } - operator xy_float_t() { return xy_float_t({ x, y }); } - operator xyz_float_t() { return xyz_float_t({ x, y, z }); } + operator xy_float_t() { return xy_float_t({ x OPTARG(HAS_Y_AXIS, y) }); } + operator xyz_float_t() { return xyz_float_t({ x OPTARG(HAS_Y_AXIS, y) OPTARG(HAS_Z_AXIS, z) }); } void debug(FSTR_P const title); }; From a58f27763f67a0ee88bb58e4305ce32bd7ff916b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20Jos=C3=A9=20Tagle?= Date: Thu, 29 Sep 2022 19:54:59 -0300 Subject: [PATCH 084/243] =?UTF-8?q?=F0=9F=90=9B=20Fix=20DUE=20compile=20an?= =?UTF-8?q?d=20errors=20(#24809)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/DUE/HAL.h | 2 +- Marlin/src/HAL/DUE/HAL_SPI.cpp | 4 ++-- Marlin/src/HAL/DUE/InterruptVectors.cpp | 2 +- Marlin/src/HAL/DUE/usb/usb_task.c | 2 +- Marlin/src/core/types.h | 4 ++-- Marlin/src/module/planner.h | 10 +++++----- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Marlin/src/HAL/DUE/HAL.h b/Marlin/src/HAL/DUE/HAL.h index 4d3f4823a517..585b8938417f 100644 --- a/Marlin/src/HAL/DUE/HAL.h +++ b/Marlin/src/HAL/DUE/HAL.h @@ -210,7 +210,7 @@ class MarlinHAL { static void adc_init() {} // Called by Temperature::init for each sensor at startup - static void adc_enable(const uint8_t ch) {} + static void adc_enable(const uint8_t /*ch*/) {} // Begin ADC sampling on the given channel. Called from Temperature::isr! static void adc_start(const uint8_t ch) { adc_result = analogRead(ch); } diff --git a/Marlin/src/HAL/DUE/HAL_SPI.cpp b/Marlin/src/HAL/DUE/HAL_SPI.cpp index 7e3fe0135645..f5bcaacee505 100644 --- a/Marlin/src/HAL/DUE/HAL_SPI.cpp +++ b/Marlin/src/HAL/DUE/HAL_SPI.cpp @@ -247,12 +247,12 @@ b <<= 1; // little setup time WRITE(SD_SCK_PIN, HIGH); - DELAY_NS(spiDelayNS); + DELAY_NS_VAR(spiDelayNS); b |= (READ(SD_MISO_PIN) != 0); WRITE(SD_SCK_PIN, LOW); - DELAY_NS(spiDelayNS); + DELAY_NS_VAR(spiDelayNS); } while (--bits); return b; } diff --git a/Marlin/src/HAL/DUE/InterruptVectors.cpp b/Marlin/src/HAL/DUE/InterruptVectors.cpp index e4e0ce99f2b5..70795d1c30af 100644 --- a/Marlin/src/HAL/DUE/InterruptVectors.cpp +++ b/Marlin/src/HAL/DUE/InterruptVectors.cpp @@ -41,7 +41,7 @@ practice, we need alignment to 256 bytes to make this work in all cases */ __attribute__ ((aligned(256))) -static DeviceVectors ram_tab = { nullptr }; +static DeviceVectors ram_tab[61] = { nullptr }; /** * This function checks if the exception/interrupt table is already in SRAM or not. diff --git a/Marlin/src/HAL/DUE/usb/usb_task.c b/Marlin/src/HAL/DUE/usb/usb_task.c index 54a808d7f4f1..86ab27217abc 100644 --- a/Marlin/src/HAL/DUE/usb/usb_task.c +++ b/Marlin/src/HAL/DUE/usb/usb_task.c @@ -62,7 +62,7 @@ void usb_task_idle(void) { // Attend SD card access from the USB MSD -- Prioritize access to improve speed int delay = 2; while (main_b_msc_enable && --delay > 0) { - if (udi_msc_process_trans()) delay = 10000; + if (udi_msc_process_trans()) delay = 20; // Reset the watchdog, just to be sure REG_WDT_CR = WDT_CR_WDRSTT | WDT_CR_KEY(0xA5); diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index 3ef1eb788111..cb087204fea6 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -99,8 +99,8 @@ struct Flags { void set(const int n) { b |= (bits_t)_BV(n); } void clear(const int n) { b &= ~(bits_t)_BV(n); } bool test(const int n) const { return TEST(b, n); } - const bool operator[](const int n) { return test(n); } - const bool operator[](const int n) const { return test(n); } + bool operator[](const int n) { return test(n); } + bool operator[](const int n) const { return test(n); } int size() const { return sizeof(b); } }; diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index 974dcd2ad371..bd505e784698 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -192,11 +192,11 @@ typedef struct PlannerBlock { volatile block_flags_t flag; // Block flags - volatile bool is_fan_sync() { return TERN0(LASER_SYNCHRONOUS_M106_M107, flag.sync_fans); } - volatile bool is_pwr_sync() { return TERN0(LASER_POWER_SYNC, flag.sync_laser_pwr); } - volatile bool is_sync() { return flag.sync_position || is_fan_sync() || is_pwr_sync(); } - volatile bool is_page() { return TERN0(DIRECT_STEPPING, flag.page); } - volatile bool is_move() { return !(is_sync() || is_page()); } + bool is_fan_sync() { return TERN0(LASER_SYNCHRONOUS_M106_M107, flag.sync_fans); } + bool is_pwr_sync() { return TERN0(LASER_POWER_SYNC, flag.sync_laser_pwr); } + bool is_sync() { return flag.sync_position || is_fan_sync() || is_pwr_sync(); } + bool is_page() { return TERN0(DIRECT_STEPPING, flag.page); } + bool is_move() { return !(is_sync() || is_page()); } // Fields used by the motion planner to manage acceleration float nominal_speed, // The nominal speed for this block in (mm/sec) From f17a07df99fcb248af05872ee1bac0375d8ae174 Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Sat, 1 Oct 2022 09:19:51 -0700 Subject: [PATCH 085/243] =?UTF-8?q?=F0=9F=94=A7=20Thermistor=20(66)=20sani?= =?UTF-8?q?ty-check=20(#24803)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration.h | 2 +- Marlin/src/core/macros.h | 5 ++-- Marlin/src/inc/Conditionals_adv.h | 5 ++-- Marlin/src/inc/Conditionals_post.h | 2 +- Marlin/src/inc/SanityCheck.h | 31 ++++++++++++++++++++ Marlin/src/lcd/thermistornames.h | 2 +- Marlin/src/module/temperature.cpp | 2 +- Marlin/src/module/thermistor/thermistor_66.h | 2 +- Marlin/src/module/thermistor/thermistors.h | 2 +- 9 files changed, 43 insertions(+), 10 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 1d2542e26628..9783b2ec6797 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -496,7 +496,7 @@ * 30 : 100kΩ Kis3d Silicone heating mat 200W/300W with 6mm precision cast plate (EN AW 5083) NTC100K - beta 3950 * 60 : 100kΩ Maker's Tool Works Kapton Bed Thermistor - beta 3950 * 61 : 100kΩ Formbot/Vivedino 350°C Thermistor - beta 3950 - * 66 : 4.7MΩ Dyze Design High Temperature Thermistor + * 66 : 4.7MΩ Dyze Design / Trianglelab T-D500 500°C High Temperature Thermistor * 67 : 500kΩ SliceEngineering 450°C Thermistor * 68 : PT100 amplifier board from Dyze Design * 70 : 100kΩ bq Hephestos 2 diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index cfeb9db33c52..3029009c06b8 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -738,6 +738,7 @@ #define MAPLIST(OP,V...) EVAL(_MAPLIST(OP,V)) // Temperature Sensor Config -#define _HAS_E_TEMP(N) || (TEMP_SENSOR_##N != 0) +#define TEMP_SENSOR(N) TEMP_SENSOR_##N +#define _HAS_E_TEMP(N) || TEMP_SENSOR(N) #define HAS_E_TEMP_SENSOR (0 REPEAT(EXTRUDERS, _HAS_E_TEMP)) -#define TEMP_SENSOR_IS_MAX_TC(T) (TEMP_SENSOR_##T == -5 || TEMP_SENSOR_##T == -3 || TEMP_SENSOR_##T == -2) +#define TEMP_SENSOR_IS_MAX_TC(T) (TEMP_SENSOR(T) == -5 || TEMP_SENSOR(T) == -3 || TEMP_SENSOR(T) == -2) diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 7d3306ffb892..c3f746dc72d0 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -161,9 +161,10 @@ #define HID_E6 6 #define HID_E7 7 -#define _SENSOR_IS(I,N) || (TEMP_SENSOR_##N == I) +#define _SENSOR_IS(I,N) || (TEMP_SENSOR(N) == I) #define _E_SENSOR_IS(I,N) _SENSOR_IS(N,I) -#define ANY_THERMISTOR_IS(N) (0 REPEAT2(HOTENDS, _E_SENSOR_IS, N) \ +#define ANY_E_SENSOR_IS(N) (0 REPEAT2(HOTENDS, _E_SENSOR_IS, N)) +#define ANY_THERMISTOR_IS(N) ( ANY_E_SENSOR_IS(N) \ _SENSOR_IS(N,BED) _SENSOR_IS(N,PROBE) _SENSOR_IS(N,CHAMBER) \ _SENSOR_IS(N,COOLER) _SENSOR_IS(N,BOARD) _SENSOR_IS(N,REDUNDANT) ) diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index c208466dd01f..45eccaade959 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -2656,7 +2656,7 @@ // // ADC Temp Sensors (Thermistor or Thermocouple with amplifier ADC interface) // -#define HAS_ADC_TEST(P) (PIN_EXISTS(TEMP_##P) && TEMP_SENSOR_##P != 0 && !TEMP_SENSOR_IS_MAX_TC(P) && !TEMP_SENSOR_##P##_IS_DUMMY) +#define HAS_ADC_TEST(P) (TEMP_SENSOR(P) && PIN_EXISTS(TEMP_##P) && !TEMP_SENSOR_IS_MAX_TC(P) && !TEMP_SENSOR_##P##_IS_DUMMY) #if HOTENDS > 0 && HAS_ADC_TEST(0) #define HAS_TEMP_ADC_0 1 #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index e9675feaf1d4..95d0e7492261 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2272,6 +2272,37 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "TEMP_SENSOR_REDUNDANT 1000 requires REDUNDANT_PULLUP_RESISTOR_OHMS, REDUNDANT_RESISTANCE_25C_OHMS and REDUNDANT_BETA in Configuration_adv.h." #endif +/** + * Required thermistor 66 (Dyze Design / Trianglelab T-D500) settings + * https://docs.dyzedesign.com/hotends.html#_500-%C2%B0c-thermistor + */ +#if ANY_E_SENSOR_IS(66) + #define _BAD_MINTEMP(N) (TEMP_SENSOR(N) == 66 && HEATER_##N##_MINTEMP <= 20) + #if _BAD_MINTEMP(0) + #error "Thermistor 66 requires HEATER_0_MINTEMP > 20." + #elif _BAD_MINTEMP(1) + #error "Thermistor 66 requires HEATER_1_MINTEMP > 20." + #elif _BAD_MINTEMP(2) + #error "Thermistor 66 requires HEATER_2_MINTEMP > 20." + #elif _BAD_MINTEMP(3) + #error "Thermistor 66 requires HEATER_3_MINTEMP > 20." + #elif _BAD_MINTEMP(4) + #error "Thermistor 66 requires HEATER_4_MINTEMP > 20." + #elif _BAD_MINTEMP(5) + #error "Thermistor 66 requires HEATER_5_MINTEMP > 20." + #elif _BAD_MINTEMP(6) + #error "Thermistor 66 requires HEATER_6_MINTEMP > 20." + #elif _BAD_MINTEMP(7) + #error "Thermistor 66 requires HEATER_7_MINTEMP > 20." + #endif + #if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED < 5 + #error "Thermistor 66 requires MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED ≥ 5." + #elif MILLISECONDS_PREHEAT_TIME < 30000 + #error "Thermistor 66 requires MILLISECONDS_PREHEAT_TIME ≥ 30000." + #endif + #undef _BAD_MINTEMP +#endif + /** * Required MAX31865 settings */ diff --git a/Marlin/src/lcd/thermistornames.h b/Marlin/src/lcd/thermistornames.h index 1b40a8c7d49a..54542bed4ed8 100644 --- a/Marlin/src/lcd/thermistornames.h +++ b/Marlin/src/lcd/thermistornames.h @@ -141,7 +141,7 @@ #elif THERMISTOR_ID == 61 #define THERMISTOR_NAME "Formbot 350°C" #elif THERMISTOR_ID == 66 - #define THERMISTOR_NAME "Dyze 4.7M" + #define THERMISTOR_NAME "Dyze / TL 4.7M" #elif THERMISTOR_ID == 67 #define THERMISTOR_NAME "SliceEng 450°C" diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 8c662948bc54..7954611bc4a9 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -2649,7 +2649,7 @@ void Temperature::init() { temp_range[NR].raw_max -= TEMPDIR(NR) * (OVERSAMPLENR); \ }while(0) - #define _MINMAX_TEST(N,M) (HOTENDS > N && TEMP_SENSOR_##N > 0 && TEMP_SENSOR_##N != 998 && TEMP_SENSOR_##N != 999 && defined(HEATER_##N##_##M##TEMP)) + #define _MINMAX_TEST(N,M) (HOTENDS > N && TEMP_SENSOR(N) > 0 && TEMP_SENSOR(N) != 998 && TEMP_SENSOR(N) != 999 && defined(HEATER_##N##_##M##TEMP)) #if _MINMAX_TEST(0, MIN) _TEMP_MIN_E(0); diff --git a/Marlin/src/module/thermistor/thermistor_66.h b/Marlin/src/module/thermistor/thermistor_66.h index 07cb29767935..7c2455b7c652 100644 --- a/Marlin/src/module/thermistor/thermistor_66.h +++ b/Marlin/src/module/thermistor/thermistor_66.h @@ -21,7 +21,7 @@ */ #pragma once -// R25 = 2.5 MOhm, beta25 = 4500 K, 4.7 kOhm pull-up, DyzeDesign 500 °C Thermistor +// R25 = 2.5 MOhm, beta25 = 4500 K, 4.7 kOhm pull-up, DyzeDesign / Trianglelab T-D500 500 °C Thermistor constexpr temp_entry_t temptable_66[] PROGMEM = { { OV( 17.5), 850 }, { OV( 17.9), 500 }, diff --git a/Marlin/src/module/thermistor/thermistors.h b/Marlin/src/module/thermistor/thermistors.h index 5d89dd3aa901..c596d746f7fd 100644 --- a/Marlin/src/module/thermistor/thermistors.h +++ b/Marlin/src/module/thermistor/thermistors.h @@ -338,7 +338,7 @@ static_assert(255 > TEMPTABLE_0_LEN || 255 > TEMPTABLE_1_LEN || 255 > TEMPTABLE_ // For thermocouples the highest temperature results in the highest ADC value #define _TT_REV(N) REVERSE_TEMP_SENSOR_RANGE_##N -#define TT_REV(N) TERN0(TEMP_SENSOR_##N##_IS_THERMISTOR, DEFER4(_TT_REV)(TEMP_SENSOR_##N)) +#define TT_REV(N) TERN0(TEMP_SENSOR_##N##_IS_THERMISTOR, DEFER4(_TT_REV)(TEMP_SENSOR(N))) #define _TT_REVRAW(N) !TEMP_SENSOR_##N##_IS_THERMISTOR #define TT_REVRAW(N) (TT_REV(N) || _TT_REVRAW(N)) From 74435b0dcb2a1a157811631ae79fe8064443d8a6 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Sun, 2 Oct 2022 05:25:00 +1300 Subject: [PATCH 086/243] =?UTF-8?q?=E2=9C=A8=20Creality=20v5.2.1=20board?= =?UTF-8?q?=20(#24815)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to #24760 --- Marlin/src/core/boards.h | 2 +- Marlin/src/pins/pins.h | 4 ++-- ini/stm32f1.ini | 31 ++++++++++--------------------- 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index 17051b484cc9..51d419da0460 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -355,7 +355,7 @@ #define BOARD_CREALITY_V431_D 4051 // Creality v4.3.1d (STM32F103RC / STM32F103RE) #define BOARD_CREALITY_V452 4052 // Creality v4.5.2 (STM32F103RC / STM32F103RE) #define BOARD_CREALITY_V453 4053 // Creality v4.5.3 (STM32F103RC / STM32F103RE) -#define BOARD_CREALITY_V521 4054 // SV04 Board +#define BOARD_CREALITY_V521 4054 // Creality v5.2.1 (STM32F103VE) as found in the SV04 #define BOARD_CREALITY_V24S1 4055 // Creality v2.4.S1 (STM32F103RC / STM32F103RE) v101 as found in the Ender-7 #define BOARD_CREALITY_V24S1_301 4056 // Creality v2.4.S1_301 (STM32F103RC / STM32F103RE) v301 as found in the Ender-3 S1 #define BOARD_CREALITY_V25S1 4057 // Creality v2.5.S1 (STM32F103RE) as found in the CR-10 Smart Pro diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 1e7f5ec3981a..9efafe9af566 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -591,6 +591,8 @@ #include "stm32f1/pins_CREALITY_V24S1_301.h" // STM32F1 env:STM32F103RE_creality env:STM32F103RE_creality_xfer env:STM32F103RC_creality env:STM32F103RC_creality_xfer env:STM32F103RE_creality_maple #elif MB(CREALITY_V25S1) #include "stm32f1/pins_CREALITY_V25S1.h" // STM32F1 env:STM32F103RE_creality_smartPro env:STM32F103RE_creality_smartPro_maple +#elif MB(CREALITY_V521) + #include "stm32f1/pins_CREALITY_V521.h" // STM32F103VE env:STM32F103VE_creality #elif MB(TRIGORILLA_PRO) #include "stm32f1/pins_TRIGORILLA_PRO.h" // STM32F1 env:trigorilla_pro env:trigorilla_pro_maple env:trigorilla_pro_disk #elif MB(FLY_MINI) @@ -611,8 +613,6 @@ #include "stm32f1/pins_ERYONE_ERY32_MINI.h" // STM32F103VET6 env:ERYONE_ERY32_MINI_maple #elif MB(PANDA_PI_V29) #include "stm32f1/pins_PANDA_PI_V29.h" // STM32F103RCT6 env:PANDA_PI_V29 -#elif MB(CREALITY_V521) - #include "stm32f1/pins_CREALITY_V521.h" // STM32F103RET6 env:STM32F103RET6_creality // // ARM Cortex-M4F diff --git a/ini/stm32f1.ini b/ini/stm32f1.ini index ecdf554328e4..d8db3628c307 100644 --- a/ini/stm32f1.ini +++ b/ini/stm32f1.ini @@ -171,6 +171,16 @@ board = genericSTM32F103RC extends = STM32F103Rx_creality_xfer board = genericSTM32F103RC +# +# Creality 512K (STM32F103VE) +# +[env:STM32F103VE_creality] +extends = STM32F103Rx_creality +board = genericSTM32F103VE +board_build.variant = MARLIN_F103Vx +build_flags = ${stm32_variant.build_flags} + -DSS_TIMER=4 -DTIMER_SERVO=TIM5 + -DENABLE_HWSERIAL3 -DTRANSFER_CLOCK_DIV=8 # # BigTreeTech SKR Mini E3 V2.0 & DIP / SKR CR6 (STM32F103RET6 ARM Cortex-M3) # @@ -467,24 +477,3 @@ board = genericSTM32F103VE board_build.variant = MARLIN_F103Vx build_flags = ${ZONESTAR_ZM3E.build_flags} -DTIMER_TONE=TIM1 board_upload.maximum_size = 499712 - -# -# Creality (STM32F103RET6) -# -[env:STM32F103RET6_creality] -platform = ${common_stm32f1.platform} -extends = stm32_variant -board = genericSTM32F103VE -board_build.variant = MARLIN_F103Vx -board_build.offset = 0x7000 -board_upload.offset_address = 0x08007000 -build_flags = ${stm32_variant.build_flags} - -DSS_TIMER=4 -DTIMER_SERVO=TIM5 - -DENABLE_HWSERIAL3 -DTRANSFER_CLOCK_DIV=8 -build_unflags = ${stm32_variant.build_unflags} - -DUSBCON -DUSBD_USE_CDC -extra_scripts = ${stm32_variant.extra_scripts} - pre:buildroot/share/PlatformIO/scripts/random-bin.py -monitor_speed = 115200 -debug_tool = jlink -upload_protocol = jlink From 5c68d26d4e14a86b82c67a8ad5ebe41897833456 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Sun, 2 Oct 2022 05:35:47 +1300 Subject: [PATCH 087/243] =?UTF-8?q?=F0=9F=94=A8=20Detect=20feature=20parsi?= =?UTF-8?q?ng=20error=20(#24824)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildroot/share/PlatformIO/scripts/preflight-checks.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/buildroot/share/PlatformIO/scripts/preflight-checks.py b/buildroot/share/PlatformIO/scripts/preflight-checks.py index 16f39368b654..d810120ec0f1 100644 --- a/buildroot/share/PlatformIO/scripts/preflight-checks.py +++ b/buildroot/share/PlatformIO/scripts/preflight-checks.py @@ -60,10 +60,10 @@ def sanity_check_target(): raise SystemExit("Error: Marlin requires PlatformIO >= 6.1.1. Use 'pio upgrade' to get a newer version.") if 'MARLIN_FEATURES' not in env: - raise SystemExit("Error: this script should be used after common Marlin scripts") + raise SystemExit("Error: this script should be used after common Marlin scripts.") - if 'MOTHERBOARD' not in env['MARLIN_FEATURES']: - raise SystemExit("Error: MOTHERBOARD is not defined in Configuration.h") + if len(env['MARLIN_FEATURES']) == 0: + raise SystemExit("Error: Failed to parse Marlin features. See previous error messages.") build_env = env['PIOENV'] motherboard = env['MARLIN_FEATURES']['MOTHERBOARD'] From 8b37b60e5872a96304e0ce5100556556a83f3d4f Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Sun, 2 Oct 2022 05:39:10 +1300 Subject: [PATCH 088/243] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Ein?= =?UTF-8?q?sy=20Rambo=20EXP=20headers=20(#24825)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/pins/rambo/pins_EINSY_RAMBO.h | 71 +++++++++++++++++------- 1 file changed, 50 insertions(+), 21 deletions(-) diff --git a/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h b/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h index 9150bf13655d..c5d5fcef78f7 100644 --- a/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h +++ b/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h @@ -136,27 +136,56 @@ #ifndef FAN1_PIN #ifdef MK3_FAN_PINS - #define FAN1_PIN -1 + #define FAN1_PIN -1 #else - #define FAN1_PIN 6 + #define FAN1_PIN 6 #endif #endif +/** + * ------ ------ ------ + * 84 PH2 | 1 2 | PH6 9 50 MISO | 1 2 | SCK 52 62 PK0 | 1 2 | PJ5 76 + * 61 PF7 | 3 4 | PD5 82 72 PJ2 | 3 4 | SDSS 77 20 SDA | 3 4 | GND + * 59 PF5 | 5 6 PG4 70 14 TX3 | 5 6 MOSI 51 21 SCL | 5 6 RX2 16 + * 85 PH7 | 7 8 | PG3 71 15 RX3 | 7 8 | RESET GND | 7 8 | TX2 17 + * GND | 9 10 | 5V GND | 9 10 | PE3 5 5V | 9 10 | 5V + * ------ ------ ------ + * P1 P2 P3 + */ + +#define EXP1_01_PIN 84 +#define EXP1_02_PIN 9 +#define EXP1_03_PIN 61 +#define EXP1_04_PIN 82 +#define EXP1_05_PIN 59 +#define EXP1_06_PIN 70 +#define EXP1_07_PIN 85 +#define EXP1_08_PIN 71 + +#define EXP2_01_PIN 50 +#define EXP2_02_PIN 52 +#define EXP2_03_PIN 72 +#define EXP2_04_PIN 77 +#define EXP2_05_PIN 14 +#define EXP2_06_PIN 51 +#define EXP2_07_PIN 15 +#define EXP2_08_PIN -1 + // // Misc. Functions // -#define SDSS 77 +#define SDSS EXP2_04_PIN #define LED_PIN 13 #ifndef CASE_LIGHT_PIN - #define CASE_LIGHT_PIN 9 + #define CASE_LIGHT_PIN EXP1_02_PIN #endif // // M3/M4/M5 - Spindle/Laser Control // // use P1 connector for spindle pins -#define SPINDLE_LASER_PWM_PIN 9 // Hardware PWM +#define SPINDLE_LASER_PWM_PIN EXP1_02_PIN // Hardware PWM #define SPINDLE_LASER_ENA_PIN 18 // Pullup! #define SPINDLE_DIR_PIN 19 @@ -179,20 +208,20 @@ #if IS_ULTIPANEL || TOUCH_UI_ULTIPANEL #if ENABLED(CR10_STOCKDISPLAY) - #define LCD_PINS_RS 85 - #define LCD_PINS_ENABLE 71 - #define LCD_PINS_D4 70 - #define BTN_EN1 61 - #define BTN_EN2 59 + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN #else - #define LCD_PINS_RS 82 - #define LCD_PINS_ENABLE 61 - #define LCD_PINS_D4 59 - #define LCD_PINS_D5 70 - #define LCD_PINS_D6 85 - #define LCD_PINS_D7 71 - #define BTN_EN1 14 - #define BTN_EN2 72 + #define LCD_PINS_RS EXP1_04_PIN + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + #define BTN_EN1 EXP2_05_PIN + #define BTN_EN2 EXP2_03_PIN #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder @@ -200,9 +229,9 @@ #endif - #define BTN_ENC 9 // AUX-2 - #define BEEPER_PIN 84 // AUX-4 - #define SD_DETECT_PIN 15 + #define BTN_ENC EXP1_02_PIN // P1 + #define BEEPER_PIN EXP1_01_PIN // P1 + #define SD_DETECT_PIN EXP2_07_PIN #endif // IS_ULTIPANEL || TOUCH_UI_ULTIPANEL #endif // HAS_WIRED_LCD From d6ff8f0062ec29acf2403e6e6c21528fd08862cd Mon Sep 17 00:00:00 2001 From: Adam <54421854+aamott@users.noreply.github.com> Date: Sat, 1 Oct 2022 10:49:12 -0600 Subject: [PATCH 089/243] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20Switching=20Toolhe?= =?UTF-8?q?ad=20compile=20(#24814)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/module/tool_change.cpp | 11 +++++------ Marlin/src/pins/stm32f1/pins_CREALITY_V4.h | 2 +- Marlin/src/pins/stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h | 2 +- .../MARLIN_FYSETC_SPIDER_KING407/PeripheralPins.c | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 0ff0856ddd1f..4eb72a5b7d1d 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -440,6 +440,11 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. } } + +#endif // TOOL_SENSOR + +#if ENABLED(SWITCHING_TOOLHEAD) + inline void switching_toolhead_lock(const bool locked) { #ifdef SWITCHING_TOOLHEAD_SERVO_ANGLES const uint16_t swt_angles[2] = SWITCHING_TOOLHEAD_SERVO_ANGLES; @@ -452,8 +457,6 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. #endif } - #include - void swt_init() { switching_toolhead_lock(true); @@ -494,10 +497,6 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. #endif // TOOL_SENSOR } -#endif // TOOL_SENSOR - -#if ENABLED(SWITCHING_TOOLHEAD) - inline void switching_toolhead_tool_change(const uint8_t new_tool, bool no_move/*=false*/) { if (no_move) return; diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h index ea2cc52f03d1..11384799a39a 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h @@ -234,7 +234,7 @@ #elif ENABLED(FYSETC_MINI_12864_2_1) #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING - #error "CAUTION! FYSETC_MINI_12864_2_1 and clones require wiring modifications. See 'pins_CREALITY_V4.h' for details. Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning" + #error "CAUTION! FYSETC_MINI_12864_2_1 and clones require wiring modifications. See 'pins_CREALITY_V4.h' for details. Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning." #endif #if SD_CONNECTION_IS(LCD) diff --git a/Marlin/src/pins/stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h b/Marlin/src/pins/stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h index 956cb71f832b..f931d9924acf 100644 --- a/Marlin/src/pins/stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h +++ b/Marlin/src/pins/stm32g0/pins_BTT_SKR_MINI_E3_V3_0.h @@ -311,7 +311,7 @@ #elif ENABLED(FYSETC_MINI_12864_2_1) #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING - #error "CAUTION! FYSETC_MINI_12864_2_1 and clones require wiring modifications. See 'pins_BTT_SKR_MINI_E3_V3_0.h' for details. Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning" + #error "CAUTION! FYSETC_MINI_12864_2_1 and clones require wiring modifications. See 'pins_BTT_SKR_MINI_E3_V3_0.h' for details. Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning." #endif /** diff --git a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/PeripheralPins.c index 4205e103184f..5c7c301f8218 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/PeripheralPins.c +++ b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/PeripheralPins.c @@ -59,7 +59,7 @@ WEAK const PinMap PinMap_ADC[] = { //{PA_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC2_IN5 //{PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 //{PA_6, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC2_IN6 - //{PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 + //{PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 //{PA_7, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC2_IN7 //{PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 //{PB_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC2_IN8 From b0f02b8f9ed553160561ae9b277080e410b96905 Mon Sep 17 00:00:00 2001 From: EvilGremlin <22657714+EvilGremlin@users.noreply.github.com> Date: Sat, 1 Oct 2022 23:04:50 +0300 Subject: [PATCH 090/243] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20Color=20UI=20touch?= =?UTF-8?q?screen=20sleep=20(#24826)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/marlinui.cpp | 17 +++++++++-------- Marlin/src/lcd/menu/menu_configuration.cpp | 2 +- Marlin/src/module/settings.cpp | 4 ++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 8b9c0e048e6b..2f30da001fef 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -191,11 +191,12 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; uint8_t MarlinUI::sleep_timeout_minutes; // Initialized by settings.load() millis_t MarlinUI::screen_timeout_millis = 0; - void MarlinUI::refresh_screen_timeout() { - screen_timeout_millis = sleep_timeout_minutes ? millis() + sleep_timeout_minutes * 60UL * 1000UL : 0; - sleep_display(false); - } - + #if DISABLED(TFT_COLOR_UI) + void MarlinUI::refresh_screen_timeout() { + screen_timeout_millis = sleep_timeout_minutes ? millis() + sleep_timeout_minutes * 60UL * 1000UL : 0; + sleep_display(false); + } + #endif #endif void MarlinUI::init() { @@ -1065,7 +1066,7 @@ void MarlinUI::init() { #if LCD_BACKLIGHT_TIMEOUT_MINS refresh_backlight_timeout(); - #elif HAS_DISPLAY_SLEEP + #elif HAS_DISPLAY_SLEEP && DISABLED(TFT_COLOR_UI) refresh_screen_timeout(); #endif @@ -1178,9 +1179,9 @@ void MarlinUI::init() { WRITE(LCD_BACKLIGHT_PIN, LOW); // Backlight off backlight_off_ms = 0; } - #elif HAS_DISPLAY_SLEEP + #elif HAS_DISPLAY_SLEEP && DISABLED(TFT_COLOR_UI) if (screen_timeout_millis && ELAPSED(ms, screen_timeout_millis)) - sleep_display(); + sleep_display(true); #endif // Change state of drawing flag between screen updates diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 7ae199dfd6e9..1ac12656dd36 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -550,7 +550,7 @@ void menu_configuration() { // #if LCD_BACKLIGHT_TIMEOUT_MINS EDIT_ITEM(uint8, MSG_SCREEN_TIMEOUT, &ui.backlight_timeout_minutes, ui.backlight_timeout_min, ui.backlight_timeout_max, ui.refresh_backlight_timeout); - #elif HAS_DISPLAY_SLEEP + #elif HAS_DISPLAY_SLEEP && DISABLED(TFT_COLOR_UI) EDIT_ITEM(uint8, MSG_SCREEN_TIMEOUT, &ui.sleep_timeout_minutes, ui.sleep_timeout_min, ui.sleep_timeout_max, ui.refresh_screen_timeout); #endif diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 2b6a98b0452f..4ccaa805c553 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -642,7 +642,7 @@ void MarlinSettings::postprocess() { #if LCD_BACKLIGHT_TIMEOUT_MINS ui.refresh_backlight_timeout(); - #elif HAS_DISPLAY_SLEEP + #elif HAS_DISPLAY_SLEEP && DISABLED(TFT_COLOR_UI) ui.refresh_screen_timeout(); #endif } @@ -3167,7 +3167,7 @@ void MarlinSettings::reset() { #if LCD_BACKLIGHT_TIMEOUT_MINS ui.backlight_timeout_minutes = LCD_BACKLIGHT_TIMEOUT_MINS; #elif HAS_DISPLAY_SLEEP - ui.sleep_timeout_minutes = DISPLAY_SLEEP_MINUTES; + ui.sleep_timeout_minutes = TERN(TOUCH_SCREEN, TOUCH_IDLE_SLEEP_MINS, DISPLAY_SLEEP_MINUTES); #endif // From 84812645666ee6988fdadf59d3bc83be9bf53d8d Mon Sep 17 00:00:00 2001 From: EvilGremlin <22657714+EvilGremlin@users.noreply.github.com> Date: Sun, 9 Oct 2022 18:30:47 +0300 Subject: [PATCH 091/243] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Set=20Progress=20w?= =?UTF-8?q?ithout=20LCD=20(#24767)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- .gitignore | 1 + Marlin/Configuration_adv.h | 61 ++-- Marlin/src/MarlinCore.cpp | 2 +- Marlin/src/gcode/gcode.cpp | 4 +- Marlin/src/gcode/gcode.h | 4 +- Marlin/src/gcode/host/M115.cpp | 2 +- Marlin/src/gcode/lcd/M73.cpp | 54 ++- Marlin/src/gcode/sd/M1001.cpp | 4 +- Marlin/src/gcode/sd/M23.cpp | 2 +- Marlin/src/inc/Conditionals_LCD.h | 4 - Marlin/src/inc/Conditionals_adv.h | 8 +- Marlin/src/inc/SanityCheck.h | 26 +- Marlin/src/lcd/HD44780/marlinui_HD44780.cpp | 123 ++++--- Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp | 2 +- Marlin/src/lcd/dogm/status_screen_DOGM.cpp | 224 +++++------- .../lcd/dogm/status_screen_lite_ST7920.cpp | 327 +++++++++++------- .../src/lcd/dogm/status_screen_lite_ST7920.h | 17 +- Marlin/src/lcd/e3v2/jyersui/dwin.cpp | 14 +- Marlin/src/lcd/e3v2/jyersui/dwin.h | 2 +- .../lcd/e3v2/marlinui/ui_status_480x272.cpp | 6 +- Marlin/src/lcd/e3v2/proui/dwin.cpp | 4 +- .../lcd/extui/dgus/fysetc/DGUSDisplayDef.cpp | 2 +- .../lcd/extui/dgus/hiprecy/DGUSDisplayDef.cpp | 2 +- .../src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp | 2 +- Marlin/src/lcd/extui/mks_ui/draw_printing.cpp | 4 +- Marlin/src/lcd/extui/ui_api.h | 3 + Marlin/src/lcd/marlinui.cpp | 58 +++- Marlin/src/lcd/marlinui.h | 32 +- Marlin/src/lcd/menu/menu.cpp | 2 +- Marlin/src/libs/numtostr.cpp | 4 +- buildroot/tests/SAMD51_grandcentral_m4 | 2 +- buildroot/tests/STM32F103RE_creality | 2 +- buildroot/tests/mega2560 | 109 +++--- ini/features.ini | 2 +- 34 files changed, 627 insertions(+), 488 deletions(-) diff --git a/.gitignore b/.gitignore index 0b852d767325..09db344257e7 100755 --- a/.gitignore +++ b/.gitignore @@ -147,6 +147,7 @@ vc-fileutils.settings imgui.ini eeprom.dat spi_flash.bin +fs.img #cmake CMakeLists.txt diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index cb327e9b730d..29873073d308 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1403,9 +1403,6 @@ // On the Info Screen, display XY with one decimal place when possible //#define LCD_DECIMAL_SMALL_XY - // Add an 'M73' G-code to set the current percentage - //#define LCD_SET_PROGRESS_MANUALLY - // Show the E position (filament used) during printing //#define LCD_SHOW_E_TOTAL @@ -1426,37 +1423,43 @@ //#define LED_USER_PRESET_STARTUP // Have the printer display the user preset color on startup #endif #if ENABLED(NEO2_COLOR_PRESETS) - #define NEO2_USER_PRESET_RED 255 // User defined RED value - #define NEO2_USER_PRESET_GREEN 128 // User defined GREEN value - #define NEO2_USER_PRESET_BLUE 0 // User defined BLUE value - #define NEO2_USER_PRESET_WHITE 255 // User defined WHITE value - #define NEO2_USER_PRESET_BRIGHTNESS 255 // User defined intensity - //#define NEO2_USER_PRESET_STARTUP // Have the printer display the user preset color on startup for the second strip + #define NEO2_USER_PRESET_RED 255 // User defined RED value + #define NEO2_USER_PRESET_GREEN 128 // User defined GREEN value + #define NEO2_USER_PRESET_BLUE 0 // User defined BLUE value + #define NEO2_USER_PRESET_WHITE 255 // User defined WHITE value + #define NEO2_USER_PRESET_BRIGHTNESS 255 // User defined intensity + //#define NEO2_USER_PRESET_STARTUP // Have the printer display the user preset color on startup for the second strip #endif #endif -#endif +#endif // HAS_DISPLAY || DWIN_LCD_PROUI -// LCD Print Progress options -#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) - #if CAN_SHOW_REMAINING_TIME - //#define SHOW_REMAINING_TIME // Display estimated time to completion - #if ENABLED(SHOW_REMAINING_TIME) - //#define USE_M73_REMAINING_TIME // Use remaining time from M73 command instead of estimation - //#define ROTATE_PROGRESS_DISPLAY // Display (P)rogress, (E)lapsed, and (R)emaining time - #endif +// Add the G-code 'M73' to set / report the current job progress +//#define SET_PROGRESS_MANUALLY +#if ENABLED(SET_PROGRESS_MANUALLY) + //#define SET_PROGRESS_PERCENT // Add 'P' parameter to set percentage done, otherwise use Marlin's estimate + //#define SET_REMAINING_TIME // Add 'R' parameter to set remaining time, otherwise use Marlin's estimate + //#define SET_INTERACTION_TIME // Add 'C' parameter to set time until next filament change or other user interaction + #if ENABLED(SET_INTERACTION_TIME) + #define SHOW_INTERACTION_TIME // Display time until next user interaction ('C' = filament change) #endif + //#define M73_REPORT // Report progress to host with 'M73' +#endif - #if EITHER(HAS_MARLINUI_U8GLIB, EXTENSIBLE_UI) - //#define PRINT_PROGRESS_SHOW_DECIMALS // Show progress with decimal digits - #endif +// LCD Print Progress options, multiple can be rotated depending on screen layout +#if HAS_DISPLAY && EITHER(SDSUPPORT, SET_PROGRESS_MANUALLY) + #define SHOW_PROGRESS_PERCENT // Show print progress percentage (doesn't affect progress bar) + #define SHOW_ELAPSED_TIME // Display elapsed printing time (prefix 'E') + //#define SHOW_REMAINING_TIME // Display estimated time to completion (prefix 'R') + + //#define PRINT_PROGRESS_SHOW_DECIMALS // Show/report progress with decimal digits, not all UIs support this #if EITHER(HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL) //#define LCD_PROGRESS_BAR // Show a progress bar on HD44780 LCDs for SD printing #if ENABLED(LCD_PROGRESS_BAR) #define PROGRESS_BAR_BAR_TIME 2000 // (ms) Amount of time to show the bar #define PROGRESS_BAR_MSG_TIME 3000 // (ms) Amount of time to show the status message - #define PROGRESS_MSG_EXPIRE 0 // (ms) Amount of time to retain the status message (0=forever) + #define PROGRESS_MSG_EXPIRE 0 // (ms) Amount of time to retain the status message (0=forever) //#define PROGRESS_MSG_ONCE // Show the message for MSG_TIME then clear it //#define LCD_PROGRESS_BAR_TEST // Add a menu item to test the progress bar #endif @@ -1799,14 +1802,8 @@ #endif // HAS_MARLINUI_U8GLIB #if HAS_MARLINUI_U8GLIB || IS_DWIN_MARLINUI - // Show SD percentage next to the progress bar - //#define SHOW_SD_PERCENT - - // Enable to save many cycles by drawing a hollow frame on Menu Screens - #define MENU_HOLLOW_FRAME - - // Swap the CW/CCW indicators in the graphics overlay - //#define OVERLAY_GFX_REVERSE + #define MENU_HOLLOW_FRAME // Enable to save many cycles by drawing a hollow frame on Menu Screens + //#define OVERLAY_GFX_REVERSE // Swap the CW/CCW indicators in the graphics overlay #endif // @@ -2064,7 +2061,7 @@ */ //#define LIN_ADVANCE #if ENABLED(LIN_ADVANCE) - //#define EXTRA_LIN_ADVANCE_K // Add a second linear advance constant, configurable with M900. + //#define EXTRA_LIN_ADVANCE_K // Add a second linear advance constant, configurable with M900 L. #define LIN_ADVANCE_K 0.22 // Unit: mm compression per 1mm/s extruder speed //#define LA_DEBUG // Print debug information to serial during operation. Disable for production use. //#define EXPERIMENTAL_SCURVE // Allow S-Curve Acceleration to be used with LA. @@ -4058,7 +4055,7 @@ /** * Mechanical Gantry Calibration - * Modern replacement for the Prusa TMC_Z_CALIBRATION. + * Modern replacement for the Průša TMC_Z_CALIBRATION. * Adds capability to work with any adjustable current drivers. * Implemented as G34 because M915 is deprecated. * @section calibrate diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 0ea55b7ef458..ea57e3ccd782 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -347,7 +347,7 @@ void startOrResumeJob() { TERN_(GCODE_REPEAT_MARKERS, repeat.reset()); TERN_(CANCEL_OBJECTS, cancelable.reset()); TERN_(LCD_SHOW_E_TOTAL, e_move_accumulator = 0); - #if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME) + #if ENABLED(SET_REMAINING_TIME) ui.reset_remaining_time(); #endif } diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 405e2d460ca8..863d4320956c 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -561,8 +561,8 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 48: M48(); break; // M48: Z probe repeatability test #endif - #if ENABLED(LCD_SET_PROGRESS_MANUALLY) - case 73: M73(); break; // M73: Set progress percentage (for display on LCD) + #if ENABLED(SET_PROGRESS_MANUALLY) + case 73: M73(); break; // M73: Set progress percentage #endif case 75: M75(); break; // M75: Start print timer diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 2b15706395bd..d69298e28b53 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -114,7 +114,7 @@ * M43 - Display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins (Requires PINS_DEBUGGING) * 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) + * M73 - Set the progress percentage. (Requires SET_PROGRESS_MANUALLY) * M75 - Start the print job timer. * M76 - Pause the print job timer. * M77 - Stop the print job timer. @@ -677,7 +677,7 @@ class GcodeSuite { static void M48(); #endif - #if ENABLED(LCD_SET_PROGRESS_MANUALLY) + #if ENABLED(SET_PROGRESS_MANUALLY) static void M73(); #endif diff --git a/Marlin/src/gcode/host/M115.cpp b/Marlin/src/gcode/host/M115.cpp index a244e9802f77..d3338d396dad 100644 --- a/Marlin/src/gcode/host/M115.cpp +++ b/Marlin/src/gcode/host/M115.cpp @@ -142,7 +142,7 @@ void GcodeSuite::M115() { cap_line(F("LEVELING_DATA"), ENABLED(HAS_LEVELING)); // BUILD_PERCENT (M73) - cap_line(F("BUILD_PERCENT"), ENABLED(LCD_SET_PROGRESS_MANUALLY)); + cap_line(F("BUILD_PERCENT"), ENABLED(SET_PROGRESS_PERCENT)); // SOFTWARE_POWER (M80, M81) cap_line(F("SOFTWARE_POWER"), ENABLED(PSU_CONTROL)); diff --git a/Marlin/src/gcode/lcd/M73.cpp b/Marlin/src/gcode/lcd/M73.cpp index a86eee4d9967..77d93019acaf 100644 --- a/Marlin/src/gcode/lcd/M73.cpp +++ b/Marlin/src/gcode/lcd/M73.cpp @@ -22,21 +22,35 @@ #include "../../inc/MarlinConfig.h" -#if ENABLED(LCD_SET_PROGRESS_MANUALLY) +#if ENABLED(SET_PROGRESS_MANUALLY) #include "../gcode.h" #include "../../lcd/marlinui.h" #include "../../sd/cardreader.h" +#include "../../libs/numtostr.h" #if ENABLED(DWIN_LCD_PROUI) #include "../../lcd/e3v2/proui/dwin.h" #endif +#if ENABLED(M73_REPORT) + #define M73_REPORT_PRUSA +#endif + /** * M73: Set percentage complete (for display on LCD) * * Example: - * M73 P25 ; Set progress to 25% + * M73 P25.63 ; Set progress to 25.63% + * M73 R456 ; Set remaining time to 456 minutes + * M73 C12 ; Set next interaction countdown to 12 minutes + * M73 ; Report current values + * + * Use a shorter-than-Průša report format: + * M73 Percent done: ---%; Time left: -----m; Change: -----m; + * + * When PRINT_PROGRESS_SHOW_DECIMALS is enabled - reports percent with 100 / 23.4 / 3.45 format + * */ void GcodeSuite::M73() { @@ -46,17 +60,39 @@ void GcodeSuite::M73() { #else - if (parser.seenval('P')) - ui.set_progress((PROGRESS_SCALE) > 1 - ? parser.value_float() * (PROGRESS_SCALE) - : parser.value_byte() - ); + #if ENABLED(SET_PROGRESS_PERCENT) + if (parser.seenval('P')) + ui.set_progress((PROGRESS_SCALE) > 1 + ? parser.value_float() * (PROGRESS_SCALE) + : parser.value_byte() + ); + #endif - #if ENABLED(USE_M73_REMAINING_TIME) + #if ENABLED(SET_REMAINING_TIME) if (parser.seenval('R')) ui.set_remaining_time(60 * parser.value_ulong()); #endif + #if ENABLED(SET_INTERACTION_TIME) + if (parser.seenval('C')) ui.set_interaction_time(60 * parser.value_ulong()); + #endif + + #endif + + #if ENABLED(M73_REPORT) + { + SERIAL_ECHO_MSG( + TERN(M73_REPORT_PRUSA, "M73 Percent done: ", "Progress: ") + , TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(ui.get_progress_permyriad()), ui.get_progress_percent()) + #if ENABLED(SET_REMAINING_TIME) + , TERN(M73_REPORT_PRUSA, "; Print time remaining in mins: ", "%; Time left: "), ui.remaining_time / 60 + #endif + #if ENABLED(SET_INTERACTION_TIME) + , TERN(M73_REPORT_PRUSA, "; Change in mins: ", "m; Change: "), ui.interaction_time / 60 + #endif + , TERN(M73_REPORT_PRUSA, ";", "m") + ); + } #endif } -#endif // LCD_SET_PROGRESS_MANUALLY +#endif // SET_PROGRESS_MANUALLY diff --git a/Marlin/src/gcode/sd/M1001.cpp b/Marlin/src/gcode/sd/M1001.cpp index 197177882c31..f40435886241 100644 --- a/Marlin/src/gcode/sd/M1001.cpp +++ b/Marlin/src/gcode/sd/M1001.cpp @@ -34,7 +34,7 @@ #include "../queue.h" #endif -#if EITHER(LCD_SET_PROGRESS_MANUALLY, SD_REPRINT_LAST_SELECTED_FILE) +#if EITHER(SET_PROGRESS_MANUALLY, SD_REPRINT_LAST_SELECTED_FILE) #include "../../lcd/marlinui.h" #endif @@ -84,7 +84,7 @@ void GcodeSuite::M1001() { process_subcommands_now(F("M77")); // Set the progress bar "done" state - TERN_(LCD_SET_PROGRESS_MANUALLY, ui.set_progress_done()); + TERN_(SET_PROGRESS_PERCENT, ui.set_progress_done()); // Announce SD file completion { diff --git a/Marlin/src/gcode/sd/M23.cpp b/Marlin/src/gcode/sd/M23.cpp index 51bc82413040..8722e9b6de95 100644 --- a/Marlin/src/gcode/sd/M23.cpp +++ b/Marlin/src/gcode/sd/M23.cpp @@ -38,7 +38,7 @@ void GcodeSuite::M23() { for (char *fn = parser.string_arg; *fn; ++fn) if (*fn == ' ') *fn = '\0'; card.openFileRead(parser.string_arg); - TERN_(LCD_SET_PROGRESS_MANUALLY, ui.set_progress(0)); + TERN_(SET_PROGRESS_PERCENT, ui.set_progress(0)); } #endif // SDSUPPORT diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 5e23cedc4d38..e1c764f9f02f 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -529,10 +529,6 @@ #define HAS_MANUAL_MOVE_MENU 1 #endif -#if ANY(HAS_MARLINUI_U8GLIB, EXTENSIBLE_UI, HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL, IS_DWIN_MARLINUI, DWIN_CREALITY_LCD_JYERSUI) - #define CAN_SHOW_REMAINING_TIME 1 -#endif - #if HAS_MARLINUI_U8GLIB #ifndef LCD_PIXEL_WIDTH #define LCD_PIXEL_WIDTH 128 diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index c3f746dc72d0..ba8c3587fec0 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -599,10 +599,16 @@ #undef MENU_ADDAUTOSTART #endif -#if EITHER(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) +#if EITHER(SDSUPPORT, SET_PROGRESS_MANUALLY) #define HAS_PRINT_PROGRESS 1 #endif +#if DISABLED(SET_PROGRESS_MANUALLY) + #undef SET_REMAINING_TIME + #undef SET_INTERACTION_TIME + #undef M73_REPORT +#endif + #if ANY(HAS_MARLINUI_MENU, ULTIPANEL_FEEDMULTIPLY, SOFT_RESET_ON_KILL) #define HAS_ENCODER_ACTION 1 #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 95d0e7492261..a76ea7418b6b 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -587,7 +587,7 @@ #elif defined(MKS_LCD12864) #error "MKS_LCD12864 is now MKS_LCD12864A or MKS_LCD12864B." #elif defined(DOGM_SD_PERCENT) - #error "DOGM_SD_PERCENT is now SHOW_SD_PERCENT." + #error "DOGM_SD_PERCENT is now SHOW_PROGRESS_PERCENT." #elif defined(NEOPIXEL_BKGD_LED_INDEX) #error "NEOPIXEL_BKGD_LED_INDEX is now NEOPIXEL_BKGD_INDEX_FIRST." #elif defined(TEMP_SENSOR_1_AS_REDUNDANT) @@ -646,6 +646,12 @@ #error "TOUCH_IDLE_SLEEP (seconds) is now TOUCH_IDLE_SLEEP_MINS (minutes)." #elif defined(LCD_BACKLIGHT_TIMEOUT) #error "LCD_BACKLIGHT_TIMEOUT (seconds) is now LCD_BACKLIGHT_TIMEOUT_MINS (minutes)." +#elif defined(LCD_SET_PROGRESS_MANUALLY) + #error "LCD_SET_PROGRESS_MANUALLY is now SET_PROGRESS_MANUALLY." +#elif defined(USE_M73_REMAINING_TIME) + #error "USE_M73_REMAINING_TIME is now SET_REMAINING_TIME." +#elif defined(SHOW_SD_PERCENT) + #error "SHOW_SD_PERCENT is now SHOW_PROGRESS_PERCENT." #endif // L64xx stepper drivers have been removed @@ -894,8 +900,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS * Progress Bar */ #if ENABLED(LCD_PROGRESS_BAR) - #if NONE(SDSUPPORT, LCD_SET_PROGRESS_MANUALLY) - #error "LCD_PROGRESS_BAR requires SDSUPPORT or LCD_SET_PROGRESS_MANUALLY." + #if NONE(SDSUPPORT, SET_PROGRESS_MANUALLY) + #error "LCD_PROGRESS_BAR requires SDSUPPORT or SET_PROGRESS_MANUALLY." #elif NONE(HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL) #error "LCD_PROGRESS_BAR only applies to HD44780 character LCD and TFTGLCD_PANEL_(SPI|I2C)." #elif HAS_MARLINUI_U8GLIB || IS_DWIN_MARLINUI @@ -905,12 +911,14 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #elif PROGRESS_MSG_EXPIRE < 0 #error "PROGRESS_MSG_EXPIRE must be greater than or equal to 0." #endif -#elif ENABLED(LCD_SET_PROGRESS_MANUALLY) && NONE(HAS_MARLINUI_U8GLIB, HAS_GRAPHICAL_TFT, HAS_MARLINUI_HD44780, EXTENSIBLE_UI, HAS_DWIN_E3V2, IS_DWIN_MARLINUI) - #error "LCD_SET_PROGRESS_MANUALLY requires LCD_PROGRESS_BAR, Character LCD, Graphical LCD, TFT, DWIN_CREALITY_LCD, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI, DWIN_MARLINUI_*, OR EXTENSIBLE_UI." #endif -#if ENABLED(USE_M73_REMAINING_TIME) && DISABLED(LCD_SET_PROGRESS_MANUALLY) - #error "USE_M73_REMAINING_TIME requires LCD_SET_PROGRESS_MANUALLY" +#if ENABLED(SET_PROGRESS_MANUALLY) && NONE(SET_PROGRESS_PERCENT, SET_REMAINING_TIME, SET_INTERACTION_TIME) + #error "SET_PROGRESS_MANUALLY requires at least one of SET_PROGRESS_PERCENT, SET_REMAINING_TIME, SET_INTERACTION_TIME to be enabled." +#endif + +#if HAS_LCDPRINT && LCD_HEIGHT < 4 && ANY(SHOW_PROGRESS_PERCENT, SHOW_ELAPSED_TIME, SHOW_REMAINING_TIME, SHOW_INTERACTION_TIME) + #error "Displays with fewer than 4 rows of text can't show progress values." #endif #if !HAS_MARLINUI_MENU && ENABLED(SD_REPRINT_LAST_SELECTED_FILE) @@ -4038,10 +4046,6 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #error "COOLANT_FLOOD requires COOLANT_FLOOD_PIN to be defined." #endif -#if NONE(HAS_MARLINUI_U8GLIB, EXTENSIBLE_UI, IS_DWIN_MARLINUI) && ENABLED(PRINT_PROGRESS_SHOW_DECIMALS) - #error "PRINT_PROGRESS_SHOW_DECIMALS currently requires a Graphical LCD." -#endif - #if HAS_ADC_BUTTONS && defined(ADC_BUTTON_DEBOUNCE_DELAY) && ADC_BUTTON_DEBOUNCE_DELAY < 16 #error "ADC_BUTTON_DEBOUNCE_DELAY must be greater than 16." #endif diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index b8dc8db8177a..ba222897fccf 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -612,20 +612,6 @@ FORCE_INLINE void _draw_bed_status(const bool blink) { _draw_heater_status(H_BED, TERN0(HAS_LEVELING, blink && planner.leveling_active) ? '_' : LCD_STR_BEDTEMP[0], blink); } -#if HAS_PRINT_PROGRESS - - FORCE_INLINE void _draw_print_progress() { - const uint8_t progress = ui.get_progress_percent(); - lcd_put_u8str(F(TERN(SDSUPPORT, "SD", "P:"))); - if (progress) - lcd_put_u8str(ui8tostr3rj(progress)); - else - lcd_put_u8str(F("---")); - lcd_put_lchar('%'); - } - -#endif - #if ENABLED(LCD_PROGRESS_BAR) void MarlinUI::draw_progress_bar(const uint8_t percent) { @@ -733,6 +719,56 @@ void MarlinUI::draw_status_message(const bool blink) { #endif } +#if HAS_PRINT_PROGRESS + #define TPOFFSET (LCD_WIDTH - 1) + static uint8_t timepos = TPOFFSET - 6; + static char buffer[14]; + static lcd_uint_t pc, pr; + + #if ENABLED(SHOW_PROGRESS_PERCENT) + void MarlinUI::drawPercent() { + const uint8_t progress = ui.get_progress_percent(); + if (progress) { + lcd_moveto(pc, pr); + lcd_put_u8str(F(TERN(IS_SD_PRINTING, "SD", "P:"))); + lcd_put_u8str(TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(ui.get_progress_permyriad()), ui8tostr3rj(progress))); + lcd_put_lchar('%'); + } + } + #endif + #if ENABLED(SHOW_REMAINING_TIME) + void MarlinUI::drawRemain() { + const duration_t remaint = ui.get_remaining_time(); + if (printJobOngoing()) { + timepos = TPOFFSET - remaint.toDigital(buffer); + lcd_put_lchar(TERN(LCD_INFO_SCREEN_STYLE, 11, timepos), 2, 'R'); + lcd_put_u8str(buffer); + } + } + #endif + #if ENABLED(SHOW_INTERACTION_TIME) + void MarlinUI::drawInter() { + const duration_t interactt = ui.interaction_time; + if (printingIsActive() && interactt.value) { + timepos = TPOFFSET - interactt.toDigital(buffer); + lcd_put_lchar(TERN(LCD_INFO_SCREEN_STYLE, 11, timepos), 2, 'C'); + lcd_put_u8str(buffer); + } + } + #endif + #if ENABLED(SHOW_ELAPSED_TIME) + void MarlinUI::drawElapsed() { + const duration_t elapsedt = print_job_timer.duration(); + if (printJobOngoing()) { + timepos = TPOFFSET - elapsedt.toDigital(buffer); + lcd_put_lchar(TERN(LCD_INFO_SCREEN_STYLE, 11, timepos), 2, 'E'); + //lcd_put_lchar(timepos, 2, LCD_STR_CLOCK[0]); + lcd_put_u8str(buffer); + } + } + #endif +#endif // HAS_PRINT_PROGRESS + /** * LCD_INFO_SCREEN_STYLE 0 : Classic Status Screen * @@ -765,35 +801,6 @@ void MarlinUI::draw_status_message(const bool blink) { * |01234567890123456789| */ -inline uint8_t draw_elapsed_or_remaining_time(uint8_t timepos, const bool blink) { - char buffer[14]; - - #if ENABLED(SHOW_REMAINING_TIME) - const bool show_remain = TERN1(ROTATE_PROGRESS_DISPLAY, blink) && printingIsActive(); - if (show_remain) { - #if ENABLED(USE_M73_REMAINING_TIME) - duration_t remaining = ui.get_remaining_time(); - #else - uint8_t progress = ui.get_progress_percent(); - uint32_t elapsed = print_job_timer.duration(); - duration_t remaining = (progress > 0) ? ((elapsed * 25600 / progress) >> 8) - elapsed : 0; - #endif - timepos -= remaining.toDigital(buffer); - lcd_put_lchar(timepos, 2, 'R'); - } - #else - constexpr bool show_remain = false; - #endif - - if (!show_remain) { - duration_t elapsed = print_job_timer.duration(); - timepos -= elapsed.toDigital(buffer); - lcd_put_lchar(timepos, 2, LCD_STR_CLOCK[0]); - } - lcd_put_u8str(buffer); - return timepos; -} - void MarlinUI::draw_status_screen() { const bool blink = get_blink(); @@ -856,8 +863,8 @@ void MarlinUI::draw_status_screen() { #if LCD_WIDTH < 20 #if HAS_PRINT_PROGRESS - lcd_moveto(0, 2); - _draw_print_progress(); + pc = 0, pr = 2; + rotate_progress(); #endif #else // LCD_WIDTH >= 20 @@ -940,12 +947,11 @@ void MarlinUI::draw_status_screen() { lcd_put_u8str(i16tostr3rj(feedrate_percentage)); lcd_put_lchar('%'); - const uint8_t timepos = draw_elapsed_or_remaining_time(LCD_WIDTH - 1, blink); - #if LCD_WIDTH >= 20 - lcd_moveto(timepos - 7, 2); + #if HAS_PRINT_PROGRESS - _draw_print_progress(); + pc = timepos - 7, pr = 2; + rotate_progress(); #else char c; uint16_t per; @@ -1016,7 +1022,7 @@ void MarlinUI::draw_status_screen() { // ========== Line 3 ========== // - // SD Percent, Hotend 2, or Bed + // Progress percent, Hotend 2, or Bed // lcd_moveto(0, 2); #if HOTENDS > 2 @@ -1025,24 +1031,17 @@ void MarlinUI::draw_status_screen() { _draw_bed_status(blink); #elif HAS_PRINT_PROGRESS #define DREW_PRINT_PROGRESS 1 - _draw_print_progress(); + pc = 0, pr = 2; + rotate_progress(); #endif // - // Elapsed Time or SD Percent + // All progress strings // - lcd_moveto(LCD_WIDTH - 9, 2); - #if HAS_PRINT_PROGRESS && !DREW_PRINT_PROGRESS - - _draw_print_progress(); - - #else - - (void)draw_elapsed_or_remaining_time(LCD_WIDTH - 4, blink); - + pc = LCD_WIDTH - 9, pr = 2; + rotate_progress(); #endif - #endif // LCD_INFO_SCREEN_STYLE 1 // ========= Last Line ======== diff --git a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp index f3d98ec55584..029a04bf97c8 100644 --- a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp @@ -606,7 +606,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const const uint8_t progress = ui._get_progress(); #if ENABLED(SDSUPPORT) lcd_put_u8str(F("SD")); - #elif ENABLED(LCD_SET_PROGRESS_MANUALLY) + #elif ENABLED(SET_PROGRESS_PERCENT) lcd_put_u8str(F("P:")); #endif if (progress) diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index 67039d52de7b..81119c0a1089 100644 --- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -40,9 +40,7 @@ #include "../../gcode/parser.h" // for units (and volumetric) -#if ENABLED(LCD_SHOW_E_TOTAL) - #include "../../MarlinCore.h" // for printingIsActive() -#endif +#include "../../MarlinCore.h" // for printingIsActive() #if ENABLED(FILAMENT_LCD_DISPLAY) #include "../../feature/filwidth.h" @@ -445,6 +443,55 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const lcd_put_u8str(value); } +// Prepare strings for progress display +#if HAS_PRINT_PROGRESS + #define _PRGR_INFO_X(len) (LCD_PIXEL_WIDTH - (len) * (MENU_FONT_WIDTH)) + #define PCENTERED 1 // center percent value over progress bar, else align to the right + static uint8_t lastProgress = 0xFF; + static u8g_uint_t progress_bar_solid_width = 0; + #if ENABLED(SHOW_PROGRESS_PERCENT) + static char progress_string[5]; + static u8g_uint_t progress_x_pos; + void MarlinUI::drawPercent() { + if (progress_string[0]) { + lcd_put_u8str(progress_x_pos, EXTRAS_BASELINE, progress_string); + lcd_put_lchar('%'); + } + } + #endif + #if ENABLED(SHOW_REMAINING_TIME) + static char remaining_string[10]; + static u8g_uint_t remaining_x_pos = 0; + void MarlinUI::drawRemain() { + if (printJobOngoing()){ + lcd_put_u8str(PROGRESS_BAR_X, EXTRAS_BASELINE, F("R:")); + lcd_put_u8str(remaining_x_pos, EXTRAS_BASELINE, remaining_string); + } + } + #endif + #if ENABLED(SHOW_INTERACTION_TIME) + static char interaction_string[10]; + static u8g_uint_t interaction_x_pos = 0; + void MarlinUI::drawInter() { + if (printingIsActive() && interaction_string[0]) { + lcd_put_u8str(PROGRESS_BAR_X, EXTRAS_BASELINE, F("C:")); + lcd_put_u8str(interaction_x_pos, EXTRAS_BASELINE, interaction_string); + } + } + #endif + #if ENABLED(SHOW_ELAPSED_TIME) + static char elapsed_string[10]; + static u8g_uint_t elapsed_x_pos = 0; + static uint8_t lastElapsed; + void MarlinUI::drawElapsed() { + if (printJobOngoing()) { + lcd_put_u8str(PROGRESS_BAR_X, EXTRAS_BASELINE, F("E:")); + lcd_put_u8str(elapsed_x_pos, EXTRAS_BASELINE, elapsed_string); + } + } + #endif +#endif // HAS_PRINT_PROGRESS + /** * Draw the Status Screen for a 128x64 DOGM (U8glib) display. * @@ -459,30 +506,6 @@ void MarlinUI::draw_status_screen() { static char wstring[5], mstring[4]; #endif - #if HAS_PRINT_PROGRESS - #if DISABLED(SHOW_SD_PERCENT) - #define _SD_INFO_X(len) (PROGRESS_BAR_X + (PROGRESS_BAR_WIDTH) / 2 - (len) * (MENU_FONT_WIDTH) / 2) - #else - #define _SD_INFO_X(len) (LCD_PIXEL_WIDTH - (len) * (MENU_FONT_WIDTH)) - #endif - - #if ENABLED(SHOW_SD_PERCENT) - static char progress_string[5]; - #endif - static uint8_t lastElapsed = 0xFF, lastProgress = 0xFF; - static u8g_uint_t elapsed_x_pos = 0, progress_bar_solid_width = 0; - static char elapsed_string[16]; - #if ENABLED(SHOW_REMAINING_TIME) - static u8g_uint_t estimation_x_pos = 0; - static char estimation_string[10]; - #if BOTH(SHOW_SD_PERCENT, ROTATE_PROGRESS_DISPLAY) - static u8g_uint_t progress_x_pos = 0; - static uint8_t progress_state = 0; - static bool prev_blink = 0; - #endif - #endif - #endif - const bool show_e_total = TERN0(LCD_SHOW_E_TOTAL, printingIsActive()); // At the first page, generate new display values @@ -523,61 +546,59 @@ void MarlinUI::draw_status_screen() { // Progress / elapsed / estimation updates and string formatting to avoid float math on each LCD draw #if HAS_PRINT_PROGRESS const progress_t progress = TERN(HAS_PRINT_PROGRESS_PERMYRIAD, get_progress_permyriad, get_progress_percent)(); - duration_t elapsed = print_job_timer.duration(); - const uint8_t p = progress & 0xFF, ev = elapsed.value & 0xFF; + duration_t elapsedt = print_job_timer.duration(); + const uint8_t p = progress & 0xFF, ev = elapsedt.value & 0xFF; if (p != lastProgress) { lastProgress = p; progress_bar_solid_width = u8g_uint_t((PROGRESS_BAR_WIDTH - 2) * (progress / (PROGRESS_SCALE)) * 0.01f); - #if ENABLED(SHOW_SD_PERCENT) - if (progress == 0) { + #if ENABLED(SHOW_PROGRESS_PERCENT) + if (progress == 0) progress_string[0] = '\0'; - #if ENABLED(SHOW_REMAINING_TIME) - estimation_string[0] = '\0'; - estimation_x_pos = _SD_INFO_X(0); - #endif - } else strcpy(progress_string, TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(progress), ui8tostr3rj(progress / (PROGRESS_SCALE)))); - - #if BOTH(SHOW_REMAINING_TIME, ROTATE_PROGRESS_DISPLAY) // Tri-state progress display mode - progress_x_pos = _SD_INFO_X(strlen(progress_string) + 1); - #endif + progress_x_pos = TERN(PCENTERED, 77, _PRGR_INFO_X(strlen(progress_string) + 1)); #endif } - constexpr bool can_show_days = DISABLED(SHOW_SD_PERCENT) || ENABLED(ROTATE_PROGRESS_DISPLAY); - if (ev != lastElapsed) { - lastElapsed = ev; - const uint8_t len = elapsed.toDigital(elapsed_string, can_show_days && elapsed.value >= 60*60*24L); - elapsed_x_pos = _SD_INFO_X(len); - - #if ENABLED(SHOW_REMAINING_TIME) - if (!(ev & 0x3)) { - uint32_t timeval = (0 - #if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME) - + get_remaining_time() - #endif - ); - if (!timeval && progress > 0) timeval = elapsed.value * (100 * (PROGRESS_SCALE) - progress) / progress; - if (!timeval) { - estimation_string[0] = '\0'; - estimation_x_pos = _SD_INFO_X(0); - } - else { - duration_t estimation = timeval; - const uint8_t len = estimation.toDigital(estimation_string, can_show_days && estimation.value >= 60*60*24L); - estimation_x_pos = _SD_INFO_X(len + !BOTH(SHOW_SD_PERCENT, ROTATE_PROGRESS_DISPLAY)); - } + #if ENABLED(SHOW_INTERACTION_TIME) + if (!(interaction_time)) { + interaction_string[0] = '\0'; + interaction_x_pos = _PRGR_INFO_X(0); + } + else { + const duration_t interactt = ui.interaction_time; + interactt.toDigital(interaction_string, interactt.value >= 60*60*24L); + interaction_x_pos = _PRGR_INFO_X(strlen(interaction_string)); + } + #endif + + #if ENABLED(SHOW_ELAPSED_TIME) + if (ev != lastElapsed) { + lastElapsed = ev; + const uint8_t len = elapsedt.toDigital(elapsed_string, elapsedt.value >= 60*60*24L); + elapsed_x_pos = _PRGR_INFO_X(len); + } + #endif + + #if ENABLED(SHOW_REMAINING_TIME) + if (!(ev & 0x3)) { + uint32_t timeval = get_remaining_time(); + if (!timeval) { + remaining_string[0] = '\0'; + remaining_x_pos = _PRGR_INFO_X(0); } - #endif - } + else { + const duration_t remaint = timeval; + const uint8_t len = remaint.toDigital(remaining_string, remaint.value >= 60*60*24L); + remaining_x_pos = _PRGR_INFO_X(len); + } + } + #endif #endif } - const bool blink = get_blink(); - // Status Menu Font set_font(FONT_STATUSMENU); @@ -634,6 +655,8 @@ void MarlinUI::draw_status_screen() { u8g.drawBitmapP(STATUS_CHAMBER_X, chambery, STATUS_CHAMBER_BYTEWIDTH, chamberh, CHAMBER_BITMAP(CHAMBER_ALT())); #endif + const bool blink = ui.get_blink(); + #if DO_DRAW_FAN #if STATUS_FAN_FRAMES > 2 static bool old_blink; @@ -664,8 +687,7 @@ void MarlinUI::draw_status_screen() { if (PAGE_UNDER(6 + 1 + 12 + 1 + 6 + 1)) { // Extruders #if DO_DRAW_HOTENDS - LOOP_L_N(e, MAX_HOTEND_DRAW) - _draw_hotend_status((heater_id_t)e, blink); + LOOP_L_N(e, MAX_HOTEND_DRAW) _draw_hotend_status((heater_id_t)e, blink); #endif // Laser / Spindle @@ -757,74 +779,18 @@ void MarlinUI::draw_status_screen() { #endif // SDSUPPORT #if HAS_PRINT_PROGRESS - // // Progress bar frame - // - if (PAGE_CONTAINS(PROGRESS_BAR_Y, PROGRESS_BAR_Y + 3)) u8g.drawFrame(PROGRESS_BAR_X, PROGRESS_BAR_Y, PROGRESS_BAR_WIDTH, 4); - // // Progress bar solid part - // - if (PAGE_CONTAINS(PROGRESS_BAR_Y + 1, PROGRESS_BAR_Y + 2)) u8g.drawBox(PROGRESS_BAR_X + 1, PROGRESS_BAR_Y + 1, progress_bar_solid_width, 2); - if (PAGE_CONTAINS(EXTRAS_BASELINE - INFO_FONT_ASCENT, EXTRAS_BASELINE - 1)) { - - #if ALL(SHOW_SD_PERCENT, SHOW_REMAINING_TIME, ROTATE_PROGRESS_DISPLAY) - - if (prev_blink != blink) { - prev_blink = blink; - if (++progress_state >= 3) progress_state = 0; - } - - if (progress_state == 0) { - if (progress_string[0]) { - lcd_put_u8str(progress_x_pos, EXTRAS_BASELINE, progress_string); - lcd_put_lchar('%'); - } - } - else if (progress_state == 2 && estimation_string[0]) { - lcd_put_u8str(PROGRESS_BAR_X, EXTRAS_BASELINE, F("R:")); - lcd_put_u8str(estimation_x_pos, EXTRAS_BASELINE, estimation_string); - } - else if (elapsed_string[0]) { - lcd_put_u8str(PROGRESS_BAR_X, EXTRAS_BASELINE, F("E:")); - lcd_put_u8str(elapsed_x_pos, EXTRAS_BASELINE, elapsed_string); - } - - #else // !SHOW_SD_PERCENT || !SHOW_REMAINING_TIME || !ROTATE_PROGRESS_DISPLAY - - // - // SD Percent Complete - // - - #if ENABLED(SHOW_SD_PERCENT) - if (progress_string[0]) { - lcd_put_u8str(55, EXTRAS_BASELINE, progress_string); // Percent complete - lcd_put_lchar('%'); - } - #endif - - // - // Elapsed Time - // - - #if ENABLED(SHOW_REMAINING_TIME) - if (blink && estimation_string[0]) { - lcd_put_lchar(estimation_x_pos, EXTRAS_BASELINE, 'R'); - lcd_put_u8str(estimation_string); - } - else - #endif - lcd_put_u8str(elapsed_x_pos, EXTRAS_BASELINE, elapsed_string); - - #endif // !SHOW_SD_PERCENT || !SHOW_REMAINING_TIME || !ROTATE_PROGRESS_DISPLAY - } - - #endif // HAS_PRINT_PROGRESS + // Progress strings + if (PAGE_CONTAINS(EXTRAS_BASELINE - INFO_FONT_ASCENT, EXTRAS_BASELINE - 1)) + ui.rotate_progress(); + #endif // // XYZ Coordinates diff --git a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp index 492a79a31108..9ed0d8a9d674 100644 --- a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp +++ b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.cpp @@ -40,12 +40,38 @@ // Lightweight Status Screen for Graphical Display // +/** One hotend layout + * ------------------ + * |⟱ xxx➜xxx° ✱xxx% + * |_ xxx➜xxx° Fxxx% + * ||||||||||R•xxx:xx + * | status string + * ------------------ + * + * hotend temp | fan speed + * bed temp | feedrate + * progress bar| progress time + * status string + * + * **************************** + * Two hotends layout + * ------------------ + * |⟱ xxx➜xxx° ✱xxx% + * |⟱ xxx➜xxx°||||||| + * |_ xxx➜xxx°Rxxx:xx + * | status string + * ------------------ + * + * hotend temp | fan speed + * hotend temp | progress bar + * bed temp | progress time + * status string + */ + #include "../../inc/MarlinConfigPre.h" #if ENABLED(LIGHTWEIGHT_UI) -#include "status_screen_lite_ST7920.h" - #include "../marlinui.h" #include "../fontutils.h" #include "../lcdprint.h" @@ -53,12 +79,13 @@ #include "../../module/motion.h" #include "../../module/printcounter.h" #include "../../module/temperature.h" +#include "../../libs/numtostr.h" #if ENABLED(SDSUPPORT) #include "../../sd/cardreader.h" #endif -#if ENABLED(LCD_SHOW_E_TOTAL) +#if ENABLED(LCD_SHOW_E_TOTAL) || HAS_PRINT_PROGRESS #include "../../MarlinCore.h" // for printingIsActive #endif @@ -72,6 +99,9 @@ #define DDRAM_LINE_3 0x08 #define DDRAM_LINE_4 0x18 +#include "status_screen_lite_ST7920.h" +extern ST7920_Lite_Status_Screen lightUI; + ST7920_Lite_Status_Screen::st7920_state_t ST7920_Lite_Status_Screen::current_bits; void ST7920_Lite_Status_Screen::cmd(const uint8_t cmd) { @@ -442,72 +472,6 @@ void ST7920_Lite_Status_Screen::draw_static_elements() { draw_fan_icon(false); } -/** - * Although this is undocumented, the ST7920 allows the character - * data buffer (DDRAM) to be used in conjunction with the graphics - * bitmap buffer (CGRAM). The contents of the graphics buffer is - * XORed with the data from the character generator. This allows - * us to make the progress bar out of graphical data (the bar) and - * text data (the percentage). - */ -void ST7920_Lite_Status_Screen::draw_progress_bar(const uint8_t value) { - #if HOTENDS == 1 - // If we have only one extruder, draw a long progress bar on the third line - constexpr uint8_t top = 1, // Top in pixels - bottom = 13, // Bottom in pixels - left = 12, // Left edge, in 16-bit words - width = 4; // Width of progress bar, in 16-bit words - #else - constexpr uint8_t top = 16 + 1, - bottom = 16 + 13, - left = 5, - width = 3; - #endif - const uint8_t char_pcnt = 100 / width; // How many percent does each 16-bit word represent? - - // Draw the progress bar as a bitmap in CGRAM - LOOP_S_LE_N(y, top, bottom) { - set_gdram_address(left, y); - begin_data(); - LOOP_L_N(x, width) { - uint16_t gfx_word = 0x0000; - if ((x + 1) * char_pcnt <= value) - gfx_word = 0xFFFF; // Draw completely filled bytes - else if ((x * char_pcnt) < value) - gfx_word = int(0x8000) >> (value % char_pcnt) * 16 / char_pcnt; // Draw partially filled bytes - - // Draw the frame around the progress bar - if (y == top || y == bottom) - gfx_word = 0xFFFF; // Draw top/bottom border - else if (x == width - 1) - gfx_word |= 0x0001; // Draw right border - else if (x == 0) - gfx_word |= 0x8000; // Draw left border - write_word(gfx_word); - } - } - - // Draw the percentage as text in DDRAM - #if HOTENDS == 1 - set_ddram_address(DDRAM_LINE_3 + 4); - begin_data(); - write_byte(' '); - #else - set_ddram_address(DDRAM_LINE_2 + left); - begin_data(); - #endif - - // Draw centered - if (value > 9) { - write_number(value, 4); - write_str(F("% ")); - } - else { - write_number(value, 3); - write_str(F("% ")); - } -} - void ST7920_Lite_Status_Screen::draw_fan_icon(const bool whichIcon) { set_ddram_address(DDRAM_LINE_1 + 5); begin_data(); @@ -592,22 +556,8 @@ void ST7920_Lite_Status_Screen::draw_fan_speed(const uint8_t value) { write_byte('%'); } -void ST7920_Lite_Status_Screen::draw_print_time(const duration_t &elapsed, char suffix) { - #if HOTENDS == 1 - set_ddram_address(DDRAM_LINE_3); - #else - set_ddram_address(DDRAM_LINE_3 + 5); - #endif - char str[7]; - int str_length = elapsed.toDigital(str); - str[str_length++] = suffix; - begin_data(); - write_str(str, str_length); -} - void ST7920_Lite_Status_Screen::draw_feedrate_percentage(const uint16_t percentage) { - // We only have enough room for the feedrate when - // we have one extruder + // We only have enough room for the feedrate when we have one extruder #if HOTENDS == 1 set_ddram_address(DDRAM_LINE_2 + 6); begin_data(); @@ -631,11 +581,9 @@ void ST7920_Lite_Status_Screen::draw_status_message() { write_str(str); while (slen < TEXT_MODE_LCD_WIDTH) { write_byte(' '); ++slen; } } - else { - // String is larger than the available space in screen. + else { // String is larger than the available space in ST7920_Lite_Status_Screen:: - // Get a pointer to the next valid UTF8 character - // and the string remaining length + // Get a pointer to the next valid UTF8 character and the string remaining length uint8_t rlen; const char *stat = ui.status_and_len(rlen); write_str(stat, TEXT_MODE_LCD_WIDTH); @@ -643,12 +591,12 @@ void ST7920_Lite_Status_Screen::draw_status_message() { // If the remaining string doesn't completely fill the screen if (rlen < TEXT_MODE_LCD_WIDTH) { uint8_t chars = TEXT_MODE_LCD_WIDTH - rlen; // Amount of space left in characters - write_byte(' '); // Always at 1+ spaces left, draw a space - if (--chars) { // Draw a second space if there's room + write_byte(' '); // Always at 1+ spaces left, draw a space + if (--chars) { // Draw a second space if there's room write_byte(' '); - if (--chars) { // Draw a third space if there's room + if (--chars) { // Draw a third space if there's room write_byte(' '); - if (--chars) write_str(str, chars); // Print a second copy of the message + if (--chars) write_str(str, chars); // Print a second copy of the message } } } @@ -715,11 +663,155 @@ bool ST7920_Lite_Status_Screen::indicators_changed() { return true; } +// Process progress strings +#if HAS_PRINT_PROGRESS + static char screenstr[8]; + + char * ST7920_Lite_Status_Screen::prepare_time_string(const duration_t &time, char prefix) { + static char str[6]; + memset(&screenstr, 0x20, 8); // fill with spaces to avoid artifacts, not doing right-justification to save cycles + screenstr[0] = prefix; + TERN_(HOTENDS == 1, screenstr[1] = 0x07;) // add bullet • separator when there is space + int str_length = time.toDigital(str); + memcpy(&screenstr[TERN(HOTENDS == 1, 2, 1)], str, str_length); //memcpy because we can't have terminator + return screenstr; + } + + void ST7920_Lite_Status_Screen::draw_progress_string(uint8_t addr, const char *str) { + set_ddram_address(addr); + begin_data(); + write_str(str, TERN(HOTENDS == 1, 8, 6)); + } + + #define PPOS (DDRAM_LINE_3 + TERN(HOTENDS == 1, 4, 5)) // progress string position, in 16-bit words + + #if ENABLED(SHOW_PROGRESS_PERCENT) + void MarlinUI::drawPercent() { lightUI.drawPercent(); } + void ST7920_Lite_Status_Screen::drawPercent() { + #define LSHIFT TERN(HOTENDS == 1, 0, 1) + const uint8_t progress = ui.get_progress_percent(); + memset(&screenstr, 0x20, 8); // fill with spaces to avoid artifacts + if (progress){ + memcpy(&screenstr[2 - LSHIFT], \ + TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(ui.get_progress_permyriad()), ui8tostr3rj(progress)), \ + TERN(PRINT_PROGRESS_SHOW_DECIMALS, 4, 3)); + screenstr[(TERN(PRINT_PROGRESS_SHOW_DECIMALS, 6, 5) - LSHIFT)] = '%'; + draw_progress_string(PPOS, screenstr); + } + } + #endif + #if ENABLED(SHOW_REMAINING_TIME) + void MarlinUI::drawRemain() { lightUI.drawRemain(); } + void ST7920_Lite_Status_Screen::drawRemain() { + const duration_t remaint = TERN0(SET_REMAINING_TIME, ui.get_remaining_time()); + if (printJobOngoing() && remaint.value) { + draw_progress_string( PPOS, prepare_time_string(remaint, 'R')); + } + } + #endif + #if ENABLED(SHOW_INTERACTION_TIME) + void MarlinUI::drawInter() { lightUI.drawInter(); } + void ST7920_Lite_Status_Screen::drawInter() { + const duration_t interactt = ui.interaction_time; + if (printingIsActive() && interactt.value) { + draw_progress_string( PPOS, prepare_time_string(interactt, 'C')); + } + } + #endif + #if ENABLED(SHOW_ELAPSED_TIME) + void MarlinUI::drawElapsed() { lightUI.drawElapsed(); } + void ST7920_Lite_Status_Screen::drawElapsed() { + if (printJobOngoing()) { + const duration_t elapsedt = print_job_timer.duration(); + draw_progress_string( PPOS, prepare_time_string(elapsedt, 'E')); + } + } + #endif + + /** + * Although this is undocumented, the ST7920 allows the character + * data buffer (DDRAM) to be used in conjunction with the graphics + * bitmap buffer (CGRAM). The contents of the graphics buffer is + * XORed with the data from the character generator. This allows + * us to make the progress bar out of graphical data (the bar) and + * text data (the percentage). + */ + void ST7920_Lite_Status_Screen::draw_progress_bar(const uint8_t value) { + #if HOTENDS == 1 + // If we have only one extruder, draw a long progress bar on the third line + constexpr uint8_t top = 1, // Top in pixels + bottom = 13, // Bottom in pixels + left = 8, // Left edge, in 16-bit words + width = 4; // Width of progress bar, in 16-bit words + #else + constexpr uint8_t top = 16 + 1, + bottom = 16 + 13, + left = 5, + width = 3; + #endif + const uint8_t char_pcnt = 100 / width; // How many percent does each 16-bit word represent? + + // Draw the progress bar as a bitmap in CGRAM + // This drawing is a mess and only produce readable result around 25% steps + // i.e. 74-76% look fine [|||||||||||||||||||||||| ], but 73% look like this: [|||||||||||||||| | ] + // meaning partially filled bytes produce only single vertical line, and i bet they're not supposed to! + LOOP_S_LE_N(y, top, bottom) { + set_gdram_address(left, y); + begin_data(); + LOOP_L_N(x, width) { + uint16_t gfx_word = 0x0000; + if ((x + 1) * char_pcnt <= value) + gfx_word = 0xFFFF; // Draw completely filled bytes + else if ((x * char_pcnt) < value) + gfx_word = int16_t(0x8000) >> (value % char_pcnt) * 16 / char_pcnt; // Draw partially filled bytes + + // Draw the frame around the progress bar + if (y == top || y == bottom) + gfx_word = 0xFFFF; // Draw top/bottom border + else if (x == width - 1) + gfx_word |= 0x0001; // Draw right border + else if (x == 0) + gfx_word |= 0x8000; // Draw left border + write_word(gfx_word); + } + } + + // // Draw the percentage as text in DDRAM + // #if HOTENDS == 1 + // set_ddram_address(DDRAM_LINE_3 + 4); + // begin_data(); + // write_byte(' '); + // #else + // set_ddram_address(DDRAM_LINE_2 + left); + // begin_data(); + // #endif + + // // Draw centered + // if (value > 9) + // write_number(value, 4); + // else + // write_number(value, 3); + // write_str(F("% ")); + } + + void ST7920_Lite_Status_Screen::update_progress(const bool forceUpdate) { + + // Since the progress bar involves writing + // quite a few bytes to GDRAM, only do this + // when an update is actually necessary. + + const uint8_t progress = ui.get_progress_percent(); + static uint8_t last_progress = 0; + if (forceUpdate || last_progress != progress/2) { + last_progress = progress/2; // Because progress bar turns out only 62||46px wide, we only need to redraw it every 2% + draw_progress_bar(progress); + } + } +#endif // HAS_PRINT_PROGRESS + void ST7920_Lite_Status_Screen::update_indicators(const bool forceUpdate) { if (forceUpdate || indicators_changed()) { const bool blink = ui.get_blink(); - const duration_t elapsed = print_job_timer.duration(); - duration_t remaining = TERN0(USE_M73_REMAINING_TIME, ui.get_remaining_time()); const uint16_t feedrate_perc = feedrate_percentage; const celsius_t extruder_1_temp = thermalManager.wholeDegHotend(0), extruder_1_target = thermalManager.degTargetHotend(0); @@ -736,30 +828,20 @@ void ST7920_Lite_Status_Screen::update_indicators(const bool forceUpdate) { TERN_(HAS_MULTI_HOTEND, draw_extruder_2_temp(extruder_2_temp, extruder_2_target, forceUpdate)); TERN_(HAS_HEATED_BED, draw_bed_temp(bed_temp, bed_target, forceUpdate)); + // Update the fan and bed animations uint8_t spd = thermalManager.fan_speed[0]; #if ENABLED(ADAPTIVE_FAN_SLOWING) if (!blink && thermalManager.fan_speed_scaler[0] < 128) spd = thermalManager.scaledFanSpeed(0, spd); #endif draw_fan_speed(thermalManager.pwmToPercent(spd)); - - // Draw elapsed/remaining time - const bool show_remaining = ENABLED(SHOW_REMAINING_TIME) && (DISABLED(ROTATE_PROGRESS_DISPLAY) || blink); - if (show_remaining && !remaining.second()) { - const auto progress = ui.get_progress_percent(); - if (progress) - remaining = elapsed.second() * (100 - progress) / progress; - } - if (show_remaining && remaining.second()) - draw_print_time(remaining, 'R'); - else - draw_print_time(elapsed); + if (spd) draw_fan_icon(blink); + TERN_(HAS_HEATED_BED, draw_heat_icon(bed_target > 0 && blink, bed_target > 0)); draw_feedrate_percentage(feedrate_perc); - // Update the fan and bed animations - if (spd) draw_fan_icon(blink); - TERN_(HAS_HEATED_BED, draw_heat_icon(bed_target > 0 && blink, bed_target > 0)); + // Update and draw progress strings + TERN_(HAS_PRINT_PROGRESS, ui.rotate_progress()); } } @@ -839,27 +921,6 @@ void ST7920_Lite_Status_Screen::update_status_or_position(bool forceUpdate) { #endif } -void ST7920_Lite_Status_Screen::update_progress(const bool forceUpdate) { - #if EITHER(LCD_SET_PROGRESS_MANUALLY, SDSUPPORT) - - // Since the progress bar involves writing - // quite a few bytes to GDRAM, only do this - // when an update is actually necessary. - - static uint8_t last_progress = 0; - const uint8_t progress = ui.get_progress_percent(); - if (forceUpdate || last_progress != progress) { - last_progress = progress; - draw_progress_bar(progress); - } - - #else - - UNUSED(forceUpdate); - - #endif -} - void ST7920_Lite_Status_Screen::update(const bool forceUpdate) { cs(); update_indicators(forceUpdate); @@ -902,7 +963,7 @@ void ST7920_Lite_Status_Screen::clear_text_buffer() { } void MarlinUI::draw_status_screen() { - ST7920_Lite_Status_Screen::update(false); + lightUI.update(false); } // This method is called before each screen update and @@ -912,9 +973,9 @@ void MarlinUI::lcd_in_status(const bool inStatus) { static bool lastInStatus = false; if (lastInStatus == inStatus) return; if ((lastInStatus = inStatus)) - ST7920_Lite_Status_Screen::on_entry(); + lightUI.on_entry(); else - ST7920_Lite_Status_Screen::on_exit(); + lightUI.on_exit(); } #endif // LIGHTWEIGHT_UI diff --git a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.h b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.h index 7fe878356b0d..d838ee1a3a68 100644 --- a/Marlin/src/lcd/dogm/status_screen_lite_ST7920.h +++ b/Marlin/src/lcd/dogm/status_screen_lite_ST7920.h @@ -75,7 +75,6 @@ class ST7920_Lite_Status_Screen { protected: static void draw_degree_symbol(uint8_t x, uint8_t y, const bool draw); static void draw_static_elements(); - static void draw_progress_bar(const uint8_t value); static void draw_fan_icon(const bool whichIcon); static void draw_heat_icon(const bool whichIcon, const bool heating); static void draw_temps(uint8_t line, const int16_t temp, const int16_t target, bool showTarget, bool targetStateChange); @@ -83,7 +82,12 @@ class ST7920_Lite_Status_Screen { static void draw_extruder_2_temp(const int16_t temp, const int16_t target, bool forceUpdate=false); static void draw_bed_temp(const int16_t temp, const int16_t target, bool forceUpdate=false); static void draw_fan_speed(const uint8_t value); - static void draw_print_time(const duration_t &elapsed, char suffix=' '); + #if HAS_PRINT_PROGRESS + static void draw_progress_bar(const uint8_t value); + static char* prepare_time_string(const duration_t &time, char prefix=' '); + static void draw_progress_string(uint8_t addr, const char *str); + static void update_progress(const bool forceUpdate); + #endif static void draw_feedrate_percentage(const uint16_t percentage); static void draw_status_message(); static void draw_position(const xyze_pos_t &pos, bool position_known=true); @@ -96,11 +100,18 @@ class ST7920_Lite_Status_Screen { static void update_indicators(const bool forceUpdate); static void update_position(const bool forceUpdate, bool resetChecksum); static void update_status_or_position(bool forceUpdate); - static void update_progress(const bool forceUpdate); public: static void update(const bool forceUpdate); static void on_entry(); static void on_exit(); static void clear_text_buffer(); + #if HAS_PRINT_PROGRESS + static void drawPercent(); + static void drawRemain(); + static void drawInter(); + static void drawElapsed(); + #endif }; + +extern ST7920_Lite_Status_Screen lightUI; diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index df758da61786..d6f3d859c649 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -733,7 +733,7 @@ void CrealityDWINClass::Draw_Print_Screen() { Update_Status_Bar(true); Draw_Print_ProgressBar(); Draw_Print_ProgressElapsed(); - TERN_(USE_M73_REMAINING_TIME, Draw_Print_ProgressRemain()); + TERN_(SET_REMAINING_TIME, Draw_Print_ProgressRemain()); Draw_Print_Filename(true); } @@ -759,7 +759,7 @@ void CrealityDWINClass::Draw_Print_ProgressBar() { DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_percent, Percent_Color), Color_Bg_Black, 133, 133, F("%")); } -#if ENABLED(USE_M73_REMAINING_TIME) +#if ENABLED(SET_REMAINING_TIME) void CrealityDWINClass::Draw_Print_ProgressRemain() { uint16_t remainingtime = ui.get_remaining_time(); @@ -4565,8 +4565,8 @@ void CrealityDWINClass::Start_Print(bool sd) { } else strcpy_P(filename, PSTR("Host Print")); - TERN_(LCD_SET_PROGRESS_MANUALLY, ui.set_progress(0)); - TERN_(USE_M73_REMAINING_TIME, ui.set_remaining_time(0)); + TERN_(SET_PROGRESS_PERCENT, ui.set_progress(0)); + TERN_(SET_REMAINING_TIME, ui.set_remaining_time(0)); Draw_Print_Screen(); } } @@ -4575,8 +4575,8 @@ void CrealityDWINClass::Stop_Print() { printing = false; sdprint = false; thermalManager.cooldown(); - TERN_(LCD_SET_PROGRESS_MANUALLY, ui.set_progress(100 * (PROGRESS_SCALE))); - TERN_(USE_M73_REMAINING_TIME, ui.set_remaining_time(0)); + TERN_(SET_PROGRESS_PERCENT, ui.set_progress(100 * (PROGRESS_SCALE))); + TERN_(SET_REMAINING_TIME, ui.set_remaining_time(0)); Draw_Print_confirm(); } @@ -4653,7 +4653,7 @@ void CrealityDWINClass::Screen_Update() { if (process == Print) { Draw_Print_ProgressBar(); Draw_Print_ProgressElapsed(); - TERN_(USE_M73_REMAINING_TIME, Draw_Print_ProgressRemain()); + TERN_(SET_REMAINING_TIME, Draw_Print_ProgressRemain()); } } diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.h b/Marlin/src/lcd/e3v2/jyersui/dwin.h index 8985647cd131..7e213a65e540 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.h +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.h @@ -188,7 +188,7 @@ class CrealityDWINClass { static void Draw_Print_Screen(); static void Draw_Print_Filename(const bool reset=false); static void Draw_Print_ProgressBar(); - #if ENABLED(USE_M73_REMAINING_TIME) + #if ENABLED(SET_REMAINING_TIME) static void Draw_Print_ProgressRemain(); #endif static void Draw_Print_ProgressElapsed(); diff --git a/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp b/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp index 8024085ef734..0bd1b2ff2af2 100644 --- a/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp @@ -374,11 +374,11 @@ void MarlinUI::draw_status_screen() { #if ENABLED(DWIN_MARLINUI_PORTRAIT) - // Portrait mode only shows one value at a time, and will rotate if ROTATE_PROGRESS_DISPLAY + // Portrait mode only shows one value at a time, and will rotate if many are enabled dwin_string.set(); char prefix = ' '; #if ENABLED(SHOW_REMAINING_TIME) - if (TERN1(ROTATE_PROGRESS_DISPLAY, blink) && print_job_timer.isRunning()) { + if (blink && print_job_timer.isRunning()) { time = get_remaining_time(); prefix = 'R'; } @@ -447,7 +447,7 @@ void MarlinUI::draw_status_screen() { //if (pb_solid < old_solid) DWIN_Draw_Rectangle(1, Color_Bg_Black, pb_left + 1 + pb_solid, pb_top + 1, pb_right - 1, pb_bottom - 1); // Erase the rest - #if ENABLED(SHOW_SD_PERCENT) + #if ENABLED(SHOW_PROGRESS_PERCENT) dwin_string.set(TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(progress), ui8tostr3rj(progress / (PROGRESS_SCALE)))); dwin_string.add('%'); DWIN_Draw_String( diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp index 09c3ca9ab8df..06768ed18f95 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -43,8 +43,8 @@ #if DISABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU) #warning "INDIVIDUAL_AXIS_HOMING_SUBMENU is recommended with ProUI." #endif -#if DISABLED(LCD_SET_PROGRESS_MANUALLY) - #warning "LCD_SET_PROGRESS_MANUALLY is recommended with ProUI." +#if DISABLED(SET_PROGRESS_MANUALLY) + #warning "SET_PROGRESS_MANUALLY is recommended with ProUI." #endif #if DISABLED(STATUS_MESSAGE_SCROLLING) #warning "STATUS_MESSAGE_SCROLLING is recommended with ProUI." diff --git a/Marlin/src/lcd/extui/dgus/fysetc/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/dgus/fysetc/DGUSDisplayDef.cpp index a4c0997bf8a0..0e825c9e7c33 100644 --- a/Marlin/src/lcd/extui/dgus/fysetc/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/dgus/fysetc/DGUSDisplayDef.cpp @@ -63,7 +63,7 @@ const uint16_t VPList_Main[] PROGMEM = { VP_XPos, VP_YPos, VP_ZPos, VP_Fan0_Percentage, VP_Feedrate_Percentage, - #if ENABLED(LCD_SET_PROGRESS_MANUALLY) + #if ENABLED(SET_PROGRESS_PERCENT) VP_PrintProgress_Percentage, #endif 0x0000 diff --git a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.cpp index 4c850183da0f..6e4c76ca68df 100644 --- a/Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/dgus/hiprecy/DGUSDisplayDef.cpp @@ -63,7 +63,7 @@ const uint16_t VPList_Main[] PROGMEM = { VP_XPos, VP_YPos, VP_ZPos, VP_Fan0_Percentage, VP_Feedrate_Percentage, - #if ENABLED(LCD_SET_PROGRESS_MANUALLY) + #if ENABLED(SET_PROGRESS_PERCENT) VP_PrintProgress_Percentage, #endif 0x0000 diff --git a/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp b/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp index 86920d6841c9..ae8d9565e3f5 100644 --- a/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp +++ b/Marlin/src/lcd/extui/dgus/mks/DGUSDisplayDef.cpp @@ -135,7 +135,7 @@ const uint16_t VPList_Main[] PROGMEM = { VP_XPos, VP_YPos, VP_ZPos, VP_Fan0_Percentage, VP_Feedrate_Percentage, - #if ENABLED(LCD_SET_PROGRESS_MANUALLY) + #if ENABLED(SET_PROGRESS_PERCENT) VP_PrintProgress_Percentage, #endif 0x0000 diff --git a/Marlin/src/lcd/extui/mks_ui/draw_printing.cpp b/Marlin/src/lcd/extui/mks_ui/draw_printing.cpp index be596c874074..5dc3861f6525 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_printing.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_printing.cpp @@ -39,7 +39,7 @@ #include "../../../feature/powerloss.h" #endif -#if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME) +#if ENABLED(SET_REMAINING_TIME) #include "../../marlinui.h" #endif @@ -244,7 +244,7 @@ void disp_fan_speed() { } void disp_print_time() { - #if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME) + #if ENABLED(SET_REMAINING_TIME) const uint32_t r = ui.get_remaining_time(); sprintf_P(public_buf_l, PSTR("%02d:%02d R"), r / 3600, (r % 3600) / 60); #else diff --git a/Marlin/src/lcd/extui/ui_api.h b/Marlin/src/lcd/extui/ui_api.h index bf32c5703e36..c2ce52ba4c1e 100644 --- a/Marlin/src/lcd/extui/ui_api.h +++ b/Marlin/src/lcd/extui/ui_api.h @@ -164,6 +164,9 @@ namespace ExtUI { #if ENABLED(SHOW_REMAINING_TIME) inline uint32_t getProgress_seconds_remaining() { return ui.get_remaining_time(); } #endif + #if ENABLED(SHOW_INTERACTION_TIME) + inline uint32_t getInteraction_seconds_remaining() { return ui.interaction_time; } + #endif #if HAS_LEVELING bool getLevelingActive(); diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 2f30da001fef..00b0d62e1ae0 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -79,11 +79,16 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; statusResetFunc_t MarlinUI::status_reset_callback; // = nullptr #endif -#if ENABLED(LCD_SET_PROGRESS_MANUALLY) - MarlinUI::progress_t MarlinUI::progress_override; // = 0 - #if ENABLED(USE_M73_REMAINING_TIME) +#if ENABLED(SET_PROGRESS_MANUALLY) + #if ENABLED(SET_PROGRESS_PERCENT) + MarlinUI::progress_t MarlinUI::progress_override; // = 0 + #endif + #if ENABLED(SET_REMAINING_TIME) uint32_t MarlinUI::remaining_time; #endif + #if ENABLED(SET_INTERACTION_TIME) + uint32_t MarlinUI::interaction_time; + #endif #endif #if HAS_MULTI_LANGUAGE @@ -153,7 +158,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; bool MarlinUI::lcd_clicked; #endif -#if EITHER(HAS_WIRED_LCD, DWIN_CREALITY_LCD_JYERSUI) +#if LCD_WITH_BLINK bool MarlinUI::get_blink() { static uint8_t blink = 0; @@ -1677,19 +1682,6 @@ void MarlinUI::init() { print_job_timer.start(); // Also called by M24 } - #if HAS_PRINT_PROGRESS - - MarlinUI::progress_t MarlinUI::_get_progress() { - return ( - TERN0(LCD_SET_PROGRESS_MANUALLY, (progress_override & PROGRESS_MASK)) - #if ENABLED(SDSUPPORT) - ?: TERN(HAS_PRINT_PROGRESS_PERMYRIAD, card.permyriadDone(), card.percentDone()) - #endif - ); - } - - #endif - #if HAS_TOUCH_BUTTONS // @@ -1723,6 +1715,38 @@ void MarlinUI::init() { #endif // HAS_DISPLAY +#if HAS_PRINT_PROGRESS + + MarlinUI::progress_t MarlinUI::_get_progress() { + return ( + TERN0(SET_PROGRESS_PERCENT, (progress_override & PROGRESS_MASK)) + #if ENABLED(SDSUPPORT) + ?: TERN(HAS_PRINT_PROGRESS_PERMYRIAD, card.permyriadDone(), card.percentDone()) + #endif + ); + } + + #if LCD_WITH_BLINK + typedef void (*PrintProgress_t)(); + void MarlinUI::rotate_progress() { // Renew and redraw all enabled progress strings + const PrintProgress_t progFunc[] = { + OPTITEM(SHOW_PROGRESS_PERCENT, drawPercent) + OPTITEM(SHOW_ELAPSED_TIME, drawElapsed) + OPTITEM(SHOW_REMAINING_TIME, drawRemain) + OPTITEM(SHOW_INTERACTION_TIME, drawInter) + }; + static bool prev_blink; + static uint8_t i; + if (prev_blink != get_blink()) { + prev_blink = get_blink(); + if (++i >= COUNT(progFunc)) i = 0; + (*progFunc[i])(); + } + } + #endif + +#endif // HAS_PRINT_PROGRESS + #if ENABLED(SDSUPPORT) #if ENABLED(EXTENSIBLE_UI) diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index d2e370890727..b1a98248bb71 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -25,7 +25,6 @@ #include "../sd/cardreader.h" #include "../module/motion.h" #include "../libs/buzzer.h" - #include "buttons.h" #if ENABLED(TOUCH_SCREEN_CALIBRATION) @@ -36,7 +35,7 @@ #define MULTI_E_MANUAL 1 #endif -#if HAS_DISPLAY +#if HAS_PRINT_PROGRESS #include "../module/printcounter.h" #endif @@ -86,6 +85,7 @@ typedef bool (*statusResetFunc_t)(); #endif // HAS_WIRED_LCD #if EITHER(HAS_WIRED_LCD, DWIN_CREALITY_LCD_JYERSUI) + #define LCD_WITH_BLINK 1 #define LCD_UPDATE_INTERVAL TERN(HAS_TOUCH_BUTTONS, 50, 100) #endif @@ -303,19 +303,19 @@ class MarlinUI { #define PROGRESS_SCALE 1U #define PROGRESS_MASK 0x7F #endif - #if ENABLED(LCD_SET_PROGRESS_MANUALLY) + #if ENABLED(SET_PROGRESS_PERCENT) static progress_t progress_override; static void set_progress(const progress_t p) { progress_override = _MIN(p, 100U * (PROGRESS_SCALE)); } static void set_progress_done() { progress_override = (PROGRESS_MASK + 1U) + 100U * (PROGRESS_SCALE); } static void progress_reset() { if (progress_override & (PROGRESS_MASK + 1U)) set_progress(0); } #endif - #if ENABLED(SHOW_REMAINING_TIME) + #if EITHER(SHOW_REMAINING_TIME, SET_PROGRESS_MANUALLY) static uint32_t _calculated_remaining_time() { const duration_t elapsed = print_job_timer.duration(); const progress_t progress = _get_progress(); return progress ? elapsed.value * (100 * (PROGRESS_SCALE) - progress) / progress : 0; } - #if ENABLED(USE_M73_REMAINING_TIME) + #if ENABLED(SET_REMAINING_TIME) static uint32_t remaining_time; FORCE_INLINE static void set_remaining_time(const uint32_t r) { remaining_time = r; } FORCE_INLINE static uint32_t get_remaining_time() { return remaining_time ?: _calculated_remaining_time(); } @@ -323,12 +323,32 @@ class MarlinUI { #else FORCE_INLINE static uint32_t get_remaining_time() { return _calculated_remaining_time(); } #endif + #if ENABLED(SET_INTERACTION_TIME) + static uint32_t interaction_time; + FORCE_INLINE static void set_interaction_time(const uint32_t r) { interaction_time = r; } + FORCE_INLINE static void reset_interaction_time() { set_interaction_time(0); } + #endif #endif static progress_t _get_progress(); #if HAS_PRINT_PROGRESS_PERMYRIAD FORCE_INLINE static uint16_t get_progress_permyriad() { return _get_progress(); } #endif static uint8_t get_progress_percent() { return uint8_t(_get_progress() / (PROGRESS_SCALE)); } + #if LCD_WITH_BLINK + #if ENABLED(SHOW_PROGRESS_PERCENT) + static void drawPercent(); + #endif + #if ENABLED(SHOW_ELAPSED_TIME) + static void drawElapsed(); + #endif + #if ENABLED(SHOW_REMAINING_TIME) + static void drawRemain(); + #endif + #if ENABLED(SHOW_INTERACTION_TIME) + static void drawInter(); + #endif + static void rotate_progress(); + #endif #else static constexpr uint8_t get_progress_percent() { return 0; } #endif @@ -390,7 +410,7 @@ class MarlinUI { static void poweroff(); #endif - #if EITHER(HAS_WIRED_LCD, DWIN_CREALITY_LCD_JYERSUI) + #if LCD_WITH_BLINK static bool get_blink(); #endif diff --git a/Marlin/src/lcd/menu/menu.cpp b/Marlin/src/lcd/menu/menu.cpp index 9dd74988f32a..7ae1078f4deb 100644 --- a/Marlin/src/lcd/menu/menu.cpp +++ b/Marlin/src/lcd/menu/menu.cpp @@ -175,7 +175,7 @@ void MarlinUI::goto_screen(screenFunc_t screen, const uint16_t encoder/*=0*/, co TERN_(HAS_TOUCH_BUTTONS, repeat_delay = BUTTON_DELAY_MENU); - TERN_(LCD_SET_PROGRESS_MANUALLY, progress_reset()); + TERN_(SET_PROGRESS_PERCENT, progress_reset()); #if BOTH(DOUBLECLICK_FOR_Z_BABYSTEPPING, BABYSTEPPING) static millis_t doubleclick_expire_ms = 0; diff --git a/Marlin/src/libs/numtostr.cpp b/Marlin/src/libs/numtostr.cpp index f4d47983d225..594255aea81e 100644 --- a/Marlin/src/libs/numtostr.cpp +++ b/Marlin/src/libs/numtostr.cpp @@ -73,10 +73,10 @@ const char* i8tostr3rj(const int8_t x) { } #if HAS_PRINT_PROGRESS_PERMYRIAD - // Convert unsigned 16-bit permyriad to percent with 100 / 23 / 23.4 / 3.45 format + // Convert unsigned 16-bit permyriad to percent with 100 / 23.4 / 3.45 format const char* permyriadtostr4(const uint16_t xx) { if (xx >= 10000) - return "100"; + return " 100"; // space to keep 4-width alignment else if (xx >= 1000) { conv[3] = DIGIMOD(xx, 1000); conv[4] = DIGIMOD(xx, 100); diff --git a/buildroot/tests/SAMD51_grandcentral_m4 b/buildroot/tests/SAMD51_grandcentral_m4 index c8e08c19e6b8..f96e0b18cdf1 100755 --- a/buildroot/tests/SAMD51_grandcentral_m4 +++ b/buildroot/tests/SAMD51_grandcentral_m4 @@ -21,7 +21,7 @@ opt_enable ENDSTOP_INTERRUPTS_FEATURE S_CURVE_ACCELERATION BLTOUCH Z_MIN_PROBE_R FILAMENT_RUNOUT_SENSOR G26_MESH_VALIDATION MESH_EDIT_GFX_OVERLAY Z_SAFE_HOMING \ EEPROM_SETTINGS NOZZLE_PARK_FEATURE SDSUPPORT SD_CHECK_AND_RETRY \ REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER Z_STEPPER_AUTO_ALIGN ADAPTIVE_STEP_SMOOTHING \ - STATUS_MESSAGE_SCROLLING LCD_SET_PROGRESS_MANUALLY SHOW_REMAINING_TIME USE_M73_REMAINING_TIME \ + STATUS_MESSAGE_SCROLLING SET_PROGRESS_MANUALLY SHOW_REMAINING_TIME SET_REMAINING_TIME \ LONG_FILENAME_HOST_SUPPORT CUSTOM_FIRMWARE_UPLOAD M20_TIMESTAMP_SUPPORT \ SCROLL_LONG_FILENAMES BABYSTEPPING DOUBLECLICK_FOR_Z_BABYSTEPPING \ MOVE_Z_WHEN_IDLE BABYSTEP_ZPROBE_OFFSET BABYSTEP_ZPROBE_GFX_OVERLAY \ diff --git a/buildroot/tests/STM32F103RE_creality b/buildroot/tests/STM32F103RE_creality index f1478bc2c421..a3c52372ef37 100755 --- a/buildroot/tests/STM32F103RE_creality +++ b/buildroot/tests/STM32F103RE_creality @@ -20,7 +20,7 @@ exec_test $1 $2 "Ender 3 v2 with JyersUI" "$3" use_example_configs "Creality/Ender-3 S1/STM32F1" opt_disable DWIN_CREALITY_LCD Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN AUTO_BED_LEVELING_BILINEAR CONFIGURATION_EMBEDDING CANCEL_OBJECTS FWRETRACT -opt_enable DWIN_LCD_PROUI INDIVIDUAL_AXIS_HOMING_SUBMENU LCD_SET_PROGRESS_MANUALLY STATUS_MESSAGE_SCROLLING \ +opt_enable DWIN_LCD_PROUI INDIVIDUAL_AXIS_HOMING_SUBMENU SET_PROGRESS_MANUALLY SET_PROGRESS_PERCENT STATUS_MESSAGE_SCROLLING \ SOUND_MENU_ITEM PRINTCOUNTER NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE FILAMENT_RUNOUT_SENSOR \ BLTOUCH Z_SAFE_HOMING AUTO_BED_LEVELING_UBL MESH_EDIT_MENU \ LIMITED_MAX_FR_EDITING LIMITED_MAX_ACCEL_EDITING LIMITED_JERK_EDITING BAUD_RATE_GCODE diff --git a/buildroot/tests/mega2560 b/buildroot/tests/mega2560 index 9cb50688cdea..24f91c5f9010 100755 --- a/buildroot/tests/mega2560 +++ b/buildroot/tests/mega2560 @@ -31,7 +31,7 @@ opt_enable AUTO_BED_LEVELING_UBL RESTORE_LEVELING_AFTER_G28 DEBUG_LEVELING_FEATU SDSUPPORT SDCARD_SORT_ALPHA USB_FLASH_DRIVE_SUPPORT AUTO_REPORT_SD_STATUS SCROLL_LONG_FILENAMES MEDIA_MENU_AT_TOP \ EEPROM_SETTINGS EEPROM_CHITCHAT GCODE_MACROS CUSTOM_MENU_MAIN FREEZE_FEATURE CANCEL_OBJECTS SOUND_MENU_ITEM \ MULTI_NOZZLE_DUPLICATION CLASSIC_JERK LIN_ADVANCE EXTRA_LIN_ADVANCE_K QUICK_HOME \ - LCD_SET_PROGRESS_MANUALLY PRINT_PROGRESS_SHOW_DECIMALS SHOW_REMAINING_TIME \ + SET_PROGRESS_MANUALLY SET_PROGRESS_PERCENT PRINT_PROGRESS_SHOW_DECIMALS SHOW_REMAINING_TIME \ ENCODER_NOISE_FILTER BABYSTEPPING BABYSTEP_XY NANODLP_Z_SYNC I2C_POSITION_ENCODERS M114_DETAIL exec_test $1 $2 "Azteeg X3 Pro | EXTRUDERS 5 | RRDFGSC | UBL | LIN_ADVANCE ..." "$3" @@ -42,7 +42,7 @@ use_example_configs AnimationExample opt_set MOTHERBOARD BOARD_AZTEEG_X3_PRO LCD_LANGUAGE jp_kana DEFAULT_EJERK 10 \ EXTRUDERS 5 TEMP_SENSOR_1 1 TEMP_SENSOR_2 5 TEMP_SENSOR_3 20 TEMP_SENSOR_4 1000 TEMP_SENSOR_BED 1 opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LIGHTWEIGHT_UI SHOW_CUSTOM_BOOTSCREEN BOOT_MARLIN_LOGO_SMALL \ - LCD_SET_PROGRESS_MANUALLY PRINT_PROGRESS_SHOW_DECIMALS SHOW_REMAINING_TIME STATUS_MESSAGE_SCROLLING SCROLL_LONG_FILENAMES \ + SET_PROGRESS_MANUALLY SET_PROGRESS_PERCENT PRINT_PROGRESS_SHOW_DECIMALS SHOW_REMAINING_TIME STATUS_MESSAGE_SCROLLING SCROLL_LONG_FILENAMES \ SDSUPPORT LONG_FILENAME_WRITE_SUPPORT SDCARD_SORT_ALPHA NO_SD_AUTOSTART USB_FLASH_DRIVE_SUPPORT CANCEL_OBJECTS \ Z_PROBE_SLED AUTO_BED_LEVELING_UBL UBL_HILBERT_CURVE RESTORE_LEVELING_AFTER_G28 DEBUG_LEVELING_FEATURE G26_MESH_VALIDATION ENABLE_LEVELING_FADE_HEIGHT \ EEPROM_SETTINGS EEPROM_CHITCHAT GCODE_MACROS CUSTOM_MENU_MAIN \ @@ -177,52 +177,52 @@ exec_test $1 $2 "Azteeg X3 | Mixing Extruder (x5) | Gradient Mix | Greek" "$3" #opt_enable LCM1602 #exec_test $1 $2 "Stuff" "$3" -# -# Test Laser features with 12864 LCD -# -restore_configs -opt_set MOTHERBOARD BOARD_RAMPS_14_EFB EXTRUDERS 0 LCD_LANGUAGE en TEMP_SENSOR_COOLER 1 TEMP_SENSOR_1 0 SERIAL_PORT_2 2 \ - DEFAULT_AXIS_STEPS_PER_UNIT '{ 80, 80, 400 }' \ - DEFAULT_MAX_FEEDRATE '{ 300, 300, 5 }' \ - DEFAULT_MAX_ACCELERATION '{ 3000, 3000, 100 }' \ - MANUAL_FEEDRATE '{ 50*60, 50*60, 4*60 }' \ - AXIS_RELATIVE_MODES '{ false, false, false }' -opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER SDSUPPORT EEPROM_SETTINGS EEPROM_BOOT_SILENT EEPROM_AUTO_INIT MEATPACK_ON_SERIAL_PORT_1 \ - LASER_FEATURE LASER_SAFETY_TIMEOUT_MS LASER_COOLANT_FLOW_METER AIR_EVACUATION AIR_EVACUATION_PIN AIR_ASSIST AIR_ASSIST_PIN LASER_SYNCHRONOUS_M106_M107 -exec_test $1 $2 "MEGA2560 RAMPS | Laser Options | 12864 | Meatpack | Fan Sync | SERIAL_PORT_2 " "$3" +# # +# # Test Laser features with 12864 LCD +# # +# restore_configs +# opt_set MOTHERBOARD BOARD_RAMPS_14_EFB EXTRUDERS 0 LCD_LANGUAGE en TEMP_SENSOR_COOLER 1 TEMP_SENSOR_1 0 SERIAL_PORT_2 2 \ +# DEFAULT_AXIS_STEPS_PER_UNIT '{ 80, 80, 400 }' \ +# DEFAULT_MAX_FEEDRATE '{ 300, 300, 5 }' \ +# DEFAULT_MAX_ACCELERATION '{ 3000, 3000, 100 }' \ +# MANUAL_FEEDRATE '{ 50*60, 50*60, 4*60 }' \ +# AXIS_RELATIVE_MODES '{ false, false, false }' +# opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER SDSUPPORT EEPROM_SETTINGS EEPROM_BOOT_SILENT EEPROM_AUTO_INIT MEATPACK_ON_SERIAL_PORT_1 \ +# LASER_FEATURE LASER_SAFETY_TIMEOUT_MS LASER_COOLANT_FLOW_METER AIR_EVACUATION AIR_EVACUATION_PIN AIR_ASSIST AIR_ASSIST_PIN LASER_SYNCHRONOUS_M106_M107 +# exec_test $1 $2 "MEGA2560 RAMPS | Laser Options | 12864 | Meatpack | Fan Sync | SERIAL_PORT_2 " "$3" -# -# Test Laser features with 44780 LCD -# -restore_configs -opt_set MOTHERBOARD BOARD_RAMPS_14_EFB EXTRUDERS 0 LCD_LANGUAGE en TEMP_SENSOR_COOLER 1 TEMP_SENSOR_1 0 \ - DEFAULT_AXIS_STEPS_PER_UNIT '{ 80, 80, 400 }' \ - DEFAULT_MAX_FEEDRATE '{ 300, 300, 5 }' \ - DEFAULT_MAX_ACCELERATION '{ 3000, 3000, 100 }' \ - MANUAL_FEEDRATE '{ 50*60, 50*60, 4*60 }' \ - AXIS_RELATIVE_MODES '{ false, false, false }' -opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER SDSUPPORT EEPROM_SETTINGS EEPROM_BOOT_SILENT EEPROM_AUTO_INIT PRINTCOUNTER I2C_AMMETER \ - LASER_FEATURE LASER_SAFETY_TIMEOUT_MS LASER_COOLANT_FLOW_METER AIR_EVACUATION AIR_EVACUATION_PIN AIR_ASSIST AIR_ASSIST_PIN -exec_test $1 $2 "MEGA2560 RAMPS | Laser Feature | Air Evacuation | Air Assist | Cooler | Laser Safety Timeout | Flowmeter | 44780 LCD " "$3" +# # +# # Test Laser features with 44780 LCD +# # +# restore_configs +# opt_set MOTHERBOARD BOARD_RAMPS_14_EFB EXTRUDERS 0 LCD_LANGUAGE en TEMP_SENSOR_COOLER 1 TEMP_SENSOR_1 0 \ +# DEFAULT_AXIS_STEPS_PER_UNIT '{ 80, 80, 400 }' \ +# DEFAULT_MAX_FEEDRATE '{ 300, 300, 5 }' \ +# DEFAULT_MAX_ACCELERATION '{ 3000, 3000, 100 }' \ +# MANUAL_FEEDRATE '{ 50*60, 50*60, 4*60 }' \ +# AXIS_RELATIVE_MODES '{ false, false, false }' +# opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER SDSUPPORT EEPROM_SETTINGS EEPROM_BOOT_SILENT EEPROM_AUTO_INIT PRINTCOUNTER I2C_AMMETER \ +# LASER_FEATURE LASER_SAFETY_TIMEOUT_MS LASER_COOLANT_FLOW_METER AIR_EVACUATION AIR_EVACUATION_PIN AIR_ASSIST AIR_ASSIST_PIN +# exec_test $1 $2 "MEGA2560 RAMPS | Laser Feature | Air Evacuation | Air Assist | Cooler | Laser Safety Timeout | Flowmeter | 44780 LCD " "$3" -# -# Test redundant temperature sensors + MAX TC + Backlight Timeout -# -restore_configs -opt_set MOTHERBOARD BOARD_RAMPS_14_EFB EXTRUDERS 1 \ - TEMP_SENSOR_0 -2 TEMP_SENSOR_REDUNDANT -2 \ - TEMP_SENSOR_REDUNDANT_SOURCE E1 TEMP_SENSOR_REDUNDANT_TARGET E0 \ - TEMP_0_CS_PIN 11 TEMP_1_CS_PIN 12 \ - LCD_BACKLIGHT_TIMEOUT_MINS 2 -opt_enable MPCTEMP MINIPANEL -opt_disable PIDTEMP -exec_test $1 $2 "MEGA2560 RAMPS | Redundant temperature sensor | 2x MAX6675 | BL Timeout" "$3" +# # +# # Test redundant temperature sensors + MAX TC + Backlight Timeout +# # +# restore_configs +# opt_set MOTHERBOARD BOARD_RAMPS_14_EFB EXTRUDERS 1 \ +# TEMP_SENSOR_0 -2 TEMP_SENSOR_REDUNDANT -2 \ +# TEMP_SENSOR_REDUNDANT_SOURCE E1 TEMP_SENSOR_REDUNDANT_TARGET E0 \ +# TEMP_0_CS_PIN 11 TEMP_1_CS_PIN 12 \ +# LCD_BACKLIGHT_TIMEOUT_MINS 2 +# opt_enable MPCTEMP MINIPANEL +# opt_disable PIDTEMP +# exec_test $1 $2 "MEGA2560 RAMPS | Redundant temperature sensor | 2x MAX6675 | BL Timeout" "$3" -# -# Polargraph Config -# -use_example_configs Polargraph -exec_test $1 $2 "RUMBA | POLARGRAPH | RRD LCD" "$3" +# # +# # Polargraph Config +# # +# use_example_configs Polargraph +# exec_test $1 $2 "RUMBA | POLARGRAPH | RRD LCD" "$3" # # Language files test with REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER @@ -239,8 +239,8 @@ exec_test $1 $2 "RUMBA | POLARGRAPH | RRD LCD" "$3" # # Test a basic DUAL_X_CARRIAGE configuration # -use_example_configs Formbot/T_Rex_3 -exec_test $1 $2 "Formbot/T_Rex_3 example configuration." "$3" +# use_example_configs Formbot/T_Rex_3 +# exec_test $1 $2 "Formbot/T_Rex_3 example configuration." "$3" # # BQ Hephestos 2 @@ -260,5 +260,20 @@ exec_test $1 $2 "Formbot/T_Rex_3 example configuration." "$3" #use_example_configs tvrrug/Round2 #exec_test $1 $2 "Stuff" "$3" +# +# Test progress display rotation +# +restore_configs +opt_set MOTHERBOARD BOARD_RAMPS_14_EFB +opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER \ + SET_PROGRESS_MANUALLY SET_PROGRESS_PERCENT SET_REMAINING_TIME SET_INTERACTION_TIME M73_REPORT \ + SHOW_PROGRESS_PERCENT SHOW_ELAPSED_TIME SHOW_REMAINING_TIME SHOW_INTERACTION_TIME PRINT_PROGRESS_SHOW_DECIMALS +exec_test $1 $2 "MEGA2560 RAMPS | 12864 | progress rotation" "$3" +opt_enable LIGHTWEIGHT_UI +exec_test $1 $2 "MEGA2560 RAMPS | 12864 LIGHTWEIGHT_UI | progress rotation" "$3" +opt_disable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER +opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER +exec_test $1 $2 "MEGA2560 RAMPS | 44780 | progress rotation" "$3" + # clean up restore_configs diff --git a/ini/features.ini b/ini/features.ini index d3d863ccd406..7e4a3f97be6d 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -201,7 +201,7 @@ AUTO_REPORT_POSITION = src_filter=+ REPETIER_GCODE_M360 = src_filter=+ HAS_GCODE_M876 = src_filter=+ HAS_RESUME_CONTINUE = src_filter=+ -LCD_SET_PROGRESS_MANUALLY = src_filter=+ +SET_PROGRESS_MANUALLY = src_filter=+ HAS_STATUS_MESSAGE = src_filter=+ HAS_LCD_CONTRAST = src_filter=+ HAS_GCODE_M255 = src_filter=+ From 0203e32c734c780fba3059ac0f8fbdc57f37ff85 Mon Sep 17 00:00:00 2001 From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Date: Mon, 10 Oct 2022 20:49:37 +0200 Subject: [PATCH 092/243] =?UTF-8?q?=E2=9C=A8=20ADVANCE=5FK=20per-extruder?= =?UTF-8?q?=20(#24821)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/Configuration_adv.h | 16 ++++++++++------ Marlin/src/gcode/feature/advance/M900.cpp | 22 +++++++++++----------- Marlin/src/inc/Conditionals_LCD.h | 2 +- Marlin/src/inc/SanityCheck.h | 15 +++++++++++---- Marlin/src/lcd/e3v2/jyersui/dwin.cpp | 2 +- Marlin/src/lcd/extui/ui_api.cpp | 6 +++--- Marlin/src/lcd/menu/menu_advanced.cpp | 12 ++++++------ Marlin/src/lcd/menu/menu_tune.cpp | 4 ++-- Marlin/src/module/planner.cpp | 10 +++++----- Marlin/src/module/planner.h | 2 +- Marlin/src/module/settings.cpp | 23 ++++++++++++++--------- buildroot/tests/mega2560 | 2 +- buildroot/tests/rambo | 4 ++-- 13 files changed, 68 insertions(+), 52 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 29873073d308..4a60ec613906 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -2061,12 +2061,16 @@ */ //#define LIN_ADVANCE #if ENABLED(LIN_ADVANCE) - //#define EXTRA_LIN_ADVANCE_K // Add a second linear advance constant, configurable with M900 L. - #define LIN_ADVANCE_K 0.22 // Unit: mm compression per 1mm/s extruder speed - //#define LA_DEBUG // Print debug information to serial during operation. Disable for production use. - //#define EXPERIMENTAL_SCURVE // Allow S-Curve Acceleration to be used with LA. - //#define ALLOW_LOW_EJERK // Allow a DEFAULT_EJERK value of <10. Recommended for direct drive hotends. - //#define EXPERIMENTAL_I2S_LA // Allow I2S_STEPPER_STREAM to be used with LA. Performance degrades as the LA step rate reaches ~20kHz. + #if ENABLED(DISTINCT_E_FACTORS) + #define ADVANCE_K { 0.22 } // (mm) Compression length per 1mm/s extruder speed, per extruder + #else + #define ADVANCE_K 0.22 // (mm) Compression length applying to all extruders + #endif + //#define ADVANCE_K_EXTRA // Add a second linear advance constant, configurable with M900 L. + //#define LA_DEBUG // Print debug information to serial during operation. Disable for production use. + //#define EXPERIMENTAL_SCURVE // Allow S-Curve Acceleration to be used with LA. + //#define ALLOW_LOW_EJERK // Allow a DEFAULT_EJERK value of <10. Recommended for direct drive hotends. + //#define EXPERIMENTAL_I2S_LA // Allow I2S_STEPPER_STREAM to be used with LA. Performance degrades as the LA step rate reaches ~20kHz. #endif // @section leveling diff --git a/Marlin/src/gcode/feature/advance/M900.cpp b/Marlin/src/gcode/feature/advance/M900.cpp index db09faa88310..50d968627b6f 100644 --- a/Marlin/src/gcode/feature/advance/M900.cpp +++ b/Marlin/src/gcode/feature/advance/M900.cpp @@ -27,8 +27,8 @@ #include "../../gcode.h" #include "../../../module/planner.h" -#if ENABLED(EXTRA_LIN_ADVANCE_K) - float other_extruder_advance_K[EXTRUDERS]; +#if ENABLED(ADVANCE_K_EXTRA) + float other_extruder_advance_K[DISTINCT_E]; uint8_t lin_adv_slot = 0; #endif @@ -36,8 +36,8 @@ * M900: Get or Set Linear Advance K-factor * T Which tool to address * K Set current advance K factor (Slot 0). - * L Set secondary advance K factor (Slot 1). Requires EXTRA_LIN_ADVANCE_K. - * S<0/1> Activate slot 0 or 1. Requires EXTRA_LIN_ADVANCE_K. + * L Set secondary advance K factor (Slot 1). Requires ADVANCE_K_EXTRA. + * S<0/1> Activate slot 0 or 1. Requires ADVANCE_K_EXTRA. */ void GcodeSuite::M900() { @@ -58,12 +58,12 @@ void GcodeSuite::M900() { } #endif - float &kref = planner.extruder_advance_K[tool_index], newK = kref; + float &kref = planner.extruder_advance_K[E_INDEX_N(tool_index)], newK = kref; const float oldK = newK; - #if ENABLED(EXTRA_LIN_ADVANCE_K) + #if ENABLED(ADVANCE_K_EXTRA) - float &lref = other_extruder_advance_K[tool_index]; + float &lref = other_extruder_advance_K[E_INDEX_N(tool_index)]; const bool old_slot = TEST(lin_adv_slot, tool_index), // The tool's current slot (0 or 1) new_slot = parser.boolval('S', old_slot); // The passed slot (default = current) @@ -111,9 +111,9 @@ void GcodeSuite::M900() { if (!parser.seen_any()) { - #if ENABLED(EXTRA_LIN_ADVANCE_K) + #if ENABLED(ADVANCE_K_EXTRA) - #if EXTRUDERS < 2 + #if DISTINCT_E < 2 SERIAL_ECHOLNPGM("Advance S", new_slot, " K", kref, "(S", !new_slot, " K", lref, ")"); #else EXTRUDER_LOOP() { @@ -127,7 +127,7 @@ void GcodeSuite::M900() { #else SERIAL_ECHO_START(); - #if EXTRUDERS < 2 + #if DISTINCT_E < 2 SERIAL_ECHOLNPGM("Advance K=", planner.extruder_advance_K[0]); #else SERIAL_ECHOPGM("Advance K"); @@ -145,7 +145,7 @@ void GcodeSuite::M900() { void GcodeSuite::M900_report(const bool forReplay/*=true*/) { report_heading(forReplay, F(STR_LINEAR_ADVANCE)); - #if EXTRUDERS < 2 + #if DISTINCT_E < 2 report_echo_start(forReplay); SERIAL_ECHOLNPGM(" M900 K", planner.extruder_advance_K[0]); #else diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index e1c764f9f02f..47ae0a6dffbb 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -990,7 +990,7 @@ * with shared motion and temperature settings. * * DISTINCT_E is the number of distinguished extruders. By default this - * well be 1 which indicates all extruders share the same settings. + * will be 1 which indicates all extruders share the same settings. * * E_INDEX_N(E) should be used to get the E index of any item that might be * distinguished. diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index a76ea7418b6b..017a7b3459b1 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -652,6 +652,8 @@ #error "USE_M73_REMAINING_TIME is now SET_REMAINING_TIME." #elif defined(SHOW_SD_PERCENT) #error "SHOW_SD_PERCENT is now SHOW_PROGRESS_PERCENT." +#elif defined(EXTRA_LIN_ADVANCE_K) + #error "EXTRA_LIN_ADVANCE_K is now ADVANCE_K_EXTRA." #endif // L64xx stepper drivers have been removed @@ -1336,10 +1338,15 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS * Linear Advance 1.5 - Check K value range */ #if ENABLED(LIN_ADVANCE) - static_assert( - WITHIN(LIN_ADVANCE_K, 0, 10), - "LIN_ADVANCE_K must be a value from 0 to 10 (Changed in LIN_ADVANCE v1.5, Marlin 1.1.9)." - ); + #if DISTINCT_E > 1 + constexpr float lak[] = ADVANCE_K; + static_assert(COUNT(lak) < DISTINCT_E, "The ADVANCE_K array has too many elements (i.e., more than " STRINGIFY(DISTINCT_E) ")."); + #define _LIN_ASSERT(N) static_assert(N >= COUNT(lak) || WITHIN(lak[N], 0, 10), "ADVANCE_K values must be from 0 to 10 (Changed in LIN_ADVANCE v1.5, Marlin 1.1.9)."); + REPEAT(DISTINCT_E, _LIN_ASSERT) + #undef _LIN_ASSERT + #else + static_assert(WITHIN(ADVANCE_K, 0, 10), "ADVANCE_K must be from 0 to 10 (Changed in LIN_ADVANCE v1.5, Marlin 1.1.9)."); + #endif #if ENABLED(S_CURVE_ACCELERATION) && DISABLED(EXPERIMENTAL_SCURVE) #error "LIN_ADVANCE and S_CURVE_ACCELERATION may not play well together! Enable EXPERIMENTAL_SCURVE to continue." #elif ENABLED(DIRECT_STEPPING) diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index d6f3d859c649..21f93c6b98d4 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -2772,7 +2772,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ #if ENABLED(LIN_ADVANCE) case ADVANCED_LA: if (draw) { - Draw_Menu_Item(row, ICON_MaxAccelerated, F("Lin Advance Kp")); + Draw_Menu_Item(row, ICON_MaxAccelerated, F("Lin Advance K")); Draw_Float(planner.extruder_advance_K[0], row, false, 100); } else diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index f4d02d8cca4a..967fb1021d19 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -712,17 +712,17 @@ namespace ExtUI { #if ENABLED(POWER_LOSS_RECOVERY) bool getPowerLossRecoveryEnabled() { return recovery.enabled; } - void setPowerLossRecoveryEnabled(const bool value) { recovery.enable(value); } + void setPowerLossRecoveryEnabled(const bool value) { recovery.enable(value); } #endif #if ENABLED(LIN_ADVANCE) float getLinearAdvance_mm_mm_s(const extruder_t extruder) { - return (extruder < EXTRUDERS) ? planner.extruder_advance_K[extruder - E0] : 0; + return (extruder < EXTRUDERS) ? planner.extruder_advance_K[E_INDEX_N(extruder - E0)] : 0; } void setLinearAdvance_mm_mm_s(const_float_t value, const extruder_t extruder) { if (extruder < EXTRUDERS) - planner.extruder_advance_K[extruder - E0] = constrain(value, 0, 10); + planner.extruder_advance_K[E_INDEX_N(extruder - E0)] = constrain(value, 0, 10); } #endif diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index e79fe55938e3..19e38820184d 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -109,9 +109,9 @@ void menu_backlash(); BACK_ITEM(MSG_ADVANCED_SETTINGS); #if ENABLED(LIN_ADVANCE) - #if EXTRUDERS == 1 + #if DISTINCT_E < 2 EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 10); - #elif HAS_MULTI_EXTRUDER + #else EXTRUDER_LOOP() EDIT_ITEM_N(float42_52, e, MSG_ADVANCE_K_E, &planner.extruder_advance_K[e], 0, 10); #endif @@ -687,11 +687,11 @@ void menu_advanced_settings() { #if DISABLED(NO_VOLUMETRICS) || ENABLED(ADVANCED_PAUSE_FEATURE) SUBMENU(MSG_FILAMENT, menu_advanced_filament); #elif ENABLED(LIN_ADVANCE) - #if EXTRUDERS == 1 + #if DISTINCT_E < 2 EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 10); - #elif HAS_MULTI_EXTRUDER - LOOP_L_N(n, E_STEPPERS) - EDIT_ITEM_N(float42_52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[n], 0, 10); + #else + EXTRUDER_LOOP() + EDIT_ITEM_N(float42_52, n, MSG_ADVANCE_K_E, &planner.extruder_advance_K[e], 0, 10); #endif #endif diff --git a/Marlin/src/lcd/menu/menu_tune.cpp b/Marlin/src/lcd/menu/menu_tune.cpp index bc5200196717..79d87bb6ca92 100644 --- a/Marlin/src/lcd/menu/menu_tune.cpp +++ b/Marlin/src/lcd/menu/menu_tune.cpp @@ -210,9 +210,9 @@ void menu_tune() { // Advance K: // #if ENABLED(LIN_ADVANCE) && DISABLED(SLIM_LCD_MENUS) - #if EXTRUDERS == 1 + #if DISTINCT_E < 2 EDIT_ITEM(float42_52, MSG_ADVANCE_K, &planner.extruder_advance_K[0], 0, 10); - #elif HAS_MULTI_EXTRUDER + #else EXTRUDER_LOOP() EDIT_ITEM_N(float42_52, e, MSG_ADVANCE_K_E, &planner.extruder_advance_K[e], 0, 10); #endif diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 6ef1ed6c2848..dee86cad90ee 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -227,7 +227,7 @@ float Planner::previous_nominal_speed; #endif #if ENABLED(LIN_ADVANCE) - float Planner::extruder_advance_K[EXTRUDERS]; // Initialized by settings.load() + float Planner::extruder_advance_K[DISTINCT_E]; // Initialized by settings.load() #endif #if HAS_POSITION_FLOAT @@ -854,7 +854,7 @@ void Planner::calculate_trapezoid_for_block(block_t * const block, const_float_t #if ENABLED(LIN_ADVANCE) if (block->la_advance_rate) { - const float comp = extruder_advance_K[block->extruder] * block->steps.e / block->step_event_count; + const float comp = extruder_advance_K[E_INDEX_N(block->extruder)] * block->steps.e / block->step_event_count; block->max_adv_steps = cruise_rate * comp; block->final_adv_steps = final_rate * comp; } @@ -2541,7 +2541,7 @@ bool Planner::_populate_block( * * de > 0 : Extruder is running forward (e.g., for "Wipe while retracting" (Slic3r) or "Combing" (Cura) moves) */ - use_advance_lead = esteps && extruder_advance_K[extruder] && de > 0; + use_advance_lead = esteps && extruder_advance_K[E_INDEX_N(extruder)] && de > 0; if (use_advance_lead) { float e_D_ratio = (target_float.e - position_float.e) / @@ -2557,7 +2557,7 @@ bool Planner::_populate_block( use_advance_lead = false; else { // Scale E acceleration so that it will be possible to jump to the advance speed. - const uint32_t max_accel_steps_per_s2 = MAX_E_JERK(extruder) / (extruder_advance_K[extruder] * e_D_ratio) * steps_per_mm; + const uint32_t max_accel_steps_per_s2 = MAX_E_JERK(extruder) / (extruder_advance_K[E_INDEX_N(extruder)] * e_D_ratio) * steps_per_mm; if (TERN0(LA_DEBUG, accel > max_accel_steps_per_s2)) SERIAL_ECHOLNPGM("Acceleration limited."); NOMORE(accel, max_accel_steps_per_s2); @@ -2594,7 +2594,7 @@ bool Planner::_populate_block( if (use_advance_lead) { // the Bresenham algorithm will convert this step rate into extruder steps - block->la_advance_rate = extruder_advance_K[extruder] * block->acceleration_steps_per_s2; + block->la_advance_rate = extruder_advance_K[E_INDEX_N(extruder)] * block->acceleration_steps_per_s2; // reduce LA ISR frequency by calling it only often enough to ensure that there will // never be more than four extruder steps per call diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index bd505e784698..32b5a8795bcb 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -459,7 +459,7 @@ class Planner { #endif #if ENABLED(LIN_ADVANCE) - static float extruder_advance_K[EXTRUDERS]; + static float extruder_advance_K[DISTINCT_E]; #endif /** diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 4ccaa805c553..ec1a03eb0528 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -118,8 +118,8 @@ #endif #endif -#if ENABLED(EXTRA_LIN_ADVANCE_K) - extern float other_extruder_advance_K[EXTRUDERS]; +#if ENABLED(ADVANCE_K_EXTRA) + extern float other_extruder_advance_K[DISTINCT_E]; #endif #if HAS_MULTI_EXTRUDER @@ -442,7 +442,7 @@ typedef struct SettingsDataStruct { // // LIN_ADVANCE // - float planner_extruder_advance_K[_MAX(EXTRUDERS, 1)]; // M900 K planner.extruder_advance_K + float planner_extruder_advance_K[DISTINCT_E]; // M900 K planner.extruder_advance_K // // HAS_MOTOR_CURRENT_PWM @@ -2334,7 +2334,7 @@ void MarlinSettings::postprocess() { // Linear Advance // { - float extruder_advance_K[_MAX(EXTRUDERS, 1)]; + float extruder_advance_K[DISTINCT_E]; _FIELD_TEST(planner_extruder_advance_K); EEPROM_READ(extruder_advance_K); #if ENABLED(LIN_ADVANCE) @@ -3206,12 +3206,17 @@ void MarlinSettings::reset() { // // Linear Advance // - #if ENABLED(LIN_ADVANCE) - EXTRUDER_LOOP() { - planner.extruder_advance_K[e] = LIN_ADVANCE_K; - TERN_(EXTRA_LIN_ADVANCE_K, other_extruder_advance_K[e] = LIN_ADVANCE_K); - } + #if ENABLED(DISTINCT_E_FACTORS) + constexpr float linAdvanceK[] = ADVANCE_K; + EXTRUDER_LOOP() { + const float a = linAdvanceK[_MAX(e, COUNT(linAdvanceK) - 1)]; + planner.extruder_advance_K[e] = a; + TERN_(ADVANCE_K_EXTRA, other_extruder_advance_K[e] = a); + } + #else + planner.extruder_advance_K[0] = ADVANCE_K; + #endif #endif // diff --git a/buildroot/tests/mega2560 b/buildroot/tests/mega2560 index 24f91c5f9010..86b27790324d 100755 --- a/buildroot/tests/mega2560 +++ b/buildroot/tests/mega2560 @@ -30,7 +30,7 @@ opt_enable AUTO_BED_LEVELING_UBL RESTORE_LEVELING_AFTER_G28 DEBUG_LEVELING_FEATU REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LIGHTWEIGHT_UI STATUS_MESSAGE_SCROLLING SHOW_CUSTOM_BOOTSCREEN BOOT_MARLIN_LOGO_SMALL \ SDSUPPORT SDCARD_SORT_ALPHA USB_FLASH_DRIVE_SUPPORT AUTO_REPORT_SD_STATUS SCROLL_LONG_FILENAMES MEDIA_MENU_AT_TOP \ EEPROM_SETTINGS EEPROM_CHITCHAT GCODE_MACROS CUSTOM_MENU_MAIN FREEZE_FEATURE CANCEL_OBJECTS SOUND_MENU_ITEM \ - MULTI_NOZZLE_DUPLICATION CLASSIC_JERK LIN_ADVANCE EXTRA_LIN_ADVANCE_K QUICK_HOME \ + MULTI_NOZZLE_DUPLICATION CLASSIC_JERK LIN_ADVANCE ADVANCE_K_EXTRA QUICK_HOME \ SET_PROGRESS_MANUALLY SET_PROGRESS_PERCENT PRINT_PROGRESS_SHOW_DECIMALS SHOW_REMAINING_TIME \ ENCODER_NOISE_FILTER BABYSTEPPING BABYSTEP_XY NANODLP_Z_SYNC I2C_POSITION_ENCODERS M114_DETAIL exec_test $1 $2 "Azteeg X3 Pro | EXTRUDERS 5 | RRDFGSC | UBL | LIN_ADVANCE ..." "$3" diff --git a/buildroot/tests/rambo b/buildroot/tests/rambo index b5d6491d2870..de6cdc71297b 100755 --- a/buildroot/tests/rambo +++ b/buildroot/tests/rambo @@ -34,7 +34,7 @@ opt_enable USE_ZMAX_PLUG REPRAP_DISCOUNT_SMART_CONTROLLER LCD_PROGRESS_BAR LCD_P FWRETRACT ARC_P_CIRCLES CNC_WORKSPACE_PLANES CNC_COORDINATE_SYSTEMS \ PSU_CONTROL PS_OFF_CONFIRM PS_OFF_SOUND POWER_OFF_WAIT_FOR_COOLDOWN \ POWER_LOSS_RECOVERY POWER_LOSS_PIN POWER_LOSS_STATE POWER_LOSS_RECOVER_ZHOME POWER_LOSS_ZHOME_POS \ - SLOW_PWM_HEATERS THERMAL_PROTECTION_CHAMBER LIN_ADVANCE EXTRA_LIN_ADVANCE_K \ + SLOW_PWM_HEATERS THERMAL_PROTECTION_CHAMBER LIN_ADVANCE ADVANCE_K_EXTRA \ HOST_ACTION_COMMANDS HOST_PROMPT_SUPPORT PINS_DEBUGGING MAX7219_DEBUG M114_DETAIL opt_add DEBUG_POWER_LOSS_RECOVERY exec_test $1 $2 "RAMBO | EXTRUDERS 2 | CHAR LCD + SD | FIX Probe | ABL-Linear | Advanced Pause | PLR | LEDs ..." "$3" @@ -93,7 +93,7 @@ opt_set MOTHERBOARD BOARD_MINIRAMBO \ opt_enable EEPROM_SETTINGS EEPROM_CHITCHAT REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER \ SDSUPPORT PCA9632 SOUND_MENU_ITEM GCODE_REPEAT_MARKERS \ AUTO_BED_LEVELING_LINEAR PROBE_MANUALLY LCD_BED_LEVELING \ - LIN_ADVANCE EXTRA_LIN_ADVANCE_K \ + LIN_ADVANCE ADVANCE_K_EXTRA \ INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT EXPERIMENTAL_I2CBUS M100_FREE_MEMORY_WATCHER \ NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE \ ADVANCED_PAUSE_FEATURE PARK_HEAD_ON_PAUSE ADVANCED_PAUSE_CONTINUOUS_PURGE FILAMENT_LOAD_UNLOAD_GCODES \ From 3c870f2d4bcec4ed7e1499a7dee541c448d8751a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 10 Oct 2022 17:51:33 -0400 Subject: [PATCH 093/243] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Min?= =?UTF-8?q?=20and=20max=20for=20base=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/types.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index cb087204fea6..4292cd0cf1cd 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -347,6 +347,10 @@ struct XYval { FI operator T* () { return pos; } // If any element is true then it's true FI operator bool() { return x || y; } + // Smallest element + FI T _min() const { return _MIN(x, y); } + // Largest element + FI T _max() const { return _MAX(x, y); } // Explicit copy and copies with conversion FI XYval copy() const { return *this; } @@ -500,6 +504,10 @@ struct XYZval { FI operator T* () { return pos; } // If any element is true then it's true FI operator bool() { return NUM_AXIS_GANG(x, || y, || z, || i, || j, || k, || u, || v, || w); } + // Smallest element + FI T _min() const { return _MIN(NUM_AXIS_LIST(x, y, z, i, j, k, u, v, w)); } + // Largest element + FI T _max() const { return _MAX(NUM_AXIS_LIST(x, y, z, i, j, k, u, v, w)); } // Explicit copy and copies with conversion FI XYZval copy() const { XYZval o = *this; return o; } @@ -651,6 +659,10 @@ struct XYZEval { FI operator T* () { return pos; } // If any element is true then it's true FI operator bool() { return 0 LOGICAL_AXIS_GANG(|| e, || x, || y, || z, || i, || j, || k, || u, || v, || w); } + // Smallest element + FI T _min() const { return _MIN(LOGICAL_AXIS_LIST(e, x, y, z, i, j, k, u, v, w)); } + // Largest element + FI T _max() const { return _MAX(LOGICAL_AXIS_LIST(e, x, y, z, i, j, k, u, v, w)); } // Explicit copy and copies with conversion FI XYZEval copy() const { XYZEval v = *this; return v; } From 62b7db9bb783f509ab44e109f9b6e82da3d58048 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 10 Oct 2022 18:02:18 -0400 Subject: [PATCH 094/243] =?UTF-8?q?=F0=9F=94=A8=20Update=20mfinfo=20for=20?= =?UTF-8?q?2.1.x?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildroot/share/git/mfinfo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildroot/share/git/mfinfo b/buildroot/share/git/mfinfo index 3f183b8fd8f0..c74e48650cbc 100755 --- a/buildroot/share/git/mfinfo +++ b/buildroot/share/git/mfinfo @@ -56,7 +56,7 @@ done case "$REPO" in Marlin ) TARG=bugfix-2.1.x ; ((INDEX == 1)) && TARG=bugfix-1.1.x ; [[ $BRANCH =~ ^[12]$ ]] && USAGE=1 ;; - Configurations ) TARG=import-2.0.x ;; + Configurations ) TARG=import-2.1.x ;; MarlinDocumentation ) TARG=master ;; AutoBuildMarlin ) TARG=master ;; esac From 505f0a647e9ac26c69b5aafb781672c399c28cb8 Mon Sep 17 00:00:00 2001 From: EvilGremlin <22657714+EvilGremlin@users.noreply.github.com> Date: Wed, 12 Oct 2022 02:31:37 +0300 Subject: [PATCH 095/243] =?UTF-8?q?=E2=9C=A8=20MKS=20SKIPR=20board=20(#247?= =?UTF-8?q?91)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/boards.h | 1 + Marlin/src/pins/pins.h | 2 + Marlin/src/pins/stm32f4/pins_MKS_SKIPR_V1_0.h | 381 ++++++++++++++ .../boards/marlin_MKS_SKIPR_V1.json | 55 ++ .../variants/MARLIN_F4x7Vx/variant.h | 184 +++---- .../MARLIN_MKS_SKIPR_V1/PeripheralPins.c | 169 ++++++ .../MARLIN_MKS_SKIPR_V1/PinNamesVar.h | 30 ++ .../MARLIN_MKS_SKIPR_V1/hal_conf_extra.h | 496 ++++++++++++++++++ .../variants/MARLIN_MKS_SKIPR_V1/ldscript.ld | 203 +++++++ .../variants/MARLIN_MKS_SKIPR_V1/variant.cpp | 288 ++++++++++ .../variants/MARLIN_MKS_SKIPR_V1/variant.h | 196 +++++++ ini/stm32f4.ini | 17 +- 12 files changed, 1929 insertions(+), 93 deletions(-) create mode 100644 Marlin/src/pins/stm32f4/pins_MKS_SKIPR_V1_0.h create mode 100644 buildroot/share/PlatformIO/boards/marlin_MKS_SKIPR_V1.json create mode 100644 buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/PeripheralPins.c create mode 100644 buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/PinNamesVar.h create mode 100644 buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/hal_conf_extra.h create mode 100644 buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/ldscript.ld create mode 100644 buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/variant.cpp create mode 100644 buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/variant.h diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index 51d419da0460..74ff44d9905b 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -425,6 +425,7 @@ #define BOARD_CREALITY_V24S1_301F4 4240 // Creality v2.4.S1_301F4 (STM32F401RC) as found in the Ender-3 S1 F4 #define BOARD_OPULO_LUMEN_REV4 4241 // Opulo Lumen PnP Controller REV4 (STM32F407VE / STM32F407VG) #define BOARD_FYSETC_SPIDER_KING407 4242 // FYSETC Spider King407 (STM32F407ZG) +#define BOARD_MKS_SKIPR_V1 4243 // MKS SKIPR v1.0 all-in-one board (STM32F407VE) // // ARM Cortex M7 diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 9efafe9af566..c623b4844d20 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -709,6 +709,8 @@ #include "stm32f4/pins_OPULO_LUMEN_REV4.h" // STM32F4 env:Opulo_Lumen_REV4 #elif MB(FYSETC_SPIDER_KING407) #include "stm32f4/pins_FYSETC_SPIDER_KING407.h" // STM32F4 env:FYSETC_SPIDER_KING407 +#elif MB(MKS_SKIPR_V1) + #include "stm32f4/pins_MKS_SKIPR_V1_0.h" // STM32F4 env:mks_skipr_v1 env:mks_skipr_v1_nobootloader // // ARM Cortex M7 diff --git a/Marlin/src/pins/stm32f4/pins_MKS_SKIPR_V1_0.h b/Marlin/src/pins/stm32f4/pins_MKS_SKIPR_V1_0.h new file mode 100644 index 000000000000..046fbb95bf29 --- /dev/null +++ b/Marlin/src/pins/stm32f4/pins_MKS_SKIPR_V1_0.h @@ -0,0 +1,381 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include "env_validate.h" + +#if HOTENDS > 4 || E_STEPPERS > 4 + #error "MKS SKIPR supports up to 4 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "MKS SKIPR V1.0" + +// Valid SERIAL_PORT values: -1 (USB-C), 1 (direct to RK3328), 3 (USART3 header) + +#define USES_DIAG_JUMPERS + +// Onboard I2C EEPROM +#define I2C_EEPROM +#define MARLIN_EEPROM_SIZE 0x1000 // 4KB (AT24C32) +#define I2C_SCL_PIN PB8 +#define I2C_SDA_PIN PB9 + +// +// Servos +// +#define SERVO0_PIN PA8 + +// +// Trinamic Stallguard pins // Connector labels +#define X_DIAG_PIN PA14 // X- +#define Y_DIAG_PIN PA15 // Y- +#define Z_DIAG_PIN PB15 // Z- +#define E0_DIAG_PIN PA13 // MT-DET +#define E1_DIAG_PIN PC5 // NEOPIXEL +#define E2_DIAG_PIN PB14 // Z+ + +// +// Check for additional used endstop pins +// +#if HAS_EXTRA_ENDSTOPS + #define _ENDSTOP_IS_ANY(ES) X2_USE_ENDSTOP == ES || Y2_USE_ENDSTOP == ES || Z2_USE_ENDSTOP == ES || Z3_USE_ENDSTOP == ES || Z4_USE_ENDSTOP == ES + #if _ENDSTOP_IS_ANY(_XMIN_) || _ENDSTOP_IS_ANY(_XMAX_) + #define NEEDS_X_MINMAX 1 + #endif + #if _ENDSTOP_IS_ANY(_YMIN_) || _ENDSTOP_IS_ANY(_YMAX_) + #define NEEDS_Y_MINMAX 1 + #endif + #if _ENDSTOP_IS_ANY(_ZMIN_) || _ENDSTOP_IS_ANY(_ZMAX_) + #define NEEDS_Z_MINMAX 1 + #endif + #undef _ENDSTOP_IS_ANY +#endif + +// +// Limit Switches +// +#ifdef X_STALL_SENSITIVITY + #define X_STOP_PIN X_DIAG_PIN // X- +#elif EITHER(DUAL_X_CARRIAGE, NEEDS_X_MINMAX) + #ifndef X_MIN_PIN + #define X_MIN_PIN X_DIAG_PIN // X- + #endif + #ifndef X_MAX_PIN + #define X_MAX_PIN E0_DIAG_PIN // MT-DET + #endif +#else + #define X_STOP_PIN X_DIAG_PIN // X- +#endif + +#ifdef Y_STALL_SENSITIVITY + #define Y_STOP_PIN Y_DIAG_PIN // Y- +#elif NEEDS_Y_MINMAX + #ifndef Y_MIN_PIN + #define Y_MIN_PIN Y_DIAG_PIN // Y- + #endif + #ifndef Y_MAX_PIN + #define Y_MAX_PIN E1_DIAG_PIN // NEOPIXEL + #endif +#else + #define Y_STOP_PIN Y_DIAG_PIN // Y- +#endif + +#ifdef Z_STALL_SENSITIVITY + #define Z_STOP_PIN Z_DIAG_PIN // Z- +#elif NEEDS_Z_MINMAX + #ifndef Z_MIN_PIN + #define Z_MIN_PIN Z_DIAG_PIN // Z- + #endif + #ifndef Z_MAX_PIN + #define Z_MAX_PIN E2_DIAG_PIN // Z+ + #endif +#else + #define Z_STOP_PIN Z_DIAG_PIN // Z- +#endif + +#if DISABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) || ENABLED(USE_PROBE_FOR_Z_HOMING) + #ifndef Z_MIN_PROBE + #define Z_MIN_PROBE_PIN E2_DIAG_PIN // defaults to 'Z+' connector + #endif +#endif + +#undef NEEDS_X_MINMAX +#undef NEEDS_Y_MINMAX +#undef NEEDS_Z_MINMAX + +// +// Steppers +// +#define X_STEP_PIN PC14 +#define X_DIR_PIN PC13 +#define X_ENABLE_PIN PC15 +#ifndef X_CS_PIN + #define X_CS_PIN PE6 +#endif + +#define Y_STEP_PIN PE5 +#define Y_DIR_PIN PE4 +#define Y_ENABLE_PIN PD14 +#ifndef Y_CS_PIN + #define Y_CS_PIN PE3 +#endif + +#define Z_STEP_PIN PE1 // "Z1" +#define Z_DIR_PIN PE0 +#define Z_ENABLE_PIN PE2 +#ifndef Z_CS_PIN + #define Z_CS_PIN PB7 +#endif + +#define E0_STEP_PIN PB5 +#define E0_DIR_PIN PB4 +#define E0_ENABLE_PIN PB6 +#ifndef E0_CS_PIN + #define E0_CS_PIN PB3 +#endif + +#define E1_STEP_PIN PD6 // "Z2" +#define E1_DIR_PIN PD5 +#define E1_ENABLE_PIN PD7 +#ifndef E1_CS_PIN + #define E1_CS_PIN PD4 +#endif + +#define E2_STEP_PIN PD2 // "Z3" +#define E2_DIR_PIN PD1 +#define E2_ENABLE_PIN PD3 +#ifndef E2_CS_PIN + #define E2_CS_PIN PD0 +#endif + +#define E3_STEP_PIN PC7 // "Z4" +#define E3_DIR_PIN PC6 +#define E3_ENABLE_PIN PC8 +#ifndef E3_CS_PIN + #define E3_CS_PIN PD15 +#endif + +// +// Temperature Sensors +// +#define TEMP_BED_PIN PC0 // TB +#define TEMP_0_PIN PC1 // TH0 +#define TEMP_1_PIN PC2 // TH1 +#define TEMP_2_PIN PC3 // TH2 + +// +// Heaters / Fans +// +#define HEATER_BED_PIN PD12 // Hotbed +#define HEATER_0_PIN PB1 // Heater0 +#define HEATER_1_PIN PB0 // Heater1 +#define HEATER_2_PIN PA3 // Heater2 + +#define FAN_PIN PA2 // Fan0 +#define FAN1_PIN PA1 // Fan1 +#define FAN2_PIN PA0 // Fan2 + +// +// Software SPI pins for TMC2130 stepper drivers +// This board doesn't support hardware SPI there +// +#if HAS_TMC_SPI + #define TMC_USE_SW_SPI + #define TMC_SW_MOSI PE14 + #define TMC_SW_MISO PE13 + #define TMC_SW_SCK PE12 +#endif + +// +// TMC2208/TMC2209 stepper drivers +// This board is routed for one-wire software serial +// +#if HAS_TMC_UART + #define X_SERIAL_TX_PIN PE6 + #define X_SERIAL_RX_PIN X_SERIAL_TX_PIN + + #define Y_SERIAL_TX_PIN PE3 + #define Y_SERIAL_RX_PIN Y_SERIAL_TX_PIN + + #define Z_SERIAL_TX_PIN PB7 + #define Z_SERIAL_RX_PIN Z_SERIAL_TX_PIN + + #define E0_SERIAL_TX_PIN PB3 + #define E0_SERIAL_RX_PIN E0_SERIAL_TX_PIN + + #define E1_SERIAL_TX_PIN PD4 + #define E1_SERIAL_RX_PIN E1_SERIAL_TX_PIN + + #define E2_SERIAL_TX_PIN PD0 + #define E2_SERIAL_RX_PIN E2_SERIAL_TX_PIN + + #define E3_SERIAL_TX_PIN PD15 + #define E3_SERIAL_RX_PIN E3_SERIAL_TX_PIN + + // Reduce baud rate to improve software serial reliability + #define TMC_BAUD_RATE 19200 +#endif + +/** ------ ------ + * (BEEPER) PB2 | 1 2 | PE10 (BTN_ENC) (MISO) PA6 | 1 2 | PA5 (SCK) + * (LCD_EN) PE11 | 3 4 | PD10 (LCD_RS) (BTN_EN1) PE9 | 3 4 | PA4 (SD_SS) + * (LCD_D4) PD9 | 5 6 PD8 (LCD_D5) (BTN_EN2) PE8 | 5 6 PA7 (MOSI) + * (LCD_D6) PE15 | 7 8 | PE7 (LCD_D7) (SD_DETECT) PD13 | 7 8 | RESET + * GND | 9 10 | 5V GND | 9 10 | -- + * ------ ------ + * EXP1 EXP2 + */ +#define EXP1_01_PIN PB2 +#define EXP1_02_PIN PE10 +#define EXP1_03_PIN PE11 +#define EXP1_04_PIN PD10 +#define EXP1_05_PIN PD9 +#define EXP1_06_PIN PD8 +#define EXP1_07_PIN PE15 +#define EXP1_08_PIN PE7 + +#define EXP2_01_PIN PA6 +#define EXP2_02_PIN PA5 +#define EXP2_03_PIN PE9 +#define EXP2_04_PIN PA4 +#define EXP2_05_PIN PE8 +#define EXP2_06_PIN PA7 +#define EXP2_07_PIN PD13 +#define EXP2_08_PIN -1 // connected to MCU reset + +// +// SD Support +// Onboard SD card use hardware SPI3 (defined in variant), LCD SD card use hardware SPI1 +// +#if ENABLED(SDSUPPORT) + #ifndef SDCARD_CONNECTION + #define SDCARD_CONNECTION LCD + #endif + #if SD_CONNECTION_IS(ONBOARD) + //#define SOFTWARE_SPI + //#define SD_SPI_SPEED SPI_HALF_SPEED + #undef SD_DETECT_STATE + #define SD_DETECT_STATE LOW + #define SD_DETECT_PIN PC4 + #elif SD_CONNECTION_IS(LCD) + //#define SOFTWARE_SPI + //#define SD_SPI_SPEED SPI_QUARTER_SPEED + #define SD_SS_PIN EXP2_04_PIN + #define SD_SCK_PIN EXP2_02_PIN + #define SD_MISO_PIN EXP2_01_PIN + #define SD_MOSI_PIN EXP2_06_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #elif SD_CONNECTION_IS(CUSTOM_CABLE) + #error "CUSTOM_CABLE is not a supported SDCARD_CONNECTION for this board" + #endif + #define SDSS SD_SS_PIN +#endif + +// +// LCDs and Controllers +// +#if IS_TFTGLCD_PANEL + + #if ENABLED(TFTGLCD_PANEL_SPI) + #define TFTGLCD_CS EXP2_03_PIN + #endif + +#elif HAS_WIRED_LCD + + #define BEEPER_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN + + #if ENABLED(CR10_STOCKDISPLAY) + + #define LCD_PINS_RS EXP1_07_PIN + + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN + + #else + + #define LCD_PINS_RS EXP1_04_PIN + + #define BTN_EN1 EXP2_03_PIN + #define BTN_EN2 EXP2_05_PIN + + #define LCD_PINS_ENABLE EXP1_03_PIN + #define LCD_PINS_D4 EXP1_05_PIN + + #if ENABLED(FYSETC_MINI_12864) + #define DOGLCD_CS EXP1_03_PIN + #define DOGLCD_A0 EXP1_04_PIN + //#define LCD_BACKLIGHT_PIN -1 + #define LCD_RESET_PIN EXP1_05_PIN // Must be high or open for LCD to operate normally. + #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) + #ifndef RGB_LED_R_PIN + #define RGB_LED_R_PIN EXP1_06_PIN + #endif + #ifndef RGB_LED_G_PIN + #define RGB_LED_G_PIN EXP1_07_PIN + #endif + #ifndef RGB_LED_B_PIN + #define RGB_LED_B_PIN EXP1_08_PIN + #endif + #elif ENABLED(FYSETC_MINI_12864_2_1) + #define NEOPIXEL_PIN EXP1_06_PIN + #endif + #endif // !FYSETC_MINI_12864 + + #if IS_ULTIPANEL + #define LCD_PINS_D5 EXP1_06_PIN + #define LCD_PINS_D6 EXP1_07_PIN + #define LCD_PINS_D7 EXP1_08_PIN + #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) + #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder + #endif + #endif + + #endif +#endif // HAS_WIRED_LCD + +// Alter timing for graphical display +#if IS_U8GLIB_ST7920 + #define BOARD_ST7920_DELAY_1 120 + #define BOARD_ST7920_DELAY_2 80 + #define BOARD_ST7920_DELAY_3 580 +#endif + +// +// NeoPixel LED +// +#ifndef NEOPIXEL_PIN + #define NEOPIXEL_PIN PC5 +#endif + +// +// MAX31865 +// +#if HAS_MAX31865 + #define TEMP_0_CS_PIN PD11 + #define TEMP_0_SCK_PIN PE12 + #define TEMP_0_MISO_PIN PE13 + #define TEMP_0_MOSI_PIN PE14 +#endif diff --git a/buildroot/share/PlatformIO/boards/marlin_MKS_SKIPR_V1.json b/buildroot/share/PlatformIO/boards/marlin_MKS_SKIPR_V1.json new file mode 100644 index 000000000000..7ca62db00531 --- /dev/null +++ b/buildroot/share/PlatformIO/boards/marlin_MKS_SKIPR_V1.json @@ -0,0 +1,55 @@ +{ + "build": { + "core": "stm32", + "cpu": "cortex-m4", + "extra_flags": "-DSTM32F4 -DSTM32F407xx", + "f_cpu": "168000000L", + "offset": "0xC000", + "hwids": [ + [ + "0x1EAF", + "0x0003" + ], + [ + "0x0483", + "0x3748" + ] + ], + "mcu": "stm32f407vet6", + "product_line": "STM32F407xx", + "variant": "MARLIN_MKS_SKIPR_V1" + }, + "debug": { + "default_tools": [ + "stlink" + ], + "jlink_device": "STM32F407VE", + "openocd_extra_args": [ + "-c", + "reset_config none" + ], + "openocd_target": "stm32f4x", + "svd_path": "STM32F40x.svd" + }, + "frameworks": [ + "arduino" + ], + "name": "STM32F407VE (128k RAM, 64k CCM RAM, 512k Flash", + "upload": { + "disable_flushing": false, + "maximum_ram_size": 131072, + "maximum_size": 524288, + "protocol": "stlink", + "protocols": [ + "stlink", + "dfu", + "jlink" + ], + "offset_address": "0x0800C000", + "require_upload_port": false, + "use_1200bps_touch": false, + "wait_for_upload_port": false + }, + "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32f407ve.html", + "vendor": "ST" +} diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/variant.h index ba145d058cb3..0b78be627fc5 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/variant.h @@ -27,98 +27,98 @@ extern "C" { * Pins *----------------------------------------------------------------------------*/ -// | DIGITAL | ANALOG IN | ANALOG OUT | UART/USART | TWI | SPI | SPECIAL | -// |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| -#define PA0 PIN_A0 // | 0 | A0 (ADC1) | | UART4_TX | | | | -#define PA1 PIN_A1 // | 1 | A1 (ADC1) | | UART4_RX | | | | -#define PA2 PIN_A2 // | 2 | A2 (ADC1) | | USART2_TX | | | | -#define PA3 PIN_A3 // | 3 | A3 (ADC1) | | USART2_RX | | | | -#define PA4 PIN_A4 // | 4 | A4 (ADC1) | DAC_OUT1 | | | SPI1_SS, (SPI3_SS) | | -#define PA5 PIN_A5 // | 5 | A5 (ADC1) | DAC_OUT2 | | | SPI1_SCK | | -#define PA6 PIN_A6 // | 6 | A6 (ADC1) | | | | SPI1_MISO | | -#define PA7 PIN_A7 // | 7 | A7 (ADC1) | | | | SPI1_MOSI | | -#define PA8 8 // | 8 | | | | TWI3_SCL | | | -#define PA9 9 // | 9 | | | USART1_TX | | | | -#define PA10 10 // | 10 | | | USART1_RX | | | | -#define PA11 11 // | 11 | | | | | | | -#define PA12 12 // | 12 | | | | | | | -#define PA13 13 // | 13 | | | | | | SWD_SWDIO | -#define PA14 14 // | 14 | | | | | | SWD_SWCLK | -#define PA15 15 // | 15 | | | | | SPI3_SS, (SPI1_SS) | | -// |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| -#define PB0 PIN_A8 // | 16 | A8 (ADC1) | | | | | | -#define PB1 PIN_A9 // | 17 | A9 (ADC1) | | | | | | -#define PB2 18 // | 18 | | | | | | BOOT1 | -#define PB3 19 // | 19 | | | | | SPI3_SCK, (SPI1_SCK) | | -#define PB4 20 // | 20 | | | | | SPI3_MISO, (SPI1_MISO) | | -#define PB5 21 // | 21 | | | | | SPI3_MOSI, (SPI1_MOSI) | | -#define PB6 22 // | 22 | | | USART1_TX | TWI1_SCL | | | -#define PB7 23 // | 23 | | | USART1_RX | TWI1_SDA | | | -#define PB8 24 // | 24 | | | | TWI1_SCL | | | -#define PB9 25 // | 25 | | | | TWI1_SDA | SPI2_SS | | -#define PB10 26 // | 26 | | | USART3_TX, (UART4_TX) | TWI2_SCL | SPI2_SCK | | -#define PB11 27 // | 27 | | | USART3_RX | TWI2_SDA | | | -#define PB12 28 // | 28 | | | | | SPI2_SS | | -#define PB13 29 // | 29 | | | | | SPI2_SCK | | -#define PB14 30 // | 30 | | | | | SPI2_MISO | | -#define PB15 31 // | 31 | | | | | SPI2_MOSI | | -// |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| -#define PC0 PIN_A10 // | 32 | A10 (ADC1) | | | | | | -#define PC1 PIN_A11 // | 33 | A11 (ADC1) | | | | | | -#define PC2 PIN_A12 // | 34 | A12 (ADC1) | | | | SPI2_MISO | | -#define PC3 PIN_A13 // | 35 | A13 (ADC1) | | | | SPI2_MOSI | | -#define PC4 PIN_A14 // | 36 | A14 (ADC1) | | | | | | -#define PC5 PIN_A15 // | 37 | A15 (ADC1) | | USART3_RX | | | | -#define PC6 38 // | 38 | | | USART6_TX | | | | -#define PC7 39 // | 39 | | | USART6_RX | | | | -#define PC8 40 // | 40 | | | | | | | -#define PC9 41 // | 41 | | | USART3_TX | TWI3_SDA | | | -#define PC10 42 // | 42 | | | | | SPI3_SCK | | -#define PC11 43 // | 43 | | | USART3_RX, (UART4_RX) | | SPI3_MISO | | -#define PC12 44 // | 44 | | | UART5_TX | | SPI3_MOSI | | -#define PC13 45 // | 45 | | | | | | | -#define PC14 46 // | 46 | | | | | | OSC32_IN | -#define PC15 47 // | 47 | | | | | | OSC32_OUT | -// |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| -#define PD0 48 // | 48 | | | | | | | -#define PD1 49 // | 49 | | | | | | | -#define PD2 50 // | 50 | | | UART5_RX | | | | -#define PD3 51 // | 51 | | | | | | | -#define PD4 52 // | 52 | | | | | | | -#define PD5 53 // | 53 | | | USART2_TX | | | | -#define PD6 54 // | 54 | | | USART2_RX | | | | -#define PD7 55 // | 55 | | | | | | | -#define PD8 56 // | 56 | | | USART3_TX | | | | -#define PD9 57 // | 57 | | | USART3_RX | | | | -#define PD10 58 // | 58 | | | | | | | -#define PD11 59 // | 59 | | | | | | | -#define PD12 60 // | 60 | | | | | | | -#define PD13 61 // | 61 | | | | | | | -#define PD14 62 // | 62 | | | | | | | -#define PD15 63 // | 63 | | | | | | | -// |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| -#define PE0 64 // | 64 | | | | | | | -#define PE1 65 // | 65 | | | | | | | -#define PE2 66 // | 66 | | | | | | | -#define PE3 67 // | 67 | | | | | | | -#define PE4 68 // | 68 | | | | | | | -#define PE5 69 // | 69 | | | | | | | -#define PE6 70 // | 70 | | | | | | | -#define PE7 71 // | 71 | | | | | | | -#define PE8 72 // | 72 | | | | | | | -#define PE9 73 // | 73 | | | | | | | -#define PE10 74 // | 74 | | | | | | | -#define PE11 75 // | 75 | | | | | | | -#define PE12 76 // | 76 | | | | | | | -#define PE13 77 // | 77 | | | | | | | -#define PE14 78 // | 78 | | | | | | | -#define PE15 79 // | 79 | | | | | | | -// |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| -#define PH0 80 // | 80 | | | | | | OSC_IN | -#define PH1 81 // | 81 | | | | | | OSC_OUT | -// |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| - -/// This must be a literal + // | DIGITAL | ANALOG IN | ANALOG OUT | UART/USART | TWI | SPI | SPECIAL | + // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| +#define PA0 PIN_A0 // | 0 | A0 (ADC1) | | UART4_TX | | | | +#define PA1 PIN_A1 // | 1 | A1 (ADC1) | | UART4_RX | | | | +#define PA2 PIN_A2 // | 2 | A2 (ADC1) | | USART2_TX | | | | +#define PA3 PIN_A3 // | 3 | A3 (ADC1) | | USART2_RX | | | | +#define PA4 PIN_A4 // | 4 | A4 (ADC1) | DAC_OUT1 | | | SPI1_SS, (SPI3_SS) | | +#define PA5 PIN_A5 // | 5 | A5 (ADC1) | DAC_OUT2 | | | SPI1_SCK | | +#define PA6 PIN_A6 // | 6 | A6 (ADC1) | | | | SPI1_MISO | | +#define PA7 PIN_A7 // | 7 | A7 (ADC1) | | | | SPI1_MOSI | | +#define PA8 8 // | 8 | | | | TWI3_SCL | | | +#define PA9 9 // | 9 | | | USART1_TX | | | | +#define PA10 10 // | 10 | | | USART1_RX | | | | +#define PA11 11 // | 11 | | | | | | | +#define PA12 12 // | 12 | | | | | | | +#define PA13 13 // | 13 | | | | | | SWD_SWDIO | +#define PA14 14 // | 14 | | | | | | SWD_SWCLK | +#define PA15 15 // | 15 | | | | | SPI3_SS, (SPI1_SS) | | + // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| +#define PB0 PIN_A8 // | 16 | A8 (ADC1) | | | | | | +#define PB1 PIN_A9 // | 17 | A9 (ADC1) | | | | | | +#define PB2 18 // | 18 | | | | | | BOOT1 | +#define PB3 19 // | 19 | | | | | SPI3_SCK, (SPI1_SCK) | | +#define PB4 20 // | 20 | | | | | SPI3_MISO, (SPI1_MISO) | | +#define PB5 21 // | 21 | | | | | SPI3_MOSI, (SPI1_MOSI) | | +#define PB6 22 // | 22 | | | USART1_TX | TWI1_SCL | | | +#define PB7 23 // | 23 | | | USART1_RX | TWI1_SDA | | | +#define PB8 24 // | 24 | | | | TWI1_SCL | | | +#define PB9 25 // | 25 | | | | TWI1_SDA | SPI2_SS | | +#define PB10 26 // | 26 | | | USART3_TX, (UART4_TX) | TWI2_SCL | SPI2_SCK | | +#define PB11 27 // | 27 | | | USART3_RX | TWI2_SDA | | | +#define PB12 28 // | 28 | | | | | SPI2_SS | | +#define PB13 29 // | 29 | | | | | SPI2_SCK | | +#define PB14 30 // | 30 | | | | | SPI2_MISO | | +#define PB15 31 // | 31 | | | | | SPI2_MOSI | | + // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| +#define PC0 PIN_A10 // | 32 | A10 (ADC1) | | | | | | +#define PC1 PIN_A11 // | 33 | A11 (ADC1) | | | | | | +#define PC2 PIN_A12 // | 34 | A12 (ADC1) | | | | SPI2_MISO | | +#define PC3 PIN_A13 // | 35 | A13 (ADC1) | | | | SPI2_MOSI | | +#define PC4 PIN_A14 // | 36 | A14 (ADC1) | | | | | | +#define PC5 PIN_A15 // | 37 | A15 (ADC1) | | USART3_RX | | | | +#define PC6 38 // | 38 | | | USART6_TX | | | | +#define PC7 39 // | 39 | | | USART6_RX | | | | +#define PC8 40 // | 40 | | | | | | | +#define PC9 41 // | 41 | | | USART3_TX | TWI3_SDA | | | +#define PC10 42 // | 42 | | | | | SPI3_SCK | | +#define PC11 43 // | 43 | | | USART3_RX, (UART4_RX) | | SPI3_MISO | | +#define PC12 44 // | 44 | | | UART5_TX | | SPI3_MOSI | | +#define PC13 45 // | 45 | | | | | | | +#define PC14 46 // | 46 | | | | | | OSC32_IN | +#define PC15 47 // | 47 | | | | | | OSC32_OUT | + // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| +#define PD0 48 // | 48 | | | | | | | +#define PD1 49 // | 49 | | | | | | | +#define PD2 50 // | 50 | | | UART5_RX | | | | +#define PD3 51 // | 51 | | | | | | | +#define PD4 52 // | 52 | | | | | | | +#define PD5 53 // | 53 | | | USART2_TX | | | | +#define PD6 54 // | 54 | | | USART2_RX | | | | +#define PD7 55 // | 55 | | | | | | | +#define PD8 56 // | 56 | | | USART3_TX | | | | +#define PD9 57 // | 57 | | | USART3_RX | | | | +#define PD10 58 // | 58 | | | | | | | +#define PD11 59 // | 59 | | | | | | | +#define PD12 60 // | 60 | | | | | | | +#define PD13 61 // | 61 | | | | | | | +#define PD14 62 // | 62 | | | | | | | +#define PD15 63 // | 63 | | | | | | | + // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| +#define PE0 64 // | 64 | | | | | | | +#define PE1 65 // | 65 | | | | | | | +#define PE2 66 // | 66 | | | | | | | +#define PE3 67 // | 67 | | | | | | | +#define PE4 68 // | 68 | | | | | | | +#define PE5 69 // | 69 | | | | | | | +#define PE6 70 // | 70 | | | | | | | +#define PE7 71 // | 71 | | | | | | | +#define PE8 72 // | 72 | | | | | | | +#define PE9 73 // | 73 | | | | | | | +#define PE10 74 // | 74 | | | | | | | +#define PE11 75 // | 75 | | | | | | | +#define PE12 76 // | 76 | | | | | | | +#define PE13 77 // | 77 | | | | | | | +#define PE14 78 // | 78 | | | | | | | +#define PE15 79 // | 79 | | | | | | | + // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| +#define PH0 80 // | 80 | | | | | | OSC_IN | +#define PH1 81 // | 81 | | | | | | OSC_OUT | + // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| + +// This must be a literal #define NUM_DIGITAL_PINS 82 #define NUM_ANALOG_INPUTS 16 diff --git a/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/PeripheralPins.c new file mode 100644 index 000000000000..640fbdbe13c0 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/PeripheralPins.c @@ -0,0 +1,169 @@ +/* + ******************************************************************************* + * Copyright (c) 2016, STMicroelectronics + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************* + */ +#include "Arduino.h" +#include "PeripheralPins.h" + +// ===== +// Note: Commented lines are alternative possibilities which are not used per default. +// If you change them, you will have to know what you do +// ===== + +//*** ADC *** + +#ifdef HAL_ADC_MODULE_ENABLED +WEAK const PinMap PinMap_ADC[] = { + {PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 THBED + {PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 TH0 + {PC_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 TH1 + {PC_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 TH2 + {NC, NP, 0} +}; +#endif + +//*** I2C *** + +#ifdef HAL_I2C_MODULE_ENABLED +WEAK const PinMap PinMap_I2C_SDA[] = { + {PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_I2C_SCL[] = { + {PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {NC, NP, 0} +}; +#endif + +//*** PWM *** + +#ifdef HAL_TIM_MODULE_ENABLED +// Some pins can perform PWM from more than one timer. These were selected to utilize as many channels as +// possible from timers which were already dedicated to PWM output. + +// TIM1 = HEATER0, HEATER1, [SERVO] +// TIM2 = FAN1, FAN2, [BEEPER] +// TIM4 = HEATER_BED +// TIM5 = HEATER2, FAN0 + +WEAK const PinMap PinMap_PWM[] = { + {PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 Fan2 + {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 Fan1 + {PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 Fan0 + {PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 HE2 + {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 Servo + {PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N HE1 + {PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N HE0 + {PB_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 BEEPER + {PD_12, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 HOTBED + {NC, NP, 0} +}; +#endif + +//*** SERIAL *** + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_TX[] = { + {PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PB_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_UART_RX[] = { + {PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PB_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_UART_RTS[] = { + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_UART_CTS[] = { + {NC, NP, 0} +}; +#endif + +//*** SPI *** + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_MOSI[] = { + {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_SPI_MISO[] = { + {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_SPI_SCLK[] = { + {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PC_10, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_SPI_SSEL[] = { + {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {NC, NP, 0} +}; +#endif + +//*** CAN *** + +#ifdef HAL_CAN_MODULE_ENABLED +WEAK const PinMap PinMap_CAN_RD[] = { + {PB_12, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + {NC, NP, 0} +}; + +const PinMap PinMap_CAN_TD[] = { + {PB_13, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + {NC, NP, 0} +}; +#endif + +//*** USB *** + +// If anyone for some unfathomable reason want to run gcode from Marlin's USB-C drive at 12Mbps - you can +#ifdef HAL_PCD_MODULE_ENABLED +WEAK const PinMap PinMap_USB_OTG_FS[] = { + {PA_11, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DM + {PA_12, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DP + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_USB_OTG_HS[] = { + {NC, NP, 0} +}; +#endif + + diff --git a/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/PinNamesVar.h new file mode 100644 index 000000000000..bff3f2134987 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/PinNamesVar.h @@ -0,0 +1,30 @@ +/* SYS_WKUP */ +#ifdef PWR_WAKEUP_PIN1 + SYS_WKUP1 = PA_0, /* SYS_WKUP0 */ +#endif +#ifdef PWR_WAKEUP_PIN2 + SYS_WKUP2 = NC, +#endif +#ifdef PWR_WAKEUP_PIN3 + SYS_WKUP3 = NC, +#endif +#ifdef PWR_WAKEUP_PIN4 + SYS_WKUP4 = NC, +#endif +#ifdef PWR_WAKEUP_PIN5 + SYS_WKUP5 = NC, +#endif +#ifdef PWR_WAKEUP_PIN6 + SYS_WKUP6 = NC, +#endif +#ifdef PWR_WAKEUP_PIN7 + SYS_WKUP7 = NC, +#endif +#ifdef PWR_WAKEUP_PIN8 + SYS_WKUP8 = NC, +#endif +/* USB */ +#ifdef USBCON + USB_OTG_FS_DM = PA_11, + USB_OTG_FS_DP = PA_12, +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/hal_conf_extra.h new file mode 100644 index 000000000000..599c78ce5c49 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/hal_conf_extra.h @@ -0,0 +1,496 @@ +/** + ****************************************************************************** + * @file stm32f4xx_hal_conf_template.h + * @author MCD Application Team + * @brief HAL configuration template file. + * This file should be copied to the application folder and renamed + * to stm32f4xx_hal_conf.h. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F4xx_HAL_CONF_H +#define __STM32F4xx_HAL_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED +#define HAL_ADC_MODULE_ENABLED +#define HAL_CAN_LEGACY_MODULE_ENABLED +#define HAL_CRC_MODULE_ENABLED +#define HAL_DAC_MODULE_ENABLED +#define HAL_DMA_MODULE_ENABLED +#define HAL_EXTI_MODULE_ENABLED // Needed for Endstop (and other external) Interrupts +#define HAL_GPIO_MODULE_ENABLED +#define HAL_I2C_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +#define HAL_USART_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED +// #define HAL_UART_MODULE_ENABLED +// #define HAL_PCD_MODULE_ENABLED + +// #define HAL_CAN_MODULE_ENABLED +//#define HAL_CEC_MODULE_ENABLED +//#define HAL_CRYP_MODULE_ENABLED +//#define HAL_DCMI_MODULE_ENABLED +//#define HAL_DMA2D_MODULE_ENABLED +//#define HAL_ETH_MODULE_ENABLED +//#define HAL_FLASH_MODULE_ENABLED +//#define HAL_NAND_MODULE_ENABLED +//#define HAL_NOR_MODULE_ENABLED +//#define HAL_PCCARD_MODULE_ENABLED +//#define HAL_SRAM_MODULE_ENABLED +//#define HAL_SDRAM_MODULE_ENABLED +//#define HAL_HASH_MODULE_ENABLED +//#define HAL_SMBUS_MODULE_ENABLED +//#define HAL_I2S_MODULE_ENABLED +//#define HAL_IWDG_MODULE_ENABLED +//#define HAL_LTDC_MODULE_ENABLED +//#define HAL_DSI_MODULE_ENABLED +//#define HAL_QSPI_MODULE_ENABLED +//#define HAL_RNG_MODULE_ENABLED +//#define HAL_RTC_MODULE_ENABLED +//#define HAL_SAI_MODULE_ENABLED +//#define HAL_SD_MODULE_ENABLED +//#define HAL_IRDA_MODULE_ENABLED +//#define HAL_SMARTCARD_MODULE_ENABLED +//#define HAL_WWDG_MODULE_ENABLED +//#define HAL_HCD_MODULE_ENABLED +//#define HAL_FMPI2C_MODULE_ENABLED +//#define HAL_SPDIFRX_MODULE_ENABLED +//#define HAL_DFSDM_MODULE_ENABLED +//#define HAL_LPTIM_MODULE_ENABLED +//#define HAL_MMC_MODULE_ENABLED + +/* ########################## HSE/HSI Values adaptation ##################### */ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#ifndef HSE_VALUE + #define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#ifndef HSE_STARTUP_TIMEOUT + #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#ifndef HSI_VALUE + #define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz */ +#endif /* HSI_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#ifndef LSI_VALUE + #define LSI_VALUE 32000U /*!< LSI Typical Value in Hz */ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature. */ +/** + * @brief External Low Speed oscillator (LSE) value. + */ +#ifndef LSE_VALUE + #define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +#ifndef LSE_STARTUP_TIMEOUT + #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#ifndef EXTERNAL_CLOCK_VALUE + #define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External oscillator in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE 3300U /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY 0x0FU /*!< tick interrupt priority */ +#define USE_RTOS 0U +#define PREFETCH_ENABLE 1U +#define INSTRUCTION_CACHE_ENABLE 1U +#define DATA_CACHE_ENABLE 1U + +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ +#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ +#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ +#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */ +#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */ +#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */ +#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ +#define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */ +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ +#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */ +#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ +#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */ +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */ +#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ +#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */ +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ +#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */ +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ +#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ +#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +// #define USE_FULL_ASSERT 1U + +/* ################## Ethernet peripheral configuration ##################### */ + +/* Section 1 : Ethernet peripheral configuration */ + +/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ +#define MAC_ADDR0 2U +#define MAC_ADDR1 0U +#define MAC_ADDR2 0U +#define MAC_ADDR3 0U +#define MAC_ADDR4 0U +#define MAC_ADDR5 0U + +/* Definition of the Ethernet driver buffers size and count */ +#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ +#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ +#define ETH_RXBUFNB 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ + +/* Section 2: PHY configuration section */ + +/* DP83848 PHY Address*/ +#define DP83848_PHY_ADDRESS 0x01U +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY 0x000000FFU +/* PHY Configuration delay */ +#define PHY_CONFIG_DELAY 0x00000FFFU + +#define PHY_READ_TO 0x0000FFFFU +#define PHY_WRITE_TO 0x0000FFFFU + +/* Section 3: Common PHY Registers */ + +#define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */ +#define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */ + +#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */ +#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */ +#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */ +#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */ +#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */ +#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */ +#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */ +#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */ +#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */ +#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */ + +#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */ +#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */ +#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */ + +/* Section 4: Extended PHY Registers */ + +#define PHY_SR ((uint16_t)0x0010) /*!< PHY status register Offset */ +#define PHY_MICR ((uint16_t)0x0011) /*!< MII Interrupt Control Register */ +#define PHY_MISR ((uint16_t)0x0012) /*!< MII Interrupt Status and Misc. Control Register */ + +#define PHY_LINK_STATUS ((uint16_t)0x0001) /*!< PHY Link mask */ +#define PHY_SPEED_STATUS ((uint16_t)0x0002) /*!< PHY Speed mask */ +#define PHY_DUPLEX_STATUS ((uint16_t)0x0004) /*!< PHY Duplex mask */ + +#define PHY_MICR_INT_EN ((uint16_t)0x0002) /*!< PHY Enable interrupts */ +#define PHY_MICR_INT_OE ((uint16_t)0x0001) /*!< PHY Enable output interrupt events */ + +#define PHY_MISR_LINK_INT_EN ((uint16_t)0x0020) /*!< Enable Interrupt on change of link status */ +#define PHY_LINK_INTERRUPT ((uint16_t)0x2000) /*!< PHY link status interrupt mask */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver +* Activated: CRC code is present inside driver +* Deactivated: CRC code cleaned from driver +*/ + +#define USE_SPI_CRC 0U + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32f4xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32f4xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED + #include "stm32f4xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32f4xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32f4xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32f4xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED + #include "stm32f4xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CAN_LEGACY_MODULE_ENABLED + #include "stm32f4xx_hal_can_legacy.h" +#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32f4xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED + #include "stm32f4xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED + #include "stm32f4xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED + #include "stm32f4xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED + #include "stm32f4xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED + #include "stm32f4xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32f4xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED + #include "stm32f4xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED + #include "stm32f4xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED + #include "stm32f4xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_PCCARD_MODULE_ENABLED + #include "stm32f4xx_hal_pccard.h" +#endif /* HAL_PCCARD_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED + #include "stm32f4xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED + #include "stm32f4xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32f4xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED + #include "stm32f4xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED + #include "stm32f4xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32f4xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED + #include "stm32f4xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32f4xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED + #include "stm32f4xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32f4xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED + #include "stm32f4xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED + #include "stm32f4xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32f4xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32f4xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32f4xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32f4xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32f4xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32f4xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED + #include "stm32f4xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED + #include "stm32f4xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED + #include "stm32f4xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED + #include "stm32f4xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED + #include "stm32f4xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED + #include "stm32f4xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_FMPI2C_MODULE_ENABLED + #include "stm32f4xx_hal_fmpi2c.h" +#endif /* HAL_FMPI2C_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED + #include "stm32f4xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED + #include "stm32f4xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED + #include "stm32f4xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED + #include "stm32f4xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(uint8_t *file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F4xx_HAL_CONF_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ \ No newline at end of file diff --git a/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/ldscript.ld new file mode 100644 index 000000000000..8b38135a2a51 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/ldscript.ld @@ -0,0 +1,203 @@ +/* +****************************************************************************** +** +** File : LinkerScript.ld +** +** Abstract : Linker script for STM32F4x7Vx Device with +** 512/1024KByte FLASH, 192KByte RAM +** +** Set heap size, stack size and stack location according +** to application requirements. +** +** Set memory bank area and size if external memory is used. +** +** Target : STMicroelectronics STM32 +** +** Distribution: The file is distributed “as is,” without any warranty +** of any kind. +** +***************************************************************************** +** @attention +** +**

© COPYRIGHT(c) 2019 STMicroelectronics

+** +** Redistribution and use in source and binary forms, with or without modification, +** are permitted provided that the following conditions are met: +** 1. Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** 3. Neither the name of STMicroelectronics nor the names of its contributors +** may be used to endorse or promote products derived from this software +** without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +***************************************************************************** +*/ + +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Highest address of the user mode stack */ +_estack = 0x20000000 + LD_MAX_DATA_SIZE; /* end of RAM */ +/* Generate a link error if heap and stack don't fit into RAM */ +_Min_Heap_Size = 0x200; /* required amount of heap */ +_Min_Stack_Size = 0x400; /* required amount of stack */ + +/* Specify the memory areas */ +MEMORY +{ +RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE +CCMRAM (rw) : ORIGIN = 0x10000000, LENGTH = 64K +FLASH (rx) : ORIGIN = 0x08000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET +} + +/* Define output sections */ +SECTIONS +{ + /* The startup code goes first into FLASH */ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + } >FLASH + + /* The program code and other data goes into FLASH */ + .text : + { + . = ALIGN(4); + *(.text) /* .text sections (code) */ + *(.text*) /* .text* sections (code) */ + *(.glue_7) /* glue arm to thumb code */ + *(.glue_7t) /* glue thumb to arm code */ + *(.eh_frame) + + KEEP (*(.init)) + KEEP (*(.fini)) + + . = ALIGN(4); + _etext = .; /* define a global symbols at end of code */ + } >FLASH + + /* Constant data goes into FLASH */ + .rodata : + { + . = ALIGN(4); + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + . = ALIGN(4); + } >FLASH + + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH + .ARM : { + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + } >FLASH + + .preinit_array : + { + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)) + PROVIDE_HIDDEN (__preinit_array_end = .); + } >FLASH + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + } >FLASH + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array*)) + PROVIDE_HIDDEN (__fini_array_end = .); + } >FLASH + + /* used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* Initialized data sections goes into RAM, load LMA copy after code */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + } >RAM AT> FLASH + + _siccmram = LOADADDR(.ccmram); + + /* CCM-RAM section + * + * IMPORTANT NOTE! + * If initialized variables will be placed in this section, + * the startup code needs to be modified to copy the init-values. + */ + .ccmram : + { + . = ALIGN(4); + _sccmram = .; /* create a global symbol at ccmram start */ + *(.ccmram) + *(.ccmram*) + + . = ALIGN(4); + _eccmram = .; /* create a global symbol at ccmram end */ + } >CCMRAM AT> FLASH + + + /* Uninitialized data section */ + . = ALIGN(4); + .bss : + { + /* This is used by the startup in order to initialize the .bss section */ + _sbss = .; /* define a global symbol at bss start */ + __bss_start__ = _sbss; + *(.bss) + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end */ + __bss_end__ = _ebss; + } >RAM + + /* User_heap_stack section, used to check that there is enough RAM left */ + ._user_heap_stack : + { + . = ALIGN(8); + PROVIDE ( end = . ); + PROVIDE ( _end = . ); + . = . + _Min_Heap_Size; + . = . + _Min_Stack_Size; + . = ALIGN(8); + } >RAM + + + /* Remove information from the standard libraries */ + /DISCARD/ : + { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + + .ARM.attributes 0 : { *(.ARM.attributes) } +} diff --git a/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/variant.cpp b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/variant.cpp new file mode 100644 index 000000000000..00c7a90db313 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/variant.cpp @@ -0,0 +1,288 @@ +/* + ******************************************************************************* + * Copyright (c) 2017, STMicroelectronics + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************* + */ + +#include "pins_arduino.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +// Digital PinName array +const PinName digitalPin[] = { + PA_0, // Digital pin 0 + PA_1, // Digital pin 1 + PA_2, // Digital pin 2 + PA_3, // Digital pin 3 + PA_4, // Digital pin 4 + PA_5, // Digital pin 5 + PA_6, // Digital pin 6 + PA_7, // Digital pin 7 + PA_8, // Digital pin 8 + PA_9, // Digital pin 9 + PA_10, // Digital pin 10 + PA_11, // Digital pin 11 + PA_12, // Digital pin 12 + PA_13, // Digital pin 13 + PA_14, // Digital pin 14 + PA_15, // Digital pin 15 + + PB_0, // Digital pin 16 + PB_1, // Digital pin 17 + PB_2, // Digital pin 18 + PB_3, // Digital pin 19 + PB_4, // Digital pin 20 + PB_5, // Digital pin 21 + PB_6, // Digital pin 22 + PB_7, // Digital pin 23 + PB_8, // Digital pin 24 + PB_9, // Digital pin 25 + PB_10, // Digital pin 26 + PB_11, // Digital pin 27 + PB_12, // Digital pin 28 + PB_13, // Digital pin 29 + PB_14, // Digital pin 30 + PB_15, // Digital pin 31 + + PC_0, // Digital pin 32 + PC_1, // Digital pin 33 + PC_2, // Digital pin 34 + PC_3, // Digital pin 35 + PC_4, // Digital pin 36 + PC_5, // Digital pin 37 + PC_6, // Digital pin 38 + PC_7, // Digital pin 39 + PC_8, // Digital pin 40 + PC_9, // Digital pin 41 + PC_10, // Digital pin 42 + PC_11, // Digital pin 43 + PC_12, // Digital pin 44 + PC_13, // Digital pin 45 + PC_14, // Digital pin 46 + PC_15, // Digital pin 47 + + PD_0, // Digital pin 48 + PD_1, // Digital pin 49 + PD_2, // Digital pin 50 + PD_3, // Digital pin 51 + PD_4, // Digital pin 52 + PD_5, // Digital pin 53 + PD_6, // Digital pin 54 + PD_7, // Digital pin 55 + PD_8, // Digital pin 56 + PD_9, // Digital pin 57 + PD_10, // Digital pin 58 + PD_11, // Digital pin 59 + PD_12, // Digital pin 60 + PD_13, // Digital pin 61 + PD_14, // Digital pin 62 + PD_15, // Digital pin 63 + + PE_0, // Digital pin 64 + PE_1, // Digital pin 65 + PE_2, // Digital pin 66 + PE_3, // Digital pin 67 + PE_4, // Digital pin 68 + PE_5, // Digital pin 69 + PE_6, // Digital pin 70 + PE_7, // Digital pin 71 + PE_8, // Digital pin 72 + PE_9, // Digital pin 73 + PE_10, // Digital pin 74 + PE_11, // Digital pin 75 + PE_12, // Digital pin 76 + PE_13, // Digital pin 77 + PE_14, // Digital pin 78 + PE_15, // Digital pin 79 + + PH_0, // Digital pin 80, used by the external oscillator + PH_1 // Digital pin 81, used by the external oscillator +}; + +// Analog (Ax) pin number array +const uint32_t analogInputPin[] = { + 0, // A0, PA0 + 1, // A1, PA1 + 2, // A2, PA2 + 3, // A3, PA3 + 4, // A4, PA4 + 5, // A5, PA5 + 6, // A6, PA6 + 7, // A7, PA7 + 16, // A8, PB0 + 17, // A9, PB1 + 32, // A10, PC0 + 33, // A11, PC1 + 34, // A12, PC2 + 35, // A13, PC3 + 36, // A14, PC4 + 37 // A15, PC5 +}; + +#ifdef __cplusplus +} +#endif + +// ---------------------------------------------------------------------------- + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * @brief Configures the System clock source, PLL Multiplier and Divider factors, + * AHB/APBx prescalers and Flash settings + * @note This function should be called only once the RCC clock configuration + * is reset to the default reset state (done in SystemInit() function). + * @param None + * @retval None + */ + +/******************************************************************************/ +/* PLL (clocked by HSE) used as System clock source */ +/******************************************************************************/ +static uint8_t SetSysClock_PLL_HSE(uint8_t bypass) +{ + RCC_OscInitTypeDef RCC_OscInitStruct; + RCC_ClkInitTypeDef RCC_ClkInitStruct; + + /* The voltage scaling allows optimizing the power consumption when the device is + clocked below the maximum system frequency, to update the voltage scaling value + regarding system frequency refer to product datasheet. */ + __HAL_RCC_PWR_CLK_ENABLE(); + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); + + // Enable HSE oscillator and activate PLL with HSE as source + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; + if (bypass == 0) { + RCC_OscInitStruct.HSEState = RCC_HSE_ON; // External 8 MHz xtal on OSC_IN/OSC_OUT + } else { + RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS; // External 8 MHz clock on OSC_IN + } + + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = HSE_VALUE / 1000000L; // Expects an 8 MHz external clock by default. Redefine HSE_VALUE if not + RCC_OscInitStruct.PLL.PLLN = 336; // VCO output clock = 336 MHz (1 MHz * 336) + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; // PLLCLK = 168 MHz (336 MHz / 2) + RCC_OscInitStruct.PLL.PLLQ = 7; + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { + return 0; // FAIL + } + + // Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 168 MHz + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; // 42 MHz + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; // 84 MHz + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) { + return 0; // FAIL + } + + /* Output clock on MCO1 pin(PA8) for debugging purpose */ + /* + if (bypass == 0) + HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_2); // 4 MHz + else + HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSE, RCC_MCODIV_1); // 8 MHz + */ + + return 1; // OK +} + +/******************************************************************************/ +/* PLL (clocked by HSI) used as System clock source */ +/******************************************************************************/ +uint8_t SetSysClock_PLL_HSI(void) +{ + RCC_OscInitTypeDef RCC_OscInitStruct; + RCC_ClkInitTypeDef RCC_ClkInitStruct; + + /* The voltage scaling allows optimizing the power consumption when the device is + clocked below the maximum system frequency, to update the voltage scaling value + regarding system frequency refer to product datasheet. */ + __HAL_RCC_PWR_CLK_ENABLE(); + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); + + // Enable HSI oscillator and activate PLL with HSI as source + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSIState = RCC_HSI_ON; + RCC_OscInitStruct.HSEState = RCC_HSE_OFF; + RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; + RCC_OscInitStruct.PLL.PLLM = 16; // VCO input clock = 1 MHz (16 MHz / 16) + RCC_OscInitStruct.PLL.PLLN = 336; // VCO output clock = 336 MHz (1 MHz * 336) + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; // PLLCLK = 168 MHz (336 MHz / 2) + RCC_OscInitStruct.PLL.PLLQ = 7; + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { + return 0; // FAIL + } + + /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */ + RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; // 168 MHz + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; // 42 MHz + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; // 84 MHz + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) { + return 0; // FAIL + } + + /* Output clock on MCO1 pin(PA8) for debugging purpose */ + //HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSI, RCC_MCODIV_1); // 16 MHz + + return 1; // OK +} + +WEAK void SystemClock_Config(void) +{ + /* 1- If fail try to start with HSE and external xtal */ + if (SetSysClock_PLL_HSE(0) == 0) { + /* 2- Try to start with HSE and external clock */ + if (SetSysClock_PLL_HSE(1) == 0) { + /* 3- If fail start with HSI clock */ + if (SetSysClock_PLL_HSI() == 0) { + Error_Handler(); + } + } + } + + /* Ensure CCM RAM clock is enabled */ + __HAL_RCC_CCMDATARAMEN_CLK_ENABLE(); + + /* Output clock on MCO2 pin(PC9) for debugging purpose */ + //HAL_RCC_MCOConfig(RCC_MCO2, RCC_MCO2SOURCE_SYSCLK, RCC_MCODIV_4); +} + +#ifdef __cplusplus +} +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/variant.h new file mode 100644 index 000000000000..dcc8c493956c --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/variant.h @@ -0,0 +1,196 @@ +/* + ******************************************************************************* + * Copyright (c) 2017, STMicroelectronics + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************* + */ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus +// +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + // | DIGITAL | ANALOG IN | ANALOG OUT | UART/USART | TWI | SPI | SPECIAL | + // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| +#define PA0 PIN_A0 // | 0 | A0 (ADC1) | | UART4_TX | | | | +#define PA1 PIN_A1 // | 1 | A1 (ADC1) | | UART4_RX | | | | +#define PA2 PIN_A2 // | 2 | A2 (ADC1) | | USART2_TX | | | | +#define PA3 PIN_A3 // | 3 | A3 (ADC1) | | USART2_RX | | | | +#define PA4 PIN_A4 // | 4 | A4 (ADC1) | DAC_OUT1 | | | SPI1_SS, (SPI3_SS) | | +#define PA5 PIN_A5 // | 5 | A5 (ADC1) | DAC_OUT2 | | | SPI1_SCK | | +#define PA6 PIN_A6 // | 6 | A6 (ADC1) | | | | SPI1_MISO | | +#define PA7 PIN_A7 // | 7 | A7 (ADC1) | | | | SPI1_MOSI | | +#define PA8 8 // | 8 | | | | TWI3_SCL | | | +#define PA9 9 // | 9 | | | USART1_TX | | | | +#define PA10 10 // | 10 | | | USART1_RX | | | | +#define PA11 11 // | 11 | | | | | | | +#define PA12 12 // | 12 | | | | | | | +#define PA13 13 // | 13 | | | | | | SWD_SWDIO | +#define PA14 14 // | 14 | | | | | | SWD_SWCLK | +#define PA15 15 // | 15 | | | | | SPI3_SS, (SPI1_SS) | | + // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| +#define PB0 PIN_A8 // | 16 | A8 (ADC1) | | | | | | +#define PB1 PIN_A9 // | 17 | A9 (ADC1) | | | | | | +#define PB2 18 // | 18 | | | | | | BOOT1 | +#define PB3 19 // | 19 | | | | | SPI3_SCK, (SPI1_SCK) | | +#define PB4 20 // | 20 | | | | | SPI3_MISO, (SPI1_MISO) | | +#define PB5 21 // | 21 | | | | | SPI3_MOSI, (SPI1_MOSI) | | +#define PB6 22 // | 22 | | | USART1_TX | TWI1_SCL | | | +#define PB7 23 // | 23 | | | USART1_RX | TWI1_SDA | | | +#define PB8 24 // | 24 | | | | TWI1_SCL | | | +#define PB9 25 // | 25 | | | | TWI1_SDA | SPI2_SS | | +#define PB10 26 // | 26 | | | USART3_TX, (UART4_TX) | TWI2_SCL | SPI2_SCK | | +#define PB11 27 // | 27 | | | USART3_RX | TWI2_SDA | | | +#define PB12 28 // | 28 | | | | | SPI2_SS | | +#define PB13 29 // | 29 | | | | | SPI2_SCK | | +#define PB14 30 // | 30 | | | | | SPI2_MISO | | +#define PB15 31 // | 31 | | | | | SPI2_MOSI | | + // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| +#define PC0 PIN_A10 // | 32 | A10 (ADC1) | | | | | | +#define PC1 PIN_A11 // | 33 | A11 (ADC1) | | | | | | +#define PC2 PIN_A12 // | 34 | A12 (ADC1) | | | | SPI2_MISO | | +#define PC3 PIN_A13 // | 35 | A13 (ADC1) | | | | SPI2_MOSI | | +#define PC4 PIN_A14 // | 36 | A14 (ADC1) | | | | | | +#define PC5 PIN_A15 // | 37 | A15 (ADC1) | | USART3_RX | | | | +#define PC6 38 // | 38 | | | USART6_TX | | | | +#define PC7 39 // | 39 | | | USART6_RX | | | | +#define PC8 40 // | 40 | | | | | | | +#define PC9 41 // | 41 | | | USART3_TX | TWI3_SDA | | | +#define PC10 42 // | 42 | | | | | SPI3_SCK | | +#define PC11 43 // | 43 | | | USART3_RX, (UART4_RX) | | SPI3_MISO | | +#define PC12 44 // | 44 | | | UART5_TX | | SPI3_MOSI | | +#define PC13 45 // | 45 | | | | | | | +#define PC14 46 // | 46 | | | | | | OSC32_IN | +#define PC15 47 // | 47 | | | | | | OSC32_OUT | + // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| +#define PD0 48 // | 48 | | | | | | | +#define PD1 49 // | 49 | | | | | | | +#define PD2 50 // | 50 | | | UART5_RX | | | | +#define PD3 51 // | 51 | | | | | | | +#define PD4 52 // | 52 | | | | | | | +#define PD5 53 // | 53 | | | USART2_TX | | | | +#define PD6 54 // | 54 | | | USART2_RX | | | | +#define PD7 55 // | 55 | | | | | | | +#define PD8 56 // | 56 | | | USART3_TX | | | | +#define PD9 57 // | 57 | | | USART3_RX | | | | +#define PD10 58 // | 58 | | | | | | | +#define PD11 59 // | 59 | | | | | | | +#define PD12 60 // | 60 | | | | | | | +#define PD13 61 // | 61 | | | | | | | +#define PD14 62 // | 62 | | | | | | | +#define PD15 63 // | 63 | | | | | | | + // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| +#define PE0 64 // | 64 | | | | | | | +#define PE1 65 // | 65 | | | | | | | +#define PE2 66 // | 66 | | | | | | | +#define PE3 67 // | 67 | | | | | | | +#define PE4 68 // | 68 | | | | | | | +#define PE5 69 // | 69 | | | | | | | +#define PE6 70 // | 70 | | | | | | | +#define PE7 71 // | 71 | | | | | | | +#define PE8 72 // | 72 | | | | | | | +#define PE9 73 // | 73 | | | | | | | +#define PE10 74 // | 74 | | | | | | | +#define PE11 75 // | 75 | | | | | | | +#define PE12 76 // | 76 | | | | | | | +#define PE13 77 // | 77 | | | | | | | +#define PE14 78 // | 78 | | | | | | | +#define PE15 79 // | 79 | | | | | | | + // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| +#define PH0 80 // | 80 | | | | | | OSC_IN | +#define PH1 81 // | 81 | | | | | | OSC_OUT | + // |---------|------------|------------|-----------------------|----------------------|-----------------------------------|-----------| + +// This must be a literal +#define NUM_DIGITAL_PINS 82 +#define NUM_ANALOG_INPUTS 16 + +// Below SPI and I2C definitions already done in the core +// Could be redefined here if differs from the default one +// SPI Definitions +#define PIN_SPI_SS PC9 +#define PIN_SPI_SCK PC10 +#define PIN_SPI_MISO PC11 +#define PIN_SPI_MOSI PC12 + +// I2C Definitions +#define PIN_WIRE_SCL PB8 +#define PIN_WIRE_SDA PB9 + +// Timer Definitions +// Do not use timer used by PWM pins when possible. See PinMap_PWM in PeripheralPins.c +// TIM1 = HEATER0, HEATER1, [SERVO] +// TIM2 = FAN1, FAN2, [BEEPER] +// TIM4 = HEATER_BED +// TIM5 = HEATER2, FAN0 +// Uses default for STM32F4xx STEP_TIMER 6 and TEMP_TIMER 14 +#define TIMER_SERVO TIM1 // TIMER_SERVO must be defined in this file +#define TIMER_TONE TIM2 // TIMER_TONE must be defined in this file +#define TIMER_SERIAL TIM3 // TIMER_SERIAL must be defined in this file + +// USART1 (direct to RK3328 SoC) +#define ENABLE_HWSERIAL1 +#define PIN_SERIAL1_TX PA9 +#define PIN_SERIAL1_RX PA10 + +// USART3 connector +#define ENABLE_HWSERIAL3 +#define PIN_SERIAL3_TX PB10 +#define PIN_SERIAL3_RX PB11 + +#ifdef __cplusplus +} // extern "C" +#endif +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +// These serial port names are intended to allow libraries and architecture-neutral +// sketches to automatically default to the correct port name for a particular type +// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, +// the first hardware serial port whose RX/TX pins are not dedicated to another use. +// +// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor +// +// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial +// +// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library +// +// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. +// +// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX +// pins are NOT connected to anything by default. +#define SERIAL_PORT_MONITOR Serial1 +#define SERIAL_PORT_USBVIRTUAL SerialUSB +#define SERIAL_PORT_HARDWARE Serial1 +#define SERIAL_PORT_HARDWARE1 Serial3 +#define SERIAL_PORT_HARDWARE_OPEN Serial1 +#define SERIAL_PORT_HARDWARE_OPEN1 Serial3 +#endif diff --git a/ini/stm32f4.ini b/ini/stm32f4.ini index b0d2a5600c3d..471e9e7fb496 100644 --- a/ini/stm32f4.ini +++ b/ini/stm32f4.ini @@ -47,7 +47,6 @@ board = marlin_STM32F407ZGT6 board_build.variant = MARLIN_FLY_F407ZG board_build.offset = 0x8000 upload_protocol = dfu - # # FYSETC S6 (STM32F446RET6 ARM Cortex-M4) # @@ -684,3 +683,19 @@ build_flags = ${stm32_variant.build_flags} -DSTEP_TIMER_IRQ_PRIO=0 upload_protocol = stlink debug_tool = stlink + +# +# MKS SKIPR v1.0 all-in-one board (STM32F407VE) +# +[env:mks_skipr_v1] +extends = stm32_variant +board = marlin_MKS_SKIPR_V1 +board_build.rename = mks_skipr.bin + +[env:mks_skipr_v1_nobootloader] +extends = env:mks_skipr_v1 +board_build.rename = firmware.bin +board_build.offset = 0x0000 +board_upload.offset_address = 0x08000000 +upload_protocol = dfu +upload_command = dfu-util -a 0 -s 0x08000000:leave -D "$SOURCE" From 1a6f9daee89e048fe9794e60b0ce71a359d21357 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 12 Oct 2022 15:24:05 -0500 Subject: [PATCH 096/243] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Min?= =?UTF-8?q?=20and=20max=20for=20base=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/types.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index 4292cd0cf1cd..84a969ad0bdf 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -348,9 +348,9 @@ struct XYval { // If any element is true then it's true FI operator bool() { return x || y; } // Smallest element - FI T _min() const { return _MIN(x, y); } + FI T small() const { return _MIN(x, y); } // Largest element - FI T _max() const { return _MAX(x, y); } + FI T large() const { return _MAX(x, y); } // Explicit copy and copies with conversion FI XYval copy() const { return *this; } @@ -505,9 +505,9 @@ struct XYZval { // If any element is true then it's true FI operator bool() { return NUM_AXIS_GANG(x, || y, || z, || i, || j, || k, || u, || v, || w); } // Smallest element - FI T _min() const { return _MIN(NUM_AXIS_LIST(x, y, z, i, j, k, u, v, w)); } + FI T small() const { return _MIN(NUM_AXIS_LIST(x, y, z, i, j, k, u, v, w)); } // Largest element - FI T _max() const { return _MAX(NUM_AXIS_LIST(x, y, z, i, j, k, u, v, w)); } + FI T large() const { return _MAX(NUM_AXIS_LIST(x, y, z, i, j, k, u, v, w)); } // Explicit copy and copies with conversion FI XYZval copy() const { XYZval o = *this; return o; } @@ -660,9 +660,9 @@ struct XYZEval { // If any element is true then it's true FI operator bool() { return 0 LOGICAL_AXIS_GANG(|| e, || x, || y, || z, || i, || j, || k, || u, || v, || w); } // Smallest element - FI T _min() const { return _MIN(LOGICAL_AXIS_LIST(e, x, y, z, i, j, k, u, v, w)); } + FI T small() const { return _MIN(LOGICAL_AXIS_LIST(e, x, y, z, i, j, k, u, v, w)); } // Largest element - FI T _max() const { return _MAX(LOGICAL_AXIS_LIST(e, x, y, z, i, j, k, u, v, w)); } + FI T large() const { return _MAX(LOGICAL_AXIS_LIST(e, x, y, z, i, j, k, u, v, w)); } // Explicit copy and copies with conversion FI XYZEval copy() const { XYZEval v = *this; return v; } From 5c195078ffd5d3e86cf9c836cf1313746516d750 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 12 Oct 2022 17:53:42 -0500 Subject: [PATCH 097/243] =?UTF-8?q?=F0=9F=8E=A8=20Misc.=20variant=20cleanu?= =?UTF-8?q?p?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../variants/MARLIN_ARTILLERY_RUBY/hal_conf_custom.h | 4 ++-- .../PlatformIO/variants/MARLIN_ARTILLERY_RUBY/ldscript.ld | 2 +- .../PlatformIO/variants/MARLIN_ARTILLERY_RUBY/startup.S | 2 +- .../PlatformIO/variants/MARLIN_BIGTREE_BTT002/ldscript.ld | 2 +- .../PlatformIO/variants/MARLIN_BIGTREE_E3_RRF/ldscript.ld | 2 +- .../PlatformIO/variants/MARLIN_BIGTREE_GTR_V1/ldscript.ld | 2 +- .../variants/MARLIN_BIGTREE_OCTOPUS_PRO_V1_F429/ldscript.ld | 2 +- .../variants/MARLIN_BIGTREE_OCTOPUS_V1/ldscript.ld | 2 +- .../variants/MARLIN_BIGTREE_SKR_PRO_11/ldscript.ld | 2 +- .../variants/MARLIN_BTT_SKR_SE_BX/hal_conf_extra.h | 4 ++-- .../PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/ldscript.ld | 2 +- .../variants/MARLIN_CREALITY_STM32F401RC/hal_conf_custom.h | 4 ++-- .../variants/MARLIN_CREALITY_STM32F401RC/ldscript.ld | 4 ++-- .../share/PlatformIO/variants/MARLIN_F103Rx/ldscript.ld | 2 +- .../PlatformIO/variants/MARLIN_F103VE_LONGER/ldscript.ld | 2 +- .../share/PlatformIO/variants/MARLIN_F103Vx/ldscript.ld | 2 +- .../PlatformIO/variants/MARLIN_F103Zx/hal_conf_custom.h | 4 ++-- .../share/PlatformIO/variants/MARLIN_F103Zx/ldscript.ld | 2 +- .../share/PlatformIO/variants/MARLIN_F401RC/ldscript.ld | 4 ++-- .../PlatformIO/variants/MARLIN_F407VE/hal_conf_custom.h | 4 ++-- .../share/PlatformIO/variants/MARLIN_F407VE/ldscript.ld | 2 +- .../share/PlatformIO/variants/MARLIN_F446VE/ldscript.ld | 2 +- .../PlatformIO/variants/MARLIN_F4x7Vx/hal_conf_extra.h | 4 ++-- .../share/PlatformIO/variants/MARLIN_F4x7Vx/ldscript.ld | 2 +- .../share/PlatformIO/variants/MARLIN_FLY_F407ZG/ldscript.ld | 2 +- .../variants/MARLIN_FYSETC_CHEETAH_V20/hal_conf_custom.h | 4 ++-- .../variants/MARLIN_FYSETC_CHEETAH_V20/ldscript.ld | 4 ++-- .../share/PlatformIO/variants/MARLIN_FYSETC_S6/ldscript.ld | 2 +- .../variants/MARLIN_FYSETC_SPIDER_KING407/ldscript.ld | 2 +- .../share/PlatformIO/variants/MARLIN_G0B1RE/ldscript.ld | 4 ++-- .../share/PlatformIO/variants/MARLIN_H743Vx/ldscript.ld | 2 +- .../variants/MARLIN_MKS_SKIPR_V1/hal_conf_extra.h | 6 +++--- .../PlatformIO/variants/MARLIN_MKS_SKIPR_V1/ldscript.ld | 2 +- .../variants/MARLIN_TH3D_EZBOARD_V2/hal_conf_extra.h | 4 ++-- .../PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/ldscript.ld | 2 +- 35 files changed, 49 insertions(+), 49 deletions(-) diff --git a/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/hal_conf_custom.h b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/hal_conf_custom.h index 9fa98807d68e..bbce8a1c9a11 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/hal_conf_custom.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/hal_conf_custom.h @@ -5,8 +5,8 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2017 STMicroelectronics. - * All rights reserved.

+ * Copyright (c) 2017 STMicroelectronics. + * All rights reserved. * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the diff --git a/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/ldscript.ld index 57c01c8df8fc..0f8a490044f7 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/ldscript.ld @@ -20,7 +20,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2014 Ac6

+** Copyright (c) 2014 Ac6 ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/startup.S b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/startup.S index 81999dda6a42..9348cd057ade 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/startup.S +++ b/buildroot/share/PlatformIO/variants/MARLIN_ARTILLERY_RUBY/startup.S @@ -16,7 +16,7 @@ ****************************************************************************** * @attention * - *

© COPYRIGHT 2015 STMicroelectronics

+ * Copyright (c) 2015 STMicroelectronics * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/ldscript.ld index 6af296a521ff..f7e09b8ef0e7 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_BTT002/ldscript.ld @@ -21,7 +21,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2014 Ac6

+** Copyright (c) 2014 Ac6 ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_E3_RRF/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_E3_RRF/ldscript.ld index 6af296a521ff..f7e09b8ef0e7 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_E3_RRF/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_E3_RRF/ldscript.ld @@ -21,7 +21,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2014 Ac6

+** Copyright (c) 2014 Ac6 ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_GTR_V1/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_GTR_V1/ldscript.ld index 6af296a521ff..f7e09b8ef0e7 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_GTR_V1/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_GTR_V1/ldscript.ld @@ -21,7 +21,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2014 Ac6

+** Copyright (c) 2014 Ac6 ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_PRO_V1_F429/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_PRO_V1_F429/ldscript.ld index 4cac4ac6e2a7..063525c96400 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_PRO_V1_F429/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_PRO_V1_F429/ldscript.ld @@ -21,7 +21,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2014 Ac6

+** Copyright (c) 2014 Ac6 ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_V1/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_V1/ldscript.ld index ca21498cd2d9..ed6cae4379b9 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_V1/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_OCTOPUS_V1/ldscript.ld @@ -21,7 +21,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2014 Ac6

+** Copyright (c) 2014 Ac6 ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_SKR_PRO_11/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_SKR_PRO_11/ldscript.ld index 6af296a521ff..f7e09b8ef0e7 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_SKR_PRO_11/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_BIGTREE_SKR_PRO_11/ldscript.ld @@ -21,7 +21,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2014 Ac6

+** Copyright (c) 2014 Ac6 ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/hal_conf_extra.h index 92730f594520..f355549a675e 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/hal_conf_extra.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/hal_conf_extra.h @@ -5,8 +5,8 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2017 STMicroelectronics. - * All rights reserved.

+ * Copyright (c) 2017 STMicroelectronics. + * All rights reserved. * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the diff --git a/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/ldscript.ld index 006c87a17a18..931091bc3109 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_BTT_SKR_SE_BX/ldscript.ld @@ -26,7 +26,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2019 STMicroelectronics

+** Copyright (c) 2019 STMicroelectronics ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_CREALITY_STM32F401RC/hal_conf_custom.h b/buildroot/share/PlatformIO/variants/MARLIN_CREALITY_STM32F401RC/hal_conf_custom.h index 1dd047bb9005..808b5588ed5c 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_CREALITY_STM32F401RC/hal_conf_custom.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_CREALITY_STM32F401RC/hal_conf_custom.h @@ -5,8 +5,8 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2017 STMicroelectronics. - * All rights reserved.

+ * Copyright (c) 2017 STMicroelectronics. + * All rights reserved. * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the diff --git a/buildroot/share/PlatformIO/variants/MARLIN_CREALITY_STM32F401RC/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_CREALITY_STM32F401RC/ldscript.ld index 004714cd6dc0..d12edc719777 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_CREALITY_STM32F401RC/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_CREALITY_STM32F401RC/ldscript.ld @@ -21,7 +21,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2014 Ac6

+** Copyright (c) 2014 Ac6 ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: @@ -184,4 +184,4 @@ SECTIONS } .ARM.attributes 0 : { *(.ARM.attributes) } -} \ No newline at end of file +} diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103Rx/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_F103Rx/ldscript.ld index cd7503b3a51d..4eb277cb06f4 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103Rx/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103Rx/ldscript.ld @@ -23,7 +23,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2019 STMicroelectronics

+** Copyright (c) 2019 STMicroelectronics ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/ldscript.ld index 6bc577236a9c..a1042aa8d29a 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103VE_LONGER/ldscript.ld @@ -22,7 +22,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2019 STMicroelectronics

+** Copyright (c) 2019 STMicroelectronics ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/ldscript.ld index a65b07d61c5f..3013b096073c 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103Vx/ldscript.ld @@ -23,7 +23,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2019 STMicroelectronics

+** Copyright (c) 2019 STMicroelectronics ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/hal_conf_custom.h b/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/hal_conf_custom.h index 2443052621d7..a9475dbdd912 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/hal_conf_custom.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/hal_conf_custom.h @@ -5,8 +5,8 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2017 STMicroelectronics. - * All rights reserved.

+ * Copyright (c) 2017 STMicroelectronics. + * All rights reserved. * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/ldscript.ld index cc4b323f763a..cac12da5c2a1 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_F103Zx/ldscript.ld @@ -23,7 +23,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2019 STMicroelectronics

+** Copyright (c) 2019 STMicroelectronics ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F401RC/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_F401RC/ldscript.ld index a0ab41f631c5..c7e67d311e89 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F401RC/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_F401RC/ldscript.ld @@ -13,8 +13,8 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2020 STMicroelectronics. - * All rights reserved.

+ * Copyright (c) 2020 STMicroelectronics. + * All rights reserved. * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F407VE/hal_conf_custom.h b/buildroot/share/PlatformIO/variants/MARLIN_F407VE/hal_conf_custom.h index 58e9646b57f5..ea5e2cc70934 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F407VE/hal_conf_custom.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F407VE/hal_conf_custom.h @@ -5,8 +5,8 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2017 STMicroelectronics. - * All rights reserved.

+ * Copyright (c) 2017 STMicroelectronics. + * All rights reserved. * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F407VE/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_F407VE/ldscript.ld index 68b65973226f..9357c4b52c17 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F407VE/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_F407VE/ldscript.ld @@ -21,7 +21,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2014 Ac6

+** Copyright (c) 2014 Ac6 ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F446VE/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_F446VE/ldscript.ld index a375232d5981..7d5307717c1e 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F446VE/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_F446VE/ldscript.ld @@ -20,7 +20,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2014 Ac6

+** Copyright (c) 2014 Ac6 ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/hal_conf_extra.h index d246a1e7454e..f2f4ed3e96b5 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/hal_conf_extra.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/hal_conf_extra.h @@ -8,8 +8,8 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2017 STMicroelectronics. - * All rights reserved.

+ * Copyright (c) 2017 STMicroelectronics. + * All rights reserved. * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/ldscript.ld index 8b38135a2a51..df1ed1581a39 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_F4x7Vx/ldscript.ld @@ -19,7 +19,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2019 STMicroelectronics

+** Copyright (c) 2019 STMicroelectronics ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_FLY_F407ZG/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_FLY_F407ZG/ldscript.ld index d644d49beb1d..cd7ccef85ff3 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_FLY_F407ZG/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_FLY_F407ZG/ldscript.ld @@ -21,7 +21,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2014 Ac6

+** Copyright (c) 2014 Ac6 ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/hal_conf_custom.h b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/hal_conf_custom.h index 2ff2fd686ea4..fb3d21c6acb3 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/hal_conf_custom.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/hal_conf_custom.h @@ -5,8 +5,8 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2017 STMicroelectronics. - * All rights reserved.

+ * Copyright (c) 2017 STMicroelectronics. + * All rights reserved. * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the diff --git a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/ldscript.ld index eaaff196cd0d..1ded9f2a3e13 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_CHEETAH_V20/ldscript.ld @@ -21,7 +21,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2014 Ac6

+** Copyright (c) 2014 Ac6 ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: @@ -184,4 +184,4 @@ SECTIONS } .ARM.attributes 0 : { *(.ARM.attributes) } -} \ No newline at end of file +} diff --git a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/ldscript.ld index 900ef0639101..5db15287845f 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_S6/ldscript.ld @@ -21,7 +21,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2014 Ac6

+** Copyright (c) 2014 Ac6 ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/ldscript.ld index 6af296a521ff..f7e09b8ef0e7 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_FYSETC_SPIDER_KING407/ldscript.ld @@ -21,7 +21,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2014 Ac6

+** Copyright (c) 2014 Ac6 ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/ldscript.ld index 3b619b6a97e8..4e0e997341c4 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_G0B1RE/ldscript.ld @@ -13,8 +13,8 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2020 STMicroelectronics. - * All rights reserved.

+ * Copyright (c) 2020 STMicroelectronics. + * All rights reserved. * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the diff --git a/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/ldscript.ld index 7d248a268283..5f439f3f8e1f 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_H743Vx/ldscript.ld @@ -26,7 +26,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2019 STMicroelectronics

+** Copyright (c) 2019 STMicroelectronics ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/hal_conf_extra.h index 599c78ce5c49..2ca9df2efcdf 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/hal_conf_extra.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/hal_conf_extra.h @@ -8,8 +8,8 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2017 STMicroelectronics. - * All rights reserved.

+ * Copyright (c) 2017 STMicroelectronics. + * All rights reserved. * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the @@ -493,4 +493,4 @@ #endif /* __STM32F4xx_HAL_CONF_H */ -/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ \ No newline at end of file +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/ldscript.ld index 8b38135a2a51..df1ed1581a39 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/ldscript.ld @@ -19,7 +19,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2019 STMicroelectronics

+** Copyright (c) 2019 STMicroelectronics ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: diff --git a/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/hal_conf_extra.h b/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/hal_conf_extra.h index a5961a488bf7..8a04b8be103b 100755 --- a/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/hal_conf_extra.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/hal_conf_extra.h @@ -8,8 +8,8 @@ ****************************************************************************** * @attention * - *

© Copyright (c) 2017 STMicroelectronics. - * All rights reserved.

+ * Copyright (c) 2017 STMicroelectronics. + * All rights reserved. * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the diff --git a/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/ldscript.ld index e07c5e4acef9..55ae9227db3b 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/ldscript.ld +++ b/buildroot/share/PlatformIO/variants/MARLIN_TH3D_EZBOARD_V2/ldscript.ld @@ -20,7 +20,7 @@ ***************************************************************************** ** @attention ** -**

© COPYRIGHT(c) 2019 STMicroelectronics

+** Copyright (c) 2019 STMicroelectronics ** ** Redistribution and use in source and binary forms, with or without modification, ** are permitted provided that the following conditions are met: From 0047b3064da8b7e1a3789b497853fb93c1e7f7f9 Mon Sep 17 00:00:00 2001 From: EvilGremlin <22657714+EvilGremlin@users.noreply.github.com> Date: Thu, 13 Oct 2022 01:57:22 +0300 Subject: [PATCH 098/243] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20temperature=20incl?= =?UTF-8?q?ude=20(#24834)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/module/temperature.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 7954611bc4a9..349264606aec 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -30,6 +30,7 @@ #include "../MarlinCore.h" #include "../HAL/shared/Delay.h" #include "../lcd/marlinui.h" +#include "../gcode/gcode.h" #include "temperature.h" #include "endstops.h" @@ -63,10 +64,6 @@ #include "../feature/host_actions.h" #endif -#if EITHER(HAS_TEMP_SENSOR, LASER_FEATURE) - #include "../gcode/gcode.h" -#endif - #if ENABLED(NOZZLE_PARK_FEATURE) #include "../libs/nozzle.h" #endif From bfcb8c704a8ddbdd86d145151e3a305a780034f1 Mon Sep 17 00:00:00 2001 From: adam3654 Date: Wed, 12 Oct 2022 19:03:32 -0400 Subject: [PATCH 099/243] =?UTF-8?q?=E2=9C=A8=20DOGM=20Display=20Sleep=20(#?= =?UTF-8?q?24829)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/gcode.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 863d4320956c..6be4f46b21f3 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -793,6 +793,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 250: M250(); break; // M250: Set LCD contrast #endif + #if HAS_GCODE_M255 + case 255: M255(); break; // M255: Set LCD Sleep/Backlight Timeout (Minutes) + #endif + #if HAS_LCD_BRIGHTNESS case 256: M256(); break; // M256: Set LCD brightness #endif From c52cf77d0ade00b7cdf9e796e98b6c294c2abaa6 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 12 Oct 2022 18:15:29 -0500 Subject: [PATCH 100/243] =?UTF-8?q?=F0=9F=90=9B=20Fix=20M876=20without=20e?= =?UTF-8?q?mergency=20parser?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix regression from 1fb2fffdbf --- Marlin/src/gcode/gcode.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 6be4f46b21f3..7edcaa981cd4 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -600,7 +600,9 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 108: M108(); break; // M108: Cancel Waiting case 112: M112(); break; // M112: Full Shutdown case 410: M410(); break; // M410: Quickstop - Abort all the planned moves. - TERN_(HOST_PROMPT_SUPPORT, case 876:) // M876: Handle Host prompt responses + #if ENABLED(HOST_PROMPT_SUPPORT) + case 876: M876(); break; // M876: Handle Host prompt responses + #endif #else case 108: case 112: case 410: TERN_(HOST_PROMPT_SUPPORT, case 876:) From a4d58e887667a14d7a6639b579416ff799309b0e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 14 Oct 2022 13:15:37 -0500 Subject: [PATCH 101/243] =?UTF-8?q?=F0=9F=8E=A8=20MMU2=20cleanup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/mmu/mmu2.cpp | 46 ++++++++++++++------------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/Marlin/src/feature/mmu/mmu2.cpp b/Marlin/src/feature/mmu/mmu2.cpp index 54553a4f2d4b..4f86578a60a7 100644 --- a/Marlin/src/feature/mmu/mmu2.cpp +++ b/Marlin/src/feature/mmu/mmu2.cpp @@ -54,7 +54,8 @@ MMU2 mmu2; #define MMU_CMD_TIMEOUT 45000UL // 45s timeout for mmu commands (except P0) #define MMU_P0_TIMEOUT 3000UL // Timeout for P0 command: 3seconds -#define MMU2_COMMAND(S) tx_str(F(S "\n")) +#define MMU2_SEND(S) tx_str(F(S "\n")) +#define MMU2_RECV(S) rx_str(F(S "\n")) #if ENABLED(MMU_EXTRUDER_SENSOR) uint8_t mmu_idl_sens = 0; @@ -131,7 +132,7 @@ void MMU2::reset() { safe_delay(20); WRITE(MMU2_RST_PIN, HIGH); #else - MMU2_COMMAND("X0"); // Send soft reset + MMU2_SEND("X0"); // Send soft reset #endif } @@ -157,11 +158,9 @@ void MMU2::mmu_loop() { case -1: if (rx_start()) { prev_P0_request = millis(); // Initialize finda sensor timeout - DEBUG_ECHOLNPGM("MMU => 'start'"); DEBUG_ECHOLNPGM("MMU <= 'S1'"); - - MMU2_COMMAND("S1"); // Read Version + MMU2_SEND("S1"); // Read Version state = -2; } else if (millis() > 30000) { // 30sec after reset disable MMU @@ -173,10 +172,8 @@ void MMU2::mmu_loop() { case -2: if (rx_ok()) { sscanf(rx_buffer, "%huok\n", &version); - DEBUG_ECHOLNPGM("MMU => ", version, "\nMMU <= 'S2'"); - - MMU2_COMMAND("S2"); // Read Build Number + MMU2_SEND("S2"); // Read Build Number state = -3; } break; @@ -191,14 +188,12 @@ void MMU2::mmu_loop() { #if ENABLED(MMU2_MODE_12V) DEBUG_ECHOLNPGM("MMU <= 'M1'"); - - MMU2_COMMAND("M1"); // Stealth Mode + MMU2_SEND("M1"); // Stealth Mode state = -5; #else DEBUG_ECHOLNPGM("MMU <= 'P0'"); - - MMU2_COMMAND("P0"); // Read FINDA + MMU2_SEND("P0"); // Read FINDA state = -4; #endif } @@ -209,10 +204,8 @@ void MMU2::mmu_loop() { // response to M1 if (rx_ok()) { DEBUG_ECHOLNPGM("MMU => ok"); - DEBUG_ECHOLNPGM("MMU <= 'P0'"); - - MMU2_COMMAND("P0"); // Read FINDA + MMU2_SEND("P0"); // Read FINDA state = -4; } break; @@ -250,14 +243,13 @@ void MMU2::mmu_loop() { else if (cmd == MMU_CMD_C0) { // continue loading DEBUG_ECHOLNPGM("MMU <= 'C0'"); - MMU2_COMMAND("C0"); + MMU2_SEND("C0"); state = 3; // wait for response } else if (cmd == MMU_CMD_U0) { // unload current DEBUG_ECHOLNPGM("MMU <= 'U0'"); - - MMU2_COMMAND("U0"); + MMU2_SEND("U0"); state = 3; // wait for response } else if (WITHIN(cmd, MMU_CMD_E0, MMU_CMD_E0 + EXTRUDERS - 1)) { @@ -270,7 +262,7 @@ void MMU2::mmu_loop() { else if (cmd == MMU_CMD_R0) { // recover after eject DEBUG_ECHOLNPGM("MMU <= 'R0'"); - MMU2_COMMAND("R0"); + MMU2_SEND("R0"); state = 3; // wait for response } else if (WITHIN(cmd, MMU_CMD_F0, MMU_CMD_F0 + EXTRUDERS - 1)) { @@ -285,7 +277,7 @@ void MMU2::mmu_loop() { cmd = MMU_CMD_NONE; } else if (ELAPSED(millis(), prev_P0_request + 300)) { - MMU2_COMMAND("P0"); // Read FINDA + MMU2_SEND("P0"); // Read FINDA state = 2; // wait for response } @@ -314,7 +306,7 @@ void MMU2::mmu_loop() { if (mmu_idl_sens) { if (FILAMENT_PRESENT() && mmu_loading_flag) { DEBUG_ECHOLNPGM("MMU <= 'A'"); - MMU2_COMMAND("A"); // send 'abort' request + MMU2_SEND("A"); // send 'abort' request mmu_idl_sens = 0; DEBUG_ECHOLNPGM("MMU IDLER_SENSOR = 0 - ABORT"); } @@ -327,9 +319,9 @@ void MMU2::mmu_loop() { const bool keep_trying = !mmu2s_triggered && last_cmd == MMU_CMD_C0; if (keep_trying) { // MMU ok received but filament sensor not triggered, retrying... - DEBUG_ECHOLNPGM("MMU => 'ok' (filament not present in gears)"); + DEBUG_ECHOLNPGM("MMU => 'ok' (no filament in gears)"); DEBUG_ECHOLNPGM("MMU <= 'C0' (keep trying)"); - MMU2_COMMAND("C0"); + MMU2_SEND("C0"); } #else constexpr bool keep_trying = false; @@ -361,7 +353,7 @@ void MMU2::mmu_loop() { */ bool MMU2::rx_start() { // check for start message - return rx_str(F("start\n")); + return MMU2_RECV("start"); } /** @@ -440,7 +432,7 @@ void MMU2::clear_rx_buffer() { * Check if we received 'ok' from MMU */ bool MMU2::rx_ok() { - if (rx_str(F("ok\n"))) { + if (MMU2_RECV("ok")) { prev_P0_request = millis(); return true; } @@ -673,7 +665,7 @@ static void mmu2_not_responding() { // When (T0 rx->ok) load is ready, but in fact it did not load // successfully or an overload created pressure in the extruder. // Send (C0) to load more and move E_AXIS a little to release pressure. - if ((fil_present = FILAMENT_PRESENT())) MMU2_COMMAND("A"); + if ((fil_present = FILAMENT_PRESENT())) MMU2_SEND("A"); } while (!fil_present && PENDING(millis(), expire_ms)); stepper.disable_extruder(); manage_response(true, true); @@ -882,7 +874,7 @@ void MMU2::filament_runout() { if (cmd == MMU_CMD_NONE && last_cmd == MMU_CMD_C0) { if (present && !mmu2s_triggered) { DEBUG_ECHOLNPGM("MMU <= 'A'"); - tx_str(F("A\n")); + MMU2_SEND("A"); } // Slowly spin the extruder during C0 else { From f39f4d02889b77c4d72b1b84d6f06792786a9a8c Mon Sep 17 00:00:00 2001 From: mjbogusz Date: Sat, 15 Oct 2022 01:59:31 +0200 Subject: [PATCH 102/243] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20TFT=20LCD=20in=20S?= =?UTF-8?q?imulation=20(#24871)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 4 ++-- Marlin/src/inc/Conditionals_LCD.h | 6 ++++-- Marlin/src/lcd/marlinui.cpp | 2 +- Marlin/src/pins/linux/pins_RAMPS_LINUX.h | 13 +++++++++++++ 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index ebcdf25e2d6a..d0495dc7d863 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ tests-single-ci: tests-single-local: @if ! test -n "$(TEST_TARGET)" ; then echo "***ERROR*** Set TEST_TARGET= or use make tests-all-local" ; return 1; fi - export PATH=./buildroot/bin/:./buildroot/tests/:${PATH} \ + export PATH="./buildroot/bin/:./buildroot/tests/:${PATH}" \ && export VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) \ && run_tests . $(TEST_TARGET) "$(ONLY_TEST)" .PHONY: tests-single-local @@ -38,7 +38,7 @@ tests-single-local-docker: .PHONY: tests-single-local-docker tests-all-local: - export PATH=./buildroot/bin/:./buildroot/tests/:${PATH} \ + export PATH="./buildroot/bin/:./buildroot/tests/:${PATH}" \ && export VERBOSE_PLATFORMIO=$(VERBOSE_PLATFORMIO) \ && for TEST_TARGET in $$(./get_test_targets.py) ; do echo "Running tests for $$TEST_TARGET" ; run_tests . $$TEST_TARGET ; done .PHONY: tests-all-local diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 47ae0a6dffbb..7f6857a3e0f1 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -1496,7 +1496,7 @@ #endif #elif ENABLED(TFT_GENERIC) #define TFT_DEFAULT_ORIENTATION (TFT_EXCHANGE_XY | TFT_INVERT_X | TFT_INVERT_Y) - #if NONE(TFT_RES_320x240, TFT_RES_480x272, TFT_RES_480x320) + #if NONE(TFT_RES_320x240, TFT_RES_480x272, TFT_RES_480x320, TFT_RES_1024x600) #define TFT_RES_320x240 #endif #if NONE(TFT_INTERFACE_FSMC, TFT_INTERFACE_SPI) @@ -1574,6 +1574,8 @@ #elif TFT_HEIGHT == 600 #if ENABLED(TFT_INTERFACE_LTDC) #define TFT_1024x600_LTDC + #else + #define TFT_1024x600_SIM // "Simulation" - for testing purposes only #endif #endif #endif @@ -1584,7 +1586,7 @@ #define HAS_UI_480x320 1 #elif EITHER(TFT_480x272, TFT_480x272_SPI) #define HAS_UI_480x272 1 -#elif defined(TFT_1024x600_LTDC) +#elif EITHER(TFT_1024x600_LTDC, TFT_1024x600_SIM) #define HAS_UI_1024x600 1 #endif #if ANY(HAS_UI_320x240, HAS_UI_480x320, HAS_UI_480x272) diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 00b0d62e1ae0..2e116d5479b8 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -1726,7 +1726,7 @@ void MarlinUI::init() { ); } - #if LCD_WITH_BLINK + #if LCD_WITH_BLINK && DISABLED(HAS_GRAPHICAL_TFT) typedef void (*PrintProgress_t)(); void MarlinUI::rotate_progress() { // Renew and redraw all enabled progress strings const PrintProgress_t progFunc[] = { diff --git a/Marlin/src/pins/linux/pins_RAMPS_LINUX.h b/Marlin/src/pins/linux/pins_RAMPS_LINUX.h index 9e2eedd68e80..75d6b9d93e91 100644 --- a/Marlin/src/pins/linux/pins_RAMPS_LINUX.h +++ b/Marlin/src/pins/linux/pins_RAMPS_LINUX.h @@ -450,6 +450,19 @@ #ifndef TOUCH_OFFSET_Y #define TOUCH_OFFSET_Y 1 #endif + #elif ENABLED(TFT_RES_1024x600) + #ifndef TOUCH_CALIBRATION_X + #define TOUCH_CALIBRATION_X 65533 + #endif + #ifndef TOUCH_CALIBRATION_Y + #define TOUCH_CALIBRATION_Y 38399 + #endif + #ifndef TOUCH_OFFSET_X + #define TOUCH_OFFSET_X 2 + #endif + #ifndef TOUCH_OFFSET_Y + #define TOUCH_OFFSET_Y 1 + #endif #endif #endif From b3e7d1e91e9e8e7e9184184cfd2d28cbb7bb24e8 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Sun, 16 Oct 2022 13:40:00 +1300 Subject: [PATCH 103/243] =?UTF-8?q?=F0=9F=90=9B=20Fix=20operators=20for=20?= =?UTF-8?q?V=20axis=20(#24866)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/src/core/types.h | 202 +++++++++++++++++++------------------- Marlin/src/module/probe.h | 2 +- 2 files changed, 102 insertions(+), 102 deletions(-) diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index 84a969ad0bdf..4497ff49af43 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -226,8 +226,8 @@ typedef const_float_t const_celsius_float_t; // Helpers #define _RECIP(N) ((N) ? 1.0f / static_cast(N) : 0.0f) #define _ABS(N) ((N) < 0 ? -(N) : (N)) -#define _LS(N) (N = (T)(uint32_t(N) << v)) -#define _RS(N) (N = (T)(uint32_t(N) >> v)) +#define _LS(N) (N = (T)(uint32_t(N) << p)) +#define _RS(N) (N = (T)(uint32_t(N) >> p)) #define FI FORCE_INLINE // Forward declarations @@ -409,18 +409,18 @@ struct XYval { FI XYval operator* (const XYZEval &rs) { XYval ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; } FI XYval operator/ (const XYZEval &rs) const { XYval ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; } FI XYval operator/ (const XYZEval &rs) { XYval ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; } - FI XYval operator* (const float &v) const { XYval ls = *this; ls.x *= v; ls.y *= v; return ls; } - FI XYval operator* (const float &v) { XYval ls = *this; ls.x *= v; ls.y *= v; return ls; } - FI XYval operator* (const int &v) const { XYval ls = *this; ls.x *= v; ls.y *= v; return ls; } - FI XYval operator* (const int &v) { XYval ls = *this; ls.x *= v; ls.y *= v; return ls; } - FI XYval operator/ (const float &v) const { XYval ls = *this; ls.x /= v; ls.y /= v; return ls; } - FI XYval operator/ (const float &v) { XYval ls = *this; ls.x /= v; ls.y /= v; return ls; } - FI XYval operator/ (const int &v) const { XYval ls = *this; ls.x /= v; ls.y /= v; return ls; } - FI XYval operator/ (const int &v) { XYval ls = *this; ls.x /= v; ls.y /= v; return ls; } - FI XYval operator>>(const int &v) const { XYval ls = *this; _RS(ls.x); _RS(ls.y); return ls; } - FI XYval operator>>(const int &v) { XYval ls = *this; _RS(ls.x); _RS(ls.y); return ls; } - FI XYval operator<<(const int &v) const { XYval ls = *this; _LS(ls.x); _LS(ls.y); return ls; } - FI XYval operator<<(const int &v) { XYval ls = *this; _LS(ls.x); _LS(ls.y); return ls; } + FI XYval operator* (const float &p) const { XYval ls = *this; ls.x *= p; ls.y *= p; return ls; } + FI XYval operator* (const float &p) { XYval ls = *this; ls.x *= p; ls.y *= p; return ls; } + FI XYval operator* (const int &p) const { XYval ls = *this; ls.x *= p; ls.y *= p; return ls; } + FI XYval operator* (const int &p) { XYval ls = *this; ls.x *= p; ls.y *= p; return ls; } + FI XYval operator/ (const float &p) const { XYval ls = *this; ls.x /= p; ls.y /= p; return ls; } + FI XYval operator/ (const float &p) { XYval ls = *this; ls.x /= p; ls.y /= p; return ls; } + FI XYval operator/ (const int &p) const { XYval ls = *this; ls.x /= p; ls.y /= p; return ls; } + FI XYval operator/ (const int &p) { XYval ls = *this; ls.x /= p; ls.y /= p; return ls; } + FI XYval operator>>(const int &p) const { XYval ls = *this; _RS(ls.x); _RS(ls.y); return ls; } + FI XYval operator>>(const int &p) { XYval ls = *this; _RS(ls.x); _RS(ls.y); return ls; } + FI XYval operator<<(const int &p) const { XYval ls = *this; _LS(ls.x); _LS(ls.y); return ls; } + FI XYval operator<<(const int &p) { XYval ls = *this; _LS(ls.x); _LS(ls.y); return ls; } FI const XYval operator-() const { XYval o = *this; o.x = -x; o.y = -y; return o; } FI XYval operator-() { XYval o = *this; o.x = -x; o.y = -y; return o; } @@ -434,10 +434,10 @@ struct XYval { FI XYval& operator+=(const XYZEval &rs) { x += rs.x; y += rs.y; return *this; } FI XYval& operator-=(const XYZEval &rs) { x -= rs.x; y -= rs.y; return *this; } FI XYval& operator*=(const XYZEval &rs) { x *= rs.x; y *= rs.y; return *this; } - FI XYval& operator*=(const float &v) { x *= v; y *= v; return *this; } - FI XYval& operator*=(const int &v) { x *= v; y *= v; return *this; } - FI XYval& operator>>=(const int &v) { _RS(x); _RS(y); return *this; } - FI XYval& operator<<=(const int &v) { _LS(x); _LS(y); return *this; } + FI XYval& operator*=(const float &p) { x *= p; y *= p; return *this; } + FI XYval& operator*=(const int &p) { x *= p; y *= p; return *this; } + FI XYval& operator>>=(const int &p) { _RS(x); _RS(y); return *this; } + FI XYval& operator<<=(const int &p) { _LS(x); _LS(y); return *this; } // Exact comparisons. For floats a "NEAR" operation may be better. FI bool operator==(const XYval &rs) const { return x == rs.x && y == rs.y; } @@ -567,18 +567,18 @@ struct XYZval { FI XYZval operator* (const XYZEval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; } FI XYZval operator/ (const XYZEval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; } FI XYZval operator/ (const XYZEval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; } - FI XYZval operator* (const float &v) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v, ls.u *= v, ls.v *= v, ls.w *= v ); return ls; } - FI XYZval operator* (const float &v) { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v, ls.u *= v, ls.v *= v, ls.w *= v ); return ls; } - FI XYZval operator* (const int &v) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v, ls.u *= v, ls.v *= v, ls.w *= v ); return ls; } - FI XYZval operator* (const int &v) { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v, ls.u *= v, ls.v *= v, ls.w *= v ); return ls; } - FI XYZval operator/ (const float &v) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v, ls.u /= v, ls.v /= v, ls.w /= v ); return ls; } - FI XYZval operator/ (const float &v) { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v, ls.u /= v, ls.v /= v, ls.w /= v ); return ls; } - FI XYZval operator/ (const int &v) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v, ls.u /= v, ls.v /= v, ls.w /= v ); return ls; } - FI XYZval operator/ (const int &v) { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v, ls.u /= v, ls.v /= v, ls.w /= v ); return ls; } - FI XYZval operator>>(const int &v) const { XYZval ls = *this; NUM_AXIS_CODE(_RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k), _RS(ls.u), _RS(ls.v), _RS(ls.w) ); return ls; } - FI XYZval operator>>(const int &v) { XYZval ls = *this; NUM_AXIS_CODE(_RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k), _RS(ls.u), _RS(ls.v), _RS(ls.w) ); return ls; } - FI XYZval operator<<(const int &v) const { XYZval ls = *this; NUM_AXIS_CODE(_LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k), _LS(ls.u), _LS(ls.v), _LS(ls.w) ); return ls; } - FI XYZval operator<<(const int &v) { XYZval ls = *this; NUM_AXIS_CODE(_LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k), _LS(ls.u), _LS(ls.v), _LS(ls.w) ); return ls; } + FI XYZval operator* (const float &p) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= p, ls.y *= p, ls.z *= p, ls.i *= p, ls.j *= p, ls.k *= p, ls.u *= p, ls.v *= p, ls.w *= p ); return ls; } + FI XYZval operator* (const float &p) { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= p, ls.y *= p, ls.z *= p, ls.i *= p, ls.j *= p, ls.k *= p, ls.u *= p, ls.v *= p, ls.w *= p ); return ls; } + FI XYZval operator* (const int &p) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= p, ls.y *= p, ls.z *= p, ls.i *= p, ls.j *= p, ls.k *= p, ls.u *= p, ls.v *= p, ls.w *= p ); return ls; } + FI XYZval operator* (const int &p) { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= p, ls.y *= p, ls.z *= p, ls.i *= p, ls.j *= p, ls.k *= p, ls.u *= p, ls.v *= p, ls.w *= p ); return ls; } + FI XYZval operator/ (const float &p) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= p, ls.y /= p, ls.z /= p, ls.i /= p, ls.j /= p, ls.k /= p, ls.u /= p, ls.v /= p, ls.w /= p ); return ls; } + FI XYZval operator/ (const float &p) { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= p, ls.y /= p, ls.z /= p, ls.i /= p, ls.j /= p, ls.k /= p, ls.u /= p, ls.v /= p, ls.w /= p ); return ls; } + FI XYZval operator/ (const int &p) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= p, ls.y /= p, ls.z /= p, ls.i /= p, ls.j /= p, ls.k /= p, ls.u /= p, ls.v /= p, ls.w /= p ); return ls; } + FI XYZval operator/ (const int &p) { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= p, ls.y /= p, ls.z /= p, ls.i /= p, ls.j /= p, ls.k /= p, ls.u /= p, ls.v /= p, ls.w /= p ); return ls; } + FI XYZval operator>>(const int &p) const { XYZval ls = *this; NUM_AXIS_CODE(_RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k), _RS(ls.u), _RS(ls.v), _RS(ls.w) ); return ls; } + FI XYZval operator>>(const int &p) { XYZval ls = *this; NUM_AXIS_CODE(_RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k), _RS(ls.u), _RS(ls.v), _RS(ls.w) ); return ls; } + FI XYZval operator<<(const int &p) const { XYZval ls = *this; NUM_AXIS_CODE(_LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k), _LS(ls.u), _LS(ls.v), _LS(ls.w) ); return ls; } + FI XYZval operator<<(const int &p) { XYZval ls = *this; NUM_AXIS_CODE(_LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k), _LS(ls.u), _LS(ls.v), _LS(ls.w) ); return ls; } FI const XYZval operator-() const { XYZval o = *this; NUM_AXIS_CODE(o.x = -x, o.y = -y, o.z = -z, o.i = -i, o.j = -j, o.k = -k, o.u = -u, o.v = -v, o.w = -w); return o; } FI XYZval operator-() { XYZval o = *this; NUM_AXIS_CODE(o.x = -x, o.y = -y, o.z = -z, o.i = -i, o.j = -j, o.k = -k, o.u = -u, o.v = -v, o.w = -w); return o; } @@ -595,10 +595,10 @@ struct XYZval { FI XYZval& operator-=(const XYZEval &rs) { NUM_AXIS_CODE(x -= rs.x, y -= rs.y, z -= rs.z, i -= rs.i, j -= rs.j, k -= rs.k, u -= rs.u, v -= rs.v, w -= rs.w); return *this; } FI XYZval& operator*=(const XYZEval &rs) { NUM_AXIS_CODE(x *= rs.x, y *= rs.y, z *= rs.z, i *= rs.i, j *= rs.j, k *= rs.k, u *= rs.u, v *= rs.v, w *= rs.w); return *this; } FI XYZval& operator/=(const XYZEval &rs) { NUM_AXIS_CODE(x /= rs.x, y /= rs.y, z /= rs.z, i /= rs.i, j /= rs.j, k /= rs.k, u /= rs.u, v /= rs.v, w /= rs.w); return *this; } - FI XYZval& operator*=(const float &v) { NUM_AXIS_CODE(x *= v, y *= v, z *= v, i *= v, j *= v, k *= v, u *= v, v *= v, w *= v); return *this; } - FI XYZval& operator*=(const int &v) { NUM_AXIS_CODE(x *= v, y *= v, z *= v, i *= v, j *= v, k *= v, u *= v, v *= v, w *= v); return *this; } - FI XYZval& operator>>=(const int &v) { NUM_AXIS_CODE(_RS(x), _RS(y), _RS(z), _RS(i), _RS(j), _RS(k), _RS(u), _RS(v), _RS(w)); return *this; } - FI XYZval& operator<<=(const int &v) { NUM_AXIS_CODE(_LS(x), _LS(y), _LS(z), _LS(i), _LS(j), _LS(k), _LS(u), _LS(v), _LS(w)); return *this; } + FI XYZval& operator*=(const float &p) { NUM_AXIS_CODE(x *= p, y *= p, z *= p, i *= p, j *= p, k *= p, u *= p, v *= p, w *= p); return *this; } + FI XYZval& operator*=(const int &p) { NUM_AXIS_CODE(x *= p, y *= p, z *= p, i *= p, j *= p, k *= p, u *= p, v *= p, w *= p); return *this; } + FI XYZval& operator>>=(const int &p) { NUM_AXIS_CODE(_RS(x), _RS(y), _RS(z), _RS(i), _RS(j), _RS(k), _RS(u), _RS(v), _RS(w)); return *this; } + FI XYZval& operator<<=(const int &p) { NUM_AXIS_CODE(_LS(x), _LS(y), _LS(z), _LS(i), _LS(j), _LS(k), _LS(u), _LS(v), _LS(w)); return *this; } // Exact comparisons. For floats a "NEAR" operation may be better. FI bool operator==(const XYZEval &rs) const { return true NUM_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k, && u == rs.u, && v == rs.v, && w == rs.w); } @@ -654,15 +654,15 @@ struct XYZEval { #endif // Length reduced to one dimension - FI T magnitude() const { return (T)sqrtf(LOGICAL_AXIS_GANG(+ e*e, + x*x, + y*y, + z*z, + i*i, + j*j, + k*k, + u*u, + v*v, + w*w)); } + FI T magnitude() const { return (T)sqrtf(LOGICAL_AXIS_GANG(+ e*e, + x*x, + y*y, + z*z, + i*i, + j*j, + k*k, + u*u, + v*v, + w*w)); } // Pointer to the data as a simple array - FI operator T* () { return pos; } + FI operator T* () { return pos; } // If any element is true then it's true - FI operator bool() { return 0 LOGICAL_AXIS_GANG(|| e, || x, || y, || z, || i, || j, || k, || u, || v, || w); } + FI operator bool() { return 0 LOGICAL_AXIS_GANG(|| e, || x, || y, || z, || i, || j, || k, || u, || v, || w); } // Smallest element - FI T small() const { return _MIN(LOGICAL_AXIS_LIST(e, x, y, z, i, j, k, u, v, w)); } + FI T small() const { return _MIN(LOGICAL_AXIS_LIST(e, x, y, z, i, j, k, u, v, w)); } // Largest element - FI T large() const { return _MAX(LOGICAL_AXIS_LIST(e, x, y, z, i, j, k, u, v, w)); } + FI T large() const { return _MAX(LOGICAL_AXIS_LIST(e, x, y, z, i, j, k, u, v, w)); } // Explicit copy and copies with conversion FI XYZEval copy() const { XYZEval v = *this; return v; } @@ -688,76 +688,76 @@ struct XYZEval { FI operator const XYZval&() const { return *(const XYZval*)this; } // Accessor via an AxisEnum (or any integer) [index] - FI T& operator[](const int n) { return pos[n]; } - FI const T& operator[](const int n) const { return pos[n]; } + FI T& operator[](const int n) { return pos[n]; } + FI const T& operator[](const int n) const { return pos[n]; } // Assignment operator overrides do the expected thing - FI XYZEval& operator= (const T v) { set(LOGICAL_AXIS_LIST_1(v)); return *this; } - FI XYZEval& operator= (const XYval &rs) { set(rs.x, rs.y); return *this; } - FI XYZEval& operator= (const XYZval &rs) { set(NUM_AXIS_ELEM(rs)); return *this; } + FI XYZEval& operator= (const T v) { set(LOGICAL_AXIS_LIST_1(v)); return *this; } + FI XYZEval& operator= (const XYval &rs) { set(rs.x, rs.y); return *this; } + FI XYZEval& operator= (const XYZval &rs) { set(NUM_AXIS_ELEM(rs)); return *this; } // Override other operators to get intuitive behaviors - FI XYZEval operator+ (const XYval &rs) const { XYZEval ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; } - FI XYZEval operator+ (const XYval &rs) { XYZEval ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; } - FI XYZEval operator- (const XYval &rs) const { XYZEval ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; } - FI XYZEval operator- (const XYval &rs) { XYZEval ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; } - FI XYZEval operator* (const XYval &rs) const { XYZEval ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; } - FI XYZEval operator* (const XYval &rs) { XYZEval ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; } - FI XYZEval operator/ (const XYval &rs) const { XYZEval ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; } - FI XYZEval operator/ (const XYval &rs) { XYZEval ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; } - FI XYZEval operator+ (const XYZval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k, ls.u += rs.u, ls.v += rs.v, ls.w += rs.w); return ls; } - FI XYZEval operator+ (const XYZval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k, ls.u += rs.u, ls.v += rs.v, ls.w += rs.w); return ls; } - FI XYZEval operator- (const XYZval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k, ls.u -= rs.u, ls.v -= rs.v, ls.w -= rs.w); return ls; } - FI XYZEval operator- (const XYZval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k, ls.u -= rs.u, ls.v -= rs.v, ls.w -= rs.w); return ls; } - FI XYZEval operator* (const XYZval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; } - FI XYZEval operator* (const XYZval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; } - FI XYZEval operator/ (const XYZval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; } - FI XYZEval operator/ (const XYZval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; } - FI XYZEval operator+ (const XYZEval &rs) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e += rs.e, ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k, ls.u += rs.u, ls.v += rs.v, ls.w += rs.w); return ls; } - FI XYZEval operator+ (const XYZEval &rs) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e += rs.e, ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k, ls.u += rs.u, ls.v += rs.v, ls.w += rs.w); return ls; } - FI XYZEval operator- (const XYZEval &rs) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e -= rs.e, ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k, ls.u -= rs.u, ls.v -= rs.v, ls.w -= rs.w); return ls; } - FI XYZEval operator- (const XYZEval &rs) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e -= rs.e, ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k, ls.u -= rs.u, ls.v -= rs.v, ls.w -= rs.w); return ls; } - FI XYZEval operator* (const XYZEval &rs) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= rs.e, ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; } - FI XYZEval operator* (const XYZEval &rs) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= rs.e, ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; } - FI XYZEval operator/ (const XYZEval &rs) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= rs.e, ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; } - FI XYZEval operator/ (const XYZEval &rs) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= rs.e, ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; } - FI XYZEval operator* (const float &v) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= v, ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v, ls.u *= v, ls.v *= v, ls.w *= v ); return ls; } - FI XYZEval operator* (const float &v) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= v, ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v, ls.u *= v, ls.v *= v, ls.w *= v ); return ls; } - FI XYZEval operator* (const int &v) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= v, ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v, ls.u *= v, ls.v *= v, ls.w *= v ); return ls; } - FI XYZEval operator* (const int &v) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= v, ls.x *= v, ls.y *= v, ls.z *= v, ls.i *= v, ls.j *= v, ls.k *= v, ls.u *= v, ls.v *= v, ls.w *= v ); return ls; } - FI XYZEval operator/ (const float &v) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= v, ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v, ls.u /= v, ls.v /= v, ls.w /= v ); return ls; } - FI XYZEval operator/ (const float &v) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= v, ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v, ls.u /= v, ls.v /= v, ls.w /= v ); return ls; } - FI XYZEval operator/ (const int &v) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= v, ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v, ls.u /= v, ls.v /= v, ls.w /= v ); return ls; } - FI XYZEval operator/ (const int &v) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= v, ls.x /= v, ls.y /= v, ls.z /= v, ls.i /= v, ls.j /= v, ls.k /= v, ls.u /= v, ls.v /= v, ls.w /= v ); return ls; } - FI XYZEval operator>>(const int &v) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(_RS(ls.e), _RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k), _RS(ls.u), _RS(ls.v), _RS(ls.w) ); return ls; } - FI XYZEval operator>>(const int &v) { XYZEval ls = *this; LOGICAL_AXIS_CODE(_RS(ls.e), _RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k), _RS(ls.u), _RS(ls.v), _RS(ls.w) ); return ls; } - FI XYZEval operator<<(const int &v) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(_LS(ls.e), _LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k), _LS(ls.u), _LS(ls.v), _LS(ls.w) ); return ls; } - FI XYZEval operator<<(const int &v) { XYZEval ls = *this; LOGICAL_AXIS_CODE(_LS(ls.e), _LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k), _LS(ls.u), _LS(ls.v), _LS(ls.w) ); return ls; } - FI const XYZEval operator-() const { return LOGICAL_AXIS_ARRAY(-e, -x, -y, -z, -i, -j, -k, -u, -v, -w); } - FI XYZEval operator-() { return LOGICAL_AXIS_ARRAY(-e, -x, -y, -z, -i, -j, -k, -u, -v, -w); } + FI XYZEval operator+ (const XYval &rs) const { XYZEval ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; } + FI XYZEval operator+ (const XYval &rs) { XYZEval ls = *this; ls.x += rs.x; ls.y += rs.y; return ls; } + FI XYZEval operator- (const XYval &rs) const { XYZEval ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; } + FI XYZEval operator- (const XYval &rs) { XYZEval ls = *this; ls.x -= rs.x; ls.y -= rs.y; return ls; } + FI XYZEval operator* (const XYval &rs) const { XYZEval ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; } + FI XYZEval operator* (const XYval &rs) { XYZEval ls = *this; ls.x *= rs.x; ls.y *= rs.y; return ls; } + FI XYZEval operator/ (const XYval &rs) const { XYZEval ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; } + FI XYZEval operator/ (const XYval &rs) { XYZEval ls = *this; ls.x /= rs.x; ls.y /= rs.y; return ls; } + FI XYZEval operator+ (const XYZval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k, ls.u += rs.u, ls.v += rs.v, ls.w += rs.w); return ls; } + FI XYZEval operator+ (const XYZval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k, ls.u += rs.u, ls.v += rs.v, ls.w += rs.w); return ls; } + FI XYZEval operator- (const XYZval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k, ls.u -= rs.u, ls.v -= rs.v, ls.w -= rs.w); return ls; } + FI XYZEval operator- (const XYZval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k, ls.u -= rs.u, ls.v -= rs.v, ls.w -= rs.w); return ls; } + FI XYZEval operator* (const XYZval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; } + FI XYZEval operator* (const XYZval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; } + FI XYZEval operator/ (const XYZval &rs) const { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; } + FI XYZEval operator/ (const XYZval &rs) { XYZval ls = *this; NUM_AXIS_CODE(ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; } + FI XYZEval operator+ (const XYZEval &rs) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e += rs.e, ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k, ls.u += rs.u, ls.v += rs.v, ls.w += rs.w); return ls; } + FI XYZEval operator+ (const XYZEval &rs) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e += rs.e, ls.x += rs.x, ls.y += rs.y, ls.z += rs.z, ls.i += rs.i, ls.j += rs.j, ls.k += rs.k, ls.u += rs.u, ls.v += rs.v, ls.w += rs.w); return ls; } + FI XYZEval operator- (const XYZEval &rs) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e -= rs.e, ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k, ls.u -= rs.u, ls.v -= rs.v, ls.w -= rs.w); return ls; } + FI XYZEval operator- (const XYZEval &rs) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e -= rs.e, ls.x -= rs.x, ls.y -= rs.y, ls.z -= rs.z, ls.i -= rs.i, ls.j -= rs.j, ls.k -= rs.k, ls.u -= rs.u, ls.v -= rs.v, ls.w -= rs.w); return ls; } + FI XYZEval operator* (const XYZEval &rs) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= rs.e, ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; } + FI XYZEval operator* (const XYZEval &rs) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= rs.e, ls.x *= rs.x, ls.y *= rs.y, ls.z *= rs.z, ls.i *= rs.i, ls.j *= rs.j, ls.k *= rs.k, ls.u *= rs.u, ls.v *= rs.v, ls.w *= rs.w); return ls; } + FI XYZEval operator/ (const XYZEval &rs) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= rs.e, ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; } + FI XYZEval operator/ (const XYZEval &rs) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= rs.e, ls.x /= rs.x, ls.y /= rs.y, ls.z /= rs.z, ls.i /= rs.i, ls.j /= rs.j, ls.k /= rs.k, ls.u /= rs.u, ls.v /= rs.v, ls.w /= rs.w); return ls; } + FI XYZEval operator* (const float &p) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= p, ls.x *= p, ls.y *= p, ls.z *= p, ls.i *= p, ls.j *= p, ls.k *= p, ls.u *= p, ls.v *= p, ls.w *= p ); return ls; } + FI XYZEval operator* (const float &p) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= p, ls.x *= p, ls.y *= p, ls.z *= p, ls.i *= p, ls.j *= p, ls.k *= p, ls.u *= p, ls.v *= p, ls.w *= p ); return ls; } + FI XYZEval operator* (const int &p) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= p, ls.x *= p, ls.y *= p, ls.z *= p, ls.i *= p, ls.j *= p, ls.k *= p, ls.u *= p, ls.v *= p, ls.w *= p ); return ls; } + FI XYZEval operator* (const int &p) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e *= p, ls.x *= p, ls.y *= p, ls.z *= p, ls.i *= p, ls.j *= p, ls.k *= p, ls.u *= p, ls.v *= p, ls.w *= p ); return ls; } + FI XYZEval operator/ (const float &p) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= p, ls.x /= p, ls.y /= p, ls.z /= p, ls.i /= p, ls.j /= p, ls.k /= p, ls.u /= p, ls.v /= p, ls.w /= p ); return ls; } + FI XYZEval operator/ (const float &p) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= p, ls.x /= p, ls.y /= p, ls.z /= p, ls.i /= p, ls.j /= p, ls.k /= p, ls.u /= p, ls.v /= p, ls.w /= p ); return ls; } + FI XYZEval operator/ (const int &p) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= p, ls.x /= p, ls.y /= p, ls.z /= p, ls.i /= p, ls.j /= p, ls.k /= p, ls.u /= p, ls.v /= p, ls.w /= p ); return ls; } + FI XYZEval operator/ (const int &p) { XYZEval ls = *this; LOGICAL_AXIS_CODE(ls.e /= p, ls.x /= p, ls.y /= p, ls.z /= p, ls.i /= p, ls.j /= p, ls.k /= p, ls.u /= p, ls.v /= p, ls.w /= p ); return ls; } + FI XYZEval operator>>(const int &p) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(_RS(ls.e), _RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k), _RS(ls.u), _RS(ls.v), _RS(ls.w) ); return ls; } + FI XYZEval operator>>(const int &p) { XYZEval ls = *this; LOGICAL_AXIS_CODE(_RS(ls.e), _RS(ls.x), _RS(ls.y), _RS(ls.z), _RS(ls.i), _RS(ls.j), _RS(ls.k), _RS(ls.u), _RS(ls.v), _RS(ls.w) ); return ls; } + FI XYZEval operator<<(const int &p) const { XYZEval ls = *this; LOGICAL_AXIS_CODE(_LS(ls.e), _LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k), _LS(ls.u), _LS(ls.v), _LS(ls.w) ); return ls; } + FI XYZEval operator<<(const int &p) { XYZEval ls = *this; LOGICAL_AXIS_CODE(_LS(ls.e), _LS(ls.x), _LS(ls.y), _LS(ls.z), _LS(ls.i), _LS(ls.j), _LS(ls.k), _LS(ls.u), _LS(ls.v), _LS(ls.w) ); return ls; } + FI const XYZEval operator-() const { return LOGICAL_AXIS_ARRAY(-e, -x, -y, -z, -i, -j, -k, -u, -v, -w); } + FI XYZEval operator-() { return LOGICAL_AXIS_ARRAY(-e, -x, -y, -z, -i, -j, -k, -u, -v, -w); } // Modifier operators - FI XYZEval& operator+=(const XYval &rs) { x += rs.x; y += rs.y; return *this; } - FI XYZEval& operator-=(const XYval &rs) { x -= rs.x; y -= rs.y; return *this; } - FI XYZEval& operator*=(const XYval &rs) { x *= rs.x; y *= rs.y; return *this; } - FI XYZEval& operator/=(const XYval &rs) { x /= rs.x; y /= rs.y; return *this; } - FI XYZEval& operator+=(const XYZval &rs) { NUM_AXIS_CODE(x += rs.x, y += rs.y, z += rs.z, i += rs.i, j += rs.j, k += rs.k, u += rs.u, v += rs.v, w += rs.w); return *this; } - FI XYZEval& operator-=(const XYZval &rs) { NUM_AXIS_CODE(x -= rs.x, y -= rs.y, z -= rs.z, i -= rs.i, j -= rs.j, k -= rs.k, u -= rs.u, v -= rs.v, w -= rs.w); return *this; } - FI XYZEval& operator*=(const XYZval &rs) { NUM_AXIS_CODE(x *= rs.x, y *= rs.y, z *= rs.z, i *= rs.i, j *= rs.j, k *= rs.k, u *= rs.u, v *= rs.v, w *= rs.w); return *this; } - FI XYZEval& operator/=(const XYZval &rs) { NUM_AXIS_CODE(x /= rs.x, y /= rs.y, z /= rs.z, i /= rs.i, j /= rs.j, k /= rs.k, u /= rs.u, v /= rs.v, w /= rs.w); return *this; } - FI XYZEval& operator+=(const XYZEval &rs) { LOGICAL_AXIS_CODE(e += rs.e, x += rs.x, y += rs.y, z += rs.z, i += rs.i, j += rs.j, k += rs.k, u += rs.u, v += rs.v, w += rs.w); return *this; } - FI XYZEval& operator-=(const XYZEval &rs) { LOGICAL_AXIS_CODE(e -= rs.e, x -= rs.x, y -= rs.y, z -= rs.z, i -= rs.i, j -= rs.j, k -= rs.k, u -= rs.u, v -= rs.v, w -= rs.w); return *this; } - FI XYZEval& operator*=(const XYZEval &rs) { LOGICAL_AXIS_CODE(e *= rs.e, x *= rs.x, y *= rs.y, z *= rs.z, i *= rs.i, j *= rs.j, k *= rs.k, u *= rs.u, v *= rs.v, w *= rs.w); return *this; } - FI XYZEval& operator/=(const XYZEval &rs) { LOGICAL_AXIS_CODE(e /= rs.e, x /= rs.x, y /= rs.y, z /= rs.z, i /= rs.i, j /= rs.j, k /= rs.k, u /= rs.u, v /= rs.v, w /= rs.w); return *this; } - FI XYZEval& operator*=(const T &v) { LOGICAL_AXIS_CODE(e *= v, x *= v, y *= v, z *= v, i *= v, j *= v, k *= v, u *= v, v *= v, w *= v); return *this; } - FI XYZEval& operator>>=(const int &v) { LOGICAL_AXIS_CODE(_RS(e), _RS(x), _RS(y), _RS(z), _RS(i), _RS(j), _RS(k), _RS(u), _RS(v), _RS(w)); return *this; } - FI XYZEval& operator<<=(const int &v) { LOGICAL_AXIS_CODE(_LS(e), _LS(x), _LS(y), _LS(z), _LS(i), _LS(j), _LS(k), _LS(u), _LS(v), _LS(w)); return *this; } + FI XYZEval& operator+=(const XYval &rs) { x += rs.x; y += rs.y; return *this; } + FI XYZEval& operator-=(const XYval &rs) { x -= rs.x; y -= rs.y; return *this; } + FI XYZEval& operator*=(const XYval &rs) { x *= rs.x; y *= rs.y; return *this; } + FI XYZEval& operator/=(const XYval &rs) { x /= rs.x; y /= rs.y; return *this; } + FI XYZEval& operator+=(const XYZval &rs) { NUM_AXIS_CODE(x += rs.x, y += rs.y, z += rs.z, i += rs.i, j += rs.j, k += rs.k, u += rs.u, v += rs.v, w += rs.w); return *this; } + FI XYZEval& operator-=(const XYZval &rs) { NUM_AXIS_CODE(x -= rs.x, y -= rs.y, z -= rs.z, i -= rs.i, j -= rs.j, k -= rs.k, u -= rs.u, v -= rs.v, w -= rs.w); return *this; } + FI XYZEval& operator*=(const XYZval &rs) { NUM_AXIS_CODE(x *= rs.x, y *= rs.y, z *= rs.z, i *= rs.i, j *= rs.j, k *= rs.k, u *= rs.u, v *= rs.v, w *= rs.w); return *this; } + FI XYZEval& operator/=(const XYZval &rs) { NUM_AXIS_CODE(x /= rs.x, y /= rs.y, z /= rs.z, i /= rs.i, j /= rs.j, k /= rs.k, u /= rs.u, v /= rs.v, w /= rs.w); return *this; } + FI XYZEval& operator+=(const XYZEval &rs) { LOGICAL_AXIS_CODE(e += rs.e, x += rs.x, y += rs.y, z += rs.z, i += rs.i, j += rs.j, k += rs.k, u += rs.u, v += rs.v, w += rs.w); return *this; } + FI XYZEval& operator-=(const XYZEval &rs) { LOGICAL_AXIS_CODE(e -= rs.e, x -= rs.x, y -= rs.y, z -= rs.z, i -= rs.i, j -= rs.j, k -= rs.k, u -= rs.u, v -= rs.v, w -= rs.w); return *this; } + FI XYZEval& operator*=(const XYZEval &rs) { LOGICAL_AXIS_CODE(e *= rs.e, x *= rs.x, y *= rs.y, z *= rs.z, i *= rs.i, j *= rs.j, k *= rs.k, u *= rs.u, v *= rs.v, w *= rs.w); return *this; } + FI XYZEval& operator/=(const XYZEval &rs) { LOGICAL_AXIS_CODE(e /= rs.e, x /= rs.x, y /= rs.y, z /= rs.z, i /= rs.i, j /= rs.j, k /= rs.k, u /= rs.u, v /= rs.v, w /= rs.w); return *this; } + FI XYZEval& operator*=(const T &p) { LOGICAL_AXIS_CODE(e *= p, x *= p, y *= p, z *= p, i *= p, j *= p, k *= p, u *= p, v *= p, w *= p); return *this; } + FI XYZEval& operator>>=(const int &p) { LOGICAL_AXIS_CODE(_RS(e), _RS(x), _RS(y), _RS(z), _RS(i), _RS(j), _RS(k), _RS(u), _RS(v), _RS(w)); return *this; } + FI XYZEval& operator<<=(const int &p) { LOGICAL_AXIS_CODE(_LS(e), _LS(x), _LS(y), _LS(z), _LS(i), _LS(j), _LS(k), _LS(u), _LS(v), _LS(w)); return *this; } // Exact comparisons. For floats a "NEAR" operation may be better. - FI bool operator==(const XYZval &rs) const { return true NUM_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k, && u == rs.u, && v == rs.v, && w == rs.w); } - FI bool operator==(const XYZEval &rs) const { return true LOGICAL_AXIS_GANG(&& e == rs.e, && x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k, && u == rs.u, && v == rs.v, && w == rs.w); } - FI bool operator!=(const XYZval &rs) const { return !operator==(rs); } - FI bool operator!=(const XYZEval &rs) const { return !operator==(rs); } + FI bool operator==(const XYZval &rs) const { return true NUM_AXIS_GANG(&& x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k, && u == rs.u, && v == rs.v, && w == rs.w); } + FI bool operator==(const XYZEval &rs) const { return true LOGICAL_AXIS_GANG(&& e == rs.e, && x == rs.x, && y == rs.y, && z == rs.z, && i == rs.i, && j == rs.j, && k == rs.k, && u == rs.u, && v == rs.v, && w == rs.w); } + FI bool operator!=(const XYZval &rs) const { return !operator==(rs); } + FI bool operator!=(const XYZEval &rs) const { return !operator==(rs); } }; #undef _RECIP diff --git a/Marlin/src/module/probe.h b/Marlin/src/module/probe.h index 1bcbc6564241..dc2ba45764c2 100644 --- a/Marlin/src/module/probe.h +++ b/Marlin/src/module/probe.h @@ -146,7 +146,7 @@ class Probe { #else - static constexpr xyz_pos_t offset = xyz_pos_t(NUM_AXIS_ARRAY(0, 0, 0, 0, 0, 0)); // See #16767 + static constexpr xyz_pos_t offset = xyz_pos_t(NUM_AXIS_ARRAY_1(0)); // See #16767 static bool set_deployed(const bool) { return false; } From 031ff2d024a40410d31f4e0d61261c304ef158da Mon Sep 17 00:00:00 2001 From: Dan Royer Date: Sat, 15 Oct 2022 22:03:42 -0700 Subject: [PATCH 104/243] =?UTF-8?q?=F0=9F=90=9B=20Fix=20and=20improve=20Po?= =?UTF-8?q?largraph=20(#24847)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Scott Lahteine --- Marlin/src/feature/host_actions.cpp | 27 ++++++++++++++++++--- Marlin/src/feature/host_actions.h | 18 ++++++++++++-- Marlin/src/gcode/calibrate/M665.cpp | 2 -- Marlin/src/gcode/lcd/M0_M1.cpp | 7 +++++- Marlin/src/inc/Conditionals_post.h | 2 +- Marlin/src/inc/SanityCheck.h | 4 ++-- Marlin/src/lcd/language/language_en.h | 6 +++++ Marlin/src/lcd/menu/menu_advanced.cpp | 16 ++++++++++--- Marlin/src/module/motion.cpp | 19 +++++++++------ Marlin/src/module/planner.cpp | 1 - Marlin/src/module/polargraph.cpp | 13 ++++------ Marlin/src/module/polargraph.h | 1 - Marlin/src/module/settings.cpp | 34 ++++++++++++++++++++------- 13 files changed, 109 insertions(+), 41 deletions(-) diff --git a/Marlin/src/feature/host_actions.cpp b/Marlin/src/feature/host_actions.cpp index c03a6bc5976e..773b6ebc61a4 100644 --- a/Marlin/src/feature/host_actions.cpp +++ b/Marlin/src/feature/host_actions.cpp @@ -111,20 +111,29 @@ void HostUI::action(FSTR_P const fstr, const bool eol) { if (eol) SERIAL_EOL(); } - void HostUI::prompt_plus(FSTR_P const ptype, FSTR_P const fstr, const char extra_char/*='\0'*/) { + void HostUI::prompt_plus(const bool pgm, FSTR_P const ptype, const char * const str, const char extra_char/*='\0'*/) { prompt(ptype, false); PORT_REDIRECT(SerialMask::All); SERIAL_CHAR(' '); - SERIAL_ECHOF(fstr); + if (pgm) + SERIAL_ECHOPGM_P(str); + else + SERIAL_ECHO(str); if (extra_char != '\0') SERIAL_CHAR(extra_char); SERIAL_EOL(); } + void HostUI::prompt_begin(const PromptReason reason, FSTR_P const fstr, const char extra_char/*='\0'*/) { prompt_end(); host_prompt_reason = reason; prompt_plus(F("begin"), fstr, extra_char); } - void HostUI::prompt_button(FSTR_P const fstr) { prompt_plus(F("button"), fstr); } + void HostUI::prompt_begin(const PromptReason reason, const char * const cstr, const char extra_char/*='\0'*/) { + prompt_end(); + host_prompt_reason = reason; + prompt_plus(F("begin"), cstr, extra_char); + } + void HostUI::prompt_end() { prompt(F("end")); } void HostUI::prompt_show() { prompt(F("show")); } @@ -133,14 +142,26 @@ void HostUI::action(FSTR_P const fstr, const bool eol) { if (btn2) prompt_button(btn2); prompt_show(); } + + void HostUI::prompt_button(FSTR_P const fstr) { prompt_plus(F("button"), fstr); } + void HostUI::prompt_button(const char * const cstr) { prompt_plus(F("button"), cstr); } + void HostUI::prompt_do(const PromptReason reason, FSTR_P const fstr, FSTR_P const btn1/*=nullptr*/, FSTR_P const btn2/*=nullptr*/) { prompt_begin(reason, fstr); _prompt_show(btn1, btn2); } + void HostUI::prompt_do(const PromptReason reason, const char * const cstr, FSTR_P const btn1/*=nullptr*/, FSTR_P const btn2/*=nullptr*/) { + prompt_begin(reason, cstr); + _prompt_show(btn1, btn2); + } void HostUI::prompt_do(const PromptReason reason, FSTR_P const fstr, const char extra_char, FSTR_P const btn1/*=nullptr*/, FSTR_P const btn2/*=nullptr*/) { prompt_begin(reason, fstr, extra_char); _prompt_show(btn1, btn2); } + void HostUI::prompt_do(const PromptReason reason, const char * const cstr, const char extra_char, FSTR_P const btn1/*=nullptr*/, FSTR_P const btn2/*=nullptr*/) { + prompt_begin(reason, cstr, extra_char); + _prompt_show(btn1, btn2); + } #if ENABLED(ADVANCED_PAUSE_FEATURE) void HostUI::filament_load_prompt() { diff --git a/Marlin/src/feature/host_actions.h b/Marlin/src/feature/host_actions.h index 41d66b82ec9b..3f75562398ec 100644 --- a/Marlin/src/feature/host_actions.h +++ b/Marlin/src/feature/host_actions.h @@ -79,7 +79,14 @@ class HostUI { #if ENABLED(HOST_PROMPT_SUPPORT) private: static void prompt(FSTR_P const ptype, const bool eol=true); - static void prompt_plus(FSTR_P const ptype, FSTR_P const fstr, const char extra_char='\0'); + static void prompt_plus(const bool pgm, FSTR_P const ptype, const char * const str, const char extra_char='\0'); + static void prompt_plus(FSTR_P const ptype, FSTR_P const fstr, const char extra_char='\0') { + prompt_plus(true, ptype, FTOP(fstr), extra_char); + } + static void prompt_plus(FSTR_P const ptype, const char * const cstr, const char extra_char='\0') { + prompt_plus(false, ptype, cstr, extra_char); + } + static void prompt_show(); static void _prompt_show(FSTR_P const btn1, FSTR_P const btn2); @@ -93,10 +100,17 @@ class HostUI { static void notify(const char * const message); static void prompt_begin(const PromptReason reason, FSTR_P const fstr, const char extra_char='\0'); - static void prompt_button(FSTR_P const fstr); + static void prompt_begin(const PromptReason reason, const char * const cstr, const char extra_char='\0'); static void prompt_end(); + + static void prompt_button(FSTR_P const fstr); + static void prompt_button(const char * const cstr); + static void prompt_do(const PromptReason reason, FSTR_P const pstr, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr); + static void prompt_do(const PromptReason reason, const char * const cstr, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr); static void prompt_do(const PromptReason reason, FSTR_P const pstr, const char extra_char, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr); + static void prompt_do(const PromptReason reason, const char * const cstr, const char extra_char, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr); + static void prompt_open(const PromptReason reason, FSTR_P const pstr, FSTR_P const btn1=nullptr, FSTR_P const btn2=nullptr) { if (host_prompt_reason == PROMPT_NOT_DEFINED) prompt_do(reason, pstr, btn1, btn2); } diff --git a/Marlin/src/gcode/calibrate/M665.cpp b/Marlin/src/gcode/calibrate/M665.cpp index 7dc657a61b43..a8e02831e2a8 100644 --- a/Marlin/src/gcode/calibrate/M665.cpp +++ b/Marlin/src/gcode/calibrate/M665.cpp @@ -167,8 +167,6 @@ if (parser.seenval('T')) draw_area_max.y = parser.value_linear_units(); if (parser.seenval('B')) draw_area_min.y = parser.value_linear_units(); if (parser.seenval('H')) polargraph_max_belt_len = parser.value_linear_units(); - draw_area_size.x = draw_area_max.x - draw_area_min.x; - draw_area_size.y = draw_area_max.y - draw_area_min.y; } void GcodeSuite::M665_report(const bool forReplay/*=true*/) { diff --git a/Marlin/src/gcode/lcd/M0_M1.cpp b/Marlin/src/gcode/lcd/M0_M1.cpp index af03fcb0b1a1..35afea0f6ecd 100644 --- a/Marlin/src/gcode/lcd/M0_M1.cpp +++ b/Marlin/src/gcode/lcd/M0_M1.cpp @@ -85,7 +85,12 @@ void GcodeSuite::M0_M1() { #endif - TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, parser.codenum ? F("M1 Stop") : F("M0 Stop"), FPSTR(CONTINUE_STR))); + #if ENABLED(HOST_PROMPT_SUPPORT) + if (parser.string_arg) + hostui.prompt_do(PROMPT_USER_CONTINUE, parser.string_arg, FPSTR(CONTINUE_STR)); + else + hostui.prompt_do(PROMPT_USER_CONTINUE, parser.codenum ? F("M1 Stop") : F("M0 Stop"), FPSTR(CONTINUE_STR)); + #endif TERN_(HAS_RESUME_CONTINUE, wait_for_user_response(ms)); diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 45eccaade959..90ed750d4a18 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -155,7 +155,7 @@ #define W_BED_SIZE W_MAX_LENGTH #endif -// Require 0,0 bed center for Delta and SCARA +// Require 0,0 bed center for Delta, SCARA, and Polargraph #if IS_KINEMATIC #define BED_CENTER_AT_0_0 #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 017a7b3459b1..1ee4667e3c3c 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -829,7 +829,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS /** * Granular software endstops (Marlin >= 1.1.7) */ -#if ENABLED(MIN_SOFTWARE_ENDSTOPS) && DISABLED(MIN_SOFTWARE_ENDSTOP_Z) +#if ENABLED(MIN_SOFTWARE_ENDSTOPS) && NONE(MIN_SOFTWARE_ENDSTOP_Z, POLARGRAPH) #if IS_KINEMATIC #error "MIN_SOFTWARE_ENDSTOPS on DELTA/SCARA also requires MIN_SOFTWARE_ENDSTOP_Z." #elif NONE(MIN_SOFTWARE_ENDSTOP_X, MIN_SOFTWARE_ENDSTOP_Y) @@ -837,7 +837,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #endif -#if ENABLED(MAX_SOFTWARE_ENDSTOPS) && DISABLED(MAX_SOFTWARE_ENDSTOP_Z) +#if ENABLED(MAX_SOFTWARE_ENDSTOPS) && NONE(MAX_SOFTWARE_ENDSTOP_Z, POLARGRAPH) #if IS_KINEMATIC #error "MAX_SOFTWARE_ENDSTOPS on DELTA/SCARA also requires MAX_SOFTWARE_ENDSTOP_Z." #elif NONE(MAX_SOFTWARE_ENDSTOP_X, MAX_SOFTWARE_ENDSTOP_Y) diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 6b1ca2a30d3c..e4f8ef8fb724 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -418,6 +418,12 @@ namespace Language_en { LSTR MSG_FILAMENT_DIAM_E = _UxGT("Fil. Dia. *"); LSTR MSG_FILAMENT_UNLOAD = _UxGT("Unload mm"); LSTR MSG_FILAMENT_LOAD = _UxGT("Load mm"); + LSTR MSG_SEGMENTS_PER_SECOND = _UxGT("Segments/Sec"); + LSTR MSG_DRAW_MIN_X = _UxGT("Draw Min X"); + LSTR MSG_DRAW_MAX_X = _UxGT("Draw Max X"); + LSTR MSG_DRAW_MIN_Y = _UxGT("Draw Min Y"); + LSTR MSG_DRAW_MAX_Y = _UxGT("Draw Max Y"); + LSTR MSG_MAX_BELT_LEN = _UxGT("Max Belt Len"); LSTR MSG_ADVANCE_K = _UxGT("Advance K"); LSTR MSG_ADVANCE_K_E = _UxGT("Advance K *"); LSTR MSG_CONTRAST = _UxGT("LCD Contrast"); diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 19e38820184d..6a42378aba79 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -632,10 +632,20 @@ void menu_advanced_settings() { #if DISABLED(SLIM_LCD_MENUS) + #if ENABLED(POLARGRAPH) + // M665 - Polargraph Settings + if (!is_busy) { + EDIT_ITEM_FAST(float4, MSG_SEGMENTS_PER_SECOND, &segments_per_second, 100, 9999); // M665 S + EDIT_ITEM_FAST(float51sign, MSG_DRAW_MIN_X, &draw_area_min.x, X_MIN_POS, draw_area_max.x - 10); // M665 L + EDIT_ITEM_FAST(float51sign, MSG_DRAW_MAX_X, &draw_area_max.x, draw_area_min.x + 10, X_MAX_POS); // M665 R + EDIT_ITEM_FAST(float51sign, MSG_DRAW_MIN_Y, &draw_area_min.y, Y_MIN_POS, draw_area_max.y - 10); // M665 T + EDIT_ITEM_FAST(float51sign, MSG_DRAW_MAX_Y, &draw_area_max.y, draw_area_min.y + 10, Y_MAX_POS); // M665 B + EDIT_ITEM_FAST(float51sign, MSG_MAX_BELT_LEN, &polargraph_max_belt_len, 500, 2000); // M665 H + } + #endif + #if HAS_M206_COMMAND - // - // Set Home Offsets - // + // M428 - Set Home Offsets ACTION_ITEM(MSG_SET_HOME_OFFSETS, []{ queue.inject(F("M428")); ui.return_to_status(); }); #endif diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index c0503c621dfb..dadbfab29724 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -341,7 +341,6 @@ void report_current_position_projected() { can_reach = ( a < polargraph_max_belt_len + 1 && b < polargraph_max_belt_len + 1 - && (a + b) > _MIN(draw_area_size.x, draw_area_size.y) ); #endif @@ -562,7 +561,8 @@ void do_blocking_move_to(NUM_AXIS_ARGS(const float), const_feedRate_t fr_mm_s/*= const feedRate_t w_feedrate = fr_mm_s ?: homing_feedrate(W_AXIS) ); - #if IS_KINEMATIC + #if IS_KINEMATIC && DISABLED(POLARGRAPH) + // kinematic machines are expected to home to a point 1.5x their range? never reachable. if (!position_is_reachable(x, y)) return; destination = current_position; // sync destination at the start #endif @@ -919,11 +919,16 @@ void restore_feedrate_and_scaling() { constexpr xy_pos_t offs{0}; #endif - if (TERN1(IS_SCARA, axis_was_homed(X_AXIS) && axis_was_homed(Y_AXIS))) { - const float dist_2 = HYPOT2(target.x - offs.x, target.y - offs.y); - if (dist_2 > delta_max_radius_2) - target *= float(delta_max_radius / SQRT(dist_2)); // 200 / 300 = 0.66 - } + #if ENABLED(POLARGRAPH) + LIMIT(target.x, draw_area_min.x, draw_area_max.x); + LIMIT(target.y, draw_area_min.y, draw_area_max.y); + #else + if (TERN1(IS_SCARA, axis_was_homed(X_AXIS) && axis_was_homed(Y_AXIS))) { + const float dist_2 = HYPOT2(target.x - offs.x, target.y - offs.y); + if (dist_2 > delta_max_radius_2) + target *= float(delta_max_radius / SQRT(dist_2)); // 200 / 300 = 0.66 + } + #endif #else diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index dee86cad90ee..91a994470a31 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -2244,7 +2244,6 @@ bool Planner::_populate_block( TERN_(MIXING_EXTRUDER, mixer.populate_block(block->b_color)); - #if HAS_FAN FANS_LOOP(i) block->fan_speed[i] = thermalManager.fan_speed[i]; #endif diff --git a/Marlin/src/module/polargraph.cpp b/Marlin/src/module/polargraph.cpp index 42f99304d789..d55d36a6d654 100644 --- a/Marlin/src/module/polargraph.cpp +++ b/Marlin/src/module/polargraph.cpp @@ -37,17 +37,12 @@ #include "../lcd/marlinui.h" #include "../MarlinCore.h" -float segments_per_second; // Initialized by settings.load() - -xy_pos_t draw_area_min = { X_MIN_POS, Y_MIN_POS }, - draw_area_max = { X_MAX_POS, Y_MAX_POS }; - -xy_float_t draw_area_size = { X_MAX_POS - X_MIN_POS, Y_MAX_POS - Y_MIN_POS }; - -float polargraph_max_belt_len = HYPOT(draw_area_size.x, draw_area_size.y); +// Initialized by settings.load() +float segments_per_second, polargraph_max_belt_len; +xy_pos_t draw_area_min, draw_area_max; void inverse_kinematics(const xyz_pos_t &raw) { - const float x1 = raw.x - (draw_area_min.x), x2 = (draw_area_max.x) - raw.x, y = raw.y - (draw_area_max.y); + const float x1 = raw.x - draw_area_min.x, x2 = draw_area_max.x - raw.x, y = raw.y - draw_area_max.y; delta.set(HYPOT(x1, y), HYPOT(x2, y), raw.z); } diff --git a/Marlin/src/module/polargraph.h b/Marlin/src/module/polargraph.h index b465de32874c..f4904ebfe21c 100644 --- a/Marlin/src/module/polargraph.h +++ b/Marlin/src/module/polargraph.h @@ -30,7 +30,6 @@ extern float segments_per_second; extern xy_pos_t draw_area_min, draw_area_max; -extern xy_float_t draw_area_size; extern float polargraph_max_belt_len; void inverse_kinematics(const xyz_pos_t &raw); diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index ec1a03eb0528..cb8fe217e998 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -257,7 +257,7 @@ typedef struct SettingsDataStruct { // HAS_BED_PROBE // - xyz_pos_t probe_offset; + xyz_pos_t probe_offset; // M851 X Y Z // // ABL_PLANAR @@ -319,7 +319,7 @@ typedef struct SettingsDataStruct { #endif // - // Kinematic Settings + // Kinematic Settings (Delta, SCARA, TPARA, Polargraph...) // #if IS_KINEMATIC float segments_per_second; // M665 S @@ -330,7 +330,11 @@ typedef struct SettingsDataStruct { delta_diagonal_rod; // M665 L abc_float_t delta_tower_angle_trim, // M665 X Y Z delta_diagonal_rod_trim; // M665 A B C + #elif ENABLED(POLARGRAPH) + xy_pos_t draw_area_min, draw_area_max; // M665 L R T B + float polargraph_max_belt_len; // M665 H #endif + #endif // @@ -468,7 +472,7 @@ typedef struct SettingsDataStruct { // // SKEW_CORRECTION // - skew_factor_t planner_skew_factor; // M852 I J K planner.skew_factor + skew_factor_t planner_skew_factor; // M852 I J K // // ADVANCED_PAUSE_FEATURE @@ -988,7 +992,7 @@ void MarlinSettings::postprocess() { } // - // Kinematic Settings + // Kinematic Settings (Delta, SCARA, TPARA, Polargraph...) // #if IS_KINEMATIC { @@ -1001,6 +1005,11 @@ void MarlinSettings::postprocess() { EEPROM_WRITE(delta_diagonal_rod); // 1 float EEPROM_WRITE(delta_tower_angle_trim); // 3 floats EEPROM_WRITE(delta_diagonal_rod_trim); // 3 floats + #elif ENABLED(POLARGRAPH) + _FIELD_TEST(draw_area_min); + EEPROM_WRITE(draw_area_min); // 2 floats + EEPROM_WRITE(draw_area_max); // 2 floats + EEPROM_WRITE(polargraph_max_belt_len); // 1 float #endif } #endif @@ -1923,7 +1932,7 @@ void MarlinSettings::postprocess() { } // - // Kinematic Segments-per-second + // Kinematic Settings (Delta, SCARA, TPARA, Polargraph...) // #if IS_KINEMATIC { @@ -1936,6 +1945,11 @@ void MarlinSettings::postprocess() { EEPROM_READ(delta_diagonal_rod); // 1 float EEPROM_READ(delta_tower_angle_trim); // 3 floats EEPROM_READ(delta_diagonal_rod_trim); // 3 floats + #elif ENABLED(POLARGRAPH) + _FIELD_TEST(draw_area_min); + EEPROM_READ(draw_area_min); // 2 floats + EEPROM_READ(draw_area_max); // 2 floats + EEPROM_READ(polargraph_max_belt_len); // 1 float #endif } #endif @@ -2979,7 +2993,7 @@ void MarlinSettings::reset() { #endif // - // Kinematic settings + // Kinematic Settings (Delta, SCARA, TPARA, Polargraph...) // #if IS_KINEMATIC @@ -2996,6 +3010,10 @@ void MarlinSettings::reset() { delta_diagonal_rod = DELTA_DIAGONAL_ROD; delta_tower_angle_trim = dta; delta_diagonal_rod_trim = ddr; + #elif ENABLED(POLARGRAPH) + draw_area_min.set(X_MIN_POS, Y_MIN_POS); + draw_area_max.set(X_MAX_POS, Y_MAX_POS); + polargraph_max_belt_len = POLARGRAPH_MAX_BELT_LEN; #endif #endif @@ -3492,9 +3510,7 @@ void MarlinSettings::reset() { // // LCD Preheat Settings // - #if HAS_PREHEAT - gcode.M145_report(forReplay); - #endif + TERN_(HAS_PREHEAT, gcode.M145_report(forReplay)); // // PID From 9ae078916605e79cbdf0e42b9c69dbc9b4841103 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 17 Oct 2022 13:01:45 -0500 Subject: [PATCH 105/243] =?UTF-8?q?=F0=9F=8E=A8=20HAS=5FSPI=5FFLASH=20=3D>?= =?UTF-8?q?=20SPI=5FFLASH?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/control/M993_M994.cpp | 4 ++-- Marlin/src/gcode/gcode.cpp | 2 +- Marlin/src/gcode/gcode.h | 2 +- Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.cpp | 4 ++-- Marlin/src/libs/W25Qxx.cpp | 4 ++-- Marlin/src/pins/linux/pins_RAMPS_LINUX.h | 4 ++-- Marlin/src/pins/stm32f1/pins_CHITU3D_common.h | 4 ++-- Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h | 4 ++-- Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h | 4 ++-- Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h | 4 ++-- Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h | 4 ++-- Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h | 4 ++-- Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h | 4 ++-- Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h | 4 ++-- Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h | 4 ++-- Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h | 2 +- Marlin/src/pins/stm32f4/pins_BTT_SKR_MINI_E3_V3_0_1.h | 2 +- Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3_common.h | 2 +- Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h | 2 +- Marlin/src/pins/stm32f4/pins_MKS_SKIPR_V1_0.h | 2 +- Marlin/src/pins/stm32h7/pins_BTT_SKR_V3_0_common.h | 2 +- ini/features.ini | 2 +- 22 files changed, 35 insertions(+), 35 deletions(-) diff --git a/Marlin/src/gcode/control/M993_M994.cpp b/Marlin/src/gcode/control/M993_M994.cpp index 252792e5224e..598a73fab756 100644 --- a/Marlin/src/gcode/control/M993_M994.cpp +++ b/Marlin/src/gcode/control/M993_M994.cpp @@ -22,7 +22,7 @@ #include "../../inc/MarlinConfig.h" -#if ALL(HAS_SPI_FLASH, SDSUPPORT, MARLIN_DEV_MODE) +#if ALL(SPI_FLASH, SDSUPPORT, MARLIN_DEV_MODE) #include "../gcode.h" #include "../../sd/cardreader.h" @@ -85,4 +85,4 @@ void GcodeSuite::M994() { card.closefile(); } -#endif // HAS_SPI_FLASH && SDSUPPORT && MARLIN_DEV_MODE +#endif // SPI_FLASH && SDSUPPORT && MARLIN_DEV_MODE diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 7edcaa981cd4..0667ef0b7be7 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -1053,7 +1053,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 422: M422(); break; // M422: Set Z Stepper automatic alignment position using probe #endif - #if ALL(HAS_SPI_FLASH, SDSUPPORT, MARLIN_DEV_MODE) + #if ALL(SPI_FLASH, SDSUPPORT, MARLIN_DEV_MODE) case 993: M993(); break; // M993: Backup SPI Flash to SD case 994: M994(); break; // M994: Load a Backup from SD to SPI Flash #endif diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index d69298e28b53..e2506e4ed9f3 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -1194,7 +1194,7 @@ class GcodeSuite { static void M995(); #endif - #if BOTH(HAS_SPI_FLASH, SDSUPPORT) + #if BOTH(SPI_FLASH, SDSUPPORT) static void M993(); static void M994(); #endif diff --git a/Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.cpp b/Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.cpp index 6f2351bba68c..6508f6f02473 100644 --- a/Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.cpp +++ b/Marlin/src/lcd/extui/mks_ui/SPIFlashStorage.cpp @@ -27,8 +27,8 @@ #include "../../../inc/MarlinConfig.h" #include "SPIFlashStorage.h" -#if !HAS_SPI_FLASH - #error "HAS_SPI_FLASH is required with TFT_LVGL_UI." +#if DISABLED(SPI_FLASH) + #error "SPI_FLASH is required with TFT_LVGL_UI." #endif extern W25QXXFlash W25QXX; diff --git a/Marlin/src/libs/W25Qxx.cpp b/Marlin/src/libs/W25Qxx.cpp index 033402d04ab0..591d0d069318 100644 --- a/Marlin/src/libs/W25Qxx.cpp +++ b/Marlin/src/libs/W25Qxx.cpp @@ -22,7 +22,7 @@ #include "../inc/MarlinConfig.h" -#if HAS_SPI_FLASH +#if ENABLED(SPI_FLASH) #include "W25Qxx.h" @@ -380,4 +380,4 @@ void W25QXXFlash::SPI_FLASH_BufferRead(uint8_t *pBuffer, uint32_t ReadAddr, uint SPI_FLASH_CS_H(); } -#endif // HAS_SPI_FLASH +#endif // SPI_FLASH diff --git a/Marlin/src/pins/linux/pins_RAMPS_LINUX.h b/Marlin/src/pins/linux/pins_RAMPS_LINUX.h index 75d6b9d93e91..3616b7a27c43 100644 --- a/Marlin/src/pins/linux/pins_RAMPS_LINUX.h +++ b/Marlin/src/pins/linux/pins_RAMPS_LINUX.h @@ -396,8 +396,8 @@ #define SD_DETECT_PIN 41 - #define HAS_SPI_FLASH 1 - #if HAS_SPI_FLASH + #define SPI_FLASH + #if ENABLED(SPI_FLASH) #define SPI_DEVICE 1 #define SPI_FLASH_SIZE 0x1000000 // 16MB #define SPI_FLASH_CS_PIN 31 diff --git a/Marlin/src/pins/stm32f1/pins_CHITU3D_common.h b/Marlin/src/pins/stm32f1/pins_CHITU3D_common.h index bc41e97041fc..f5dd4a42b0f6 100644 --- a/Marlin/src/pins/stm32f1/pins_CHITU3D_common.h +++ b/Marlin/src/pins/stm32f1/pins_CHITU3D_common.h @@ -114,8 +114,8 @@ #endif // SPI Flash -#define HAS_SPI_FLASH 1 -#if HAS_SPI_FLASH +#define SPI_FLASH +#if ENABLED(SPI_FLASH) #define SPI_FLASH_SIZE 0x200000 // 2MB #endif diff --git a/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h b/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h index dd621eb5c126..ff588f948812 100644 --- a/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h +++ b/Marlin/src/pins/stm32f1/pins_FLSUN_HISPEED.h @@ -68,8 +68,8 @@ #define SPI_DEVICE 2 // SPI Flash -#define HAS_SPI_FLASH 1 -#if HAS_SPI_FLASH +#define SPI_FLASH +#if ENABLED(SPI_FLASH) // SPI 2 #define SPI_FLASH_CS_PIN PB12 // SPI2_NSS / Flash chip-select #define SPI_FLASH_MOSI_PIN PB15 diff --git a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h index e6d31746539a..ad6b84b05769 100644 --- a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h +++ b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h @@ -183,7 +183,7 @@ // #if NO_EEPROM_SELECTED //#define SPI_EEPROM - //#define HAS_SPI_FLASH 1 // need MARLIN_DEV_MODE for M993/M994 eeprom backup tests + //#define SPI_FLASH // need MARLIN_DEV_MODE for M993/M994 EEPROM backup tests #define FLASH_EEPROM_EMULATION #endif @@ -196,7 +196,7 @@ #define EEPROM_MOSI_PIN BOARD_SPI1_MOSI_PIN // PA7 pin 32 #define EEPROM_PAGE_SIZE 0x1000U // 4K (from datasheet) #define MARLIN_EEPROM_SIZE 16UL * (EEPROM_PAGE_SIZE) // Limit to 64K for now... -#elif HAS_SPI_FLASH +#elif ENABLED(SPI_FLASH) #define SPI_FLASH_SIZE 0x40000U // limit to 256K (M993 will reboot with 512) #define SPI_FLASH_CS_PIN PC5 #define SPI_FLASH_MOSI_PIN PA7 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h index 2c147eb9f3e0..be5f6c740482 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN.h @@ -272,8 +272,8 @@ // // W25Q64 64Mb (8MB) SPI flash // -#define HAS_SPI_FLASH 1 -#if HAS_SPI_FLASH +#define SPI_FLASH +#if ENABLED(SPI_FLASH) #define SPI_FLASH_SIZE 0x800000 // 8MB #define SPI_FLASH_CS_PIN PG9 #define SPI_FLASH_MOSI_PIN PB15 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h index b8f6f6a330ad..89525d93ef48 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_E3P.h @@ -377,8 +377,8 @@ #endif // HAS_WIRED_LCD && !HAS_SPI_TFT -#define HAS_SPI_FLASH 1 -#if HAS_SPI_FLASH +#define SPI_FLASH +#if ENABLED(SPI_FLASH) #define SPI_FLASH_SIZE 0x1000000 // 16MB #define SPI_FLASH_CS_PIN PB12 #define SPI_FLASH_MOSI_PIN PB15 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h index 0bfc7f5c8d93..59441dc80609 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_MINI.h @@ -196,8 +196,8 @@ #endif #endif -#define HAS_SPI_FLASH 1 -#if HAS_SPI_FLASH +#define SPI_FLASH +#if ENABLED(SPI_FLASH) #define SPI_FLASH_SIZE 0x1000000 // 16MB #define SPI_FLASH_CS_PIN PB12 // Flash chip-select #define SPI_FLASH_MOSI_PIN PB15 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h index 9c6373bef987..8dba94313651 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_V2.h @@ -379,8 +379,8 @@ #endif // HAS_WIRED_LCD && !HAS_SPI_TFT -#define HAS_SPI_FLASH 1 -#if HAS_SPI_FLASH +#define SPI_FLASH +#if ENABLED(SPI_FLASH) #define SPI_FLASH_SIZE 0x1000000 // 16MB #define SPI_FLASH_CS_PIN PB12 #define SPI_FLASH_MOSI_PIN PB15 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h index 6f1a790580ad..858dabb8b986 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_NANO_common.h @@ -208,8 +208,8 @@ #define TFT_BUFFER_SIZE 14400 #endif -#define HAS_SPI_FLASH 1 -#if HAS_SPI_FLASH +#define SPI_FLASH +#if ENABLED(SPI_FLASH) #define SPI_FLASH_SIZE 0x1000000 // 16MB #define SPI_FLASH_CS_PIN PB12 #define SPI_FLASH_MOSI_PIN PB15 diff --git a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h index 1db2d0c5dd84..048570102baf 100644 --- a/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h +++ b/Marlin/src/pins/stm32f1/pins_MKS_ROBIN_PRO.h @@ -308,8 +308,8 @@ #define BOARD_ST7920_DELAY_3 125 #endif -#define HAS_SPI_FLASH 1 -#if HAS_SPI_FLASH +#define SPI_FLASH +#if ENABLED(SPI_FLASH) #define SPI_FLASH_SIZE 0x1000000 // 16MB #define SPI_FLASH_CS_PIN PB12 // Flash chip-select #define SPI_FLASH_MOSI_PIN PB15 diff --git a/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h b/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h index 9ff9f6a47567..35287050b891 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h @@ -28,7 +28,7 @@ // Onboard I2C EEPROM #define I2C_EEPROM -#define MARLIN_EEPROM_SIZE 0x1000 // 4KB (AT24C32) +#define MARLIN_EEPROM_SIZE 0x1000 // 4K (AT24C32) #define I2C_SCL_PIN PB8 #define I2C_SDA_PIN PB9 diff --git a/Marlin/src/pins/stm32f4/pins_BTT_SKR_MINI_E3_V3_0_1.h b/Marlin/src/pins/stm32f4/pins_BTT_SKR_MINI_E3_V3_0_1.h index 1e278cd4ba30..31551f6ff6f4 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_SKR_MINI_E3_V3_0_1.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_SKR_MINI_E3_V3_0_1.h @@ -49,7 +49,7 @@ #define SOFT_I2C_EEPROM // Force the use of Software I2C #define I2C_SCL_PIN PB8 #define I2C_SDA_PIN PB9 - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4K #endif // diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3_common.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3_common.h index 4ac64ae1d2c4..603da09d14ef 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3_common.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_NANO_V3_common.h @@ -225,7 +225,7 @@ #define SPI_FLASH #if ENABLED(SPI_FLASH) - #define HAS_SPI_FLASH 1 + #define SPI_FLASH #define SPI_DEVICE 2 #define SPI_FLASH_SIZE 0x1000000 #define SPI_FLASH_CS_PIN PB12 diff --git a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h index 7e08caaa82af..873ba3e90d66 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_ROBIN_PRO_V2.h @@ -273,7 +273,7 @@ // // LCD / Controller #define SPI_FLASH -#define HAS_SPI_FLASH 1 +#define SPI_FLASH #define SPI_DEVICE 2 #define SPI_FLASH_SIZE 0x1000000 #if ENABLED(SPI_FLASH) diff --git a/Marlin/src/pins/stm32f4/pins_MKS_SKIPR_V1_0.h b/Marlin/src/pins/stm32f4/pins_MKS_SKIPR_V1_0.h index 046fbb95bf29..d00b21c30b24 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_SKIPR_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_SKIPR_V1_0.h @@ -35,7 +35,7 @@ // Onboard I2C EEPROM #define I2C_EEPROM -#define MARLIN_EEPROM_SIZE 0x1000 // 4KB (AT24C32) +#define MARLIN_EEPROM_SIZE 0x1000 // 4K (AT24C32) #define I2C_SCL_PIN PB8 #define I2C_SDA_PIN PB9 diff --git a/Marlin/src/pins/stm32h7/pins_BTT_SKR_V3_0_common.h b/Marlin/src/pins/stm32h7/pins_BTT_SKR_V3_0_common.h index 24376d6f9c48..eaceafe29ee3 100644 --- a/Marlin/src/pins/stm32h7/pins_BTT_SKR_V3_0_common.h +++ b/Marlin/src/pins/stm32h7/pins_BTT_SKR_V3_0_common.h @@ -46,7 +46,7 @@ #define SOFT_I2C_EEPROM // Force the use of Software I2C #define I2C_SCL_PIN PA14 #define I2C_SDA_PIN PA13 - #define MARLIN_EEPROM_SIZE 0x1000 // 4KB + #define MARLIN_EEPROM_SIZE 0x1000 // 4K #endif // diff --git a/ini/features.ini b/ini/features.ini index 7e4a3f97be6d..5f30db8a2f08 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -119,7 +119,7 @@ EMERGENCY_PARSER = src_filter=+ EASYTHREED_UI = src_filter=+ I2C_POSITION_ENCODERS = src_filter=+ IIC_BL24CXX_EEPROM = src_filter=+ -HAS_SPI_FLASH = src_filter=+ +SPI_FLASH = src_filter=+ HAS_ETHERNET = src_filter=+ + HAS_FANCHECK = src_filter=+ + HAS_FANMUX = src_filter=+ From 6a084e3704656f5b2e7291589376ec2b2296a5c1 Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Mon, 17 Oct 2022 15:17:51 -0400 Subject: [PATCH 106/243] =?UTF-8?q?=F0=9F=90=9B=20Fix=20bed/chamber=20PID?= =?UTF-8?q?=20P=20edit=20(#24861)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/menu/menu_advanced.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 6a42378aba79..ace97c962797 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -222,10 +222,10 @@ void menu_backlash(); void apply_PID_p(const int8_t e) { switch (e) { #if ENABLED(PIDTEMPBED) - case H_BED: thermalManager.temp_bed.pid.set_Ki(raw_Ki); break; + case H_BED: thermalManager.temp_bed.pid.set_Kp(raw_Kp); break; #endif #if ENABLED(PIDTEMPCHAMBER) - case H_CHAMBER: thermalManager.temp_chamber.pid.set_Ki(raw_Ki); break; + case H_CHAMBER: thermalManager.temp_chamber.pid.set_Kp(raw_Kp); break; #endif default: #if ENABLED(PIDTEMP) From ca1968a8428f2e3a6550ee69206c6ae257dad07c Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Mon, 17 Oct 2022 12:25:37 -0700 Subject: [PATCH 107/243] =?UTF-8?q?=F0=9F=94=A7=20Check=20Sensorless=20Hom?= =?UTF-8?q?ing=20on=20all=20axes=20(#24872)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/SanityCheck.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 1ee4667e3c3c..37efabe280b9 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -3565,8 +3565,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "SENSORLESS_HOMING on DELTA currently requires STEALTHCHOP_XY and STEALTHCHOP_Z." #elif ENDSTOP_NOISE_THRESHOLD #error "SENSORLESS_HOMING is incompatible with ENDSTOP_NOISE_THRESHOLD." - #elif !(X_SENSORLESS || Y_SENSORLESS || Z_SENSORLESS) - #error "SENSORLESS_HOMING requires a TMC stepper driver with StallGuard on X, Y, or Z axes." + #elif !(X_SENSORLESS || Y_SENSORLESS || Z_SENSORLESS || I_SENSORLESS || J_SENSORLESS || K_SENSORLESS || U_SENSORLESS || V_SENSORLESS || W_SENSORLESS) + #error "SENSORLESS_HOMING requires a TMC stepper driver with StallGuard on X, Y, Z, I, J, K, U, V, or W axes." #endif #undef X_ENDSTOP_INVERTING From 256ac01ca2c47bfc187b499bacd11fd6260a6d37 Mon Sep 17 00:00:00 2001 From: karliss Date: Tue, 18 Oct 2022 04:01:18 +0300 Subject: [PATCH 108/243] =?UTF-8?q?=F0=9F=90=9B=20Fix=20compile=20without?= =?UTF-8?q?=20Y/Z=20(#24858)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/src/gcode/feature/trinamic/M569.cpp | 8 +- Marlin/src/gcode/host/M115.cpp | 33 ++++++-- Marlin/src/inc/Conditionals_LCD.h | 94 +++++++++++++--------- Marlin/src/inc/SanityCheck.h | 38 ++++----- Marlin/src/lcd/dogm/status_screen_DOGM.cpp | 22 +++-- Marlin/src/lcd/menu/menu_advanced.cpp | 4 +- Marlin/src/lcd/menu/menu_motion.cpp | 8 +- 7 files changed, 129 insertions(+), 78 deletions(-) diff --git a/Marlin/src/gcode/feature/trinamic/M569.cpp b/Marlin/src/gcode/feature/trinamic/M569.cpp index 44675a850eb5..db31fe3d8ef3 100644 --- a/Marlin/src/gcode/feature/trinamic/M569.cpp +++ b/Marlin/src/gcode/feature/trinamic/M569.cpp @@ -197,8 +197,12 @@ void GcodeSuite::M569_report(const bool forReplay/*=true*/) { if (chop_x2 || chop_y2 || chop_z2) { say_M569(forReplay, F("I1")); if (chop_x2) SERIAL_ECHOPGM_P(SP_X_STR); - if (chop_y2) SERIAL_ECHOPGM_P(SP_Y_STR); - if (chop_z2) SERIAL_ECHOPGM_P(SP_Z_STR); + #if HAS_Y_AXIS + if (chop_y2) SERIAL_ECHOPGM_P(SP_Y_STR); + #endif + #if HAS_Z_AXIS + if (chop_z2) SERIAL_ECHOPGM_P(SP_Z_STR); + #endif SERIAL_EOL(); } diff --git a/Marlin/src/gcode/host/M115.cpp b/Marlin/src/gcode/host/M115.cpp index d3338d396dad..1c00cb19f58d 100644 --- a/Marlin/src/gcode/host/M115.cpp +++ b/Marlin/src/gcode/host/M115.cpp @@ -222,24 +222,41 @@ void GcodeSuite::M115() { // Machine Geometry #if ENABLED(M115_GEOMETRY_REPORT) - const xyz_pos_t bmin = { 0, 0, 0 }, - bmax = { X_BED_SIZE , Y_BED_SIZE, Z_MAX_POS }, - dmin = { X_MIN_POS, Y_MIN_POS, Z_MIN_POS }, - dmax = { X_MAX_POS, Y_MAX_POS, Z_MAX_POS }; + constexpr xyz_pos_t bmin{0}, + bmax = ARRAY_N(NUM_AXES, X_BED_SIZE, Y_BED_SIZE, Z_MAX_POS, I_MAX_POS, J_MAX_POS, K_MAX_POS, U_MAX_POS, V_MAX_POS, W_MAX_POS), + dmin = ARRAY_N(NUM_AXES, X_MIN_POS, Y_MIN_POS, Z_MIN_POS, I_MIN_POS, J_MIN_POS, K_MIN_POS, U_MIN_POS, V_MIN_POS, W_MIN_POS), + dmax = ARRAY_N(NUM_AXES, X_MAX_POS, Y_MAX_POS, Z_MAX_POS, I_MAX_POS, J_MAX_POS, K_MAX_POS, U_MAX_POS, V_MAX_POS, W_MAX_POS); xyz_pos_t cmin = bmin, cmax = bmax; apply_motion_limits(cmin); apply_motion_limits(cmax); const xyz_pos_t lmin = dmin.asLogical(), lmax = dmax.asLogical(), wmin = cmin.asLogical(), wmax = cmax.asLogical(); + SERIAL_ECHOLNPGM( "area:{" "full:{" - "min:{x:", lmin.x, ",y:", lmin.y, ",z:", lmin.z, "}," - "max:{x:", lmax.x, ",y:", lmax.y, ",z:", lmax.z, "}" + LIST_N(DOUBLE(NUM_AXES), + "min:{x:", lmin.x, ",y:", lmin.y, ",z:", lmin.z, + ",i:", lmin.i, ",j:", lmin.j, ",k:", lmin.k, + ",u:", lmin.u, ",v:", lmin.v, ",w:", lmin.w + ), + LIST_N(DOUBLE(NUM_AXES), + "max:{x:", lmax.x, ",y:", lmax.y, ",z:", lmax.z, + ",i:", lmax.i, ",j:", lmax.j, ",k:", lmax.k, + ",u:", lmax.u, ",v:", lmax.v, ",w:", lmax.w + ), "}," "work:{" - "min:{x:", wmin.x, ",y:", wmin.y, ",z:", wmin.z, "}," - "max:{x:", wmax.x, ",y:", wmax.y, ",z:", wmax.z, "}", + LIST_N(DOUBLE(NUM_AXES), + "min:{x:", wmin.x, ",y:", wmin.y, ",z:", wmin.z, + ",i:", wmin.i, ",j:", wmin.j, ",k:", wmin.k, + ",u:", wmin.u, ",v:", wmin.v, ",w:", wmin.w + ), + LIST_N(DOUBLE(NUM_AXES), + "max:{x:", wmax.x, ",y:", wmax.y, ",z:", wmax.z, + ",i:", wmax.i, ",j:", wmax.j, ",k:", wmax.k, + ",u:", wmax.u, ",v:", wmax.v, ",w:", wmax.w + ), "}" "}" ); diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 7f6857a3e0f1..b21eca30b292 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -1204,45 +1204,61 @@ #elif X_HOME_DIR < 0 #define X_HOME_TO_MIN 1 #endif -#if Y_HOME_DIR > 0 - #define Y_HOME_TO_MAX 1 -#elif Y_HOME_DIR < 0 - #define Y_HOME_TO_MIN 1 -#endif -#if Z_HOME_DIR > 0 - #define Z_HOME_TO_MAX 1 -#elif Z_HOME_DIR < 0 - #define Z_HOME_TO_MIN 1 -#endif -#if I_HOME_DIR > 0 - #define I_HOME_TO_MAX 1 -#elif I_HOME_DIR < 0 - #define I_HOME_TO_MIN 1 -#endif -#if J_HOME_DIR > 0 - #define J_HOME_TO_MAX 1 -#elif J_HOME_DIR < 0 - #define J_HOME_TO_MIN 1 -#endif -#if K_HOME_DIR > 0 - #define K_HOME_TO_MAX 1 -#elif K_HOME_DIR < 0 - #define K_HOME_TO_MIN 1 -#endif -#if U_HOME_DIR > 0 - #define U_HOME_TO_MAX 1 -#elif U_HOME_DIR < 0 - #define U_HOME_TO_MIN 1 -#endif -#if V_HOME_DIR > 0 - #define V_HOME_TO_MAX 1 -#elif V_HOME_DIR < 0 - #define V_HOME_TO_MIN 1 -#endif -#if W_HOME_DIR > 0 - #define W_HOME_TO_MAX 1 -#elif W_HOME_DIR < 0 - #define W_HOME_TO_MIN 1 +#if HAS_Y_AXIS + #if Y_HOME_DIR > 0 + #define Y_HOME_TO_MAX 1 + #elif Y_HOME_DIR < 0 + #define Y_HOME_TO_MIN 1 + #endif +#endif +#if HAS_Z_AXIS + #if Z_HOME_DIR > 0 + #define Z_HOME_TO_MAX 1 + #elif Z_HOME_DIR < 0 + #define Z_HOME_TO_MIN 1 + #endif +#endif +#if HAS_I_AXIS + #if I_HOME_DIR > 0 + #define I_HOME_TO_MAX 1 + #elif I_HOME_DIR < 0 + #define I_HOME_TO_MIN 1 + #endif +#endif +#if HAS_J_AXIS + #if J_HOME_DIR > 0 + #define J_HOME_TO_MAX 1 + #elif J_HOME_DIR < 0 + #define J_HOME_TO_MIN 1 + #endif +#endif +#if HAS_K_AXIS + #if K_HOME_DIR > 0 + #define K_HOME_TO_MAX 1 + #elif K_HOME_DIR < 0 + #define K_HOME_TO_MIN 1 + #endif +#endif +#if HAS_U_AXIS + #if U_HOME_DIR > 0 + #define U_HOME_TO_MAX 1 + #elif U_HOME_DIR < 0 + #define U_HOME_TO_MIN 1 + #endif +#endif +#if HAS_V_AXIS + #if V_HOME_DIR > 0 + #define V_HOME_TO_MAX 1 + #elif V_HOME_DIR < 0 + #define V_HOME_TO_MIN 1 + #endif +#endif +#if HAS_W_AXIS + #if W_HOME_DIR > 0 + #define W_HOME_TO_MAX 1 + #elif W_HOME_DIR < 0 + #define W_HOME_TO_MIN 1 + #endif #endif /** diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 37efabe280b9..05a44f8e470e 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2641,7 +2641,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #define _PLUG_UNUSED_TEST(A,P) (DISABLED(USE_##P##MIN_PLUG, USE_##P##MAX_PLUG) \ && !(ENABLED(A##_DUAL_ENDSTOPS) && WITHIN(A##2_USE_ENDSTOP, _##P##MAX_, _##P##MIN_)) \ && !(ENABLED(A##_MULTI_ENDSTOPS) && WITHIN(A##2_USE_ENDSTOP, _##P##MAX_, _##P##MIN_)) ) -#define _AXIS_PLUG_UNUSED_TEST(A) (1 NUM_AXIS_GANG(&& _PLUG_UNUSED_TEST(A,X), && _PLUG_UNUSED_TEST(A,Y), && _PLUG_UNUSED_TEST(A,Z), \ +#define _AXIS_PLUG_UNUSED_TEST(A) (HAS_##A##_A NUM_AXIS_GANG(&& _PLUG_UNUSED_TEST(A,X), && _PLUG_UNUSED_TEST(A,Y), && _PLUG_UNUSED_TEST(A,Z), \ && _PLUG_UNUSED_TEST(A,I), && _PLUG_UNUSED_TEST(A,J), && _PLUG_UNUSED_TEST(A,K), \ && _PLUG_UNUSED_TEST(A,U), && _PLUG_UNUSED_TEST(A,V), && _PLUG_UNUSED_TEST(A,W) ) ) @@ -2656,22 +2656,22 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #if _AXIS_PLUG_UNUSED_TEST(Z) #error "You must enable USE_ZMIN_PLUG or USE_ZMAX_PLUG." #endif - #if HAS_I_AXIS && _AXIS_PLUG_UNUSED_TEST(I) + #if _AXIS_PLUG_UNUSED_TEST(I) #error "You must enable USE_IMIN_PLUG or USE_IMAX_PLUG." #endif - #if HAS_J_AXIS && _AXIS_PLUG_UNUSED_TEST(J) + #if _AXIS_PLUG_UNUSED_TEST(J) #error "You must enable USE_JMIN_PLUG or USE_JMAX_PLUG." #endif - #if HAS_K_AXIS && _AXIS_PLUG_UNUSED_TEST(K) + #if _AXIS_PLUG_UNUSED_TEST(K) #error "You must enable USE_KMIN_PLUG or USE_KMAX_PLUG." #endif - #if HAS_U_AXIS && _AXIS_PLUG_UNUSED_TEST(U) + #if _AXIS_PLUG_UNUSED_TEST(U) #error "You must enable USE_UMIN_PLUG or USE_UMAX_PLUG." #endif - #if HAS_V_AXIS && _AXIS_PLUG_UNUSED_TEST(V) + #if _AXIS_PLUG_UNUSED_TEST(V) #error "You must enable USE_VMIN_PLUG or USE_VMAX_PLUG." #endif - #if HAS_W_AXIS && _AXIS_PLUG_UNUSED_TEST(W) + #if _AXIS_PLUG_UNUSED_TEST(W) #error "You must enable USE_WMIN_PLUG or USE_WMAX_PLUG." #endif @@ -2685,29 +2685,29 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "Enable USE_YMIN_PLUG when homing Y to MIN." #elif Y_HOME_TO_MAX && DISABLED(USE_YMAX_PLUG) #error "Enable USE_YMAX_PLUG when homing Y to MAX." - #elif HAS_I_AXIS && I_HOME_TO_MIN && DISABLED(USE_IMIN_PLUG) + #elif I_HOME_TO_MIN && DISABLED(USE_IMIN_PLUG) #error "Enable USE_IMIN_PLUG when homing I to MIN." - #elif HAS_I_AXIS && I_HOME_TO_MAX && DISABLED(USE_IMAX_PLUG) + #elif I_HOME_TO_MAX && DISABLED(USE_IMAX_PLUG) #error "Enable USE_IMAX_PLUG when homing I to MAX." - #elif HAS_J_AXIS && J_HOME_TO_MIN && DISABLED(USE_JMIN_PLUG) + #elif J_HOME_TO_MIN && DISABLED(USE_JMIN_PLUG) #error "Enable USE_JMIN_PLUG when homing J to MIN." - #elif HAS_J_AXIS && J_HOME_TO_MAX && DISABLED(USE_JMAX_PLUG) + #elif J_HOME_TO_MAX && DISABLED(USE_JMAX_PLUG) #error "Enable USE_JMAX_PLUG when homing J to MAX." - #elif HAS_K_AXIS && K_HOME_TO_MIN && DISABLED(USE_KMIN_PLUG) + #elif K_HOME_TO_MIN && DISABLED(USE_KMIN_PLUG) #error "Enable USE_KMIN_PLUG when homing K to MIN." - #elif HAS_K_AXIS && K_HOME_TO_MAX && DISABLED(USE_KMAX_PLUG) + #elif K_HOME_TO_MAX && DISABLED(USE_KMAX_PLUG) #error "Enable USE_KMAX_PLUG when homing K to MAX." - #elif HAS_U_AXIS && U_HOME_TO_MIN && DISABLED(USE_UMIN_PLUG) + #elif U_HOME_TO_MIN && DISABLED(USE_UMIN_PLUG) #error "Enable USE_UMIN_PLUG when homing U to MIN." - #elif HAS_U_AXIS && U_HOME_TO_MAX && DISABLED(USE_UMAX_PLUG) + #elif U_HOME_TO_MAX && DISABLED(USE_UMAX_PLUG) #error "Enable USE_UMAX_PLUG when homing U to MAX." - #elif HAS_V_AXIS && V_HOME_TO_MIN && DISABLED(USE_VMIN_PLUG) + #elif V_HOME_TO_MIN && DISABLED(USE_VMIN_PLUG) #error "Enable USE_VMIN_PLUG when homing V to MIN." - #elif HAS_V_AXIS && V_HOME_TO_MAX && DISABLED(USE_VMAX_PLUG) + #elif V_HOME_TO_MAX && DISABLED(USE_VMAX_PLUG) #error "Enable USE_VMAX_PLUG when homing V to MAX." - #elif HAS_W_AXIS && W_HOME_TO_MIN && DISABLED(USE_WMIN_PLUG) + #elif W_HOME_TO_MIN && DISABLED(USE_WMIN_PLUG) #error "Enable USE_WMIN_PLUG when homing W to MIN." - #elif HAS_W_AXIS && W_HOME_TO_MAX && DISABLED(USE_WMAX_PLUG) + #elif W_HOME_TO_MAX && DISABLED(USE_WMAX_PLUG) #error "Enable USE_WMAX_PLUG when homing W to MAX." #endif #endif diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index 81119c0a1089..83f492e124c4 100644 --- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -438,7 +438,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const else if (axis_should_home(axis)) while (const char c = *value++) lcd_put_lchar(c <= '.' ? c : '?'); else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !axis_is_trusted(axis)) - lcd_put_u8str(axis == Z_AXIS ? F(" ") : F(" ")); + lcd_put_u8str(TERN0(HAS_Z_AXIS, axis == Z_AXIS) ? F(" ") : F(" ")); else lcd_put_u8str(value); } @@ -500,7 +500,13 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const */ void MarlinUI::draw_status_screen() { constexpr int xystorage = TERN(INCH_MODE_SUPPORT, 8, 5); - static char xstring[TERN(LCD_SHOW_E_TOTAL, 12, xystorage)], ystring[xystorage], zstring[8]; + static char xstring[TERN(LCD_SHOW_E_TOTAL, 12, xystorage)]; + #if HAS_Y_AXIS + static char ystring[xystorage]; + #endif + #if HAS_Z_AXIS + static char zstring[8]; + #endif #if ENABLED(FILAMENT_LCD_DISPLAY) static char wstring[5], mstring[4]; @@ -525,7 +531,9 @@ void MarlinUI::draw_status_screen() { const xyz_pos_t lpos = current_position.asLogical(); const bool is_inch = parser.using_inch_units(); - strcpy(zstring, is_inch ? ftostr42_52(LINEAR_UNIT(lpos.z)) : ftostr52sp(lpos.z)); + #if HAS_Z_AXIS + strcpy(zstring, is_inch ? ftostr42_52(LINEAR_UNIT(lpos.z)) : ftostr52sp(lpos.z)); + #endif if (show_e_total) { #if ENABLED(LCD_SHOW_E_TOTAL) @@ -535,7 +543,7 @@ void MarlinUI::draw_status_screen() { } else { strcpy(xstring, is_inch ? ftostr53_63(LINEAR_UNIT(lpos.x)) : ftostr4sign(lpos.x)); - strcpy(ystring, is_inch ? ftostr53_63(LINEAR_UNIT(lpos.y)) : ftostr4sign(lpos.y)); + TERN_(HAS_Y_AXIS, strcpy(ystring, is_inch ? ftostr53_63(LINEAR_UNIT(lpos.y)) : ftostr4sign(lpos.y))); } #if ENABLED(FILAMENT_LCD_DISPLAY) @@ -858,12 +866,14 @@ void MarlinUI::draw_status_screen() { } else { _draw_axis_value(X_AXIS, xstring, blink); - _draw_axis_value(Y_AXIS, ystring, blink); + TERN_(HAS_Y_AXIS, _draw_axis_value(Y_AXIS, ystring, blink)); } #endif - _draw_axis_value(Z_AXIS, zstring, blink); + #if HAS_Z_AXIS + _draw_axis_value(Z_AXIS, zstring, blink); + #endif #if NONE(XYZ_NO_FRAME, XYZ_HOLLOW_FRAME) u8g.setColorIndex(1); // black on white diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index ace97c962797..5978a8ec1a01 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -477,7 +477,9 @@ void menu_backlash(); // M201 / M204 Accelerations void menu_advanced_acceleration() { - const float max_accel = _MAX(planner.settings.max_acceleration_mm_per_s2[A_AXIS], planner.settings.max_acceleration_mm_per_s2[B_AXIS], planner.settings.max_acceleration_mm_per_s2[C_AXIS]); + float max_accel = planner.settings.max_acceleration_mm_per_s2[A_AXIS]; + TERN_(HAS_Y_AXIS, NOLESS(max_accel, planner.settings.max_acceleration_mm_per_s2[B_AXIS])); + TERN_(HAS_Z_AXIS, NOLESS(max_accel, planner.settings.max_acceleration_mm_per_s2[C_AXIS])); // M201 settings constexpr xyze_ulong_t max_accel_edit = diff --git a/Marlin/src/lcd/menu/menu_motion.cpp b/Marlin/src/lcd/menu/menu_motion.cpp index d5c242442994..3c2917cb7184 100644 --- a/Marlin/src/lcd/menu/menu_motion.cpp +++ b/Marlin/src/lcd/menu/menu_motion.cpp @@ -28,7 +28,7 @@ #if HAS_MARLINUI_MENU -#define LARGE_AREA_TEST ((X_BED_SIZE) >= 1000 || (Y_BED_SIZE) >= 1000 || (Z_MAX_POS) >= 1000) +#define LARGE_AREA_TEST ((X_BED_SIZE) >= 1000 || TERN0(HAS_Y_AXIS, (Y_BED_SIZE) >= 1000) || TERN0(HAS_Z_AXIS, (Z_MAX_POS) >= 1000)) #include "menu_item.h" #include "menu_addon.h" @@ -160,8 +160,10 @@ void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int SUBMENU(MSG_MOVE_10MM, []{ _goto_manual_move(10); }); SUBMENU(MSG_MOVE_1MM, []{ _goto_manual_move( 1); }); SUBMENU(MSG_MOVE_01MM, []{ _goto_manual_move( 0.1f); }); - if (axis == Z_AXIS && (FINE_MANUAL_MOVE) > 0.0f && (FINE_MANUAL_MOVE) < 0.1f) - SUBMENU_f(F(STRINGIFY(FINE_MANUAL_MOVE)), MSG_MOVE_N_MM, []{ _goto_manual_move(float(FINE_MANUAL_MOVE)); }); + #if HAS_Z_AXIS + if (axis == Z_AXIS && (FINE_MANUAL_MOVE) > 0.0f && (FINE_MANUAL_MOVE) < 0.1f) + SUBMENU_f(F(STRINGIFY(FINE_MANUAL_MOVE)), MSG_MOVE_N_MM, []{ _goto_manual_move(float(FINE_MANUAL_MOVE)); }); + #endif } END_MENU(); } From 29294007ef6ef372ceec4ca31047d9612feb173e Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Mon, 17 Oct 2022 20:24:19 -0700 Subject: [PATCH 109/243] =?UTF-8?q?=F0=9F=94=A7=20No=20Sleep=20for=20CR-10?= =?UTF-8?q?=20Stock=20Display=20(#24875)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/SanityCheck.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 05a44f8e470e..02d798543c1f 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -3106,7 +3106,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS * Display Sleep is not supported by these common displays */ #if HAS_DISPLAY_SLEEP - #if ANY(IS_U8GLIB_LM6059_AF, IS_U8GLIB_ST7565_64128, REPRAPWORLD_GRAPHICAL_LCD, FYSETC_MINI, ENDER2_STOCKDISPLAY, MINIPANEL) + #if ANY(IS_U8GLIB_LM6059_AF, IS_U8GLIB_ST7565_64128, REPRAPWORLD_GRAPHICAL_LCD, FYSETC_MINI, CR10_STOCKDISPLAY, ENDER2_STOCKDISPLAY, MINIPANEL) #error "DISPLAY_SLEEP_MINUTES is not supported by your display." #elif !WITHIN(DISPLAY_SLEEP_MINUTES, 0, 255) #error "DISPLAY_SLEEP_MINUTES must be between 0 and 255." From 485fb7759662bca476ce1b7147945f851c82c425 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Tue, 18 Oct 2022 16:41:41 +1300 Subject: [PATCH 110/243] =?UTF-8?q?=E2=9C=A8=20Tronxy=20v10=20(#24787)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration.h | 2 +- Marlin/src/core/boards.h | 1 + Marlin/src/pins/pins.h | 2 + .../src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h | 4 + Marlin/src/pins/stm32f4/pins_TRONXY_V10.h | 266 +++++++++ .../boards/marlin_STM32F446ZET_tronxy.json | 35 ++ .../MARLIN_F446Zx_TRONXY/PeripheralPins.c | 359 +++++++++++++ .../MARLIN_F446Zx_TRONXY/PinNamesVar.h | 30 ++ .../MARLIN_F446Zx_TRONXY/hal_conf_custom.h | 505 ++++++++++++++++++ .../variants/MARLIN_F446Zx_TRONXY/ldscript.ld | 188 +++++++ .../variants/MARLIN_F446Zx_TRONXY/variant.cpp | 322 +++++++++++ .../variants/MARLIN_F446Zx_TRONXY/variant.h | 242 +++++++++ ini/stm32f4.ini | 15 + 13 files changed, 1970 insertions(+), 1 deletion(-) create mode 100644 Marlin/src/pins/stm32f4/pins_TRONXY_V10.h create mode 100644 buildroot/share/PlatformIO/boards/marlin_STM32F446ZET_tronxy.json create mode 100644 buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/PeripheralPins.c create mode 100644 buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/PinNamesVar.h create mode 100644 buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/hal_conf_custom.h create mode 100644 buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/ldscript.ld create mode 100644 buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/variant.cpp create mode 100644 buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/variant.h diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 9783b2ec6797..83c1c541e363 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -3059,7 +3059,7 @@ //#define MKS_ROBIN_TFT_V1_1R // -// 480x320, 3.5", FSMC Stock Display from TronxXY +// 480x320, 3.5", FSMC Stock Display from Tronxy // //#define TFT_TRONXY_X5SA diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index 74ff44d9905b..c993b9df0e3c 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -426,6 +426,7 @@ #define BOARD_OPULO_LUMEN_REV4 4241 // Opulo Lumen PnP Controller REV4 (STM32F407VE / STM32F407VG) #define BOARD_FYSETC_SPIDER_KING407 4242 // FYSETC Spider King407 (STM32F407ZG) #define BOARD_MKS_SKIPR_V1 4243 // MKS SKIPR v1.0 all-in-one board (STM32F407VE) +#define BOARD_TRONXY_V10 4244 // TRONXY V10 (STM32F446ZE) // // ARM Cortex M7 diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index c623b4844d20..046957e1ba90 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -711,6 +711,8 @@ #include "stm32f4/pins_FYSETC_SPIDER_KING407.h" // STM32F4 env:FYSETC_SPIDER_KING407 #elif MB(MKS_SKIPR_V1) #include "stm32f4/pins_MKS_SKIPR_V1_0.h" // STM32F4 env:mks_skipr_v1 env:mks_skipr_v1_nobootloader +#elif MB(TRONXY_V10) + #include "stm32f4/pins_TRONXY_V10.h" // STM32F4 env:STM32F446_tronxy // // ARM Cortex M7 diff --git a/Marlin/src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h b/Marlin/src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h index 1a75a859e6c6..1a7a5cd1c363 100644 --- a/Marlin/src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h +++ b/Marlin/src/pins/stm32f4/pins_TH3D_EZBOARD_V2.h @@ -24,6 +24,10 @@ #define ALLOW_STM32DUINO #include "env_validate.h" +#if HOTENDS > 1 || E_STEPPERS > 1 + #error "TH3D EZBoard only supports 1 hotend / E stepper." +#endif + #define BOARD_INFO_NAME "TH3D EZBoard V2" #define BOARD_WEBSITE_URL "th3dstudio.com" diff --git a/Marlin/src/pins/stm32f4/pins_TRONXY_V10.h b/Marlin/src/pins/stm32f4/pins_TRONXY_V10.h new file mode 100644 index 000000000000..e3b9f7ef6e55 --- /dev/null +++ b/Marlin/src/pins/stm32f4/pins_TRONXY_V10.h @@ -0,0 +1,266 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include "env_validate.h" + +#if HOTENDS > 3 || E_STEPPERS > 3 + #error "Tronxy V10 supports up to 3 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "Tronxy V10" +#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME + +#define STEP_TIMER 6 +#define TEMP_TIMER 14 + +// +// Servos +// +//#define SERVO0_PIN PB10 + +// +// EEPROM +// +#if NO_EEPROM_SELECTED + #undef NO_EEPROM_SELECTED + #if TRONXY_UI > 0 + #define EEPROM_AT24CXX + #else + #define FLASH_EEPROM_EMULATION + #endif +#endif + +#if ENABLED(FLASH_EEPROM_EMULATION) + // SoC Flash (framework-arduinoststm32-maple/STM32F1/libraries/EEPROM/EEPROM.h) + #define EEPROM_START_ADDRESS (0x8000000UL + (512 * 1024) - 2 * EEPROM_PAGE_SIZE) + #define EEPROM_PAGE_SIZE (0x800U) // 2KB, but will use 2x more (4KB) + #define MARLIN_EEPROM_SIZE EEPROM_PAGE_SIZE +#else + #if ENABLED(EEPROM_AT24CXX) + #define AT24CXX_SCL PB8 + #define AT24CXX_SDA PB9 + #define AT24CXX_WP PB7 + #else + #define I2C_EEPROM // AT24C32 + #endif + #define MARLIN_EEPROM_SIZE 0x1000 // 4K +#endif + +// +// SPI Flash +// +//#define SPI_FLASH +#if ENABLED(SPI_FLASH) + #define SPI_FLASH_SIZE 0x200000 // 2MB + #define W25QXX_CS_PIN PG15 // SPI2 + #define W25QXX_MOSI_PIN PB5 + #define W25QXX_MISO_PIN PB4 + #define W25QXX_SCK_PIN PB3 +#endif + +// +// Limit Switches +// +#define X_MIN_PIN PC15 +#define X_MAX_PIN PB0 +#define Y_STOP_PIN PC14 + +#ifndef Z_MIN_PROBE_PIN + #define Z_MIN_PROBE_PIN PE3 +#endif + +#if ENABLED(DUAL_Z_ENDSTOP_PROBE) + #if NUM_Z_STEPPERS > 1 && Z_HOME_TO_MAX // Swap Z1/Z2 for dual Z with max homing + #define Z_MIN_PIN PF11 + #define Z_MAX_PIN PC13 + #else + #define Z_MIN_PIN PC13 + #define Z_MAX_PIN PF11 + #endif +#else + #ifndef Z_STOP_PIN + #define Z_STOP_PIN PC13 + #endif +#endif +// +// Filament Sensors +// +#ifndef FIL_RUNOUT_PIN + #define FIL_RUNOUT_PIN PE6 // MT_DET +#endif +#ifndef FIL_RUNOUT2_PIN + #define FIL_RUNOUT2_PIN PF12 +#endif + +// +// Steppers +// +#define X_ENABLE_PIN PF0 +#define X_STEP_PIN PE5 +#define X_DIR_PIN PF1 + +#define Y_ENABLE_PIN PF5 +#define Y_STEP_PIN PF9 +#define Y_DIR_PIN PF3 + +#define Z_ENABLE_PIN PA5 +#define Z_STEP_PIN PA6 +#define Z_DIR_PIN PF15 + +#define E0_ENABLE_PIN PF14 +#define E0_STEP_PIN PB1 +#define E0_DIR_PIN PF13 + +#define E1_ENABLE_PIN PG5 +#define E1_STEP_PIN PD12 +#define E1_DIR_PIN PG4 + +#define E2_ENABLE_PIN PF7 +#define E2_STEP_PIN PF6 +#define E2_DIR_PIN PF4 + +// +// Temperature Sensors +// +#define TEMP_0_PIN PC3 // TH1 +#define TEMP_BED_PIN PC2 // TB1 + +// +// Heaters / Fans +// +#define HEATER_0_PIN PG7 // HEATER1 +#define HEATER_BED_PIN PE2 // HOT BED +//#define HEATER_BED_INVERTING true + +#define FAN_PIN PG0 // FAN0 +#define FAN1_PIN PB6 // FAN1 +#define FAN2_PIN PG9 // FAN2 +#define FAN3_PIN PF10 // FAN3 +#define CONTROLLER_FAN_PIN PD7 // BOARD FAN +#define FAN_SOFT_PWM + +// +// Laser / Spindle +// +#if HAS_CUTTER + #define SPINDLE_LASER_ENA_PIN PB11 // wifi:TX + #if ENABLED(SPINDLE_LASER_USE_PWM) + #define SPINDLE_LASER_PWM_PIN PB10 // wifi:RX-TIM2_CH3 + // The PWM pin definition const PinMap PinMap_PWM[] in PeripheralPins.c must be compounded here + // See PWM_PIN(x) definition for details + #endif +#endif + +// +// Misc +// +#define BEEPER_PIN PA8 + +//#define LED_PIN PG10 +#define PS_ON_PIN PG10 // Temporarily switch the machine with LED simulation + +#if ENABLED(TRONXY_BACKUP_POWER) + #define POWER_LOSS_PIN PF11 // Configure as drop-down input +#else + #define POWER_LOSS_PIN PE1 // Output of LM393 comparator, configured as pullup +#endif +//#define POWER_LM393_PIN PE0 // +V for the LM393 comparator, configured as output high + +#if ENABLED(TFT_TRONXY_X5SA) + #error "TFT_TRONXY_X5SA is not yet supported." +#endif + +#if 0 + +// +// TFT with FSMC interface +// +#if HAS_FSMC_TFT + #define TFT_RESET_PIN PB12 + #define TFT_BACKLIGHT_PIN PG8 + + #define LCD_USE_DMA_FSMC // Use DMA transfers to send data to the TFT + #define FSMC_DMA_DEV DMA2 + #define FSMC_DMA_CHANNEL DMA_CH5 + + #define TFT_CS_PIN PG12 + #define TFT_RS_PIN PG2 + + //#define TFT_WIDTH 480 + //#define TFT_HEIGHT 320 + //#define TFT_PIXEL_OFFSET_X 48 + //#define TFT_PIXEL_OFFSET_Y 32 + //#define TFT_DRIVER ILI9488 + //#define TFT_BUFFER_SIZE 14400 + + #if NEED_TOUCH_PINS + #define TOUCH_CS_PIN PD11 // SPI1_NSS + #define TOUCH_SCK_PIN PB13 // SPI1_SCK + #define TOUCH_MISO_PIN PB14 // SPI1_MISO + #define TOUCH_MOSI_PIN PB15 // SPI1_MOSI + #endif + + #if (LCD_CHIP_INDEX == 1 && (TRONXY_UI == 1 || TRONXY_UI == 2)) || LCD_CHIP_INDEX == 3 + #define TOUCH_CALIBRATION_X -17181 + #define TOUCH_CALIBRATION_Y 11434 + #define TOUCH_OFFSET_X 501 + #define TOUCH_OFFSET_Y -9 + #elif LCD_CHIP_INDEX == 1 && TRONXY_UI == 4 + #define TOUCH_CALIBRATION_X 11166 + #define TOUCH_CALIBRATION_Y 17162 + #define TOUCH_OFFSET_X -10 + #define TOUCH_OFFSET_Y -16 + #elif LCD_CHIP_INDEX == 4 && TRONXY_UI == 3 + //#define TOUCH_CALIBRATION_X 8781 + //#define TOUCH_CALIBRATION_Y 11773 + //#define TOUCH_OFFSET_X -17 + //#define TOUCH_OFFSET_Y -16 + // Upside-down + #define TOUCH_CALIBRATION_X -8553 + #define TOUCH_CALIBRATION_Y -11667 + #define TOUCH_OFFSET_X 253 + #define TOUCH_OFFSET_Y 331 + #elif LCD_CHIP_INDEX == 2 + #define TOUCH_CALIBRATION_X 17184 + #define TOUCH_CALIBRATION_Y 10604 + #define TOUCH_OFFSET_X -31 + #define TOUCH_OFFSET_Y -29 + #endif +#endif + +#endif + +// +// SD Card +// +#define SDIO_SUPPORT +#define SD_DETECT_PIN -1 // PF0, but not connected +#define SDIO_CLOCK 4500000 +#define SDIO_READ_RETRIES 16 + +#define SDIO_D0_PIN PC8 +#define SDIO_D1_PIN PC9 +#define SDIO_D2_PIN PC10 +#define SDIO_D3_PIN PC11 +#define SDIO_CK_PIN PC12 +#define SDIO_CMD_PIN PD2 diff --git a/buildroot/share/PlatformIO/boards/marlin_STM32F446ZET_tronxy.json b/buildroot/share/PlatformIO/boards/marlin_STM32F446ZET_tronxy.json new file mode 100644 index 000000000000..bd129a703ad4 --- /dev/null +++ b/buildroot/share/PlatformIO/boards/marlin_STM32F446ZET_tronxy.json @@ -0,0 +1,35 @@ +{ + "build": { + "cpu": "cortex-m4", + "extra_flags": "-DSTM32F446xx", + "f_cpu": "180000000L", + "mcu": "stm32f446zet6", + "variant": "MARLIN_F446Zx_TRONXY" + }, + "connectivity": [ + "can" + ], + "debug": { + "jlink_device": "STM32F446ZE", + "openocd_target": "stm32f4x", + "svd_path": "STM32F446x.svd" + }, + "frameworks": [ + "arduino", + "stm32cube" + ], + "name": "STM32F446ZE (128k RAM. 512k Flash)", + "upload": { + "maximum_ram_size": 131072, + "maximum_size": 524288, + "protocol": "stlink", + "protocols": [ + "jlink", + "stlink", + "blackmagic", + "serial" + ] + }, + "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32f446.html", + "vendor": "Generic" +} diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/PeripheralPins.c new file mode 100644 index 000000000000..4514efe7e4c6 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/PeripheralPins.c @@ -0,0 +1,359 @@ +/* + ******************************************************************************* + * Copyright (c) 2016, STMicroelectronics + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************* + */ +#include "Arduino.h" +#include "PeripheralPins.h" + +// ===== +// Note: Commented lines are alternative possibilities which are not used per default. +// If you change them, you will have to know what you do +// ===== + + +//*** ADC *** + +#ifdef HAL_ADC_MODULE_ENABLED +const PinMap PinMap_ADC[] = { + // {PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC1_IN0 + // {PA_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC2_IN0 + // {PA_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC3_IN0 + // {PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC1_IN1 + // {PA_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC2_IN1 + // {PA_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC3_IN1 + // {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC1_IN2 + // {PA_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC2_IN2 + // {PA_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC3_IN2 + {PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC1_IN3 + // {PA_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC2_IN3 + // {PA_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC3_IN3 + {PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 + // {PA_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC2_IN4 + // {PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 + // {PA_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC2_IN5 + // {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 + // {PA_6, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC2_IN6 + // {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 + // {PA_7, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC2_IN7 + // {PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC1_IN8 + // {PB_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC2_IN8 + // {PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC1_IN9 + // {PB_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC2_IN9 + {PC_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC1_IN10 + // {PC_0, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC2_IN10 + // {PC_0, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 10, 0)}, // ADC3_IN10 + {PC_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC1_IN11 + // {PC_1, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC2_IN11 + // {PC_1, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 11, 0)}, // ADC3_IN11 + {PC_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC1_IN12 + // {PC_2, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC2_IN12 + // {PC_2, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 12, 0)}, // ADC3_IN12 + {PC_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC1_IN13 + // {PC_3, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC2_IN13 + // {PC_3, ADC3, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 13, 0)}, // ADC3_IN13 + {PC_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC1_IN14 + // {PC_4, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 14, 0)}, // ADC2_IN14 + // {PC_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC1_IN15 + // {PC_5, ADC2, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 15, 0)}, // ADC2_IN15 + {NC, NP, 0} +}; +#endif + +//*** DAC *** + +#ifdef HAL_DAC_MODULE_ENABLED +const PinMap PinMap_DAC[] = { + // {PA_4, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // DAC_OUT1 + // {PA_5, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC_OUT2 - LD2 + {NC, NP, 0} +}; +#endif + +//*** I2C *** + +#ifdef HAL_I2C_MODULE_ENABLED +const PinMap PinMap_I2C_SDA[] = { + // {PB_3, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + // {PB_4, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + // {PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + // {PC_7, FMPI2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_FMPI2C1)}, + // {PC_9, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + // {PC_12, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_I2C_MODULE_ENABLED +const PinMap PinMap_I2C_SCL[] = { + // {PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + // {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + // {PB_10, I2C2, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C2)}, + // {PC_6, FMPI2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_FMPI2C1)}, + {NC, NP, 0} +}; +#endif + +//*** PWM *** + +#ifdef HAL_TIM_MODULE_ENABLED +const PinMap PinMap_PWM[] = { + {PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + // {PA_0, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 1, 0)}, // TIM5_CH1 + // {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + {PA_1, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 2, 0)}, // TIM5_CH2 + // {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 - STLink Tx + // {PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 - STLink Tx + // {PA_2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 - STLink Tx + // {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 - STLink Rx + // {PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 - STLink Rx + // {PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 - STLink Rx + {PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + // {PA_5, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N + {PA_6, TIM13, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM13, 1, 0)}, // TIM13_CH1 + // {PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + //{PA_7, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM14, 1, 0)}, // TIM14_CH1 + // {PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + // {PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + // {PA_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 1)}, // TIM8_CH1N + // {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 + {PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 + {PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 + {PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 4, 0)}, // TIM1_CH4 + {PA_15, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + // {PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + // {PB_0, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 + {PB_0, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // Fan0, TIM8_CH2N + // {PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + // {PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + {PB_1, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // Fan1, TIM8_CH3N + {PB_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // Fan2, TIM2_CH4 + {PB_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // E0 Heater, TIM2_CH2 + {PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // E1 Heater, TIM3_CH1 + {PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // LED G, TIM3_CH2 + {PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // LED R, TIM4_CH1 + {PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // LED B, TIM4_CH2 + // {PB_8, TIM10, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM10, 1, 0)}, // TIM10_CH1 + // {PB_8, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + {PB_8, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 3, 0)}, // TIM4_CH3 + {PB_9, TIM11, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM11, 1, 0)}, // TIM11_CH1 + // {PB_9, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + // {PB_9, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + {PB_10, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 + {PB_13, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + {PB_14, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 1, 0)}, // TIM12_CH1 + // {PB_14, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + // {PB_14, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 1)}, // TIM8_CH2N + {PB_15, TIM12, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_TIM12, 2, 0)}, // TIM12_CH2 + // {PB_15, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N + // {PB_15, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 1)}, // TIM8_CH3N + {PC_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + // {PC_6, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 1, 0)}, // TIM8_CH1 + // {PC_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + {PC_7, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 2, 0)}, // TIM8_CH2 + {PC_8, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 3, 0)}, // TIM3_CH3 + // {PC_8, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 3, 0)}, // TIM8_CH3 + // {PC_9, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 4, 0)}, // TIM3_CH4 + {PC_9, TIM8, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM8, 4, 0)}, // TIM8_CH4 + {PD_15, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 4, 0)}, // TIM4_CH4 + {PE_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 + {PE_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N + {NC, NP, 0} +}; +#endif + +//*** SERIAL *** + +#ifdef HAL_UART_MODULE_ENABLED +const PinMap PinMap_UART_TX[] = { + // {PA_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + // {PA_2, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + // {PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + // {PB_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + // {PC_6, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + // {PC_10, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {PC_10, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + // {PC_12, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +const PinMap PinMap_UART_RX[] = { + // {PA_1, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + // {PA_3, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + {PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + // {PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + // {PC_5, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + // {PC_7, USART6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_USART6)}, + // {PC_11, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + {PC_11, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + // {PD_2, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART5)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +const PinMap PinMap_UART_RTS[] = { + // {PA_1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + // {PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + // {PA_15, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + // {PB_14, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + // {PC_8, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART5)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +const PinMap PinMap_UART_CTS[] = { + // {PA_0, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, + // {PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + // {PB_0, UART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_UART4)}, + // {PB_13, USART3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART3)}, + // {PC_9, UART5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_UART5)}, + {NC, NP, 0} +}; +#endif + +//*** SPI *** + +#ifdef HAL_SPI_MODULE_ENABLED +const PinMap PinMap_SPI_MOSI[] = { + {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PB_0, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI3)}, + // {PB_2, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI3)}, + // {PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PB_5, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + // {PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PC_1, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI2)}, + // {PC_1, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI3)}, + // {PC_3, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PC_12, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +const PinMap PinMap_SPI_MISO[] = { + {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PB_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + // {PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PC_2, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PC_11, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +const PinMap PinMap_SPI_SCLK[] = { + {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PA_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PB_3, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + // {PB_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PC_7, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PC_10, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +const PinMap PinMap_SPI_SSEL[] = { + {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PA_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + // {PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PA_15, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + // {PB_4, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_SPI2)}, + // {PB_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + // {PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, + {NC, NP, 0} +}; +#endif + +//*** CAN *** + +#ifdef HAL_CAN_MODULE_ENABLED +const PinMap PinMap_CAN_RD[] = { + // {PA_11, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + // {PB_5, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + // {PB_8, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + // {PB_12, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_CAN_MODULE_ENABLED +const PinMap PinMap_CAN_TD[] = { + // {PA_12, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + // {PB_6, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + // {PB_9, CAN1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)}, + // {PB_13, CAN2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)}, + {NC, NP, 0} +}; +#endif + +//*** ETHERNET *** + +//*** No Ethernet *** + +//*** QUADSPI *** + +#ifdef HAL_QSPI_MODULE_ENABLED +const PinMap PinMap_QUADSPI[] = { + // {PA_1, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO3 + // {PB_2, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_CLK + // {PB_6, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_QSPI)}, // QUADSPI_BK1_NCS + // {PC_9, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO0 + // {PC_10, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK1_IO1 + // {PC_11, QUADSPI, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF9_QSPI)}, // QUADSPI_BK2_NCS + {NC, NP, 0} +}; +#endif + +//*** USB *** + +#ifdef HAL_PCD_MODULE_ENABLED +const PinMap PinMap_USB_OTG_FS[] = { + // {PA_8, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_SOF + // {PA_9, USB_OTG_FS, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, 0)}, // USB_OTG_FS_VBUS + // {PA_10, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_ID + {PA_11, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DM + {PA_12, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DP + {NC, NP, 0} +}; +#endif + +#ifdef HAL_PCD_MODULE_ENABLED +const PinMap PinMap_USB_OTG_HS[] = { + {NC, NP, 0} +}; +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/PinNamesVar.h b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/PinNamesVar.h new file mode 100644 index 000000000000..bff3f2134987 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/PinNamesVar.h @@ -0,0 +1,30 @@ +/* SYS_WKUP */ +#ifdef PWR_WAKEUP_PIN1 + SYS_WKUP1 = PA_0, /* SYS_WKUP0 */ +#endif +#ifdef PWR_WAKEUP_PIN2 + SYS_WKUP2 = NC, +#endif +#ifdef PWR_WAKEUP_PIN3 + SYS_WKUP3 = NC, +#endif +#ifdef PWR_WAKEUP_PIN4 + SYS_WKUP4 = NC, +#endif +#ifdef PWR_WAKEUP_PIN5 + SYS_WKUP5 = NC, +#endif +#ifdef PWR_WAKEUP_PIN6 + SYS_WKUP6 = NC, +#endif +#ifdef PWR_WAKEUP_PIN7 + SYS_WKUP7 = NC, +#endif +#ifdef PWR_WAKEUP_PIN8 + SYS_WKUP8 = NC, +#endif +/* USB */ +#ifdef USBCON + USB_OTG_FS_DM = PA_11, + USB_OTG_FS_DP = PA_12, +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/hal_conf_custom.h b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/hal_conf_custom.h new file mode 100644 index 000000000000..e0775922454c --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/hal_conf_custom.h @@ -0,0 +1,505 @@ +/** + ****************************************************************************** + * @file stm32f4xx_hal_conf.h + * @brief HAL configuration file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F4xx_HAL_CONF_CUSTOM +#define __STM32F4xx_HAL_CONF_CUSTOM + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ + /** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED +#define HAL_ADC_MODULE_ENABLED +/* #define HAL_CAN_MODULE_ENABLED */ +/* #define HAL_CAN_LEGACY_MODULE_ENABLED */ +#define HAL_CRC_MODULE_ENABLED +/* #define HAL_CEC_MODULE_ENABLED */ +/* #define HAL_CRYP_MODULE_ENABLED */ +#define HAL_DAC_MODULE_ENABLED +/* #define HAL_DCMI_MODULE_ENABLED */ +#define HAL_DMA_MODULE_ENABLED +/* #define HAL_DMA2D_MODULE_ENABLED */ +/* #define HAL_ETH_MODULE_ENABLED */ +#define HAL_FLASH_MODULE_ENABLED +/* #define HAL_NAND_MODULE_ENABLED */ +/* #define HAL_NOR_MODULE_ENABLED */ +/* #define HAL_PCCARD_MODULE_ENABLED */ +#define HAL_SRAM_MODULE_ENABLED //YSZ-WORK +/* #define HAL_SDRAM_MODULE_ENABLED */ +/* #define HAL_HASH_MODULE_ENABLED */ +#define HAL_GPIO_MODULE_ENABLED +/* #define HAL_EXTI_MODULE_ENABLED */ +#define HAL_I2C_MODULE_ENABLED +/* #define HAL_SMBUS_MODULE_ENABLED */ +/* #define HAL_I2S_MODULE_ENABLED */ +/* #define HAL_IWDG_MODULE_ENABLED */ +/* #define HAL_LTDC_MODULE_ENABLED */ +/* #define HAL_DSI_MODULE_ENABLED */ +#define HAL_PWR_MODULE_ENABLED +/* #define HAL_QSPI_MODULE_ENABLED */ +#define HAL_RCC_MODULE_ENABLED +/* #define HAL_RNG_MODULE_ENABLED */ +#define HAL_RTC_MODULE_ENABLED +/* #define HAL_SAI_MODULE_ENABLED */ +#define HAL_SD_MODULE_ENABLED +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +/* #define HAL_UART_MODULE_ENABLED */ +/* #define HAL_USART_MODULE_ENABLED */ +/* #define HAL_IRDA_MODULE_ENABLED */ +/* #define HAL_SMARTCARD_MODULE_ENABLED */ +/* #define HAL_WWDG_MODULE_ENABLED */ +#define HAL_CORTEX_MODULE_ENABLED +#ifndef HAL_PCD_MODULE_ENABLED + #define HAL_PCD_MODULE_ENABLED //Since STM32 v3.10700.191028 this is automatically added if any type of USB is enabled (as in Arduino IDE) +#endif +#define HAL_HCD_MODULE_ENABLED +/* #define HAL_FMPI2C_MODULE_ENABLED */ +/* #define HAL_SPDIFRX_MODULE_ENABLED */ +/* #define HAL_DFSDM_MODULE_ENABLED */ +/* #define HAL_LPTIM_MODULE_ENABLED */ +/* #define HAL_MMC_MODULE_ENABLED */ + +/* ########################## HSE/HSI Values adaptation ##################### */ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#ifndef HSE_VALUE +#define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#ifndef HSE_STARTUP_TIMEOUT +#if STM32_TYPE == 4 +#define HSE_STARTUP_TIMEOUT 0xFFFFu +#else +#define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ +#endif +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#ifndef HSI_VALUE +#define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz */ +#endif /* HSI_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#ifndef LSI_VALUE +#define LSI_VALUE 32000U /*!< LSI Typical Value in Hz */ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz +The real value may vary depending on the variations +in voltage and temperature. */ +/** + * @brief External Low Speed oscillator (LSE) value. + */ +#ifndef LSE_VALUE +#define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +#ifndef LSE_STARTUP_TIMEOUT +#define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +/** + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#ifndef EXTERNAL_CLOCK_VALUE +#define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External oscillator in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#if !defined (VDD_VALUE) +#define VDD_VALUE 3300U /*!< Value of VDD in mv */ +#endif +#if !defined (TICK_INT_PRIORITY) +#define TICK_INT_PRIORITY 0x00U /*!< tick interrupt priority */ +#endif +#if !defined (USE_RTOS) +#define USE_RTOS 0U +#endif +#if !defined (PREFETCH_ENABLE) +#define PREFETCH_ENABLE 1U +#endif +#if !defined (INSTRUCTION_CACHE_ENABLE) +#define INSTRUCTION_CACHE_ENABLE 1U +#endif +#if !defined (DATA_CACHE_ENABLE) +#define DATA_CACHE_ENABLE 1U +#endif + +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ +#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ +#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ +#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */ +#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */ +#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */ +#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ +#define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */ +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ +#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */ +#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ +#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */ +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */ +#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ +#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */ +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ +#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */ +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ +#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ +#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1U */ + +/* ################## Ethernet peripheral configuration ##################### */ + +/* Section 1 : Ethernet peripheral configuration */ + +/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ +#define MAC_ADDR0 2U +#define MAC_ADDR1 0U +#define MAC_ADDR2 0U +#define MAC_ADDR3 0U +#define MAC_ADDR4 0U +#define MAC_ADDR5 0U + +/* Definition of the Ethernet driver buffers size and count */ +#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ +#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ +#define ETH_RXBUFNB ((uint32_t)4U) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB ((uint32_t)4U) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ + +/* Section 2: PHY configuration section */ + +/* DP83848_PHY_ADDRESS Address*/ +#define DP83848_PHY_ADDRESS 0x01U +/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ +#define PHY_RESET_DELAY 0x000000FFU +/* PHY Configuration delay */ +#define PHY_CONFIG_DELAY 0x00000FFFU + +#define PHY_READ_TO 0x0000FFFFU +#define PHY_WRITE_TO 0x0000FFFFU + +/* Section 3: Common PHY Registers */ + +#define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */ +#define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */ + +#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */ +#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */ +#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */ +#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */ +#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */ +#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */ +#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */ +#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */ +#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */ +#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */ + +#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */ +#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */ +#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */ + +/* Section 4: Extended PHY Registers */ +#define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */ + +#define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */ +#define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver + * Activated: CRC code is present inside driver + * Deactivated: CRC code cleaned from driver + */ +#ifndef USE_SPI_CRC +#define USE_SPI_CRC 0U +#endif + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED +#include "stm32f4xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED +#include "stm32f4xx_hal_gpio.h" +#include "stm32f4xx_hal_gpio_ex.h" //YSZ-WORK +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED +#include "stm32f4xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED +#include "stm32f4xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED +#include "stm32f4xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED +#include "stm32f4xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED +#include "stm32f4xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CAN_LEGACY_MODULE_ENABLED +#include "stm32f4xx_hal_can_legacy.h" +#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED +#include "stm32f4xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED +#include "stm32f4xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DMA2D_MODULE_ENABLED +#include "stm32f4xx_hal_dma2d.h" +#endif /* HAL_DMA2D_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED +#include "stm32f4xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_DCMI_MODULE_ENABLED +#include "stm32f4xx_hal_dcmi.h" +#endif /* HAL_DCMI_MODULE_ENABLED */ + +#ifdef HAL_ETH_MODULE_ENABLED +#include "stm32f4xx_hal_eth.h" +#endif /* HAL_ETH_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED +#include "stm32f4xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED +#include "stm32f4xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED +#include "stm32f4xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED +#include "stm32f4xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_PCCARD_MODULE_ENABLED +#include "stm32f4xx_hal_pccard.h" +#endif /* HAL_PCCARD_MODULE_ENABLED */ + +#ifdef HAL_SDRAM_MODULE_ENABLED +#include "stm32f4xx_hal_sdram.h" +#endif /* HAL_SDRAM_MODULE_ENABLED */ + +#ifdef HAL_HASH_MODULE_ENABLED +#include "stm32f4xx_hal_hash.h" +#endif /* HAL_HASH_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED +#include "stm32f4xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED +#include "stm32f4xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED +#include "stm32f4xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED +#include "stm32f4xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_LTDC_MODULE_ENABLED +#include "stm32f4xx_hal_ltdc.h" +#endif /* HAL_LTDC_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED +#include "stm32f4xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED +#include "stm32f4xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED +#include "stm32f4xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED +#include "stm32f4xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SD_MODULE_ENABLED +#include "stm32f4xx_hal_sd.h" +#endif /* HAL_SD_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED +#include "stm32f4xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED +#include "stm32f4xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED +#include "stm32f4xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED +#include "stm32f4xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED +#include "stm32f4xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED +#include "stm32f4xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED +#include "stm32f4xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED +#include "stm32f4xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_HCD_MODULE_ENABLED +#include "stm32f4xx_hal_hcd.h" +#endif /* HAL_HCD_MODULE_ENABLED */ + +#ifdef HAL_DSI_MODULE_ENABLED +#include "stm32f4xx_hal_dsi.h" +#endif /* HAL_DSI_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED +#include "stm32f4xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED +#include "stm32f4xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_FMPI2C_MODULE_ENABLED +#include "stm32f4xx_hal_fmpi2c.h" +#endif /* HAL_FMPI2C_MODULE_ENABLED */ + +#ifdef HAL_SPDIFRX_MODULE_ENABLED +#include "stm32f4xx_hal_spdifrx.h" +#endif /* HAL_SPDIFRX_MODULE_ENABLED */ + +#ifdef HAL_DFSDM_MODULE_ENABLED +#include "stm32f4xx_hal_dfsdm.h" +#endif /* HAL_DFSDM_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED +#include "stm32f4xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +#ifdef HAL_MMC_MODULE_ENABLED +#include "stm32f4xx_hal_mmc.h" +#endif /* HAL_MMC_MODULE_ENABLED */ + +#ifdef HAL_FSMC_MODULE_ENABLED +#include "stm32f4xx_ll_fmc.h" +#endif + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ +#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ +void assert_failed(uint8_t *file, uint32_t line); +#else +#define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F4xx_HAL_CONF_CUSTOM_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/ldscript.ld b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/ldscript.ld new file mode 100644 index 000000000000..20a9f1db1bb0 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/ldscript.ld @@ -0,0 +1,188 @@ +/* +***************************************************************************** +** + +** File : LinkerScript.ld +** +** Abstract : Linker script for STM32F446RETx Device with +** 512KByte FLASH, 128KByte RAM +** +** Set heap size, stack size and stack location according +** to application requirements. +** +** Set memory bank area and size if external memory is used. +** +** Target : STMicroelectronics STM32 +** +** +** Distribution: The file is distributed as is, without any warranty +** of any kind. +** +***************************************************************************** +** @attention +** +**

© COPYRIGHT(c) 2014 Ac6

+** +** Redistribution and use in source and binary forms, with or without modification, +** are permitted provided that the following conditions are met: +** 1. Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** 3. Neither the name of Ac6 nor the names of its contributors +** may be used to endorse or promote products derived from this software +** without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +***************************************************************************** +*/ + +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Highest address of the user mode stack */ +_estack = 0x20000000 + LD_MAX_DATA_SIZE; /* end of RAM */ +/* Generate a link error if heap and stack don't fit into RAM */ +_Min_Heap_Size = 0x2000; /* required amount of heap */ +_Min_Stack_Size = 0x400; /* required amount of stack */ + +/* Specify the memory areas */ +MEMORY +{ +RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE +FLASH (rx) : ORIGIN = 0x08000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET +} + +/* Define output sections */ +SECTIONS +{ + /* The startup code goes first into FLASH */ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + } >FLASH + + /* The program code and other data goes into FLASH */ + .text ALIGN(4): + { + . = ALIGN(4); + *(.text) /* .text sections (code) */ + *(.text*) /* .text* sections (code) */ + *(.glue_7) /* glue arm to thumb code */ + *(.glue_7t) /* glue thumb to arm code */ + *(.eh_frame) + + KEEP (*(.init)) + KEEP (*(.fini)) + + . = ALIGN(8); /*YSZ-WORK:4->8*/ + _etext = .; /* define a global symbols at end of code */ + } >FLASH + + /* Constant data goes into FLASH */ + .rodata : + { + . = ALIGN(4); + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + . = ALIGN(4); + } >FLASH + + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH + .ARM : { + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + } >FLASH + + .preinit_array : + { + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)) + PROVIDE_HIDDEN (__preinit_array_end = .); + } >FLASH + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + } >FLASH + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array*)) + PROVIDE_HIDDEN (__fini_array_end = .); + } >FLASH + + /* used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* Initialized data sections goes into RAM, load LMA copy after code */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + } >RAM AT> FLASH + + + /* Uninitialized data section */ + . = ALIGN(4); + .bss : + { + /* This is used by the startup in order to initialize the .bss secion */ + _sbss = .; /* define a global symbol at bss start */ + __bss_start__ = _sbss; + *(.bss) + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end */ + __bss_end__ = _ebss; + } >RAM + + /* User_heap_stack section, used to check that there is enough RAM left */ + ._user_heap_stack : + { + . = ALIGN(4);/*YSZ-WORK:8->4*/ + PROVIDE ( end = . ); + PROVIDE ( _end = . ); + . = . + _Min_Heap_Size; + . = . + _Min_Stack_Size; + . = ALIGN(4);/*YSZ-WORK:8->4*/ + } >RAM + + + + /* Remove information from the standard libraries */ + /DISCARD/ : + { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + + .ARM.attributes 0 : { *(.ARM.attributes) } +} + + diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/variant.cpp b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/variant.cpp new file mode 100644 index 000000000000..807b9392eb9c --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/variant.cpp @@ -0,0 +1,322 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "pins_arduino.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// Pin number +const PinName digitalPin[] = { + PA_0, //D0 + PA_1, //D1 + PA_2, //D2 + PA_3, //D3 + PA_4, //D4 + PA_5, //D5 + PA_6, //D6 + PA_7, //D7 + PA_8, //D8 + PA_9, //D9 + PA_10, //D10 + PA_11, //D11 + PA_12, //D12 + PA_13, //D13 + PA_14, //D14 + PA_15, //D15 + PB_0, //D16 + PB_1, //D17 + PB_2, //D18 + PB_3, //D19 + PB_4, //D20 + PB_5, //D21 + PB_6, //D22 + PB_7, //D23 + PB_8, //D24 + PB_9, //D25 + PB_10, //D26 + PB_11, //D27 + PB_12, //D28 + PB_13, //D29 + PB_14, //D30 + PB_15, //D31 + PC_0, //D32 + PC_1, //D33 + PC_2, //D34 + PC_3, //D35 + PC_4, //D36 + PC_5, //D37 + PC_6, //D38 + PC_7, //D39 + PC_8, //D40 + PC_9, //D41 + PC_10, //D42 + PC_11, //D43 + PC_12, //D44 + PC_13, //D45 + PC_14, //D46 + PC_15, //D47 + PD_0, //D48 + PD_1, //D49 + PD_2, //D50 + PD_3, //D51 + PD_4, //D52 + PD_5, //D53 + PD_6, //D54 + PD_7, //D55 + PD_8, //D56 + PD_9, //D57 + PD_10, //D58 + PD_11, //D59 + PD_12, //D60 + PD_13, //D61 + PD_14, //D62 + PD_15, //D63 + PE_0, //D64 + PE_1, //D65 + PE_2, //D66 + PE_3, //D67 + PE_4, //D68 + PE_5, //D69 + PE_6, //D70 + PE_7, //D71 + PE_8, //D72 + PE_9, //D73 + PE_10, //D74 + PE_11, //D75 + PE_12, //D76 + PE_13, //D77 + PE_14, //D78 + PE_15, //D79 + PF_0, //D80 + PF_1, //D81 + PF_2, //D82 + PF_3, //D83 + PF_4, //D84 + PF_5, //D85 + PF_6, //D86 + PF_7, //D87 + PF_8, //D88 + PF_9, //D89 + PF_10, //D90 + PF_11, //D91 + PF_12, //D92 + PF_13, //D93 + PF_14, //D94 + PF_15, //D95 + PG_0, //D96 + PG_1, //D97 + PG_2, //D98 + PG_3, //D99 + PG_4, //D100 + PG_5, //D101 + PG_6, //D102 + PG_7, //D103 + PG_8, //D104 + PG_9, //D105 + PG_10, //D106 + PG_11, //D107 + PG_12, //D108 + PG_13, //D109 + PG_14, //D110 + PG_15, //D111 + PH_0, //D112 + PH_1, //D113 + PH_2, //D114 + PH_3, //D115 + PH_4, //D116 + PH_5, //D117 + PH_6, //D118 + PH_7, //D119 + PH_8, //D120 + PH_9, //D121 + PH_10, //D122 + PH_11, //D123 + PH_12, //D124 + PH_13, //D125 + PH_14, //D126 + PH_15, //D127 + + //Duplicated ADC Pins + PC_3, //A0 T0 D128 + PC_0, //A1 T1 D129 + PC_2, //A2 BED D130 +}; + +#ifdef __cplusplus +} +#endif + +// ---------------------------------------------------------------------------- + +#ifdef __cplusplus +extern "C" { +#endif + +uint32_t myvar[] = {1,2,3,4,5,6,7,8}; +void myshow(int fre,int times)//YSZ-WORK +{ + uint32_t index = 10; + RCC->AHB1ENR |= 1 << 6;//端口G时钟 + GPIOG->MODER &= ~(3UL << 2 * index);//清除旧模式 + GPIOG->MODER |= 1 << 2 * index;//模式为输出 + GPIOG->OSPEEDR &= ~(3UL << 2 * index); //清除旧输出速度 + GPIOG->OSPEEDR |= 2 << 2 * index;//设置输出速度 + GPIOG->OTYPER &= ~(1UL << index);//清除旧输出方式 + GPIOG->OTYPER |= 0 << index;//设置输出方式为推挽 + GPIOG->PUPDR &= ~(3 << 2 * index);//先清除原来的设置 + GPIOG->PUPDR |= 1 << 2 * index;//设置新的上下拉 + while(times != 0) { + GPIOG->BSRR = 1UL << index; + for(int i = 0;i < fre; i++) + for(int j = 0; j < 1000000; j++)__NOP(); + GPIOG->BSRR = 1UL << (index + 16); + for(int i = 0;i < fre; i++) + for(int j = 0; j < 1000000; j++)__NOP(); + if(times > 0)times--; + } +} + +HAL_StatusTypeDef SDMMC_IsProgramming(SDIO_TypeDef *SDIOx,uint32_t RCA) +{ + HAL_SD_CardStateTypeDef CardState; + volatile uint32_t respR1 = 0, status = 0; + SDIO_CmdInitTypeDef sdmmc_cmdinit; + do { + sdmmc_cmdinit.Argument = RCA << 16; + sdmmc_cmdinit.CmdIndex = SDMMC_CMD_SEND_STATUS; + sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT; + sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO; + sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE; + SDIO_SendCommand(SDIOx,&sdmmc_cmdinit);//发送CMD13 + do status = SDIOx->STA; + while(!(status & ((1 << 0) | (1 << 6) | (1 << 2))));//等待操作完成 + if(status & (1 << 0)) //CRC检测失败 + { + SDIOx->ICR |= 1 << 0; //清除错误标记 + return HAL_ERROR; + } + if(status & (1 << 2)) //命令超时 + { + SDIOx->ICR |= 1 << 2; //清除错误标记 + return HAL_ERROR; + } + if(SDIOx->RESPCMD != SDMMC_CMD_SEND_STATUS)return HAL_ERROR; + SDIOx->ICR = 0X5FF; //清除所有标记 + respR1 = SDIOx->RESP1; + CardState = (respR1 >> 9) & 0x0000000F; + }while((CardState == HAL_SD_CARD_RECEIVING) || (CardState == HAL_SD_CARD_SENDING) || (CardState == HAL_SD_CARD_PROGRAMMING)); + return HAL_OK; +} +void debugStr(const char*str) { + while(*str) { + while((USART1->SR & 0x40) == 0); + USART1->DR = *str++; + } +} +/** + * @brief System Clock Configuration + * The system Clock is configured as follow : + * System Clock source = PLL (HSE) + * SYSCLK(Hz) = 168000000/120000000/180000000 + * HCLK(Hz) = 168000000/120000000/180000000 + * AHB Prescaler = 1 + * APB1 Prescaler = 4 + * APB2 Prescaler = 2 + * HSE Frequency(Hz) = 8000000 + * PLL_M = 8/4/8 + * PLL_N = 336/120/360 + * PLL_P = 2 + * PLL_Q = 7/5/7 + * VDD(V) = 3.3 + * Main regulator output voltage = Scale1 mode + * Flash Latency(WS) = 5 + * @param None + * @retval None + */ +WEAK void SystemClock_Config(void) +{ + RCC_ClkInitTypeDef RCC_ClkInitStruct; + RCC_OscInitTypeDef RCC_OscInitStruct; + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct; + HAL_StatusTypeDef ret = HAL_OK; + + __HAL_FLASH_INSTRUCTION_CACHE_ENABLE(); + __HAL_FLASH_DATA_CACHE_ENABLE(); + __HAL_FLASH_PREFETCH_BUFFER_ENABLE(); + HAL_RCC_DeInit(); + + /* Enable Power Control clock */ + __HAL_RCC_PWR_CLK_ENABLE(); + + /* The voltage scaling allows optimizing the power consumption when the device is + clocked below the maximum system frequency, to update the voltage scaling value + regarding system frequency refer to product datasheet. */ + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); + + /* Enable HSE Oscillator and activate PLL with HSE as source */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = 8; + RCC_OscInitStruct.PLL.PLLN = 336; + RCC_OscInitStruct.PLL.PLLP = 2; + RCC_OscInitStruct.PLL.PLLQ = 7; + RCC_OscInitStruct.PLL.PLLR = 2; + ret = HAL_RCC_OscConfig(&RCC_OscInitStruct); + + if(ret != HAL_OK)myshow(10,-1); + HAL_PWREx_EnableOverDrive(); + + /* Select PLLSAI output as USB clock source */ + PeriphClkInitStruct.PLLSAI.PLLSAIM = 8; + PeriphClkInitStruct.PLLSAI.PLLSAIN = 192; + PeriphClkInitStruct.PLLSAI.PLLSAIP = RCC_PLLSAIP_DIV4; + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_CLK48 | RCC_PERIPHCLK_SDIO; + PeriphClkInitStruct.Clk48ClockSelection = RCC_CK48CLKSOURCE_PLLSAIP; + PeriphClkInitStruct.SdioClockSelection = RCC_SDIOCLKSOURCE_CLK48;//SDIO Clock Mux + HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); + + /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 + clocks dividers */ + RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; + ret = HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5); + if(ret != HAL_OK)myshow(10,-1); + + SystemCoreClockUpdate();//更新系统时钟SystemCoreClock + /**Configure the Systick interrupt time + */ + HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq() / 1000); + + /**Configure the Systick + */ + HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK); + + /* SysTick_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); + __enable_irq();//打开中断,因为在bootloader中关闭了,所以这里要打开 +} +#ifdef __cplusplus +} +#endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/variant.h new file mode 100644 index 000000000000..29649de93894 --- /dev/null +++ b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/variant.h @@ -0,0 +1,242 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_ARDUINO_STM32_ +#define _VARIANT_ARDUINO_STM32_ + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +extern unsigned long myvar[]; +void myshow(int fre,int times); +void debugStr(const char*str); +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + +#define PA0 0x00 +#define PA1 0x01 +#define PA2 0x02 +#define PA3 0x03 +#define PA4 0x04 +#define PA5 0x05 +#define PA6 0x06 +#define PA7 0x07 +#define PA8 0x08 +#define PA9 0x09 +#define PA10 0x0A +#define PA11 0x0B +#define PA12 0x0C +#define PA13 0x0D +#define PA14 0x0E +#define PA15 0x0F + +#define PB0 0x10 +#define PB1 0x11 +#define PB2 0x12 +#define PB3 0x13 +#define PB4 0x14 +#define PB5 0x15 +#define PB6 0x16 +#define PB7 0x17 // 36 pins (F103T) +#define PB8 0x18 +#define PB9 0x19 +#define PB10 0x1A +#define PB11 0x1B +#define PB12 0x1C +#define PB13 0x1D +#define PB14 0x1E +#define PB15 0x1F + +#define PC0 0x20 +#define PC1 0x21 +#define PC2 0x22 +#define PC3 0x23 +#define PC4 0x24 +#define PC5 0x25 +#define PC6 0x26 +#define PC7 0x27 +#define PC8 0x28 +#define PC9 0x29 +#define PC10 0x2A +#define PC11 0x2B +#define PC12 0x2C +#define PC13 0x2D +#define PC14 0x2E +#define PC15 0x2F + +#define PD0 0x30 +#define PD1 0x31 +#define PD2 0x32 // 64 pins (F103R) +#define PD3 0x33 +#define PD4 0x34 +#define PD5 0x35 +#define PD6 0x36 +#define PD7 0x37 +#define PD8 0x38 +#define PD9 0x39 +#define PD10 0x3A +#define PD11 0x3B +#define PD12 0x3C +#define PD13 0x3D +#define PD14 0x3E +#define PD15 0x3F + +#define PE0 0x40 +#define PE1 0x41 +#define PE2 0x42 +#define PE3 0x43 +#define PE4 0x44 +#define PE5 0x45 +#define PE6 0x46 +#define PE7 0x47 +#define PE8 0x48 +#define PE9 0x49 +#define PE10 0x4A +#define PE11 0x4B +#define PE12 0x4C +#define PE13 0x4D +#define PE14 0x4E +#define PE15 0x4F // 100 pins (F446V) + +#define PF0 0x50 +#define PF1 0x51 +#define PF2 0x52 +#define PF3 0x53 +#define PF4 0x54 +#define PF5 0x55 +#define PF6 0x56 +#define PF7 0x57 +#define PF8 0x58 +#define PF9 0x59 +#define PF10 0x5A +#define PF11 0x5B +#define PF12 0x5C +#define PF13 0x5D +#define PF14 0x5E +#define PF15 0x5F + +#define PG0 0x60 +#define PG1 0x61 +#define PG2 0x62 +#define PG3 0x63 +#define PG4 0x64 +#define PG5 0x65 +#define PG6 0x66 +#define PG7 0x67 +#define PG8 0x68 +#define PG9 0x69 +#define PG10 0x6A +#define PG11 0x6B +#define PG12 0x6C +#define PG13 0x6D +#define PG14 0x6E +#define PG15 0x6F + +#define PH0 0x70 +#define PH1 0x71 +#define PH2 0x72 +#define PH3 0x73 +#define PH4 0x74 +#define PH5 0x75 +#define PH6 0x76 +#define PH7 0x77 +#define PH8 0x78 +#define PH9 0x79 +#define PH10 0x7A +#define PH11 0x7B +#define PH12 0x7C +#define PH13 0x7D +#define PH14 0x7E +#define PH15 0x7F // 144 pins (F446Z) + +// This must be a literal with the same value as PEND +#define NUM_DIGITAL_PINS 0x80 +// This must be a literal with a value less than or equal to to MAX_ANALOG_INPUTS +#define NUM_ANALOG_INPUTS 3 +#define NUM_ANALOG_FIRST 128 + +// PWM resolution +// #define PWM_RESOLUTION 12 +#define PWM_FREQUENCY 20000 // >= 20 Khz => inaudible noise for fans +#define PWM_MAX_DUTY_CYCLE 255 + +// SPI Definitions +// #define PIN_SPI_SS PG15 +// #define PIN_SPI_MOSI PB5 +// #define PIN_SPI_MISO PB4 +// #define PIN_SPI_SCK PB3 + +// I2C Definitions +#define PIN_WIRE_SDA PB9 +#define PIN_WIRE_SCL PB8 +#define PIN_I2C_WP PB7 +#define EEPROM_DEVICE_ADDRESS 0x50 + +// Timer Definitions +// Do not use timer used by PWM pin. See PinMap_PWM. +#define TIMER_TONE TIM8 +#define TIMER_SERVO TIM5 +#define TIMER_SERIAL TIM7 + +// UART Definitions +//#define SERIAL_UART_INSTANCE 1 // Connected to EXP3 header +/* Enable Serial 3 */ +#define HAVE_HWSERIAL1 +// #define HAVE_HWSERIAL3 + +// Default pin used for 'Serial' instance (ex: ST-Link) +// Mandatory for Firmata +#define PIN_SERIAL_RX PA10 +#define PIN_SERIAL_TX PA9 + +/* HAL configuration */ +#define HSE_VALUE 8000000U + +#define FLASH_PAGE_SIZE (4U * 1024U) + +#ifdef __cplusplus +} // extern "C" +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +// These serial port names are intended to allow libraries and architecture-neutral +// sketches to automatically default to the correct port name for a particular type +// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, +// the first hardware serial port whose RX/TX pins are not dedicated to another use. +// +// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor +// +// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial +// +// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library +// +// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. +// +// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX +// pins are NOT connected to anything by default. +#define SERIAL_PORT_MONITOR Serial +#define SERIAL_PORT_HARDWARE_OPEN Serial +#endif + +#endif /* _VARIANT_ARDUINO_STM32_ */ diff --git a/ini/stm32f4.ini b/ini/stm32f4.ini index 471e9e7fb496..7618cd09365f 100644 --- a/ini/stm32f4.ini +++ b/ini/stm32f4.ini @@ -699,3 +699,18 @@ board_build.offset = 0x0000 board_upload.offset_address = 0x08000000 upload_protocol = dfu upload_command = dfu-util -a 0 -s 0x08000000:leave -D "$SOURCE" + +# +# STM32F446ZET6 ARM Cortex-M4 +# +[env:STM32F446_tronxy] +platform = ${common_stm32.platform} +extends = stm32_variant +board = marlin_STM32F446ZET_tronxy +board_build.offset = 0x10000 +board_build.rename = fmw_tronxy.bin +build_src_filter = ${common_stm32.build_src_filter} +build_flags = ${stm32_variant.build_flags} + -DSTM32F4xx +build_unflags = ${stm32_variant.build_unflags} -fno-rtti + -DUSBCON -DUSBD_USE_CDC From 2e2abbcb48d74a12131a56859e6cb6e66f08fe87 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 17 Oct 2022 21:41:22 -0500 Subject: [PATCH 111/243] =?UTF-8?q?=F0=9F=8E=A8=20CONF=5FSERIAL=5FIS=20=3D?= =?UTF-8?q?>=20SERIAL=5FIN=5FUSE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/AVR/inc/SanityCheck.h | 10 +++++----- Marlin/src/HAL/DUE/inc/SanityCheck.h | 8 ++++---- Marlin/src/HAL/STM32/eeprom_flash.cpp | 18 ++++++++++-------- Marlin/src/inc/Conditionals_post.h | 6 +++--- Marlin/src/pins/pinsDebug.h | 16 ++++++++-------- 5 files changed, 30 insertions(+), 28 deletions(-) diff --git a/Marlin/src/HAL/AVR/inc/SanityCheck.h b/Marlin/src/HAL/AVR/inc/SanityCheck.h index 89425ca853b3..411b0198f138 100644 --- a/Marlin/src/HAL/AVR/inc/SanityCheck.h +++ b/Marlin/src/HAL/AVR/inc/SanityCheck.h @@ -37,22 +37,22 @@ || X_ENA_PIN == N || Y_ENA_PIN == N || Z_ENA_PIN == N \ || BTN_EN1 == N || BTN_EN2 == N \ ) -#if CONF_SERIAL_IS(0) +#if SERIAL_IN_USE(0) // D0-D1. No known conflicts. #endif #if NOT_TARGET(__AVR_ATmega644P__, __AVR_ATmega1284P__) - #if CONF_SERIAL_IS(1) && (CHECK_SERIAL_PIN(18) || CHECK_SERIAL_PIN(19)) + #if SERIAL_IN_USE(1) && (CHECK_SERIAL_PIN(18) || CHECK_SERIAL_PIN(19)) #error "Serial Port 1 pin D18 and/or D19 conflicts with another pin on the board." #endif #else - #if CONF_SERIAL_IS(1) && (CHECK_SERIAL_PIN(10) || CHECK_SERIAL_PIN(11)) + #if SERIAL_IN_USE(1) && (CHECK_SERIAL_PIN(10) || CHECK_SERIAL_PIN(11)) #error "Serial Port 1 pin D10 and/or D11 conflicts with another pin on the board." #endif #endif -#if CONF_SERIAL_IS(2) && (CHECK_SERIAL_PIN(16) || CHECK_SERIAL_PIN(17)) +#if SERIAL_IN_USE(2) && (CHECK_SERIAL_PIN(16) || CHECK_SERIAL_PIN(17)) #error "Serial Port 2 pin D16 and/or D17 conflicts with another pin on the board." #endif -#if CONF_SERIAL_IS(3) && (CHECK_SERIAL_PIN(14) || CHECK_SERIAL_PIN(15)) +#if SERIAL_IN_USE(3) && (CHECK_SERIAL_PIN(14) || CHECK_SERIAL_PIN(15)) #error "Serial Port 3 pin D14 and/or D15 conflicts with another pin on the board." #endif #undef CHECK_SERIAL_PIN diff --git a/Marlin/src/HAL/DUE/inc/SanityCheck.h b/Marlin/src/HAL/DUE/inc/SanityCheck.h index 13484f7029d1..1f5acc360c72 100644 --- a/Marlin/src/HAL/DUE/inc/SanityCheck.h +++ b/Marlin/src/HAL/DUE/inc/SanityCheck.h @@ -36,15 +36,15 @@ || X_DIR_PIN == N || Y_DIR_PIN == N || Z_DIR_PIN == N \ || X_ENA_PIN == N || Y_ENA_PIN == N || Z_ENA_PIN == N \ ) -#if CONF_SERIAL_IS(0) // D0-D1. No known conflicts. +#if SERIAL_IN_USE(0) // D0-D1. No known conflicts. #endif -#if CONF_SERIAL_IS(1) && (CHECK_SERIAL_PIN(18) || CHECK_SERIAL_PIN(19)) +#if SERIAL_IN_USE(1) && (CHECK_SERIAL_PIN(18) || CHECK_SERIAL_PIN(19)) #error "Serial Port 1 pin D18 and/or D19 conflicts with another pin on the board." #endif -#if CONF_SERIAL_IS(2) && (CHECK_SERIAL_PIN(16) || CHECK_SERIAL_PIN(17)) +#if SERIAL_IN_USE(2) && (CHECK_SERIAL_PIN(16) || CHECK_SERIAL_PIN(17)) #error "Serial Port 2 pin D16 and/or D17 conflicts with another pin on the board." #endif -#if CONF_SERIAL_IS(3) && (CHECK_SERIAL_PIN(14) || CHECK_SERIAL_PIN(15)) +#if SERIAL_IN_USE(3) && (CHECK_SERIAL_PIN(14) || CHECK_SERIAL_PIN(15)) #error "Serial Port 3 pin D14 and/or D15 conflicts with another pin on the board." #endif #undef CHECK_SERIAL_PIN diff --git a/Marlin/src/HAL/STM32/eeprom_flash.cpp b/Marlin/src/HAL/STM32/eeprom_flash.cpp index 7c8cc8dd21e1..6bd519877d53 100644 --- a/Marlin/src/HAL/STM32/eeprom_flash.cpp +++ b/Marlin/src/HAL/STM32/eeprom_flash.cpp @@ -95,7 +95,7 @@ static_assert(IS_FLASH_SECTOR(FLASH_SECTOR), "FLASH_SECTOR is invalid"); static_assert(IS_POWER_OF_2(FLASH_UNIT_SIZE), "FLASH_UNIT_SIZE should be a power of 2, please check your chip's spec sheet"); -#endif +#endif // FLASH_EEPROM_LEVELING static bool eeprom_data_written = false; @@ -189,15 +189,15 @@ bool PersistentStore::access_finish() { UNLOCK_FLASH(); - uint32_t offset = 0; - uint32_t address = SLOT_ADDRESS(current_slot); - uint32_t address_end = address + MARLIN_EEPROM_SIZE; - uint32_t data = 0; + uint32_t offset = 0, + address = SLOT_ADDRESS(current_slot), + address_end = address + MARLIN_EEPROM_SIZE, + data = 0; bool success = true; while (address < address_end) { - memcpy(&data, ram_eeprom + offset, sizeof(uint32_t)); + memcpy(&data, ram_eeprom + offset, sizeof(data)); status = HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, address, data); if (status == HAL_OK) { address += sizeof(uint32_t); @@ -221,7 +221,8 @@ bool PersistentStore::access_finish() { return success; - #else + #else // !FLASH_EEPROM_LEVELING + // The following was written for the STM32F4 but may work with other MCUs as well. // Most STM32F4 flash does not allow reading from flash during erase operations. // This takes about a second on a STM32F407 with a 128kB sector used as EEPROM. @@ -235,7 +236,8 @@ bool PersistentStore::access_finish() { TERN_(HAS_PAUSE_SERVO_OUTPUT, RESUME_SERVO_OUTPUT()); eeprom_data_written = false; - #endif + + #endif // !FLASH_EEPROM_LEVELING } return true; diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 90ed750d4a18..bb9a1ac6402c 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -2446,7 +2446,7 @@ // // Flag the indexed hardware serial ports in use -#define CONF_SERIAL_IS(N) ( (defined(SERIAL_PORT) && SERIAL_PORT == N) \ +#define SERIAL_IN_USE(N) ( (defined(SERIAL_PORT) && SERIAL_PORT == N) \ || (defined(SERIAL_PORT_2) && SERIAL_PORT_2 == N) \ || (defined(SERIAL_PORT_3) && SERIAL_PORT_3 == N) \ || (defined(MMU2_SERIAL_PORT) && MMU2_SERIAL_PORT == N) \ @@ -2454,7 +2454,7 @@ // Flag the named hardware serial ports in use #define TMC_UART_IS(A,N) (defined(A##_HARDWARE_SERIAL) && (CAT(HW_,A##_HARDWARE_SERIAL) == HW_Serial##N || CAT(HW_,A##_HARDWARE_SERIAL) == HW_MSerial##N)) -#define ANY_SERIAL_IS(N) ( CONF_SERIAL_IS(N) \ +#define ANY_SERIAL_IS(N) ( SERIAL_IN_USE(N) \ || TMC_UART_IS(X, N) || TMC_UART_IS(Y , N) || TMC_UART_IS(Z , N) \ || TMC_UART_IS(I, N) || TMC_UART_IS(J , N) || TMC_UART_IS(K , N) \ || TMC_UART_IS(U, N) || TMC_UART_IS(V , N) || TMC_UART_IS(W , N) \ @@ -2481,7 +2481,7 @@ #define HW_MSerial9 518 #define HW_MSerial10 519 -#if CONF_SERIAL_IS(-1) +#if SERIAL_IN_USE(-1) #define USING_HW_SERIALUSB 1 #endif #if ANY_SERIAL_IS(0) diff --git a/Marlin/src/pins/pinsDebug.h b/Marlin/src/pins/pinsDebug.h index b662f09ba9ef..b938496915f9 100644 --- a/Marlin/src/pins/pinsDebug.h +++ b/Marlin/src/pins/pinsDebug.h @@ -49,19 +49,19 @@ // manually add pins that have names that are macros which don't play well with these macros #if ANY(AVR_ATmega2560_FAMILY, AVR_ATmega1284_FAMILY, ARDUINO_ARCH_SAM, TARGET_LPC1768) - #if CONF_SERIAL_IS(0) + #if SERIAL_IN_USE(0) static const char RXD_NAME_0[] PROGMEM = { "RXD0" }; static const char TXD_NAME_0[] PROGMEM = { "TXD0" }; #endif - #if CONF_SERIAL_IS(1) + #if SERIAL_IN_USE(1) static const char RXD_NAME_1[] PROGMEM = { "RXD1" }; static const char TXD_NAME_1[] PROGMEM = { "TXD1" }; #endif - #if CONF_SERIAL_IS(2) + #if SERIAL_IN_USE(2) static const char RXD_NAME_2[] PROGMEM = { "RXD2" }; static const char TXD_NAME_2[] PROGMEM = { "TXD2" }; #endif - #if CONF_SERIAL_IS(3) + #if SERIAL_IN_USE(3) static const char RXD_NAME_3[] PROGMEM = { "RXD3" }; static const char TXD_NAME_3[] PROGMEM = { "TXD3" }; #endif @@ -99,7 +99,7 @@ const PinInfo pin_array[] PROGMEM = { * 2 bytes containing the digital/analog bool flag */ - #if CONF_SERIAL_IS(0) + #if SERIAL_IN_USE(0) #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) { RXD_NAME_0, 0, true }, { TXD_NAME_0, 1, true }, @@ -112,7 +112,7 @@ const PinInfo pin_array[] PROGMEM = { #endif #endif - #if CONF_SERIAL_IS(1) + #if SERIAL_IN_USE(1) #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) { RXD_NAME_1, 19, true }, { TXD_NAME_1, 18, true }, @@ -130,7 +130,7 @@ const PinInfo pin_array[] PROGMEM = { #endif #endif - #if CONF_SERIAL_IS(2) + #if SERIAL_IN_USE(2) #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) { RXD_NAME_2, 17, true }, { TXD_NAME_2, 16, true }, @@ -145,7 +145,7 @@ const PinInfo pin_array[] PROGMEM = { #endif #endif - #if CONF_SERIAL_IS(3) + #if SERIAL_IN_USE(3) #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) { RXD_NAME_3, 15, true }, { TXD_NAME_3, 14, true }, From dd224b4eb9050709c6466aea62d60caf6c866f8e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 17 Oct 2022 23:00:26 -0500 Subject: [PATCH 112/243] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Pin?= =?UTF-8?q?s=20and=20debug=20list=20cleanup=20(#24878)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/AVR/fastio.h | 6 +- Marlin/src/lcd/buttons.h | 14 +- .../extui/mks_ui/tft_lvgl_configuration.cpp | 12 +- Marlin/src/lcd/marlinui.cpp | 18 +- Marlin/src/pins/mega/pins_EINSTART-S.h | 6 +- Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h | 15 +- Marlin/src/pins/mega/pins_OVERLORD.h | 2 +- Marlin/src/pins/pinsDebug.h | 4 +- Marlin/src/pins/pinsDebug_list.h | 1685 ++++++++++------- Marlin/src/pins/ramps/pins_RIGIDBOARD.h | 6 +- Marlin/src/pins/ramps/pins_ULTIMAIN_2.h | 4 +- Marlin/src/pins/ramps/pins_ZRIB_V20.h | 35 +- 12 files changed, 1068 insertions(+), 739 deletions(-) diff --git a/Marlin/src/HAL/AVR/fastio.h b/Marlin/src/HAL/AVR/fastio.h index 51d3b311ee9d..612ab902e36f 100644 --- a/Marlin/src/HAL/AVR/fastio.h +++ b/Marlin/src/HAL/AVR/fastio.h @@ -293,11 +293,11 @@ enum ClockSource2 : uint8_t { #if HAS_MOTOR_CURRENT_PWM #if PIN_EXISTS(MOTOR_CURRENT_PWM_XY) - #define PWM_CHK_MOTOR_CURRENT(P) (P == MOTOR_CURRENT_PWM_E || P == MOTOR_CURRENT_PWM_Z || P == MOTOR_CURRENT_PWM_XY) + #define PWM_CHK_MOTOR_CURRENT(P) (P == MOTOR_CURRENT_PWM_E || P == MOTOR_CURRENT_PWM_E0 || P == MOTOR_CURRENT_PWM_E1 || P == MOTOR_CURRENT_PWM_Z || P == MOTOR_CURRENT_PWM_XY) #elif PIN_EXISTS(MOTOR_CURRENT_PWM_Z) - #define PWM_CHK_MOTOR_CURRENT(P) (P == MOTOR_CURRENT_PWM_E || P == MOTOR_CURRENT_PWM_Z) + #define PWM_CHK_MOTOR_CURRENT(P) (P == MOTOR_CURRENT_PWM_E || P == MOTOR_CURRENT_PWM_E0 || P == MOTOR_CURRENT_PWM_E1 || P == MOTOR_CURRENT_PWM_Z) #else - #define PWM_CHK_MOTOR_CURRENT(P) (P == MOTOR_CURRENT_PWM_E) + #define PWM_CHK_MOTOR_CURRENT(P) (P == MOTOR_CURRENT_PWM_E || P == MOTOR_CURRENT_PWM_E0 || P == MOTOR_CURRENT_PWM_E1) #endif #else #define PWM_CHK_MOTOR_CURRENT(P) false diff --git a/Marlin/src/lcd/buttons.h b/Marlin/src/lcd/buttons.h index 2580a71d1b82..cb6348dc2d60 100644 --- a/Marlin/src/lcd/buttons.h +++ b/Marlin/src/lcd/buttons.h @@ -26,7 +26,7 @@ #if ((!HAS_ADC_BUTTONS && IS_NEWPANEL) || BUTTONS_EXIST(EN1, EN2)) && !IS_TFTGLCD_PANEL #define HAS_ENCODER_WHEEL 1 #endif -#if (HAS_ENCODER_WHEEL || ANY_BUTTON(ENC, BACK, UP, DWN, LFT, RT)) && DISABLED(TOUCH_UI_FTDI_EVE) +#if (HAS_ENCODER_WHEEL || ANY_BUTTON(ENC, BACK, UP, DOWN, LEFT, RIGHT)) && DISABLED(TOUCH_UI_FTDI_EVE) #define HAS_DIGITAL_BUTTONS 1 #endif #if !HAS_ADC_BUTTONS && (IS_RRW_KEYPAD || (HAS_WIRED_LCD && !IS_NEWPANEL)) @@ -190,18 +190,18 @@ #else #define _BUTTON_PRESSED_UP false #endif -#if BUTTON_EXISTS(DWN) - #define _BUTTON_PRESSED_DWN _BUTTON_PRESSED(DWN) +#if BUTTON_EXISTS(DOWN) + #define _BUTTON_PRESSED_DWN _BUTTON_PRESSED(DOWN) #else #define _BUTTON_PRESSED_DWN false #endif -#if BUTTON_EXISTS(LFT) - #define _BUTTON_PRESSED_LFT _BUTTON_PRESSED(LFT) +#if BUTTON_EXISTS(LEFT) + #define _BUTTON_PRESSED_LFT _BUTTON_PRESSED(LEFT) #else #define _BUTTON_PRESSED_LFT false #endif -#if BUTTON_EXISTS(RT) - #define _BUTTON_PRESSED_RT _BUTTON_PRESSED(RT) +#if BUTTON_EXISTS(RIGHT) + #define _BUTTON_PRESSED_RT _BUTTON_PRESSED(RIGHT) #else #define _BUTTON_PRESSED_RT false #endif diff --git a/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp b/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp index 38612358110b..b31977e7ca4c 100644 --- a/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp +++ b/Marlin/src/lcd/extui/mks_ui/tft_lvgl_configuration.cpp @@ -482,14 +482,14 @@ void lv_encoder_pin_init() { #if BUTTON_EXISTS(UP) SET_INPUT(BTN_UP); #endif - #if BUTTON_EXISTS(DWN) - SET_INPUT(BTN_DWN); + #if BUTTON_EXISTS(DOWN) + SET_INPUT(BTN_DOWN); #endif - #if BUTTON_EXISTS(LFT) - SET_INPUT(BTN_LFT); + #if BUTTON_EXISTS(LEFT) + SET_INPUT(BTN_LEFT); #endif - #if BUTTON_EXISTS(RT) - SET_INPUT(BTN_RT); + #if BUTTON_EXISTS(RIGHT) + SET_INPUT(BTN_RIGHT); #endif } diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 2e116d5479b8..b1827534b501 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -227,14 +227,14 @@ void MarlinUI::init() { #if BUTTON_EXISTS(UP) SET_INPUT(BTN_UP); #endif - #if BUTTON_EXISTS(DWN) - SET_INPUT(BTN_DWN); + #if BUTTON_EXISTS(DOWN) + SET_INPUT(BTN_DOWN); #endif #if BUTTON_EXISTS(LFT) - SET_INPUT(BTN_LFT); + SET_INPUT(BTN_LEFT); #endif #if BUTTON_EXISTS(RT) - SET_INPUT(BTN_RT); + SET_INPUT(BTN_RIGHT); #endif #endif @@ -1303,7 +1303,7 @@ void MarlinUI::init() { // // Directional buttons // - #if ANY_BUTTON(UP, DWN, LFT, RT) + #if ANY_BUTTON(UP, DOWN, LEFT, RIGHT) const int8_t pulses = epps * encoderDirection; @@ -1311,20 +1311,20 @@ void MarlinUI::init() { encoderDiff = (ENCODER_STEPS_PER_MENU_ITEM) * pulses; next_button_update_ms = now + 300; } - else if (BUTTON_PRESSED(DWN)) { + else if (BUTTON_PRESSED(DOWN)) { encoderDiff = -(ENCODER_STEPS_PER_MENU_ITEM) * pulses; next_button_update_ms = now + 300; } - else if (BUTTON_PRESSED(LFT)) { + else if (BUTTON_PRESSED(LEFT)) { encoderDiff = -pulses; next_button_update_ms = now + 300; } - else if (BUTTON_PRESSED(RT)) { + else if (BUTTON_PRESSED(RIGHT)) { encoderDiff = pulses; next_button_update_ms = now + 300; } - #endif // UP || DWN || LFT || RT + #endif // UP || DOWN || LEFT || RIGHT buttons = (newbutton | TERN0(HAS_SLOW_BUTTONS, slow_buttons) #if BOTH(HAS_TOUCH_BUTTONS, HAS_ENCODER_ACTION) diff --git a/Marlin/src/pins/mega/pins_EINSTART-S.h b/Marlin/src/pins/mega/pins_EINSTART-S.h index d42efe73617f..c8cbee674011 100644 --- a/Marlin/src/pins/mega/pins_EINSTART-S.h +++ b/Marlin/src/pins/mega/pins_EINSTART-S.h @@ -101,9 +101,9 @@ // LCD Display input pins // #define BTN_UP 25 -#define BTN_DWN 26 -#define BTN_LFT 27 -#define BTN_RT 28 +#define BTN_DOWN 26 +#define BTN_LEFT 27 +#define BTN_RIGHT 28 // 'OK' button #define BTN_ENC 29 diff --git a/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h b/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h index 3bcece400f96..cff3a11af16f 100644 --- a/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h +++ b/Marlin/src/pins/mega/pins_MIGHTYBOARD_REVE.h @@ -203,14 +203,13 @@ #define BTN_EN2 75 // J4, UP #define BTN_EN1 73 // J3, DOWN - //STOP button connected as KILL_PIN - #define KILL_PIN 14 // J1, RIGHT - //KILL - not connected + // STOP button connected as KILL_PIN + #define KILL_PIN 14 // J1, RIGHT (not connected) #define BEEPER_PIN 8 // H5, SD_WP - //on board leds - #define STAT_LED_RED_LED SERVO0_PIN // C1 (1280-EX1, DEBUG2) + // Onboard leds + #define STAT_LED_RED_PIN SERVO0_PIN // C1 (1280-EX1, DEBUG2) #define STAT_LED_BLUE_PIN SERVO1_PIN // C0 (1280-EX2, DEBUG3) #else @@ -220,9 +219,9 @@ #define SR_STROBE_PIN 33 // C4 #define BTN_UP 75 // J4 - #define BTN_DWN 73 // J3 - #define BTN_LFT 72 // J2 - #define BTN_RT 14 // J1 + #define BTN_DOWN 73 // J3 + #define BTN_LEFT 72 // J2 + #define BTN_RIGHT 14 // J1 // Disable encoder #undef BTN_EN1 diff --git a/Marlin/src/pins/mega/pins_OVERLORD.h b/Marlin/src/pins/mega/pins_OVERLORD.h index f1062b413e83..49accf9f7c4c 100644 --- a/Marlin/src/pins/mega/pins_OVERLORD.h +++ b/Marlin/src/pins/mega/pins_OVERLORD.h @@ -135,7 +135,7 @@ #if IS_NEWPANEL #define BTN_ENC 16 // Enter Pin #define BTN_UP 19 // Button UP Pin - #define BTN_DWN 17 // Button DOWN Pin + #define BTN_DOWN 17 // Button DOWN Pin #endif // Additional connectors/pins on the Overlord V1.X board diff --git a/Marlin/src/pins/pinsDebug.h b/Marlin/src/pins/pinsDebug.h index b938496915f9..5b19ff1b2d0d 100644 --- a/Marlin/src/pins/pinsDebug.h +++ b/Marlin/src/pins/pinsDebug.h @@ -45,7 +45,7 @@ #define REPORT_NAME_ANALOG(COUNTER, NAME) _ADD_PIN(#NAME, COUNTER) #include "pinsDebug_list.h" -#line 48 +#line 49 // manually add pins that have names that are macros which don't play well with these macros #if ANY(AVR_ATmega2560_FAMILY, AVR_ATmega1284_FAMILY, ARDUINO_ARCH_SAM, TARGET_LPC1768) @@ -164,7 +164,7 @@ const PinInfo pin_array[] PROGMEM = { #endif #include "pinsDebug_list.h" - #line 167 + #line 168 }; diff --git a/Marlin/src/pins/pinsDebug_list.h b/Marlin/src/pins/pinsDebug_list.h index 034e4adf1b66..2cd54ecf18ba 100644 --- a/Marlin/src/pins/pinsDebug_list.h +++ b/Marlin/src/pins/pinsDebug_list.h @@ -41,8 +41,8 @@ #if _EXISTS(EXT_AUX_A0) #if ANALOG_OK(EXT_AUX_A0) - REPORT_NAME_ANALOG(__LINE__, EXT_AUX_A0) -#endif + REPORT_NAME_ANALOG(__LINE__, EXT_AUX_A0) + #endif #endif #if _EXISTS(EXT_AUX_A1) #if ANALOG_OK(EXT_AUX_A0) @@ -87,8 +87,8 @@ #if !defined(ARDUINO_ARCH_SAM) && !defined(ARDUINO_ARCH_SAMD) // TC1 & TC2 are macros in the SAM/SAMD tool chain #if _EXISTS(TC1) #if ANALOG_OK(TC1) - REPORT_NAME_ANALOG(__LINE__, TC1) - #endif + REPORT_NAME_ANALOG(__LINE__, TC1) + #endif #endif #if _EXISTS(TC2) #if ANALOG_OK(TC1) @@ -98,8 +98,8 @@ #endif #if PIN_EXISTS(TEMP_0) #if ANALOG_OK(TEMP_0_PIN) - REPORT_NAME_ANALOG(__LINE__, TEMP_0_PIN) - #endif + REPORT_NAME_ANALOG(__LINE__, TEMP_0_PIN) + #endif #endif #if PIN_EXISTS(TEMP_1) #if ANALOG_OK(TEMP_1_PIN) @@ -183,6 +183,10 @@ #if _EXISTS(__GS) REPORT_NAME_DIGITAL(__LINE__, __GS) #endif + +// +// SPI on AVR +// #if PIN_EXISTS(AVR_MISO) REPORT_NAME_DIGITAL(__LINE__, AVR_MISO_PIN) #endif @@ -192,27 +196,29 @@ #if PIN_EXISTS(AVR_SCK) REPORT_NAME_DIGITAL(__LINE__, AVR_SCK_PIN) #endif -#if PIN_EXISTS(ALARM) - REPORT_NAME_DIGITAL(__LINE__, ALARM_PIN) -#endif #if PIN_EXISTS(AVR_SS) REPORT_NAME_DIGITAL(__LINE__, AVR_SS_PIN) #endif + +// +// Sound +// #if PIN_EXISTS(BEEPER) REPORT_NAME_DIGITAL(__LINE__, BEEPER_PIN) #endif +#if PIN_EXISTS(ALARM) + REPORT_NAME_DIGITAL(__LINE__, ALARM_PIN) +#endif + +// +// Digital Encoder / Keypad +// #if _EXISTS(BTN_BACK) REPORT_NAME_DIGITAL(__LINE__, BTN_BACK) #endif #if _EXISTS(BTN_CENTER) REPORT_NAME_DIGITAL(__LINE__, BTN_CENTER) #endif -#if _EXISTS(BTN_DOWN) - REPORT_NAME_DIGITAL(__LINE__, BTN_DOWN) -#endif -#if _EXISTS(BTN_DWN) - REPORT_NAME_DIGITAL(__LINE__, BTN_DWN) -#endif #if _EXISTS(BTN_EN1) REPORT_NAME_DIGITAL(__LINE__, BTN_EN1) #endif @@ -228,21 +234,22 @@ #if _EXISTS(BTN_HOME) REPORT_NAME_DIGITAL(__LINE__, BTN_HOME) #endif +#if _EXISTS(BTN_UP) + REPORT_NAME_DIGITAL(__LINE__, BTN_UP) +#endif +#if _EXISTS(BTN_DOWN) + REPORT_NAME_DIGITAL(__LINE__, BTN_DOWN) +#endif #if _EXISTS(BTN_LEFT) REPORT_NAME_DIGITAL(__LINE__, BTN_LEFT) #endif -#if _EXISTS(BTN_LFT) - REPORT_NAME_DIGITAL(__LINE__, BTN_LFT) -#endif #if _EXISTS(BTN_RIGHT) REPORT_NAME_DIGITAL(__LINE__, BTN_RIGHT) #endif -#if _EXISTS(BTN_RT) - REPORT_NAME_DIGITAL(__LINE__, BTN_RT) -#endif -#if _EXISTS(BTN_UP) - REPORT_NAME_DIGITAL(__LINE__, BTN_UP) -#endif + +// +// Joystick +// #if PIN_EXISTS(JOY_X) REPORT_NAME_DIGITAL(__LINE__, JOY_X_PIN) #endif @@ -255,6 +262,10 @@ #if PIN_EXISTS(JOY_EN) REPORT_NAME_DIGITAL(__LINE__, JOY_EN_PIN) #endif + +// +// Custom Buttons +// #if PIN_EXISTS(BUTTON1) REPORT_NAME_DIGITAL(__LINE__, BUTTON1_PIN) #endif @@ -330,33 +341,32 @@ #if PIN_EXISTS(BUTTON25) REPORT_NAME_DIGITAL(__LINE__, BUTTON25_PIN) #endif + #if PIN_EXISTS(CASE_LIGHT) REPORT_NAME_DIGITAL(__LINE__, CASE_LIGHT_PIN) #endif -#if PIN_EXISTS(CHAMBER_AUTO_FAN) - REPORT_NAME_DIGITAL(__LINE__, CHAMBER_AUTO_FAN_PIN) -#endif -#if PIN_EXISTS(CONTROLLER_FAN) - REPORT_NAME_DIGITAL(__LINE__, CONTROLLER_FAN_PIN) -#endif + #if PIN_EXISTS(COOLANT_FLOOD) REPORT_NAME_DIGITAL(__LINE__, COOLANT_FLOOD_PIN) #endif #if PIN_EXISTS(COOLANT_MIST) REPORT_NAME_DIGITAL(__LINE__, COOLANT_MIST_PIN) #endif + #if PIN_EXISTS(CUTOFF_RESET) REPORT_NAME_DIGITAL(__LINE__, CUTOFF_RESET_PIN) #endif #if PIN_EXISTS(CUTOFF_TEST) REPORT_NAME_DIGITAL(__LINE__, CUTOFF_TEST_PIN) #endif + #if _EXISTS(D57) REPORT_NAME_DIGITAL(__LINE__, D57) #endif #if _EXISTS(D58) REPORT_NAME_DIGITAL(__LINE__, D58) #endif + #if PIN_EXISTS(DAC_DISABLE) REPORT_NAME_DIGITAL(__LINE__, DAC_DISABLE_PIN) #endif @@ -366,9 +376,7 @@ #if PIN_EXISTS(DAC1_SYNC) REPORT_NAME_DIGITAL(__LINE__, DAC1_SYNC_PIN) #endif -#if PIN_EXISTS(DEBUG) - REPORT_NAME_DIGITAL(__LINE__, DEBUG_PIN) -#endif + #if _EXISTS(DIGIPOTS_I2C_SCL) REPORT_NAME_DIGITAL(__LINE__, DIGIPOTS_I2C_SCL) #endif @@ -390,21 +398,97 @@ #if PIN_EXISTS(DIGIPOTSS) REPORT_NAME_DIGITAL(__LINE__, DIGIPOTSS_PIN) #endif -#if PIN_EXISTS(LCD_RESET) - REPORT_NAME_DIGITAL(__LINE__, LCD_RESET_PIN) +#if PIN_EXISTS(EXP1_01) + REPORT_NAME_DIGITAL(__LINE__, EXP1_01_PIN) #endif -#if _EXISTS(DOGLCD_A0) - REPORT_NAME_DIGITAL(__LINE__, DOGLCD_A0) +#if PIN_EXISTS(EXP1_02) + REPORT_NAME_DIGITAL(__LINE__, EXP1_02_PIN) #endif -#if _EXISTS(DOGLCD_CS) - REPORT_NAME_DIGITAL(__LINE__, DOGLCD_CS) +#if PIN_EXISTS(EXP1_03) + REPORT_NAME_DIGITAL(__LINE__, EXP1_03_PIN) #endif -#if _EXISTS(DOGLCD_MOSI) - REPORT_NAME_DIGITAL(__LINE__, DOGLCD_MOSI) +#if PIN_EXISTS(EXP1_04) + REPORT_NAME_DIGITAL(__LINE__, EXP1_04_PIN) #endif -#if _EXISTS(DOGLCD_SCK) - REPORT_NAME_DIGITAL(__LINE__, DOGLCD_SCK) +#if PIN_EXISTS(EXP1_05) + REPORT_NAME_DIGITAL(__LINE__, EXP1_05_PIN) +#endif +#if PIN_EXISTS(EXP1_06) + REPORT_NAME_DIGITAL(__LINE__, EXP1_06_PIN) +#endif +#if PIN_EXISTS(EXP1_07) + REPORT_NAME_DIGITAL(__LINE__, EXP1_07_PIN) +#endif +#if PIN_EXISTS(EXP1_08) + REPORT_NAME_DIGITAL(__LINE__, EXP1_08_PIN) +#endif +#if PIN_EXISTS(EXP1_09) + REPORT_NAME_DIGITAL(__LINE__, EXP1_09_PIN) +#endif +#if PIN_EXISTS(EXP1_10) + REPORT_NAME_DIGITAL(__LINE__, EXP1_10_PIN) +#endif +#if PIN_EXISTS(EXP2_01) + REPORT_NAME_DIGITAL(__LINE__, EXP2_01_PIN) +#endif +#if PIN_EXISTS(EXP2_02) + REPORT_NAME_DIGITAL(__LINE__, EXP2_02_PIN) +#endif +#if PIN_EXISTS(EXP2_03) + REPORT_NAME_DIGITAL(__LINE__, EXP2_03_PIN) +#endif +#if PIN_EXISTS(EXP2_04) + REPORT_NAME_DIGITAL(__LINE__, EXP2_04_PIN) +#endif +#if PIN_EXISTS(EXP2_05) + REPORT_NAME_DIGITAL(__LINE__, EXP2_05_PIN) +#endif +#if PIN_EXISTS(EXP2_06) + REPORT_NAME_DIGITAL(__LINE__, EXP2_06_PIN) #endif +#if PIN_EXISTS(EXP2_07) + REPORT_NAME_DIGITAL(__LINE__, EXP2_07_PIN) +#endif +#if PIN_EXISTS(EXP2_08) + REPORT_NAME_DIGITAL(__LINE__, EXP2_08_PIN) +#endif +#if PIN_EXISTS(EXP2_09) + REPORT_NAME_DIGITAL(__LINE__, EXP2_09_PIN) +#endif +#if PIN_EXISTS(EXP2_10) + REPORT_NAME_DIGITAL(__LINE__, EXP2_10_PIN) +#endif +#if PIN_EXISTS(EXP3_01) + REPORT_NAME_DIGITAL(__LINE__, EXP3_01_PIN) +#endif +#if PIN_EXISTS(EXP3_02) + REPORT_NAME_DIGITAL(__LINE__, EXP3_02_PIN) +#endif +#if PIN_EXISTS(EXP3_03) + REPORT_NAME_DIGITAL(__LINE__, EXP3_03_PIN) +#endif +#if PIN_EXISTS(EXP3_04) + REPORT_NAME_DIGITAL(__LINE__, EXP3_04_PIN) +#endif +#if PIN_EXISTS(EXP3_05) + REPORT_NAME_DIGITAL(__LINE__, EXP3_05_PIN) +#endif +#if PIN_EXISTS(EXP3_06) + REPORT_NAME_DIGITAL(__LINE__, EXP3_06_PIN) +#endif +#if PIN_EXISTS(EXP3_07) + REPORT_NAME_DIGITAL(__LINE__, EXP3_07_PIN) +#endif +#if PIN_EXISTS(EXP3_08) + REPORT_NAME_DIGITAL(__LINE__, EXP3_08_PIN) +#endif +#if PIN_EXISTS(EXP3_09) + REPORT_NAME_DIGITAL(__LINE__, EXP3_09_PIN) +#endif +#if PIN_EXISTS(EXP3_10) + REPORT_NAME_DIGITAL(__LINE__, EXP3_10_PIN) +#endif + #if _EXISTS(TMC_SW_MISO) REPORT_NAME_DIGITAL(__LINE__, TMC_SW_MISO) #endif @@ -417,6 +501,10 @@ #if _EXISTS(TFTGLCD_CS) REPORT_NAME_DIGITAL(__LINE__, TFTGLCD_CS) #endif + +// +// E Multiplexing +// #if PIN_EXISTS(E_MUX0) REPORT_NAME_DIGITAL(__LINE__, E_MUX0_PIN) #endif @@ -426,230 +514,155 @@ #if PIN_EXISTS(E_MUX2) REPORT_NAME_DIGITAL(__LINE__, E_MUX2_PIN) #endif -#if PIN_EXISTS(E_STOP) - REPORT_NAME_DIGITAL(__LINE__, E_STOP_PIN) -#endif -#if PIN_EXISTS(E0_ATT) - REPORT_NAME_DIGITAL(__LINE__, E0_ATT_PIN) -#endif -#if PIN_EXISTS(E0_AUTO_FAN) - REPORT_NAME_DIGITAL(__LINE__, E0_AUTO_FAN_PIN) -#endif -#if PIN_EXISTS(E0_CS) - REPORT_NAME_DIGITAL(__LINE__, E0_CS_PIN) -#endif + #if PIN_EXISTS(E0_DIR) REPORT_NAME_DIGITAL(__LINE__, E0_DIR_PIN) #endif #if PIN_EXISTS(E0_ENABLE) REPORT_NAME_DIGITAL(__LINE__, E0_ENABLE_PIN) #endif -#if PIN_EXISTS(E0_MS1) - REPORT_NAME_DIGITAL(__LINE__, E0_MS1_PIN) -#endif -#if PIN_EXISTS(E0_MS2) - REPORT_NAME_DIGITAL(__LINE__, E0_MS2_PIN) -#endif -#if PIN_EXISTS(E0_MS3) - REPORT_NAME_DIGITAL(__LINE__, E0_MS3_PIN) -#endif #if PIN_EXISTS(E0_STEP) REPORT_NAME_DIGITAL(__LINE__, E0_STEP_PIN) #endif -#if PIN_EXISTS(E0_STDBY) - REPORT_NAME_DIGITAL(__LINE__, E0_STDBY_PIN) -#endif -#if PIN_EXISTS(E1_AUTO_FAN) - REPORT_NAME_DIGITAL(__LINE__, E1_AUTO_FAN_PIN) -#endif -#if PIN_EXISTS(E1_CS) - REPORT_NAME_DIGITAL(__LINE__, E1_CS_PIN) -#endif #if PIN_EXISTS(E1_DIR) REPORT_NAME_DIGITAL(__LINE__, E1_DIR_PIN) #endif #if PIN_EXISTS(E1_ENABLE) REPORT_NAME_DIGITAL(__LINE__, E1_ENABLE_PIN) #endif -#if PIN_EXISTS(E1_MS1) - REPORT_NAME_DIGITAL(__LINE__, E1_MS1_PIN) -#endif -#if PIN_EXISTS(E1_MS2) - REPORT_NAME_DIGITAL(__LINE__, E1_MS2_PIN) -#endif -#if PIN_EXISTS(E1_MS3) - REPORT_NAME_DIGITAL(__LINE__, E1_MS3_PIN) -#endif #if PIN_EXISTS(E1_STEP) REPORT_NAME_DIGITAL(__LINE__, E1_STEP_PIN) #endif -#if PIN_EXISTS(E1_STDBY) - REPORT_NAME_DIGITAL(__LINE__, E1_STDBY_PIN) -#endif -#if PIN_EXISTS(E2_AUTO_FAN) - REPORT_NAME_DIGITAL(__LINE__, E2_AUTO_FAN_PIN) -#endif -#if PIN_EXISTS(E2_CS) - REPORT_NAME_DIGITAL(__LINE__, E2_CS_PIN) -#endif #if PIN_EXISTS(E2_DIR) REPORT_NAME_DIGITAL(__LINE__, E2_DIR_PIN) #endif #if PIN_EXISTS(E2_ENABLE) REPORT_NAME_DIGITAL(__LINE__, E2_ENABLE_PIN) #endif -#if PIN_EXISTS(E2_MS1) - REPORT_NAME_DIGITAL(__LINE__, E2_MS1_PIN) -#endif -#if PIN_EXISTS(E2_MS2) - REPORT_NAME_DIGITAL(__LINE__, E2_MS2_PIN) -#endif -#if PIN_EXISTS(E2_MS3) - REPORT_NAME_DIGITAL(__LINE__, E2_MS3_PIN) -#endif #if PIN_EXISTS(E2_STEP) REPORT_NAME_DIGITAL(__LINE__, E2_STEP_PIN) #endif -#if PIN_EXISTS(E2_STDBY) - REPORT_NAME_DIGITAL(__LINE__, E2_STDBY_PIN) -#endif -#if PIN_EXISTS(E3_AUTO_FAN) - REPORT_NAME_DIGITAL(__LINE__, E3_AUTO_FAN_PIN) -#endif -#if PIN_EXISTS(E3_CS) - REPORT_NAME_DIGITAL(__LINE__, E3_CS_PIN) -#endif #if PIN_EXISTS(E3_DIR) REPORT_NAME_DIGITAL(__LINE__, E3_DIR_PIN) #endif #if PIN_EXISTS(E3_ENABLE) REPORT_NAME_DIGITAL(__LINE__, E3_ENABLE_PIN) #endif -#if PIN_EXISTS(E3_MS1) - REPORT_NAME_DIGITAL(__LINE__, E3_MS1_PIN) -#endif -#if PIN_EXISTS(E3_MS2) - REPORT_NAME_DIGITAL(__LINE__, E3_MS2_PIN) -#endif -#if PIN_EXISTS(E3_MS3) - REPORT_NAME_DIGITAL(__LINE__, E3_MS3_PIN) -#endif #if PIN_EXISTS(E3_STEP) REPORT_NAME_DIGITAL(__LINE__, E3_STEP_PIN) #endif -#if PIN_EXISTS(E3_STDBY) - REPORT_NAME_DIGITAL(__LINE__, E3_STDBY_PIN) -#endif -#if PIN_EXISTS(E4_AUTO_FAN) - REPORT_NAME_DIGITAL(__LINE__, E4_AUTO_FAN_PIN) -#endif -#if PIN_EXISTS(E4_CS) - REPORT_NAME_DIGITAL(__LINE__, E4_CS_PIN) -#endif #if PIN_EXISTS(E4_DIR) REPORT_NAME_DIGITAL(__LINE__, E4_DIR_PIN) #endif #if PIN_EXISTS(E4_ENABLE) REPORT_NAME_DIGITAL(__LINE__, E4_ENABLE_PIN) #endif -#if PIN_EXISTS(E4_MS1) - REPORT_NAME_DIGITAL(__LINE__, E4_MS1_PIN) -#endif -#if PIN_EXISTS(E4_MS2) - REPORT_NAME_DIGITAL(__LINE__, E4_MS2_PIN) -#endif -#if PIN_EXISTS(E4_MS3) - REPORT_NAME_DIGITAL(__LINE__, E4_MS3_PIN) -#endif #if PIN_EXISTS(E4_STEP) REPORT_NAME_DIGITAL(__LINE__, E4_STEP_PIN) #endif -#if PIN_EXISTS(E4_STDBY) - REPORT_NAME_DIGITAL(__LINE__, E4_STDBY_PIN) -#endif -#if PIN_EXISTS(E5_AUTO_FAN) - REPORT_NAME_DIGITAL(__LINE__, E5_AUTO_FAN_PIN) -#endif -#if PIN_EXISTS(E5_CS) - REPORT_NAME_DIGITAL(__LINE__, E5_CS_PIN) -#endif #if PIN_EXISTS(E5_DIR) REPORT_NAME_DIGITAL(__LINE__, E5_DIR_PIN) #endif #if PIN_EXISTS(E5_ENABLE) REPORT_NAME_DIGITAL(__LINE__, E5_ENABLE_PIN) #endif -#if PIN_EXISTS(E5_MS1) - REPORT_NAME_DIGITAL(__LINE__, E5_MS1_PIN) -#endif -#if PIN_EXISTS(E5_MS2) - REPORT_NAME_DIGITAL(__LINE__, E5_MS2_PIN) -#endif -#if PIN_EXISTS(E5_MS3) - REPORT_NAME_DIGITAL(__LINE__, E5_MS3_PIN) -#endif #if PIN_EXISTS(E5_STEP) REPORT_NAME_DIGITAL(__LINE__, E5_STEP_PIN) #endif -#if PIN_EXISTS(E5_STDBY) - REPORT_NAME_DIGITAL(__LINE__, E5_STDBY_PIN) -#endif -#if PIN_EXISTS(E6_AUTO_FAN) - REPORT_NAME_DIGITAL(__LINE__, E6_AUTO_FAN_PIN) -#endif -#if PIN_EXISTS(E6_CS) - REPORT_NAME_DIGITAL(__LINE__, E6_CS_PIN) -#endif #if PIN_EXISTS(E6_DIR) REPORT_NAME_DIGITAL(__LINE__, E6_DIR_PIN) #endif #if PIN_EXISTS(E6_ENABLE) REPORT_NAME_DIGITAL(__LINE__, E6_ENABLE_PIN) #endif -#if PIN_EXISTS(E6_MS1) - REPORT_NAME_DIGITAL(__LINE__, E6_MS1_PIN) -#endif -#if PIN_EXISTS(E6_MS2) - REPORT_NAME_DIGITAL(__LINE__, E6_MS2_PIN) -#endif -#if PIN_EXISTS(E6_MS3) - REPORT_NAME_DIGITAL(__LINE__, E6_MS3_PIN) -#endif #if PIN_EXISTS(E6_STEP) REPORT_NAME_DIGITAL(__LINE__, E6_STEP_PIN) #endif -#if PIN_EXISTS(E6_STDBY) - REPORT_NAME_DIGITAL(__LINE__, E6_STDBY_PIN) -#endif -#if PIN_EXISTS(E7_AUTO_FAN) - REPORT_NAME_DIGITAL(__LINE__, E7_AUTO_FAN_PIN) -#endif -#if PIN_EXISTS(E7_CS) - REPORT_NAME_DIGITAL(__LINE__, E7_CS_PIN) -#endif #if PIN_EXISTS(E7_DIR) REPORT_NAME_DIGITAL(__LINE__, E7_DIR_PIN) #endif #if PIN_EXISTS(E7_ENABLE) REPORT_NAME_DIGITAL(__LINE__, E7_ENABLE_PIN) #endif -#if PIN_EXISTS(E7_MS1) - REPORT_NAME_DIGITAL(__LINE__, E7_MS1_PIN) -#endif -#if PIN_EXISTS(E7_MS2) - REPORT_NAME_DIGITAL(__LINE__, E7_MS2_PIN) -#endif -#if PIN_EXISTS(E7_MS3) - REPORT_NAME_DIGITAL(__LINE__, E7_MS3_PIN) -#endif #if PIN_EXISTS(E7_STEP) REPORT_NAME_DIGITAL(__LINE__, E7_STEP_PIN) #endif -#if PIN_EXISTS(E7_STDBY) - REPORT_NAME_DIGITAL(__LINE__, E7_STDBY_PIN) -#endif -#if _EXISTS(ENET_CRS) - REPORT_NAME_DIGITAL(__LINE__, ENET_CRS) + +// +// Stepper Select +// +#if PIN_EXISTS(X_CS) + REPORT_NAME_DIGITAL(__LINE__, X_CS_PIN) +#endif +#if PIN_EXISTS(X2_CS) + REPORT_NAME_DIGITAL(__LINE__, X2_CS_PIN) +#endif +#if PIN_EXISTS(Y_CS) + REPORT_NAME_DIGITAL(__LINE__, Y_CS_PIN) +#endif +#if PIN_EXISTS(Y2_CS) + REPORT_NAME_DIGITAL(__LINE__, Y2_CS_PIN) +#endif +#if PIN_EXISTS(Z_CS) + REPORT_NAME_DIGITAL(__LINE__, Z_CS_PIN) +#endif +#if PIN_EXISTS(Z2_CS) + REPORT_NAME_DIGITAL(__LINE__, Z2_CS_PIN) +#endif +#if PIN_EXISTS(Z3_CS) + REPORT_NAME_DIGITAL(__LINE__, Z3_CS_PIN) +#endif +#if PIN_EXISTS(Z4_CS) + REPORT_NAME_DIGITAL(__LINE__, Z4_CS_PIN) +#endif +#if PIN_EXISTS(I_CS) + REPORT_NAME_DIGITAL(__LINE__, I_CS_PIN) +#endif +#if PIN_EXISTS(J_CS) + REPORT_NAME_DIGITAL(__LINE__, J_CS_PIN) +#endif +#if PIN_EXISTS(K_CS) + REPORT_NAME_DIGITAL(__LINE__, K_CS_PIN) +#endif +#if PIN_EXISTS(U_CS) + REPORT_NAME_DIGITAL(__LINE__, U_CS_PIN) +#endif +#if PIN_EXISTS(V_CS) + REPORT_NAME_DIGITAL(__LINE__, V_CS_PIN) +#endif +#if PIN_EXISTS(W_CS) + REPORT_NAME_DIGITAL(__LINE__, W_CS_PIN) +#endif +#if PIN_EXISTS(E0_CS) + REPORT_NAME_DIGITAL(__LINE__, E0_CS_PIN) +#endif +#if PIN_EXISTS(E1_CS) + REPORT_NAME_DIGITAL(__LINE__, E1_CS_PIN) +#endif +#if PIN_EXISTS(E2_CS) + REPORT_NAME_DIGITAL(__LINE__, E2_CS_PIN) +#endif +#if PIN_EXISTS(E3_CS) + REPORT_NAME_DIGITAL(__LINE__, E3_CS_PIN) +#endif +#if PIN_EXISTS(E4_CS) + REPORT_NAME_DIGITAL(__LINE__, E4_CS_PIN) +#endif +#if PIN_EXISTS(E5_CS) + REPORT_NAME_DIGITAL(__LINE__, E5_CS_PIN) +#endif +#if PIN_EXISTS(E6_CS) + REPORT_NAME_DIGITAL(__LINE__, E6_CS_PIN) +#endif +#if PIN_EXISTS(E7_CS) + REPORT_NAME_DIGITAL(__LINE__, E7_CS_PIN) +#endif + +// +// Ethernet +// +#if _EXISTS(ENET_CRS) + REPORT_NAME_DIGITAL(__LINE__, ENET_CRS) #endif #if _EXISTS(ENET_MDIO) REPORT_NAME_DIGITAL(__LINE__, ENET_MDIO) @@ -675,6 +688,10 @@ #if _EXISTS(ENET_TXD1) REPORT_NAME_DIGITAL(__LINE__, ENET_TXD1) #endif +#if _EXISTS(REF_CLK) + REPORT_NAME_DIGITAL(__LINE__, REF_CLK) +#endif + #if PIN_EXISTS(EXP_VOLTAGE_LEVEL) REPORT_NAME_DIGITAL(__LINE__, EXP_VOLTAGE_LEVEL_PIN) #endif @@ -709,12 +726,10 @@ #if _EXISTS(EXT_AUX_TX1_D3) REPORT_NAME_DIGITAL(__LINE__, EXT_AUX_TX1_D3) #endif -#if _EXISTS(EXTRUDER_0_AUTO_FAN) - REPORT_NAME_DIGITAL(__LINE__, EXTRUDER_0_AUTO_FAN) -#endif -#if _EXISTS(EXTRUDER_1_AUTO_FAN) - REPORT_NAME_DIGITAL(__LINE__, EXTRUDER_1_AUTO_FAN) -#endif + +// +// Fans +// #if PIN_EXISTS(FAN) REPORT_NAME_DIGITAL(__LINE__, FAN_PIN) #endif @@ -748,12 +763,40 @@ #if PIN_EXISTS(FAN_MUX2) REPORT_NAME_DIGITAL(__LINE__, FAN_MUX2_PIN) #endif -#if PIN_EXISTS(POWER_LOSS) - REPORT_NAME_DIGITAL(__LINE__, POWER_LOSS_PIN) +#if PIN_EXISTS(E0_AUTO_FAN) + REPORT_NAME_DIGITAL(__LINE__, E0_AUTO_FAN_PIN) #endif -#if PIN_EXISTS(SAFE_POWER) - REPORT_NAME_DIGITAL(__LINE__, SAFE_POWER_PIN) +#if PIN_EXISTS(E1_AUTO_FAN) + REPORT_NAME_DIGITAL(__LINE__, E1_AUTO_FAN_PIN) +#endif +#if PIN_EXISTS(E2_AUTO_FAN) + REPORT_NAME_DIGITAL(__LINE__, E2_AUTO_FAN_PIN) +#endif +#if PIN_EXISTS(E3_AUTO_FAN) + REPORT_NAME_DIGITAL(__LINE__, E3_AUTO_FAN_PIN) +#endif +#if PIN_EXISTS(E4_AUTO_FAN) + REPORT_NAME_DIGITAL(__LINE__, E4_AUTO_FAN_PIN) +#endif +#if PIN_EXISTS(E5_AUTO_FAN) + REPORT_NAME_DIGITAL(__LINE__, E5_AUTO_FAN_PIN) +#endif +#if PIN_EXISTS(E6_AUTO_FAN) + REPORT_NAME_DIGITAL(__LINE__, E6_AUTO_FAN_PIN) +#endif +#if PIN_EXISTS(E7_AUTO_FAN) + REPORT_NAME_DIGITAL(__LINE__, E7_AUTO_FAN_PIN) #endif +#if PIN_EXISTS(CHAMBER_AUTO_FAN) + REPORT_NAME_DIGITAL(__LINE__, CHAMBER_AUTO_FAN_PIN) +#endif +#if PIN_EXISTS(CONTROLLER_FAN) + REPORT_NAME_DIGITAL(__LINE__, CONTROLLER_FAN_PIN) +#endif + +// +// Filament Runout Sensor +// #if PIN_EXISTS(FIL_RUNOUT) REPORT_NAME_DIGITAL(__LINE__, FIL_RUNOUT_PIN) #endif @@ -778,6 +821,10 @@ #if PIN_EXISTS(FIL_RUNOUT8) REPORT_NAME_DIGITAL(__LINE__, FIL_RUNOUT8_PIN) #endif + +// +// Heaters +// #if PIN_EXISTS(HEATER_0) REPORT_NAME_DIGITAL(__LINE__, HEATER_0_PIN) #endif @@ -811,23 +858,52 @@ #if PIN_EXISTS(COOLER) REPORT_NAME_DIGITAL(__LINE__, COOLER_PIN) #endif + #if PIN_EXISTS(HOME) REPORT_NAME_DIGITAL(__LINE__, HOME_PIN) #endif -#if PIN_EXISTS(I2C_SCL) - REPORT_NAME_DIGITAL(__LINE__, I2C_SCL_PIN) -#endif -#if PIN_EXISTS(I2C_SDA) - REPORT_NAME_DIGITAL(__LINE__, I2C_SDA_PIN) -#endif #if HAS_KILL REPORT_NAME_DIGITAL(__LINE__, KILL_PIN) #endif #if PIN_EXISTS(FREEZE) REPORT_NAME_DIGITAL(__LINE__, FREEZE_PIN) #endif -#if PIN_EXISTS(LCD_BACKLIGHT) - REPORT_NAME_DIGITAL(__LINE__, LCD_BACKLIGHT_PIN) +#if PIN_EXISTS(DEBUG) + REPORT_NAME_DIGITAL(__LINE__, DEBUG_PIN) +#endif +#if PIN_EXISTS(SUICIDE) + REPORT_NAME_DIGITAL(__LINE__, SUICIDE_PIN) +#endif +#if PIN_EXISTS(FET_SAFETY) + REPORT_NAME_DIGITAL(__LINE__, FET_SAFETY_PIN) +#endif +#if PIN_EXISTS(SAFETY_TRIGGERED) + REPORT_NAME_DIGITAL(__LINE__, SAFETY_TRIGGERED_PIN) +#endif +#if PIN_EXISTS(SAFE_POWER) + REPORT_NAME_DIGITAL(__LINE__, SAFE_POWER_PIN) +#endif +#if PIN_EXISTS(POWER_LOSS) + REPORT_NAME_DIGITAL(__LINE__, POWER_LOSS_PIN) +#endif +#if PIN_EXISTS(PS_ON) + REPORT_NAME_DIGITAL(__LINE__, PS_ON_PIN) +#endif + +// +// LCD +// +#if _EXISTS(DOGLCD_A0) + REPORT_NAME_DIGITAL(__LINE__, DOGLCD_A0) +#endif +#if _EXISTS(DOGLCD_CS) + REPORT_NAME_DIGITAL(__LINE__, DOGLCD_CS) +#endif +#if _EXISTS(DOGLCD_MOSI) + REPORT_NAME_DIGITAL(__LINE__, DOGLCD_MOSI) +#endif +#if _EXISTS(DOGLCD_SCK) + REPORT_NAME_DIGITAL(__LINE__, DOGLCD_SCK) #endif #if _EXISTS(LCD_PINS_D4) REPORT_NAME_DIGITAL(__LINE__, LCD_PINS_D4) @@ -850,9 +926,16 @@ #if _EXISTS(LCD_SDSS) REPORT_NAME_DIGITAL(__LINE__, LCD_SDSS) #endif -#if PIN_EXISTS(LED_GREEN) - REPORT_NAME_DIGITAL(__LINE__, LED_GREEN_PIN) +#if PIN_EXISTS(LCD_RESET) + REPORT_NAME_DIGITAL(__LINE__, LCD_RESET_PIN) #endif +#if PIN_EXISTS(LCD_BACKLIGHT) + REPORT_NAME_DIGITAL(__LINE__, LCD_BACKLIGHT_PIN) +#endif + +// +// LED Lights +// #if PIN_EXISTS(LED) REPORT_NAME_DIGITAL(__LINE__, LED_PIN) #endif @@ -865,9 +948,50 @@ #if PIN_EXISTS(LED4) REPORT_NAME_DIGITAL(__LINE__, LED4_PIN) #endif +#if PIN_EXISTS(LED_GREEN) + REPORT_NAME_DIGITAL(__LINE__, LED_GREEN_PIN) +#endif #if PIN_EXISTS(LED_RED) REPORT_NAME_DIGITAL(__LINE__, LED_RED_PIN) #endif +#if PIN_EXISTS(STAT_LED_BLUE) + REPORT_NAME_DIGITAL(__LINE__, STAT_LED_BLUE_PIN) +#endif +#if PIN_EXISTS(STAT_LED_RED) + REPORT_NAME_DIGITAL(__LINE__, STAT_LED_RED_PIN) +#endif +#if PIN_EXISTS(RGB_LED_R) + REPORT_NAME_DIGITAL(__LINE__, RGB_LED_R_PIN) +#endif +#if PIN_EXISTS(RGB_LED_G) + REPORT_NAME_DIGITAL(__LINE__, RGB_LED_G_PIN) +#endif +#if PIN_EXISTS(RGB_LED_B) + REPORT_NAME_DIGITAL(__LINE__, RGB_LED_B_PIN) +#endif +#if PIN_EXISTS(RGB_LED_W) + REPORT_NAME_DIGITAL(__LINE__, RGB_LED_W_PIN) +#endif +#if PIN_EXISTS(NEOPIXEL) + REPORT_NAME_DIGITAL(__LINE__, NEOPIXEL_PIN) +#endif +#if PIN_EXISTS(NEOPIXEL2) + REPORT_NAME_DIGITAL(__LINE__, NEOPIXEL2_PIN) +#endif + +// +// MAX7219 LED Matrix +// +#if PIN_EXISTS(MAX7219_CLK) + REPORT_NAME_DIGITAL(__LINE__, MAX7219_CLK_PIN) +#endif +#if PIN_EXISTS(MAX7219_DIN) + REPORT_NAME_DIGITAL(__LINE__, MAX7219_DIN_PIN) +#endif +#if PIN_EXISTS(MAX7219_LOAD) + REPORT_NAME_DIGITAL(__LINE__, MAX7219_LOAD_PIN) +#endif + #if PIN_EXISTS(TEMP_0_CS) REPORT_NAME_DIGITAL(__LINE__, TEMP_0_CS_PIN) #endif @@ -892,22 +1016,10 @@ #if PIN_EXISTS(TEMP_1_MISO) REPORT_NAME_DIGITAL(__LINE__, TEMP_1_MISO_PIN) #endif -#if PIN_EXISTS(MAX7219_CLK) - REPORT_NAME_DIGITAL(__LINE__, MAX7219_CLK_PIN) -#endif -#if PIN_EXISTS(MAX7219_DIN) - REPORT_NAME_DIGITAL(__LINE__, MAX7219_DIN_PIN) -#endif -#if PIN_EXISTS(MAX7219_LOAD) - REPORT_NAME_DIGITAL(__LINE__, MAX7219_LOAD_PIN) -#endif -//#if _EXISTS(MISO) -// REPORT_NAME_DIGITAL(__LINE__, MISO) -//#endif -#if PIN_EXISTS(MISO) - REPORT_NAME_DIGITAL(__LINE__, SD_MISO_PIN) -#endif +// +// MOSFETs (RAMPS) +// #if PIN_EXISTS(MOSFET_A) REPORT_NAME_DIGITAL(__LINE__, MOSFET_A_PIN) #endif @@ -920,108 +1032,139 @@ #if PIN_EXISTS(MOSFET_D) REPORT_NAME_DIGITAL(__LINE__, MOSFET_D_PIN) #endif + +// +// I2C +// + +//#if _EXISTS(SCL) +// REPORT_NAME_DIGITAL(__LINE__, SCL) +//#endif +#if PIN_EXISTS(I2C_SCL) + REPORT_NAME_DIGITAL(__LINE__, I2C_SCL_PIN) +#endif +//#if _EXISTS(SDA) +// REPORT_NAME_DIGITAL(__LINE__, SDA) +//#endif +#if PIN_EXISTS(I2C_SDA) + REPORT_NAME_DIGITAL(__LINE__, I2C_SDA_PIN) +#endif + +// +// SPI / SD Card +// + +//#if _EXISTS(MISO) +// REPORT_NAME_DIGITAL(__LINE__, MISO) +//#endif +#if PIN_EXISTS(SD_MISO) + REPORT_NAME_DIGITAL(__LINE__, SD_MISO_PIN) +#endif //#if _EXISTS(MOSI) // REPORT_NAME_DIGITAL(__LINE__, MOSI) //#endif -#if PIN_EXISTS(MOSI) +#if PIN_EXISTS(SD_MOSI) REPORT_NAME_DIGITAL(__LINE__, SD_MOSI_PIN) #endif -#if PIN_EXISTS(MOTOR_CURRENT_PWM_E) - REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_E_PIN) -#endif -#if PIN_EXISTS(MOTOR_CURRENT_PWM_E0) - REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_E0_PIN) +//#if _EXISTS(SCK) +// REPORT_NAME_DIGITAL(__LINE__, SCK) +//#endif +#if PIN_EXISTS(SD_SCK) + REPORT_NAME_DIGITAL(__LINE__, SD_SCK_PIN) #endif -#if PIN_EXISTS(MOTOR_CURRENT_PWM_E1) - REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_E1_PIN) +#if _EXISTS(SDSS) + REPORT_NAME_DIGITAL(__LINE__, SDSS) #endif -#if PIN_EXISTS(MOTOR_CURRENT_PWM_X) - REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_X_PIN) +#if PIN_EXISTS(SD_SS) + REPORT_NAME_DIGITAL(__LINE__, SD_SS_PIN) #endif -#if PIN_EXISTS(MOTOR_CURRENT_PWM_Y) - REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_Y_PIN) +#if PIN_EXISTS(SD_DETECT) + REPORT_NAME_DIGITAL(__LINE__, SD_DETECT_PIN) #endif -#if PIN_EXISTS(MOTOR_CURRENT_PWM_XY) - REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_XY_PIN) +#if PIN_EXISTS(SDPOWER) + REPORT_NAME_DIGITAL(__LINE__, SDPOWER_PIN) #endif + +// +// Motor Current PWM +// #if PIN_EXISTS(MOTOR_CURRENT_PWM_X) REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_X_PIN) #endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_Y) REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_Y_PIN) #endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_XY) + REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_XY_PIN) +#endif #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z) REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_Z_PIN) #endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_I) + REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_I_PIN) +#endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_J) + REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_J_PIN) +#endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_K) + REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_K_PIN) +#endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_U) + REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_U_PIN) +#endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_V) + REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_V_PIN) +#endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_W) + REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_W_PIN) +#endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_E) + REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_E_PIN) +#endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_E0) + REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_E0_PIN) +#endif +#if PIN_EXISTS(MOTOR_CURRENT_PWM_E1) + REPORT_NAME_DIGITAL(__LINE__, MOTOR_CURRENT_PWM_E1_PIN) +#endif #if PIN_EXISTS(MOTOR_FAULT) REPORT_NAME_DIGITAL(__LINE__, MOTOR_FAULT_PIN) #endif -#if PIN_EXISTS(PHOTOGRAPH) - REPORT_NAME_DIGITAL(__LINE__, PHOTOGRAPH_PIN) + +#if PIN_EXISTS(SLED) + REPORT_NAME_DIGITAL(__LINE__, SLED_PIN) #endif + +// +// Camera +// #if PIN_EXISTS(CHDK) REPORT_NAME_DIGITAL(__LINE__, CHDK_PIN) #endif -#if PIN_EXISTS(PS_ON) - REPORT_NAME_DIGITAL(__LINE__, PS_ON_PIN) +#if PIN_EXISTS(PHOTOGRAPH) + REPORT_NAME_DIGITAL(__LINE__, PHOTOGRAPH_PIN) #endif + #if PIN_EXISTS(PWM_1) REPORT_NAME_DIGITAL(__LINE__, PWM_1_PIN) #endif #if PIN_EXISTS(PWM_2) REPORT_NAME_DIGITAL(__LINE__, PWM_2_PIN) #endif -#if _EXISTS(REF_CLK) - REPORT_NAME_DIGITAL(__LINE__, REF_CLK) -#endif -#if PIN_EXISTS(NEOPIXEL) - REPORT_NAME_DIGITAL(__LINE__, NEOPIXEL_PIN) -#endif -#if PIN_EXISTS(NEOPIXEL2) - REPORT_NAME_DIGITAL(__LINE__, NEOPIXEL2_PIN) -#endif -#if PIN_EXISTS(RGB_LED_R) - REPORT_NAME_DIGITAL(__LINE__, RGB_LED_R_PIN) -#endif -#if PIN_EXISTS(RGB_LED_G) - REPORT_NAME_DIGITAL(__LINE__, RGB_LED_G_PIN) -#endif -#if PIN_EXISTS(RGB_LED_B) - REPORT_NAME_DIGITAL(__LINE__, RGB_LED_B_PIN) -#endif -#if PIN_EXISTS(RGB_LED_W) - REPORT_NAME_DIGITAL(__LINE__, RGB_LED_W_PIN) -#endif + +// +// Serial UART +// #if PIN_EXISTS(RX_ENABLE) REPORT_NAME_DIGITAL(__LINE__, RX_ENABLE_PIN) #endif -#if PIN_EXISTS(SAFETY_TRIGGERED) - REPORT_NAME_DIGITAL(__LINE__, SAFETY_TRIGGERED_PIN) -#endif -//#if _EXISTS(SCK) -// REPORT_NAME_DIGITAL(__LINE__, SCK) -//#endif -#if PIN_EXISTS(SCK) - REPORT_NAME_DIGITAL(__LINE__, SD_SCK_PIN) -#endif -//#if _EXISTS(SCL) -// REPORT_NAME_DIGITAL(__LINE__, SCL) -//#endif -#if PIN_EXISTS(SD_DETECT) - REPORT_NAME_DIGITAL(__LINE__, SD_DETECT_PIN) +#if PIN_EXISTS(TX_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, TX_ENABLE_PIN) #endif -//#if _EXISTS(SDA) -// REPORT_NAME_DIGITAL(__LINE__, SDA) + +//#if _EXISTS(SERVO0) +// REPORT_NAME_DIGITAL(__LINE__, SERVO0) //#endif -#if PIN_EXISTS(SDPOWER) - REPORT_NAME_DIGITAL(__LINE__, SDPOWER_PIN) -#endif -#if _EXISTS(SDSS) - REPORT_NAME_DIGITAL(__LINE__, SDSS) -#endif -#if _EXISTS(SERVO0) - REPORT_NAME_DIGITAL(__LINE__, SERVO0) -#endif #if PIN_EXISTS(SERVO0) REPORT_NAME_DIGITAL(__LINE__, SERVO0_PIN) #endif @@ -1034,6 +1177,7 @@ #if PIN_EXISTS(SERVO3) REPORT_NAME_DIGITAL(__LINE__, SERVO3_PIN) #endif + #if PIN_EXISTS(SHIFT_CLK) REPORT_NAME_DIGITAL(__LINE__, SHIFT_CLK_PIN) #endif @@ -1046,9 +1190,7 @@ #if PIN_EXISTS(SHIFT_OUT) REPORT_NAME_DIGITAL(__LINE__, SHIFT_OUT_PIN) #endif -#if PIN_EXISTS(SLED) - REPORT_NAME_DIGITAL(__LINE__, SLED_PIN) -#endif + #if PIN_EXISTS(SLEEP_WAKE) REPORT_NAME_DIGITAL(__LINE__, SLEEP_WAKE_PIN) #endif @@ -1076,9 +1218,11 @@ #if PIN_EXISTS(SOL7) REPORT_NAME_DIGITAL(__LINE__, SOL7_PIN) #endif + #if _EXISTS(SPARE_IO) REPORT_NAME_DIGITAL(__LINE__, SPARE_IO) #endif + #if PIN_EXISTS(SPI_EEPROM1_CS) REPORT_NAME_DIGITAL(__LINE__, SPI_EEPROM1_CS_PIN) #endif @@ -1088,6 +1232,7 @@ #if PIN_EXISTS(SPI_FLASH_CS) REPORT_NAME_DIGITAL(__LINE__, SPI_FLASH_CS_PIN) #endif + #if PIN_EXISTS(SPINDLE_DIR) REPORT_NAME_DIGITAL(__LINE__, SPINDLE_DIR_PIN) #endif @@ -1100,6 +1245,7 @@ #if PIN_EXISTS(SPINDLE_LASER_PWM) REPORT_NAME_DIGITAL(__LINE__, SPINDLE_LASER_PWM_PIN) #endif + #if PIN_EXISTS(SR_CLK) REPORT_NAME_DIGITAL(__LINE__, SR_CLK_PIN) #endif @@ -1109,24 +1255,10 @@ #if PIN_EXISTS(SR_STROBE) REPORT_NAME_DIGITAL(__LINE__, SR_STROBE_PIN) #endif -#if PIN_EXISTS(SS) - REPORT_NAME_DIGITAL(__LINE__, SD_SS_PIN) -#endif -#if PIN_EXISTS(STAT_LED_BLUE) - REPORT_NAME_DIGITAL(__LINE__, STAT_LED_BLUE_PIN) -#endif -#if _EXISTS(STAT_LED_RED_LED) - REPORT_NAME_DIGITAL(__LINE__, STAT_LED_RED_LED) -#endif -#if PIN_EXISTS(STAT_LED_RED) - REPORT_NAME_DIGITAL(__LINE__, STAT_LED_RED_PIN) -#endif + #if PIN_EXISTS(STEPPER_RESET) REPORT_NAME_DIGITAL(__LINE__, STEPPER_RESET_PIN) #endif -#if PIN_EXISTS(SUICIDE) - REPORT_NAME_DIGITAL(__LINE__, SUICIDE_PIN) -#endif #if PIN_EXISTS(TLC_BLANK) REPORT_NAME_DIGITAL(__LINE__, TLC_BLANK_PIN) #endif @@ -1139,6 +1271,13 @@ #if PIN_EXISTS(TLC_XLAT) REPORT_NAME_DIGITAL(__LINE__, TLC_XLAT_PIN) #endif + +// +// Generic Tool / PWM +// +#if PIN_EXISTS(TOOL_PWM) + REPORT_NAME_DIGITAL(__LINE__, TOOL_PWM_PIN) +#endif #if PIN_EXISTS(TOOL_0) REPORT_NAME_DIGITAL(__LINE__, TOOL_0_PIN) #endif @@ -1163,279 +1302,250 @@ #if PIN_EXISTS(TOOL_3_PWM) REPORT_NAME_DIGITAL(__LINE__, TOOL_3_PWM_PIN) #endif -#if PIN_EXISTS(TOOL_PWM) - REPORT_NAME_DIGITAL(__LINE__, TOOL_PWM_PIN) + +// +// Tool Sensors +// +#if PIN_EXISTS(TOOL_SENSOR1) + REPORT_NAME_DIGITAL(__LINE__, TOOL_SENSOR1_PIN) #endif -#if PIN_EXISTS(TX_ENABLE) - REPORT_NAME_DIGITAL(__LINE__, TX_ENABLE_PIN) +#if PIN_EXISTS(TOOL_SENSOR2) + REPORT_NAME_DIGITAL(__LINE__, TOOL_SENSOR2_PIN) +#endif +#if PIN_EXISTS(TOOL_SENSOR3) + REPORT_NAME_DIGITAL(__LINE__, TOOL_SENSOR3_PIN) #endif + +// +// UI +// #if _EXISTS(UI1) REPORT_NAME_DIGITAL(__LINE__, UI1) #endif #if _EXISTS(UI2) REPORT_NAME_DIGITAL(__LINE__, UI2) #endif -#if _EXISTS(UNUSED_PWM) - REPORT_NAME_DIGITAL(__LINE__, UNUSED_PWM) -#endif -#if PIN_EXISTS(X_ATT) - REPORT_NAME_DIGITAL(__LINE__, X_ATT_PIN) -#endif -#if PIN_EXISTS(X_CS) - REPORT_NAME_DIGITAL(__LINE__, X_CS_PIN) -#endif -#if PIN_EXISTS(X_DIR) - REPORT_NAME_DIGITAL(__LINE__, X_DIR_PIN) -#endif -#if PIN_EXISTS(X_ENABLE) - REPORT_NAME_DIGITAL(__LINE__, X_ENABLE_PIN) -#endif + +// +// Limit Switches +// #if PIN_EXISTS(X_MAX) REPORT_NAME_DIGITAL(__LINE__, X_MAX_PIN) #endif #if PIN_EXISTS(X_MIN) REPORT_NAME_DIGITAL(__LINE__, X_MIN_PIN) #endif -#if PIN_EXISTS(X_DIAG) - REPORT_NAME_DIGITAL(__LINE__, X_DIAG_PIN) -#endif -#if PIN_EXISTS(X_MS1) - REPORT_NAME_DIGITAL(__LINE__, X_MS1_PIN) -#endif -#if PIN_EXISTS(X_MS2) - REPORT_NAME_DIGITAL(__LINE__, X_MS2_PIN) -#endif -#if PIN_EXISTS(X_MS3) - REPORT_NAME_DIGITAL(__LINE__, X_MS3_PIN) -#endif -#if PIN_EXISTS(X_STEP) - REPORT_NAME_DIGITAL(__LINE__, X_STEP_PIN) -#endif -#if PIN_EXISTS(X_STDBY) - REPORT_NAME_DIGITAL(__LINE__, X_STDBY_PIN) -#endif #if PIN_EXISTS(X_STOP) REPORT_NAME_DIGITAL(__LINE__, X_STOP_PIN) #endif -#if PIN_EXISTS(X2_CS) - REPORT_NAME_DIGITAL(__LINE__, X2_CS_PIN) -#endif -#if PIN_EXISTS(X2_DIR) - REPORT_NAME_DIGITAL(__LINE__, X2_DIR_PIN) -#endif -#if PIN_EXISTS(X2_ENABLE) - REPORT_NAME_DIGITAL(__LINE__, X2_ENABLE_PIN) -#endif + #if PIN_EXISTS(X2_MAX) REPORT_NAME_DIGITAL(__LINE__, X2_MAX_PIN) #endif #if PIN_EXISTS(X2_MIN) REPORT_NAME_DIGITAL(__LINE__, X2_MIN_PIN) #endif -#if PIN_EXISTS(X2_MS1) - REPORT_NAME_DIGITAL(__LINE__, X2_MS1_PIN) -#endif -#if PIN_EXISTS(X2_MS2) - REPORT_NAME_DIGITAL(__LINE__, X2_MS2_PIN) -#endif -#if PIN_EXISTS(X2_MS3) - REPORT_NAME_DIGITAL(__LINE__, X2_MS3_PIN) -#endif -#if PIN_EXISTS(X2_STEP) - REPORT_NAME_DIGITAL(__LINE__, X2_STEP_PIN) -#endif -#if PIN_EXISTS(Y_ATT) - REPORT_NAME_DIGITAL(__LINE__, Y_ATT_PIN) -#endif -#if PIN_EXISTS(Y_CS) - REPORT_NAME_DIGITAL(__LINE__, Y_CS_PIN) -#endif -#if PIN_EXISTS(Y_DIR) - REPORT_NAME_DIGITAL(__LINE__, Y_DIR_PIN) -#endif -#if PIN_EXISTS(Y_ENABLE) - REPORT_NAME_DIGITAL(__LINE__, Y_ENABLE_PIN) +#if PIN_EXISTS(X2_STOP) + REPORT_NAME_DIGITAL(__LINE__, X2_STOP_PIN) #endif + #if PIN_EXISTS(Y_MAX) REPORT_NAME_DIGITAL(__LINE__, Y_MAX_PIN) #endif #if PIN_EXISTS(Y_MIN) REPORT_NAME_DIGITAL(__LINE__, Y_MIN_PIN) #endif -#if PIN_EXISTS(Y_DIAG) - REPORT_NAME_DIGITAL(__LINE__, Y_DIAG_PIN) -#endif -#if PIN_EXISTS(Y_MS1) - REPORT_NAME_DIGITAL(__LINE__, Y_MS1_PIN) -#endif -#if PIN_EXISTS(Y_MS2) - REPORT_NAME_DIGITAL(__LINE__, Y_MS2_PIN) -#endif -#if PIN_EXISTS(Y_MS3) - REPORT_NAME_DIGITAL(__LINE__, Y_MS3_PIN) -#endif -#if PIN_EXISTS(Y_STEP) - REPORT_NAME_DIGITAL(__LINE__, Y_STEP_PIN) -#endif -#if PIN_EXISTS(Y_STDBY) - REPORT_NAME_DIGITAL(__LINE__, Y_STDBY_PIN) -#endif #if PIN_EXISTS(Y_STOP) REPORT_NAME_DIGITAL(__LINE__, Y_STOP_PIN) #endif -#if PIN_EXISTS(Y2_CS) - REPORT_NAME_DIGITAL(__LINE__, Y2_CS_PIN) -#endif -#if PIN_EXISTS(Y2_DIR) - REPORT_NAME_DIGITAL(__LINE__, Y2_DIR_PIN) -#endif -#if PIN_EXISTS(Y2_ENABLE) - REPORT_NAME_DIGITAL(__LINE__, Y2_ENABLE_PIN) -#endif + #if PIN_EXISTS(Y2_MAX) REPORT_NAME_DIGITAL(__LINE__, Y2_MAX_PIN) #endif #if PIN_EXISTS(Y2_MIN) REPORT_NAME_DIGITAL(__LINE__, Y2_MIN_PIN) #endif -#if PIN_EXISTS(Y2_MS1) - REPORT_NAME_DIGITAL(__LINE__, Y2_MS1_PIN) +#if PIN_EXISTS(Y2_STOP) + REPORT_NAME_DIGITAL(__LINE__, Y2_STOP_PIN) #endif -#if PIN_EXISTS(Y2_MS2) - REPORT_NAME_DIGITAL(__LINE__, Y2_MS2_PIN) + +#if PIN_EXISTS(Z_MAX) + REPORT_NAME_DIGITAL(__LINE__, Z_MAX_PIN) #endif -#if PIN_EXISTS(Y2_MS3) - REPORT_NAME_DIGITAL(__LINE__, Y2_MS3_PIN) +#if PIN_EXISTS(Z_MIN) + REPORT_NAME_DIGITAL(__LINE__, Z_MIN_PIN) #endif -#if PIN_EXISTS(Y2_STEP) - REPORT_NAME_DIGITAL(__LINE__, Y2_STEP_PIN) +#if PIN_EXISTS(Z_STOP) + REPORT_NAME_DIGITAL(__LINE__, Z_STOP_PIN) #endif -#if PIN_EXISTS(Z_ATT) - REPORT_NAME_DIGITAL(__LINE__, Z_ATT_PIN) + +#if PIN_EXISTS(Z2_MAX) + REPORT_NAME_DIGITAL(__LINE__, Z2_MAX_PIN) #endif -#if PIN_EXISTS(Z_CS) - REPORT_NAME_DIGITAL(__LINE__, Z_CS_PIN) +#if PIN_EXISTS(Z2_MIN) + REPORT_NAME_DIGITAL(__LINE__, Z2_MIN_PIN) #endif -#if PIN_EXISTS(Z_DIR) - REPORT_NAME_DIGITAL(__LINE__, Z_DIR_PIN) +#if PIN_EXISTS(Z2_STOP) + REPORT_NAME_DIGITAL(__LINE__, Z2_STOP_PIN) #endif -#if PIN_EXISTS(Z_ENABLE) - REPORT_NAME_DIGITAL(__LINE__, Z_ENABLE_PIN) + +#if PIN_EXISTS(Z3_MAX) + REPORT_NAME_DIGITAL(__LINE__, Z3_MAX_PIN) #endif -#if PIN_EXISTS(Z_MAX) - REPORT_NAME_DIGITAL(__LINE__, Z_MAX_PIN) +#if PIN_EXISTS(Z3_MIN) + REPORT_NAME_DIGITAL(__LINE__, Z3_MIN_PIN) #endif -#if PIN_EXISTS(Z_MIN) - REPORT_NAME_DIGITAL(__LINE__, Z_MIN_PIN) +#if PIN_EXISTS(Z3_STOP) + REPORT_NAME_DIGITAL(__LINE__, Z3_STOP_PIN) #endif -#if PIN_EXISTS(Z_DIAG) - REPORT_NAME_DIGITAL(__LINE__, Z_DIAG_PIN) + +#if PIN_EXISTS(Z4_MAX) + REPORT_NAME_DIGITAL(__LINE__, Z4_MAX_PIN) #endif -#if PIN_EXISTS(Z_MS1) - REPORT_NAME_DIGITAL(__LINE__, Z_MS1_PIN) +#if PIN_EXISTS(Z4_MIN) + REPORT_NAME_DIGITAL(__LINE__, Z4_MIN_PIN) #endif -#if PIN_EXISTS(Z_MS2) - REPORT_NAME_DIGITAL(__LINE__, Z_MS2_PIN) +#if PIN_EXISTS(Z4_STOP) + REPORT_NAME_DIGITAL(__LINE__, Z4_STOP_PIN) #endif -#if PIN_EXISTS(Z_MS3) - REPORT_NAME_DIGITAL(__LINE__, Z_MS3_PIN) + +#if PIN_EXISTS(I_MAX) + REPORT_NAME_DIGITAL(__LINE__, I_MAX_PIN) #endif -#if PIN_EXISTS(Z_STEP) - REPORT_NAME_DIGITAL(__LINE__, Z_STEP_PIN) +#if PIN_EXISTS(I_MIN) + REPORT_NAME_DIGITAL(__LINE__, I_MIN_PIN) #endif -#if PIN_EXISTS(Z_STDBY) - REPORT_NAME_DIGITAL(__LINE__, Z_STDBY_PIN) +#if PIN_EXISTS(I_STOP) + REPORT_NAME_DIGITAL(__LINE__, I_STOP_PIN) #endif -#if PIN_EXISTS(Z_STOP) - REPORT_NAME_DIGITAL(__LINE__, Z_STOP_PIN) + +#if PIN_EXISTS(J_MAX) + REPORT_NAME_DIGITAL(__LINE__, J_MAX_PIN) #endif -#if PIN_EXISTS(Z2_CS) - REPORT_NAME_DIGITAL(__LINE__, Z2_CS_PIN) +#if PIN_EXISTS(J_MIN) + REPORT_NAME_DIGITAL(__LINE__, J_MIN_PIN) #endif -#if PIN_EXISTS(Z2_DIR) - REPORT_NAME_DIGITAL(__LINE__, Z2_DIR_PIN) +#if PIN_EXISTS(J_STOP) + REPORT_NAME_DIGITAL(__LINE__, J_STOP_PIN) #endif -#if PIN_EXISTS(Z2_ENABLE) - REPORT_NAME_DIGITAL(__LINE__, Z2_ENABLE_PIN) + +#if PIN_EXISTS(K_MAX) + REPORT_NAME_DIGITAL(__LINE__, K_MAX_PIN) #endif -#if PIN_EXISTS(Z2_MAX) - REPORT_NAME_DIGITAL(__LINE__, Z2_MAX_PIN) +#if PIN_EXISTS(K_MIN) + REPORT_NAME_DIGITAL(__LINE__, K_MIN_PIN) #endif -#if PIN_EXISTS(Z2_MIN) - REPORT_NAME_DIGITAL(__LINE__, Z2_MIN_PIN) +#if PIN_EXISTS(K_STOP) + REPORT_NAME_DIGITAL(__LINE__, K_STOP_PIN) #endif -#if PIN_EXISTS(Z2_DIAG) - REPORT_NAME_DIGITAL(__LINE__, Z2_DIAG_PIN) + +#if PIN_EXISTS(U_MAX) + REPORT_NAME_DIGITAL(__LINE__, U_MAX_PIN) #endif -#if PIN_EXISTS(Z2_MS1) - REPORT_NAME_DIGITAL(__LINE__, Z2_MS1_PIN) +#if PIN_EXISTS(U_MIN) + REPORT_NAME_DIGITAL(__LINE__, U_MIN_PIN) #endif -#if PIN_EXISTS(Z2_MS2) - REPORT_NAME_DIGITAL(__LINE__, Z2_MS2_PIN) +#if PIN_EXISTS(U_STOP) + REPORT_NAME_DIGITAL(__LINE__, U_STOP_PIN) #endif -#if PIN_EXISTS(Z2_MS3) - REPORT_NAME_DIGITAL(__LINE__, Z2_MS3_PIN) + +#if PIN_EXISTS(V_MAX) + REPORT_NAME_DIGITAL(__LINE__, V_MAX_PIN) #endif -#if PIN_EXISTS(Z2_STEP) - REPORT_NAME_DIGITAL(__LINE__, Z2_STEP_PIN) +#if PIN_EXISTS(V_MIN) + REPORT_NAME_DIGITAL(__LINE__, V_MIN_PIN) #endif -#if PIN_EXISTS(Z2_STOP) - REPORT_NAME_DIGITAL(__LINE__, Z2_STOP_PIN) +#if PIN_EXISTS(V_STOP) + REPORT_NAME_DIGITAL(__LINE__, V_STOP_PIN) #endif -#if PIN_EXISTS(Z3_CS) - REPORT_NAME_DIGITAL(__LINE__, Z3_CS_PIN) + +#if PIN_EXISTS(W_MAX) + REPORT_NAME_DIGITAL(__LINE__, W_MAX_PIN) #endif -#if PIN_EXISTS(Z3_DIR) - REPORT_NAME_DIGITAL(__LINE__, Z3_DIR_PIN) +#if PIN_EXISTS(W_MIN) + REPORT_NAME_DIGITAL(__LINE__, W_MIN_PIN) #endif -#if PIN_EXISTS(Z3_ENABLE) - REPORT_NAME_DIGITAL(__LINE__, Z3_ENABLE_PIN) +#if PIN_EXISTS(W_STOP) + REPORT_NAME_DIGITAL(__LINE__, W_STOP_PIN) #endif -#if PIN_EXISTS(Z3_MAX) - REPORT_NAME_DIGITAL(__LINE__, Z3_MAX_PIN) + +#if PIN_EXISTS(E_STOP) + REPORT_NAME_DIGITAL(__LINE__, E_STOP_PIN) #endif -#if PIN_EXISTS(Z3_MIN) - REPORT_NAME_DIGITAL(__LINE__, Z3_MIN_PIN) + +// +// TMC Diagnostic - Sensorless Endstops +// +#if PIN_EXISTS(X_DIAG) + REPORT_NAME_DIGITAL(__LINE__, X_DIAG_PIN) #endif -#if PIN_EXISTS(Z3_MS1) - REPORT_NAME_DIGITAL(__LINE__, Z3_MS1_PIN) +#if PIN_EXISTS(X2_DIAG) + REPORT_NAME_DIGITAL(__LINE__, X2_DIAG_PIN) #endif -#if PIN_EXISTS(Z3_MS2) - REPORT_NAME_DIGITAL(__LINE__, Z3_MS2_PIN) +#if PIN_EXISTS(Y_DIAG) + REPORT_NAME_DIGITAL(__LINE__, Y_DIAG_PIN) #endif -#if PIN_EXISTS(Z3_MS3) - REPORT_NAME_DIGITAL(__LINE__, Z3_MS3_PIN) +#if PIN_EXISTS(Y2_DIAG) + REPORT_NAME_DIGITAL(__LINE__, Y2_DIAG_PIN) #endif -#if PIN_EXISTS(Z3_STEP) - REPORT_NAME_DIGITAL(__LINE__, Z3_STEP_PIN) +#if PIN_EXISTS(Z_DIAG) + REPORT_NAME_DIGITAL(__LINE__, Z_DIAG_PIN) #endif -#if PIN_EXISTS(Z4_CS) - REPORT_NAME_DIGITAL(__LINE__, Z4_CS_PIN) +#if PIN_EXISTS(Z2_DIAG) + REPORT_NAME_DIGITAL(__LINE__, Z2_DIAG_PIN) #endif -#if PIN_EXISTS(Z4_DIR) - REPORT_NAME_DIGITAL(__LINE__, Z4_DIR_PIN) +#if PIN_EXISTS(Z3_DIAG) + REPORT_NAME_DIGITAL(__LINE__, Z3_DIAG_PIN) #endif -#if PIN_EXISTS(Z4_ENABLE) - REPORT_NAME_DIGITAL(__LINE__, Z4_ENABLE_PIN) +#if PIN_EXISTS(Z4_DIAG) + REPORT_NAME_DIGITAL(__LINE__, Z4_DIAG_PIN) #endif -#if PIN_EXISTS(Z4_MAX) - REPORT_NAME_DIGITAL(__LINE__, Z4_MAX_PIN) +#if PIN_EXISTS(I_DIAG) + REPORT_NAME_DIGITAL(__LINE__, I_DIAG_PIN) #endif -#if PIN_EXISTS(Z4_MIN) - REPORT_NAME_DIGITAL(__LINE__, Z4_MIN_PIN) +#if PIN_EXISTS(J_DIAG) + REPORT_NAME_DIGITAL(__LINE__, J_DIAG_PIN) #endif -#if PIN_EXISTS(Z4_MS1) - REPORT_NAME_DIGITAL(__LINE__, Z4_MS1_PIN) +#if PIN_EXISTS(K_DIAG) + REPORT_NAME_DIGITAL(__LINE__, K_DIAG_PIN) #endif -#if PIN_EXISTS(Z4_MS2) - REPORT_NAME_DIGITAL(__LINE__, Z4_MS2_PIN) +#if PIN_EXISTS(U_DIAG) + REPORT_NAME_DIGITAL(__LINE__, U_DIAG_PIN) #endif -#if PIN_EXISTS(Z4_MS3) - REPORT_NAME_DIGITAL(__LINE__, Z4_MS3_PIN) +#if PIN_EXISTS(V_DIAG) + REPORT_NAME_DIGITAL(__LINE__, V_DIAG_PIN) #endif -#if PIN_EXISTS(Z4_STEP) - REPORT_NAME_DIGITAL(__LINE__, Z4_STEP_PIN) +#if PIN_EXISTS(W_DIAG) + REPORT_NAME_DIGITAL(__LINE__, W_DIAG_PIN) +#endif +#if PIN_EXISTS(E0_DIAG) + REPORT_NAME_DIGITAL(__LINE__, E0_DIAG_PIN) +#endif +#if PIN_EXISTS(E1_DIAG) + REPORT_NAME_DIGITAL(__LINE__, E1_DIAG_PIN) +#endif +#if PIN_EXISTS(E2_DIAG) + REPORT_NAME_DIGITAL(__LINE__, E2_DIAG_PIN) +#endif +#if PIN_EXISTS(E3_DIAG) + REPORT_NAME_DIGITAL(__LINE__, E3_DIAG_PIN) +#endif +#if PIN_EXISTS(E4_DIAG) + REPORT_NAME_DIGITAL(__LINE__, E4_DIAG_PIN) +#endif +#if PIN_EXISTS(E5_DIAG) + REPORT_NAME_DIGITAL(__LINE__, E5_DIAG_PIN) #endif +#if PIN_EXISTS(E6_DIAG) + REPORT_NAME_DIGITAL(__LINE__, E6_DIAG_PIN) +#endif +#if PIN_EXISTS(E7_DIAG) + REPORT_NAME_DIGITAL(__LINE__, E7_DIAG_PIN) +#endif + +// +// Probes +// #if PIN_EXISTS(Z_MIN_PROBE) REPORT_NAME_DIGITAL(__LINE__, Z_MIN_PROBE_PIN) #endif @@ -1448,23 +1558,212 @@ #if PIN_EXISTS(PROBE_TARE) REPORT_NAME_DIGITAL(__LINE__, PROBE_TARE_PIN) #endif -#if PIN_EXISTS(I_ATT) - REPORT_NAME_DIGITAL(__LINE__, I_ATT_PIN) + +// +// Stepper Drivers +// +#if PIN_EXISTS(X_DIR) + REPORT_NAME_DIGITAL(__LINE__, X_DIR_PIN) #endif -#if PIN_EXISTS(I_CS) - REPORT_NAME_DIGITAL(__LINE__, I_CS_PIN) +#if PIN_EXISTS(X_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, X_ENABLE_PIN) +#endif +#if PIN_EXISTS(X_STEP) + REPORT_NAME_DIGITAL(__LINE__, X_STEP_PIN) +#endif +#if PIN_EXISTS(X2_DIR) + REPORT_NAME_DIGITAL(__LINE__, X2_DIR_PIN) +#endif +#if PIN_EXISTS(X2_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, X2_ENABLE_PIN) +#endif +#if PIN_EXISTS(X2_STEP) + REPORT_NAME_DIGITAL(__LINE__, X2_STEP_PIN) +#endif +#if PIN_EXISTS(Y_DIR) + REPORT_NAME_DIGITAL(__LINE__, Y_DIR_PIN) +#endif +#if PIN_EXISTS(Y_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, Y_ENABLE_PIN) +#endif +#if PIN_EXISTS(Y_STEP) + REPORT_NAME_DIGITAL(__LINE__, Y_STEP_PIN) +#endif +#if PIN_EXISTS(Y2_DIR) + REPORT_NAME_DIGITAL(__LINE__, Y2_DIR_PIN) +#endif +#if PIN_EXISTS(Y2_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, Y2_ENABLE_PIN) +#endif +#if PIN_EXISTS(Y2_STEP) + REPORT_NAME_DIGITAL(__LINE__, Y2_STEP_PIN) +#endif +#if PIN_EXISTS(Z_DIR) + REPORT_NAME_DIGITAL(__LINE__, Z_DIR_PIN) +#endif +#if PIN_EXISTS(Z_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, Z_ENABLE_PIN) +#endif +#if PIN_EXISTS(Z_STEP) + REPORT_NAME_DIGITAL(__LINE__, Z_STEP_PIN) +#endif +#if PIN_EXISTS(Z2_DIR) + REPORT_NAME_DIGITAL(__LINE__, Z2_DIR_PIN) +#endif +#if PIN_EXISTS(Z2_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, Z2_ENABLE_PIN) +#endif +#if PIN_EXISTS(Z2_STEP) + REPORT_NAME_DIGITAL(__LINE__, Z2_STEP_PIN) +#endif +#if PIN_EXISTS(Z3_DIR) + REPORT_NAME_DIGITAL(__LINE__, Z3_DIR_PIN) +#endif +#if PIN_EXISTS(Z3_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, Z3_ENABLE_PIN) +#endif +#if PIN_EXISTS(Z3_STEP) + REPORT_NAME_DIGITAL(__LINE__, Z3_STEP_PIN) +#endif +#if PIN_EXISTS(Z4_DIR) + REPORT_NAME_DIGITAL(__LINE__, Z4_DIR_PIN) +#endif +#if PIN_EXISTS(Z4_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, Z4_ENABLE_PIN) +#endif +#if PIN_EXISTS(Z4_STEP) + REPORT_NAME_DIGITAL(__LINE__, Z4_STEP_PIN) #endif + #if PIN_EXISTS(I_DIR) REPORT_NAME_DIGITAL(__LINE__, I_DIR_PIN) #endif #if PIN_EXISTS(I_ENABLE) REPORT_NAME_DIGITAL(__LINE__, I_ENABLE_PIN) #endif -#if PIN_EXISTS(I_MAX) - REPORT_NAME_DIGITAL(__LINE__, I_MAX_PIN) +#if PIN_EXISTS(I_STEP) + REPORT_NAME_DIGITAL(__LINE__, I_STEP_PIN) #endif -#if PIN_EXISTS(I_MIN) - REPORT_NAME_DIGITAL(__LINE__, I_MIN_PIN) +#if PIN_EXISTS(J_DIR) + REPORT_NAME_DIGITAL(__LINE__, J_DIR_PIN) +#endif +#if PIN_EXISTS(J_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, J_ENABLE_PIN) +#endif +#if PIN_EXISTS(J_STEP) + REPORT_NAME_DIGITAL(__LINE__, J_STEP_PIN) +#endif +#if PIN_EXISTS(K_DIR) + REPORT_NAME_DIGITAL(__LINE__, K_DIR_PIN) +#endif +#if PIN_EXISTS(K_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, K_ENABLE_PIN) +#endif +#if PIN_EXISTS(K_STEP) + REPORT_NAME_DIGITAL(__LINE__, K_STEP_PIN) +#endif +#if PIN_EXISTS(U_DIR) + REPORT_NAME_DIGITAL(__LINE__, U_DIR_PIN) +#endif +#if PIN_EXISTS(U_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, U_ENABLE_PIN) +#endif +#if PIN_EXISTS(U_STEP) + REPORT_NAME_DIGITAL(__LINE__, U_STEP_PIN) +#endif +#if PIN_EXISTS(V_DIR) + REPORT_NAME_DIGITAL(__LINE__, V_DIR_PIN) +#endif +#if PIN_EXISTS(V_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, V_ENABLE_PIN) +#endif +#if PIN_EXISTS(V_STEP) + REPORT_NAME_DIGITAL(__LINE__, V_STEP_PIN) +#endif +#if PIN_EXISTS(W_DIR) + REPORT_NAME_DIGITAL(__LINE__, W_DIR_PIN) +#endif +#if PIN_EXISTS(W_ENABLE) + REPORT_NAME_DIGITAL(__LINE__, W_ENABLE_PIN) +#endif +#if PIN_EXISTS(W_STEP) + REPORT_NAME_DIGITAL(__LINE__, W_STEP_PIN) +#endif + +// +// Digital Micro-steps +// +#if PIN_EXISTS(X_MS1) + REPORT_NAME_DIGITAL(__LINE__, X_MS1_PIN) +#endif +#if PIN_EXISTS(X_MS2) + REPORT_NAME_DIGITAL(__LINE__, X_MS2_PIN) +#endif +#if PIN_EXISTS(X_MS3) + REPORT_NAME_DIGITAL(__LINE__, X_MS3_PIN) +#endif +#if PIN_EXISTS(X2_MS1) + REPORT_NAME_DIGITAL(__LINE__, X2_MS1_PIN) +#endif +#if PIN_EXISTS(X2_MS2) + REPORT_NAME_DIGITAL(__LINE__, X2_MS2_PIN) +#endif +#if PIN_EXISTS(X2_MS3) + REPORT_NAME_DIGITAL(__LINE__, X2_MS3_PIN) +#endif +#if PIN_EXISTS(Y_MS1) + REPORT_NAME_DIGITAL(__LINE__, Y_MS1_PIN) +#endif +#if PIN_EXISTS(Y_MS2) + REPORT_NAME_DIGITAL(__LINE__, Y_MS2_PIN) +#endif +#if PIN_EXISTS(Y_MS3) + REPORT_NAME_DIGITAL(__LINE__, Y_MS3_PIN) +#endif +#if PIN_EXISTS(Y2_MS1) + REPORT_NAME_DIGITAL(__LINE__, Y2_MS1_PIN) +#endif +#if PIN_EXISTS(Y2_MS2) + REPORT_NAME_DIGITAL(__LINE__, Y2_MS2_PIN) +#endif +#if PIN_EXISTS(Y2_MS3) + REPORT_NAME_DIGITAL(__LINE__, Y2_MS3_PIN) +#endif +#if PIN_EXISTS(Z_MS1) + REPORT_NAME_DIGITAL(__LINE__, Z_MS1_PIN) +#endif +#if PIN_EXISTS(Z_MS2) + REPORT_NAME_DIGITAL(__LINE__, Z_MS2_PIN) +#endif +#if PIN_EXISTS(Z_MS3) + REPORT_NAME_DIGITAL(__LINE__, Z_MS3_PIN) +#endif +#if PIN_EXISTS(Z2_MS1) + REPORT_NAME_DIGITAL(__LINE__, Z2_MS1_PIN) +#endif +#if PIN_EXISTS(Z2_MS2) + REPORT_NAME_DIGITAL(__LINE__, Z2_MS2_PIN) +#endif +#if PIN_EXISTS(Z2_MS3) + REPORT_NAME_DIGITAL(__LINE__, Z2_MS3_PIN) +#endif +#if PIN_EXISTS(Z3_MS1) + REPORT_NAME_DIGITAL(__LINE__, Z3_MS1_PIN) +#endif +#if PIN_EXISTS(Z3_MS2) + REPORT_NAME_DIGITAL(__LINE__, Z3_MS2_PIN) +#endif +#if PIN_EXISTS(Z3_MS3) + REPORT_NAME_DIGITAL(__LINE__, Z3_MS3_PIN) +#endif +#if PIN_EXISTS(Z4_MS1) + REPORT_NAME_DIGITAL(__LINE__, Z4_MS1_PIN) +#endif +#if PIN_EXISTS(Z4_MS2) + REPORT_NAME_DIGITAL(__LINE__, Z4_MS2_PIN) +#endif +#if PIN_EXISTS(Z4_MS3) + REPORT_NAME_DIGITAL(__LINE__, Z4_MS3_PIN) #endif #if PIN_EXISTS(I_MS1) REPORT_NAME_DIGITAL(__LINE__, I_MS1_PIN) @@ -1475,183 +1774,231 @@ #if PIN_EXISTS(I_MS3) REPORT_NAME_DIGITAL(__LINE__, I_MS3_PIN) #endif -#if PIN_EXISTS(I_STEP) - REPORT_NAME_DIGITAL(__LINE__, I_STEP_PIN) +#if PIN_EXISTS(J_MS1) + REPORT_NAME_DIGITAL(__LINE__, J_MS1_PIN) #endif -#if PIN_EXISTS(I_STOP) - REPORT_NAME_DIGITAL(__LINE__, I_STOP_PIN) +#if PIN_EXISTS(J_MS2) + REPORT_NAME_DIGITAL(__LINE__, J_MS2_PIN) #endif -#if PIN_EXISTS(J_ATT) - REPORT_NAME_DIGITAL(__LINE__, J_ATT_PIN) +#if PIN_EXISTS(J_MS3) + REPORT_NAME_DIGITAL(__LINE__, J_MS3_PIN) #endif -#if PIN_EXISTS(J_CS) - REPORT_NAME_DIGITAL(__LINE__, J_CS_PIN) +#if PIN_EXISTS(K_MS1) + REPORT_NAME_DIGITAL(__LINE__, K_MS1_PIN) #endif -#if PIN_EXISTS(J_DIR) - REPORT_NAME_DIGITAL(__LINE__, J_DIR_PIN) +#if PIN_EXISTS(K_MS2) + REPORT_NAME_DIGITAL(__LINE__, K_MS2_PIN) #endif -#if PIN_EXISTS(J_ENABLE) - REPORT_NAME_DIGITAL(__LINE__, J_ENABLE_PIN) +#if PIN_EXISTS(K_MS3) + REPORT_NAME_DIGITAL(__LINE__, K_MS3_PIN) #endif -#if PIN_EXISTS(J_MAX) - REPORT_NAME_DIGITAL(__LINE__, J_MAX_PIN) +#if PIN_EXISTS(U_MS1) + REPORT_NAME_DIGITAL(__LINE__, U_MS1_PIN) #endif -#if PIN_EXISTS(J_MIN) - REPORT_NAME_DIGITAL(__LINE__, J_MIN_PIN) +#if PIN_EXISTS(U_MS2) + REPORT_NAME_DIGITAL(__LINE__, U_MS2_PIN) #endif -#if PIN_EXISTS(J_MS1) - REPORT_NAME_DIGITAL(__LINE__, J_MS1_PIN) +#if PIN_EXISTS(U_MS3) + REPORT_NAME_DIGITAL(__LINE__, U_MS3_PIN) #endif -#if PIN_EXISTS(J_MS2) - REPORT_NAME_DIGITAL(__LINE__, J_MS2_PIN) +#if PIN_EXISTS(V_MS1) + REPORT_NAME_DIGITAL(__LINE__, V_MS1_PIN) +#endif +#if PIN_EXISTS(V_MS2) + REPORT_NAME_DIGITAL(__LINE__, V_MS2_PIN) +#endif +#if PIN_EXISTS(V_MS3) + REPORT_NAME_DIGITAL(__LINE__, V_MS3_PIN) +#endif +#if PIN_EXISTS(W_MS1) + REPORT_NAME_DIGITAL(__LINE__, W_MS1_PIN) +#endif +#if PIN_EXISTS(W_MS2) + REPORT_NAME_DIGITAL(__LINE__, W_MS2_PIN) +#endif +#if PIN_EXISTS(W_MS3) + REPORT_NAME_DIGITAL(__LINE__, W_MS3_PIN) +#endif +#if PIN_EXISTS(E0_MS1) + REPORT_NAME_DIGITAL(__LINE__, E0_MS1_PIN) +#endif +#if PIN_EXISTS(E0_MS2) + REPORT_NAME_DIGITAL(__LINE__, E0_MS2_PIN) +#endif +#if PIN_EXISTS(E0_MS3) + REPORT_NAME_DIGITAL(__LINE__, E0_MS3_PIN) +#endif +#if PIN_EXISTS(E1_MS1) + REPORT_NAME_DIGITAL(__LINE__, E1_MS1_PIN) +#endif +#if PIN_EXISTS(E1_MS2) + REPORT_NAME_DIGITAL(__LINE__, E1_MS2_PIN) +#endif +#if PIN_EXISTS(E1_MS3) + REPORT_NAME_DIGITAL(__LINE__, E1_MS3_PIN) +#endif +#if PIN_EXISTS(E2_MS1) + REPORT_NAME_DIGITAL(__LINE__, E2_MS1_PIN) #endif -#if PIN_EXISTS(J_MS3) - REPORT_NAME_DIGITAL(__LINE__, J_MS3_PIN) +#if PIN_EXISTS(E2_MS2) + REPORT_NAME_DIGITAL(__LINE__, E2_MS2_PIN) #endif -#if PIN_EXISTS(J_STEP) - REPORT_NAME_DIGITAL(__LINE__, J_STEP_PIN) +#if PIN_EXISTS(E2_MS3) + REPORT_NAME_DIGITAL(__LINE__, E2_MS3_PIN) #endif -#if PIN_EXISTS(J_STOP) - REPORT_NAME_DIGITAL(__LINE__, J_STOP_PIN) +#if PIN_EXISTS(E3_MS1) + REPORT_NAME_DIGITAL(__LINE__, E3_MS1_PIN) #endif -#if PIN_EXISTS(K_ATT) - REPORT_NAME_DIGITAL(__LINE__, K_ATT_PIN) +#if PIN_EXISTS(E3_MS2) + REPORT_NAME_DIGITAL(__LINE__, E3_MS2_PIN) #endif -#if PIN_EXISTS(K_CS) - REPORT_NAME_DIGITAL(__LINE__, K_CS_PIN) +#if PIN_EXISTS(E3_MS3) + REPORT_NAME_DIGITAL(__LINE__, E3_MS3_PIN) #endif -#if PIN_EXISTS(K_DIR) - REPORT_NAME_DIGITAL(__LINE__, K_DIR_PIN) +#if PIN_EXISTS(E4_MS1) + REPORT_NAME_DIGITAL(__LINE__, E4_MS1_PIN) #endif -#if PIN_EXISTS(K_ENABLE) - REPORT_NAME_DIGITAL(__LINE__, K_ENABLE_PIN) +#if PIN_EXISTS(E4_MS2) + REPORT_NAME_DIGITAL(__LINE__, E4_MS2_PIN) #endif -#if PIN_EXISTS(K_MAX) - REPORT_NAME_DIGITAL(__LINE__, K_MAX_PIN) +#if PIN_EXISTS(E4_MS3) + REPORT_NAME_DIGITAL(__LINE__, E4_MS3_PIN) #endif -#if PIN_EXISTS(K_MIN) - REPORT_NAME_DIGITAL(__LINE__, K_MIN_PIN) +#if PIN_EXISTS(E5_MS1) + REPORT_NAME_DIGITAL(__LINE__, E5_MS1_PIN) #endif -#if PIN_EXISTS(K_MS1) - REPORT_NAME_DIGITAL(__LINE__, K_MS1_PIN) +#if PIN_EXISTS(E5_MS2) + REPORT_NAME_DIGITAL(__LINE__, E5_MS2_PIN) #endif -#if PIN_EXISTS(K_MS2) - REPORT_NAME_DIGITAL(__LINE__, K_MS2_PIN) +#if PIN_EXISTS(E5_MS3) + REPORT_NAME_DIGITAL(__LINE__, E5_MS3_PIN) #endif -#if PIN_EXISTS(K_MS3) - REPORT_NAME_DIGITAL(__LINE__, K_MS3_PIN) +#if PIN_EXISTS(E6_MS1) + REPORT_NAME_DIGITAL(__LINE__, E6_MS1_PIN) #endif -#if PIN_EXISTS(K_STEP) - REPORT_NAME_DIGITAL(__LINE__, K_STEP_PIN) +#if PIN_EXISTS(E6_MS2) + REPORT_NAME_DIGITAL(__LINE__, E6_MS2_PIN) #endif -#if PIN_EXISTS(K_STOP) - REPORT_NAME_DIGITAL(__LINE__, K_STOP_PIN) +#if PIN_EXISTS(E6_MS3) + REPORT_NAME_DIGITAL(__LINE__, E6_MS3_PIN) #endif -#if PIN_EXISTS(U_ATT) - REPORT_NAME_DIGITAL(__LINE__, U_ATT_PIN) +#if PIN_EXISTS(E7_MS1) + REPORT_NAME_DIGITAL(__LINE__, E7_MS1_PIN) #endif -#if PIN_EXISTS(U_CS) - REPORT_NAME_DIGITAL(__LINE__, U_CS_PIN) +#if PIN_EXISTS(E7_MS2) + REPORT_NAME_DIGITAL(__LINE__, E7_MS2_PIN) #endif -#if PIN_EXISTS(U_DIR) - REPORT_NAME_DIGITAL(__LINE__, U_DIR_PIN) +#if PIN_EXISTS(E7_MS3) + REPORT_NAME_DIGITAL(__LINE__, E7_MS3_PIN) #endif -#if PIN_EXISTS(U_ENABLE) - REPORT_NAME_DIGITAL(__LINE__, U_ENABLE_PIN) + +// +// Stepper Standby +// +#if PIN_EXISTS(X_STDBY) + REPORT_NAME_DIGITAL(__LINE__, X_STDBY_PIN) #endif -#if PIN_EXISTS(U_MAX) - REPORT_NAME_DIGITAL(__LINE__, U_MAX_PIN) +#if PIN_EXISTS(X2_STDBY) + REPORT_NAME_DIGITAL(__LINE__, X2_STDBY_PIN) #endif -#if PIN_EXISTS(U_MIN) - REPORT_NAME_DIGITAL(__LINE__, U_MIN_PIN) +#if PIN_EXISTS(Y_STDBY) + REPORT_NAME_DIGITAL(__LINE__, Y_STDBY_PIN) #endif -#if PIN_EXISTS(U_MS1) - REPORT_NAME_DIGITAL(__LINE__, U_MS1_PIN) +#if PIN_EXISTS(Y2_STDBY) + REPORT_NAME_DIGITAL(__LINE__, Y2_STDBY_PIN) #endif -#if PIN_EXISTS(U_MS2) - REPORT_NAME_DIGITAL(__LINE__, U_MS2_PIN) +#if PIN_EXISTS(Z_STDBY) + REPORT_NAME_DIGITAL(__LINE__, Z_STDBY_PIN) #endif -#if PIN_EXISTS(U_MS3) - REPORT_NAME_DIGITAL(__LINE__, U_MS3_PIN) +#if PIN_EXISTS(Z2_STDBY) + REPORT_NAME_DIGITAL(__LINE__, Z2_STDBY_PIN) #endif -#if PIN_EXISTS(U_STEP) - REPORT_NAME_DIGITAL(__LINE__, U_STEP_PIN) +#if PIN_EXISTS(Z3_STDBY) + REPORT_NAME_DIGITAL(__LINE__, Z3_STDBY_PIN) #endif -#if PIN_EXISTS(U_STOP) - REPORT_NAME_DIGITAL(__LINE__, U_STOP_PIN) +#if PIN_EXISTS(Z4_STDBY) + REPORT_NAME_DIGITAL(__LINE__, Z4_STDBY_PIN) #endif -#if PIN_EXISTS(V_ATT) - REPORT_NAME_DIGITAL(__LINE__, V_ATT_PIN) +#if PIN_EXISTS(I_STDBY) + REPORT_NAME_DIGITAL(__LINE__, I_STDBY_PIN) #endif -#if PIN_EXISTS(V_CS) - REPORT_NAME_DIGITAL(__LINE__, V_CS_PIN) +#if PIN_EXISTS(J_STDBY) + REPORT_NAME_DIGITAL(__LINE__, J_STDBY_PIN) #endif -#if PIN_EXISTS(V_DIR) - REPORT_NAME_DIGITAL(__LINE__, V_DIR_PIN) +#if PIN_EXISTS(K_STDBY) + REPORT_NAME_DIGITAL(__LINE__, K_STDBY_PIN) #endif -#if PIN_EXISTS(V_ENABLE) - REPORT_NAME_DIGITAL(__LINE__, V_ENABLE_PIN) +#if PIN_EXISTS(U_STDBY) + REPORT_NAME_DIGITAL(__LINE__, U_STDBY_PIN) #endif -#if PIN_EXISTS(V_MAX) - REPORT_NAME_DIGITAL(__LINE__, V_MAX_PIN) +#if PIN_EXISTS(V_STDBY) + REPORT_NAME_DIGITAL(__LINE__, V_STDBY_PIN) #endif -#if PIN_EXISTS(V_MIN) - REPORT_NAME_DIGITAL(__LINE__, V_MIN_PIN) +#if PIN_EXISTS(W_STDBY) + REPORT_NAME_DIGITAL(__LINE__, W_STDBY_PIN) #endif -#if PIN_EXISTS(V_MS1) - REPORT_NAME_DIGITAL(__LINE__, V_MS1_PIN) +#if PIN_EXISTS(E0_STDBY) + REPORT_NAME_DIGITAL(__LINE__, E0_STDBY_PIN) #endif -#if PIN_EXISTS(V_MS2) - REPORT_NAME_DIGITAL(__LINE__, V_MS2_PIN) +#if PIN_EXISTS(E1_STDBY) + REPORT_NAME_DIGITAL(__LINE__, E1_STDBY_PIN) #endif -#if PIN_EXISTS(V_MS3) - REPORT_NAME_DIGITAL(__LINE__, V_MS3_PIN) +#if PIN_EXISTS(E2_STDBY) + REPORT_NAME_DIGITAL(__LINE__, E2_STDBY_PIN) #endif -#if PIN_EXISTS(V_STEP) - REPORT_NAME_DIGITAL(__LINE__, V_STEP_PIN) +#if PIN_EXISTS(E3_STDBY) + REPORT_NAME_DIGITAL(__LINE__, E3_STDBY_PIN) #endif -#if PIN_EXISTS(V_STOP) - REPORT_NAME_DIGITAL(__LINE__, V_STOP_PIN) +#if PIN_EXISTS(E4_STDBY) + REPORT_NAME_DIGITAL(__LINE__, E4_STDBY_PIN) #endif -#if PIN_EXISTS(W_ATT) - REPORT_NAME_DIGITAL(__LINE__, W_ATT_PIN) +#if PIN_EXISTS(E5_STDBY) + REPORT_NAME_DIGITAL(__LINE__, E5_STDBY_PIN) #endif -#if PIN_EXISTS(W_CS) - REPORT_NAME_DIGITAL(__LINE__, W_CS_PIN) +#if PIN_EXISTS(E6_STDBY) + REPORT_NAME_DIGITAL(__LINE__, E6_STDBY_PIN) #endif -#if PIN_EXISTS(W_DIR) - REPORT_NAME_DIGITAL(__LINE__, W_DIR_PIN) +#if PIN_EXISTS(E7_STDBY) + REPORT_NAME_DIGITAL(__LINE__, E7_STDBY_PIN) #endif -#if PIN_EXISTS(W_ENABLE) - REPORT_NAME_DIGITAL(__LINE__, W_ENABLE_PIN) + +// +// LV8731V Current Attenuation +// +#if PIN_EXISTS(X_ATT) + REPORT_NAME_DIGITAL(__LINE__, X_ATT_PIN) #endif -#if PIN_EXISTS(W_MAX) - REPORT_NAME_DIGITAL(__LINE__, W_MAX_PIN) +#if PIN_EXISTS(Y_ATT) + REPORT_NAME_DIGITAL(__LINE__, Y_ATT_PIN) #endif -#if PIN_EXISTS(W_MIN) - REPORT_NAME_DIGITAL(__LINE__, W_MIN_PIN) +#if PIN_EXISTS(E0_ATT) + REPORT_NAME_DIGITAL(__LINE__, E0_ATT_PIN) #endif -#if PIN_EXISTS(W_MS1) - REPORT_NAME_DIGITAL(__LINE__, W_MS1_PIN) +#if PIN_EXISTS(Z_ATT) + REPORT_NAME_DIGITAL(__LINE__, Z_ATT_PIN) #endif -#if PIN_EXISTS(W_MS2) - REPORT_NAME_DIGITAL(__LINE__, W_MS2_PIN) +#if PIN_EXISTS(I_ATT) + REPORT_NAME_DIGITAL(__LINE__, I_ATT_PIN) #endif -#if PIN_EXISTS(W_MS3) - REPORT_NAME_DIGITAL(__LINE__, W_MS3_PIN) +#if PIN_EXISTS(J_ATT) + REPORT_NAME_DIGITAL(__LINE__, J_ATT_PIN) #endif -#if PIN_EXISTS(W_STEP) - REPORT_NAME_DIGITAL(__LINE__, W_STEP_PIN) +#if PIN_EXISTS(K_ATT) + REPORT_NAME_DIGITAL(__LINE__, K_ATT_PIN) #endif -#if PIN_EXISTS(W_STOP) - REPORT_NAME_DIGITAL(__LINE__, W_STOP_PIN) +#if PIN_EXISTS(U_ATT) + REPORT_NAME_DIGITAL(__LINE__, U_ATT_PIN) #endif -#if PIN_EXISTS(ZRIB_V20_D6) - REPORT_NAME_DIGITAL(__LINE__, ZRIB_V20_D6_PIN) +#if PIN_EXISTS(V_ATT) + REPORT_NAME_DIGITAL(__LINE__, V_ATT_PIN) #endif -#if PIN_EXISTS(ZRIB_V20_D9) - REPORT_NAME_DIGITAL(__LINE__, ZRIB_V20_D9_PIN) +#if PIN_EXISTS(W_ATT) + REPORT_NAME_DIGITAL(__LINE__, W_ATT_PIN) #endif + +// +// TMC Serial UART +// #if PIN_EXISTS(X_SERIAL_TX) REPORT_NAME_DIGITAL(__LINE__, X_SERIAL_TX_PIN) #endif @@ -1736,99 +2083,59 @@ #if PIN_EXISTS(W_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, W_SERIAL_RX_PIN) #endif -#if PIN_EXISTS(E0_DIAG) - REPORT_NAME_DIGITAL(__LINE__, E0_DIAG_PIN) -#endif + #if PIN_EXISTS(E0_SERIAL_TX) REPORT_NAME_DIGITAL(__LINE__, E0_SERIAL_TX_PIN) #endif #if PIN_EXISTS(E0_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, E0_SERIAL_RX_PIN) #endif -#if PIN_EXISTS(E1_DIAG) - REPORT_NAME_DIGITAL(__LINE__, E1_DIAG_PIN) -#endif #if PIN_EXISTS(E1_SERIAL_TX) REPORT_NAME_DIGITAL(__LINE__, E1_SERIAL_TX_PIN) #endif #if PIN_EXISTS(E1_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, E1_SERIAL_RX_PIN) #endif -#if PIN_EXISTS(E2_DIAG) - REPORT_NAME_DIGITAL(__LINE__, E2_DIAG_PIN) -#endif #if PIN_EXISTS(E2_SERIAL_TX) REPORT_NAME_DIGITAL(__LINE__, E2_SERIAL_TX_PIN) #endif #if PIN_EXISTS(E2_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, E2_SERIAL_RX_PIN) #endif -#if PIN_EXISTS(E3_DIAG) - REPORT_NAME_DIGITAL(__LINE__, E3_DIAG_PIN) -#endif #if PIN_EXISTS(E3_SERIAL_TX) REPORT_NAME_DIGITAL(__LINE__, E3_SERIAL_TX_PIN) #endif #if PIN_EXISTS(E3_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, E3_SERIAL_RX_PIN) #endif -#if PIN_EXISTS(E4_DIAG) - REPORT_NAME_DIGITAL(__LINE__, E4_DIAG_PIN) -#endif #if PIN_EXISTS(E4_SERIAL_TX) REPORT_NAME_DIGITAL(__LINE__, E4_SERIAL_TX_PIN) #endif #if PIN_EXISTS(E4_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, E4_SERIAL_RX_PIN) #endif -#if PIN_EXISTS(E5_DIAG) - REPORT_NAME_DIGITAL(__LINE__, E5_DIAG_PIN) -#endif #if PIN_EXISTS(E5_SERIAL_TX) REPORT_NAME_DIGITAL(__LINE__, E5_SERIAL_TX_PIN) #endif #if PIN_EXISTS(E5_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, E5_SERIAL_RX_PIN) #endif -#if PIN_EXISTS(E6_DIAG) - REPORT_NAME_DIGITAL(__LINE__, E6_DIAG_PIN) -#endif #if PIN_EXISTS(E6_SERIAL_TX) REPORT_NAME_DIGITAL(__LINE__, E6_SERIAL_TX_PIN) #endif #if PIN_EXISTS(E6_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, E6_SERIAL_RX_PIN) #endif -#if PIN_EXISTS(E7_DIAG) - REPORT_NAME_DIGITAL(__LINE__, E7_DIAG_PIN) -#endif #if PIN_EXISTS(E7_SERIAL_TX) REPORT_NAME_DIGITAL(__LINE__, E7_SERIAL_TX_PIN) #endif #if PIN_EXISTS(E7_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, E7_SERIAL_RX_PIN) #endif -#if PIN_EXISTS(I_SERIAL_TX) - REPORT_NAME_DIGITAL(__LINE__, I_SERIAL_TX_PIN) -#endif -#if PIN_EXISTS(I_SERIAL_RX) - REPORT_NAME_DIGITAL(__LINE__, I_SERIAL_RX_PIN) -#endif -#if PIN_EXISTS(J_SERIAL_TX) - REPORT_NAME_DIGITAL(__LINE__, J_SERIAL_TX_PIN) -#endif -#if PIN_EXISTS(J_SERIAL_RX) - REPORT_NAME_DIGITAL(__LINE__, J_SERIAL_RX_PIN) -#endif -#if PIN_EXISTS(K_SERIAL_TX) - REPORT_NAME_DIGITAL(__LINE__, K_SERIAL_TX_PIN) -#endif -#if PIN_EXISTS(K_SERIAL_RX) - REPORT_NAME_DIGITAL(__LINE__, K_SERIAL_RX_PIN) -#endif -#if PIN_EXISTS(FET_SAFETY) - REPORT_NAME_DIGITAL(__LINE__, FET_SAFETY_PIN) -#endif + +// +// Touch Screen +// #if PIN_EXISTS(TOUCH_MISO) REPORT_NAME_DIGITAL(__LINE__, TOUCH_MISO_PIN) #endif @@ -1844,27 +2151,51 @@ #if PIN_EXISTS(TOUCH_INT) REPORT_NAME_DIGITAL(__LINE__, TOUCH_INT_PIN) #endif + +// +// USB +// #if PIN_EXISTS(USB_CS) REPORT_NAME_DIGITAL(__LINE__, USB_CS_PIN) #endif #if PIN_EXISTS(USB_INTR) REPORT_NAME_DIGITAL(__LINE__, USB_INTR_PIN) #endif + +// +// MMU2 +// #if PIN_EXISTS(MMU2_RST) REPORT_NAME_DIGITAL(__LINE__, MMU2_RST_PIN) #endif + +// +// G425 Axis Calibration +// #if PIN_EXISTS(CALIBRATION) REPORT_NAME_DIGITAL(__LINE__, CALIBRATION_PIN) #endif + +// +// Duet Smart Effector +// #if PIN_EXISTS(SMART_EFFECTOR_MOD) REPORT_NAME_DIGITAL(__LINE__, SMART_EFFECTOR_MOD_PIN) #endif + +// +// Closed Loop +// #if PIN_EXISTS(CLOSED_LOOP_ENABLE) REPORT_NAME_DIGITAL(__LINE__, CLOSED_LOOP_ENABLE_PIN) #endif #if PIN_EXISTS(CLOSED_LOOP_MOVE_COMPLETE) REPORT_NAME_DIGITAL(__LINE__, CLOSED_LOOP_MOVE_COMPLETE_PIN) #endif + +// +// ESP WiFi +// #if PIN_EXISTS(ESP_WIFI_MODULE_RESET) REPORT_NAME_DIGITAL(__LINE__, ESP_WIFI_MODULE_RESET_PIN) #endif @@ -1877,7 +2208,10 @@ #if PIN_EXISTS(ESP_WIFI_MODULE_GPIO2) REPORT_NAME_DIGITAL(__LINE__, ESP_WIFI_MODULE_GPIO2_PIN) #endif -// TFT PINS + +// +// TFT +// #if PIN_EXISTS(TFT_CS) REPORT_NAME_DIGITAL(__LINE__, TFT_CS_PIN) #endif @@ -1896,3 +2230,10 @@ #if PIN_EXISTS(TFT_RESET) REPORT_NAME_DIGITAL(__LINE__, TFT_RESET_PIN) #endif + +// +// Miscellaneous +// +#if _EXISTS(UNUSED_PWM) + REPORT_NAME_DIGITAL(__LINE__, UNUSED_PWM) +#endif diff --git a/Marlin/src/pins/ramps/pins_RIGIDBOARD.h b/Marlin/src/pins/ramps/pins_RIGIDBOARD.h index 2d68577f7c86..273e0274a8e7 100644 --- a/Marlin/src/pins/ramps/pins_RIGIDBOARD.h +++ b/Marlin/src/pins/ramps/pins_RIGIDBOARD.h @@ -103,9 +103,9 @@ // Direction buttons #define BTN_UP 37 - #define BTN_DWN 35 - #define BTN_LFT 33 - #define BTN_RT 32 + #define BTN_DOWN 35 + #define BTN_LEFT 33 + #define BTN_RIGHT 32 // 'R' button #undef BTN_ENC diff --git a/Marlin/src/pins/ramps/pins_ULTIMAIN_2.h b/Marlin/src/pins/ramps/pins_ULTIMAIN_2.h index 128f1974e0e6..0b15cd35ade9 100644 --- a/Marlin/src/pins/ramps/pins_ULTIMAIN_2.h +++ b/Marlin/src/pins/ramps/pins_ULTIMAIN_2.h @@ -107,8 +107,8 @@ #define SDSS 53 #define SD_DETECT_PIN 39 #define LED_PIN 8 -#define SAFETY_TRIGGERED_PIN 28 // PIN to detect the safety circuit has triggered -#define MAIN_VOLTAGE_MEASURE_PIN 14 // ANALOG PIN to measure the main voltage, with a 100k - 4k7 resitor divider. +//#define SAFETY_TRIGGERED_PIN 28 // PIN to detect the safety circuit has triggered +//#define MAIN_VOLTAGE_MEASURE_PIN 14 // ANALOG PIN to measure the main voltage, with a 100k - 4k7 resitor divider. // // LCD / Controller diff --git a/Marlin/src/pins/ramps/pins_ZRIB_V20.h b/Marlin/src/pins/ramps/pins_ZRIB_V20.h index e9328ca7bae9..3078b9f77bbe 100644 --- a/Marlin/src/pins/ramps/pins_ZRIB_V20.h +++ b/Marlin/src/pins/ramps/pins_ZRIB_V20.h @@ -28,31 +28,20 @@ #include "pins_MKS_GEN_13.h" // ... RAMPS -#define ZRIB_V20_D6_PIN 6 // Fan -#define ZRIB_V20_D9_PIN 9 // Fan2 -#define ZRIB_V20_A10_PIN 10 -#define ZRIB_V20_D16_PIN 16 -#define ZRIB_V20_D17_PIN 17 -#define ZRIB_V20_D23_PIN 23 -#define ZRIB_V20_D25_PIN 25 -#define ZRIB_V20_D27_PIN 27 -#define ZRIB_V20_D29_PIN 29 -#define ZRIB_V20_D37_PIN 37 - // // Auto fans // #ifndef E0_AUTO_FAN_PIN - #define E0_AUTO_FAN_PIN ZRIB_V20_D6_PIN + #define E0_AUTO_FAN_PIN 6 // Fan #endif #ifndef E1_AUTO_FAN_PIN - #define E1_AUTO_FAN_PIN ZRIB_V20_D6_PIN + #define E1_AUTO_FAN_PIN 6 #endif #ifndef E2_AUTO_FAN_PIN - #define E2_AUTO_FAN_PIN ZRIB_V20_D6_PIN + #define E2_AUTO_FAN_PIN 6 #endif #ifndef E3_AUTO_FAN_PIN - #define E3_AUTO_FAN_PIN ZRIB_V20_D6_PIN + #define E3_AUTO_FAN_PIN 6 #endif #ifndef FILWIDTH_PIN @@ -76,12 +65,12 @@ #undef BTN_EN2 #undef BTN_ENC - #define LCD_PINS_RS ZRIB_V20_D16_PIN - #define LCD_PINS_ENABLE ZRIB_V20_D17_PIN - #define LCD_PINS_D4 ZRIB_V20_D23_PIN - #define LCD_PINS_D5 ZRIB_V20_D25_PIN - #define LCD_PINS_D6 ZRIB_V20_D27_PIN - #define LCD_PINS_D7 ZRIB_V20_D29_PIN - #define ADC_KEYPAD_PIN ZRIB_V20_A10_PIN - #define BEEPER_PIN ZRIB_V20_D37_PIN + #define LCD_PINS_RS 16 + #define LCD_PINS_ENABLE 17 + #define LCD_PINS_D4 23 + #define LCD_PINS_D5 25 + #define LCD_PINS_D6 27 + #define LCD_PINS_D7 29 + #define ADC_KEYPAD_PIN 10 // Analog Input + #define BEEPER_PIN 37 #endif From 6b1d738995c443f5d047d79130a146dce3f7e9e0 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Thu, 20 Oct 2022 14:29:15 +1300 Subject: [PATCH 113/243] =?UTF-8?q?=F0=9F=94=A7=20No=20Native=20USB=20on?= =?UTF-8?q?=20AVR=20(#24906)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/AVR/HAL.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Marlin/src/HAL/AVR/HAL.h b/Marlin/src/HAL/AVR/HAL.h index 149186772158..d458790979ff 100644 --- a/Marlin/src/HAL/AVR/HAL.h +++ b/Marlin/src/HAL/AVR/HAL.h @@ -32,6 +32,7 @@ #include #else #include "MarlinSerial.h" + #define BOARD_NO_NATIVE_USB #endif #include @@ -106,36 +107,36 @@ typedef Servo hal_servo_t; #define MYSERIAL1 TERN(BLUETOOTH, btSerial, MSerial0) #else - #if !WITHIN(SERIAL_PORT, -1, 3) - #error "SERIAL_PORT must be from 0 to 3, or -1 for USB Serial." + #if !WITHIN(SERIAL_PORT, 0, 3) + #error "SERIAL_PORT must be from 0 to 3." #endif #define MYSERIAL1 customizedSerial1 #ifdef SERIAL_PORT_2 - #if !WITHIN(SERIAL_PORT_2, -1, 3) - #error "SERIAL_PORT_2 must be from 0 to 3, or -1 for USB Serial." + #if !WITHIN(SERIAL_PORT_2, 0, 3) + #error "SERIAL_PORT_2 must be from 0 to 3." #endif #define MYSERIAL2 customizedSerial2 #endif #ifdef SERIAL_PORT_3 - #if !WITHIN(SERIAL_PORT_3, -1, 3) - #error "SERIAL_PORT_3 must be from 0 to 3, or -1 for USB Serial." + #if !WITHIN(SERIAL_PORT_3, 0, 3) + #error "SERIAL_PORT_3 must be from 0 to 3." #endif #define MYSERIAL3 customizedSerial3 #endif #endif #ifdef MMU2_SERIAL_PORT - #if !WITHIN(MMU2_SERIAL_PORT, -1, 3) - #error "MMU2_SERIAL_PORT must be from 0 to 3, or -1 for USB Serial." + #if !WITHIN(MMU2_SERIAL_PORT, 0, 3) + #error "MMU2_SERIAL_PORT must be from 0 to 3" #endif #define MMU2_SERIAL mmuSerial #endif #ifdef LCD_SERIAL_PORT - #if !WITHIN(LCD_SERIAL_PORT, -1, 3) - #error "LCD_SERIAL_PORT must be from 0 to 3, or -1 for USB Serial." + #if !WITHIN(LCD_SERIAL_PORT, 0, 3) + #error "LCD_SERIAL_PORT must be from 0 to 3." #endif #define LCD_SERIAL lcdSerial #if HAS_DGUS_LCD From a913b2437b1f792492d1ac29f5eff51f512320cd Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Wed, 19 Oct 2022 21:36:39 -0400 Subject: [PATCH 114/243] =?UTF-8?q?=F0=9F=90=9B=20Fix=20Print=20Timer=20st?= =?UTF-8?q?op=20with=20MarlinUI=20abort=20(#24902)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/marlinui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index b1827534b501..c885e838453e 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -1630,7 +1630,7 @@ void MarlinUI::init() { #ifdef ACTION_ON_CANCEL hostui.cancel(); #endif - IF_DISABLED(SDSUPPORT, print_job_timer.stop()); + print_job_timer.stop(); TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_open(PROMPT_INFO, F("UI Aborted"), FPSTR(DISMISS_STR))); LCD_MESSAGE(MSG_PRINT_ABORTED); TERN_(HAS_MARLINUI_MENU, return_to_status()); From 682a9b6fbefca8d58971030213b301344a2db9b8 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 19 Oct 2022 21:00:14 -0500 Subject: [PATCH 115/243] =?UTF-8?q?=F0=9F=8E=A8=20Misc.=20variant=20cleanu?= =?UTF-8?q?p,=20translation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to #24787 --- .../MARLIN_F446Zx_TRONXY/hal_conf_custom.h | 2 +- .../variants/MARLIN_F446Zx_TRONXY/variant.cpp | 102 +++++++++--------- .../variants/MARLIN_F446Zx_TRONXY/variant.h | 5 +- .../MARLIN_MKS_SKIPR_V1/PeripheralPins.c | 4 +- .../variants/MARLIN_MKS_SKIPR_V1/variant.h | 2 +- 5 files changed, 57 insertions(+), 58 deletions(-) diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/hal_conf_custom.h b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/hal_conf_custom.h index e0775922454c..c23d30ce88a9 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/hal_conf_custom.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/hal_conf_custom.h @@ -411,7 +411,7 @@ in voltage and temperature. */ #endif /* HAL_SPI_MODULE_ENABLED */ #ifdef HAL_TIM_MODULE_ENABLED -#include "stm32f4xx_hal_tim.h" +#include "stm32f4xx_hal_tim.h" #endif /* HAL_TIM_MODULE_ENABLED */ #ifdef HAL_UART_MODULE_ENABLED diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/variant.cpp b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/variant.cpp index 807b9392eb9c..2d94ee763a42 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/variant.cpp +++ b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/variant.cpp @@ -170,69 +170,69 @@ extern "C" { #endif uint32_t myvar[] = {1,2,3,4,5,6,7,8}; -void myshow(int fre,int times)//YSZ-WORK +void myshow(int fre, int times) // YSZ-WORK { uint32_t index = 10; - RCC->AHB1ENR |= 1 << 6;//端口G时钟 - GPIOG->MODER &= ~(3UL << 2 * index);//清除旧模式 - GPIOG->MODER |= 1 << 2 * index;//模式为输出 - GPIOG->OSPEEDR &= ~(3UL << 2 * index); //清除旧输出速度 - GPIOG->OSPEEDR |= 2 << 2 * index;//设置输出速度 - GPIOG->OTYPER &= ~(1UL << index);//清除旧输出方式 - GPIOG->OTYPER |= 0 << index;//设置输出方式为推挽 - GPIOG->PUPDR &= ~(3 << 2 * index);//先清除原来的设置 - GPIOG->PUPDR |= 1 << 2 * index;//设置新的上下拉 - while(times != 0) { + RCC->AHB1ENR |= 1 << 6; // port G clock + GPIOG->MODER &= ~(3UL << 2 * index); // clear old mode + GPIOG->MODER |= 1 << 2 * index; // mode is output + GPIOG->OSPEEDR &= ~(3UL << 2 * index) // Clear old output speed + GPIOG->OSPEEDR |= 2 << 2 * index; // Set output speed + GPIOG->OTYPER &= ~(1UL << index) // clear old output + GPIOG->OTYPER |= 0 << index; // Set the output mode to push-pull + GPIOG->PUPDR &= ~(3 << 2 * index) // Clear the original settings first + GPIOG->PUPDR |= 1 << 2 * index; // Set new up and down + while (times != 0) { GPIOG->BSRR = 1UL << index; - for(int i = 0;i < fre; i++) - for(int j = 0; j < 1000000; j++)__NOP(); + for (int i = 0; i < fre; i++) + for (int j = 0; j < 1000000; j++) __NOP(); GPIOG->BSRR = 1UL << (index + 16); - for(int i = 0;i < fre; i++) - for(int j = 0; j < 1000000; j++)__NOP(); - if(times > 0)times--; + for (int i = 0; i < fre; i++) + for (int j = 0; j < 1000000; j++) __NOP(); + if (times > 0) times--; } } HAL_StatusTypeDef SDMMC_IsProgramming(SDIO_TypeDef *SDIOx,uint32_t RCA) { HAL_SD_CardStateTypeDef CardState; - volatile uint32_t respR1 = 0, status = 0; - SDIO_CmdInitTypeDef sdmmc_cmdinit; + volatile uint32_t respR1 = 0, status = 0; + SDIO_CmdInitTypeDef sdmmc_cmdinit; do { sdmmc_cmdinit.Argument = RCA << 16; sdmmc_cmdinit.CmdIndex = SDMMC_CMD_SEND_STATUS; sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT; sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO; sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE; - SDIO_SendCommand(SDIOx,&sdmmc_cmdinit);//发送CMD13 + SDIO_SendCommand(SDIOx,&sdmmc_cmdinit); // send CMD13 do status = SDIOx->STA; - while(!(status & ((1 << 0) | (1 << 6) | (1 << 2))));//等待操作完成 - if(status & (1 << 0)) //CRC检测失败 - { - SDIOx->ICR |= 1 << 0; //清除错误标记 + while (!(status & ((1 << 0) | (1 << 6) | (1 << 2)))); // wait for the operation to complete + if (status & (1 << 0)) { // CRC check failed + SDIOx->ICR |= 1 << 0; // clear error flag return HAL_ERROR; } - if(status & (1 << 2)) //命令超时 - { - SDIOx->ICR |= 1 << 2; //清除错误标记 + if (status & (1 << 2)) { // command timed out + SDIOx->ICR |= 1 << 2; // clear error flag return HAL_ERROR; } - if(SDIOx->RESPCMD != SDMMC_CMD_SEND_STATUS)return HAL_ERROR; - SDIOx->ICR = 0X5FF; //清除所有标记 + if (SDIOx->RESPCMD != SDMMC_CMD_SEND_STATUS) return HAL_ERROR; + SDIOx->ICR = 0X5FF; // clear all tags respR1 = SDIOx->RESP1; CardState = (respR1 >> 9) & 0x0000000F; - }while((CardState == HAL_SD_CARD_RECEIVING) || (CardState == HAL_SD_CARD_SENDING) || (CardState == HAL_SD_CARD_PROGRAMMING)); + } while ((CardState == HAL_SD_CARD_RECEIVING) || (CardState == HAL_SD_CARD_SENDING) || (CardState == HAL_SD_CARD_PROGRAMMING)); return HAL_OK; } -void debugStr(const char*str) { - while(*str) { - while((USART1->SR & 0x40) == 0); - USART1->DR = *str++; - } + +void debugStr(const char *str) { + while (*str) { + while ((USART1->SR & 0x40) == 0); + USART1->DR = *str++; + } } + /** * @brief System Clock Configuration - * The system Clock is configured as follow : + * The system Clock is configured as follows: * System Clock source = PLL (HSE) * SYSCLK(Hz) = 168000000/120000000/180000000 * HCLK(Hz) = 168000000/120000000/180000000 @@ -265,8 +265,8 @@ WEAK void SystemClock_Config(void) /* Enable Power Control clock */ __HAL_RCC_PWR_CLK_ENABLE(); - /* The voltage scaling allows optimizing the power consumption when the device is - clocked below the maximum system frequency, to update the voltage scaling value + /* The voltage scaling allows optimizing the power consumption when the device is + clocked below the maximum system frequency, to update the voltage scaling value regarding system frequency refer to product datasheet. */ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); @@ -281,42 +281,40 @@ WEAK void SystemClock_Config(void) RCC_OscInitStruct.PLL.PLLQ = 7; RCC_OscInitStruct.PLL.PLLR = 2; ret = HAL_RCC_OscConfig(&RCC_OscInitStruct); - - if(ret != HAL_OK)myshow(10,-1); + + if (ret != HAL_OK) myshow(10,-1); HAL_PWREx_EnableOverDrive(); - + /* Select PLLSAI output as USB clock source */ PeriphClkInitStruct.PLLSAI.PLLSAIM = 8; PeriphClkInitStruct.PLLSAI.PLLSAIN = 192; PeriphClkInitStruct.PLLSAI.PLLSAIP = RCC_PLLSAIP_DIV4; PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_CLK48 | RCC_PERIPHCLK_SDIO; PeriphClkInitStruct.Clk48ClockSelection = RCC_CK48CLKSOURCE_PLLSAIP; - PeriphClkInitStruct.SdioClockSelection = RCC_SDIOCLKSOURCE_CLK48;//SDIO Clock Mux + PeriphClkInitStruct.SdioClockSelection = RCC_SDIOCLKSOURCE_CLK48; // SDIO Clock Mux HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); - /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 - clocks dividers */ + /* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */ RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2); RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; - RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; - RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; ret = HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5); - if(ret != HAL_OK)myshow(10,-1); + if (ret != HAL_OK) myshow(10,-1); - SystemCoreClockUpdate();//更新系统时钟SystemCoreClock - /**Configure the Systick interrupt time - */ + SystemCoreClockUpdate(); + /* Configure the Systick interrupt time */ HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq() / 1000); - /**Configure the Systick - */ + /* Configure the Systick */ HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK); /* SysTick_IRQn interrupt configuration */ HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); - __enable_irq();//打开中断,因为在bootloader中关闭了,所以这里要打开 + __enable_irq(); // Turn on the interrupt here because it is turned off in the bootloader } + #ifdef __cplusplus } #endif diff --git a/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/variant.h index 29649de93894..082be9403ed5 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_F446Zx_TRONXY/variant.h @@ -24,8 +24,9 @@ extern "C" { #endif // __cplusplus extern unsigned long myvar[]; -void myshow(int fre,int times); -void debugStr(const char*str); +void myshow(int fre, int times); +void debugStr(const char *str); + /*---------------------------------------------------------------------------- * Pins *----------------------------------------------------------------------------*/ diff --git a/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/PeripheralPins.c b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/PeripheralPins.c index 640fbdbe13c0..11f5cc5afc4f 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/PeripheralPins.c +++ b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/PeripheralPins.c @@ -76,8 +76,8 @@ WEAK const PinMap PinMap_PWM[] = { {PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 Fan2 {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 Fan1 {PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 Fan0 - {PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 HE2 - {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 Servo + {PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 HE2 + {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 Servo {PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 1)}, // TIM1_CH2N HE1 {PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 1)}, // TIM1_CH3N HE0 {PB_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 BEEPER diff --git a/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/variant.h b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/variant.h index dcc8c493956c..51a9e92286bf 100644 --- a/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/variant.h +++ b/buildroot/share/PlatformIO/variants/MARLIN_MKS_SKIPR_V1/variant.h @@ -32,7 +32,7 @@ #ifdef __cplusplus extern "C" { #endif // __cplusplus -// +// /*---------------------------------------------------------------------------- * Pins *----------------------------------------------------------------------------*/ From 4d9bf91edcf81dc7cdbbb71166b619a06b785329 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Thu, 20 Oct 2022 15:23:22 +1300 Subject: [PATCH 116/243] =?UTF-8?q?=F0=9F=94=A7=20Some=20STM32=20UART=20Sa?= =?UTF-8?q?nity=20Checks=20(#24795)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 2 +- Marlin/src/HAL/AVR/inc/SanityCheck.h | 16 +++-- Marlin/src/HAL/STM32/inc/SanityCheck.h | 59 +++++++++++++++++ Marlin/src/inc/Conditionals_post.h | 10 +-- Marlin/src/pins/pinsDebug_list.h | 74 ++++++++++++++++++++++ Marlin/src/pins/stm32f1/pins_CREALITY_V4.h | 55 +++++++++++----- 6 files changed, 187 insertions(+), 29 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 4a60ec613906..47b42aa8dddb 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1152,7 +1152,7 @@ #endif /** - * Automatic backlash, position and hotend offset calibration + * Automatic backlash, position, and hotend offset calibration * * Enable G425 to run automatic calibration using an electrically- * conductive cube, bolt, or washer mounted on the bed. diff --git a/Marlin/src/HAL/AVR/inc/SanityCheck.h b/Marlin/src/HAL/AVR/inc/SanityCheck.h index 411b0198f138..ff1610f74164 100644 --- a/Marlin/src/HAL/AVR/inc/SanityCheck.h +++ b/Marlin/src/HAL/AVR/inc/SanityCheck.h @@ -40,13 +40,15 @@ #if SERIAL_IN_USE(0) // D0-D1. No known conflicts. #endif -#if NOT_TARGET(__AVR_ATmega644P__, __AVR_ATmega1284P__) - #if SERIAL_IN_USE(1) && (CHECK_SERIAL_PIN(18) || CHECK_SERIAL_PIN(19)) - #error "Serial Port 1 pin D18 and/or D19 conflicts with another pin on the board." - #endif -#else - #if SERIAL_IN_USE(1) && (CHECK_SERIAL_PIN(10) || CHECK_SERIAL_PIN(11)) - #error "Serial Port 1 pin D10 and/or D11 conflicts with another pin on the board." +#if SERIAL_IN_USE(1) + #if NOT_TARGET(__AVR_ATmega644P__, __AVR_ATmega1284P__) + #if CHECK_SERIAL_PIN(18) || CHECK_SERIAL_PIN(19) + #error "Serial Port 1 pin D18 and/or D19 conflicts with another pin on the board." + #endif + #else + #if CHECK_SERIAL_PIN(10) || CHECK_SERIAL_PIN(11) + #error "Serial Port 1 pin D10 and/or D11 conflicts with another pin on the board." + #endif #endif #endif #if SERIAL_IN_USE(2) && (CHECK_SERIAL_PIN(16) || CHECK_SERIAL_PIN(17)) diff --git a/Marlin/src/HAL/STM32/inc/SanityCheck.h b/Marlin/src/HAL/STM32/inc/SanityCheck.h index a440695a06f4..e8ddfa172005 100644 --- a/Marlin/src/HAL/STM32/inc/SanityCheck.h +++ b/Marlin/src/HAL/STM32/inc/SanityCheck.h @@ -50,3 +50,62 @@ #if ANY(TFT_COLOR_UI, TFT_LVGL_UI, TFT_CLASSIC_UI) && NOT_TARGET(STM32H7xx, STM32F4xx, STM32F1xx) #error "TFT_COLOR_UI, TFT_LVGL_UI and TFT_CLASSIC_UI are currently only supported on STM32H7, STM32F4 and STM32F1 hardware." #endif + +/** + * Check for common serial pin conflicts + */ +#define _CHECK_SERIAL_PIN(N) (( \ + BTN_EN1 == N || DOGLCD_CS == N || HEATER_BED_PIN == N || FAN_PIN == N || \ + SDIO_D2_PIN == N || SDIO_D3_PIN == N || SDIO_CK_PIN == N || SDIO_CMD_PIN == N \ + )) +#define CHECK_SERIAL_PIN(T,N) defined(UART##N##_##T##_PIN) && _CHECK_SERIAL_PIN(UART##N##_##T##_PIN) +#if SERIAL_IN_USE(1) + #if CHECK_SERIAL_PIN(TX,1) + #error "Serial Port 1 TX IO pins conflict with another pin on the board." + #endif + #if CHECK_SERIAL_PIN(RX,1) + #error "Serial Port 1 RX IO pins conflict with another pin on the board." + #endif +#endif +#if SERIAL_IN_USE(2) + #if CHECK_SERIAL_PIN(TX,2) + #error "Serial Port 2 TX IO pins conflict with another pin on the board." + #endif + #if CHECK_SERIAL_PIN(RX,2) + #error "Serial Port 2 RX IO pins conflict with another pin on the board." + #endif +#endif +#if SERIAL_IN_USE(3) + #if CHECK_SERIAL_PIN(TX,3) + #error "Serial Port 3 TX IO pins conflict with another pin on the board." + #endif + #if CHECK_SERIAL_PIN(RX,3) + #error "Serial Port 3 RX IO pins conflict with another pin on the board." + #endif +#endif +#if SERIAL_IN_USE(4) + #if CHECK_SERIAL_PIN(TX,4) + #error "Serial Port 4 TX IO pins conflict with another pin on the board." + #endif + #if CHECK_SERIAL_PIN(RX,4) + #error "Serial Port 4 RX IO pins conflict with another pin on the board." + #endif +#endif +#if SERIAL_IN_USE(5) + #if CHECK_SERIAL_PIN(TX,5) + #error "Serial Port 5 TX IO pins conflict with another pin on the board." + #endif + #if CHECK_SERIAL_PIN(RX,5) + #error "Serial Port 5 RX IO pins conflict with another pin on the board." + #endif +#endif +#if SERIAL_IN_USE(6) + #if CHECK_SERIAL_PIN(TX,6) + #error "Serial Port 6 TX IO pins conflict with another pin on the board." + #endif + #if CHECK_SERIAL_PIN(RX,6) + #error "Serial Port 6 RX IO pins conflict with another pin on the board." + #endif +#endif +#undef CHECK_SERIAL_PIN +#undef _CHECK_SERIAL_PIN diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index bb9a1ac6402c..417ce4479a26 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -2446,11 +2446,11 @@ // // Flag the indexed hardware serial ports in use -#define SERIAL_IN_USE(N) ( (defined(SERIAL_PORT) && SERIAL_PORT == N) \ - || (defined(SERIAL_PORT_2) && SERIAL_PORT_2 == N) \ - || (defined(SERIAL_PORT_3) && SERIAL_PORT_3 == N) \ - || (defined(MMU2_SERIAL_PORT) && MMU2_SERIAL_PORT == N) \ - || (defined(LCD_SERIAL_PORT) && LCD_SERIAL_PORT == N) ) +#define SERIAL_IN_USE(N) ( (defined(SERIAL_PORT) && N == SERIAL_PORT) \ + || (defined(SERIAL_PORT_2) && N == SERIAL_PORT_2) \ + || (defined(SERIAL_PORT_3) && N == SERIAL_PORT_3) \ + || (defined(MMU2_SERIAL_PORT) && N == MMU2_SERIAL_PORT) \ + || (defined(LCD_SERIAL_PORT) && N == LCD_SERIAL_PORT) ) // Flag the named hardware serial ports in use #define TMC_UART_IS(A,N) (defined(A##_HARDWARE_SERIAL) && (CAT(HW_,A##_HARDWARE_SERIAL) == HW_Serial##N || CAT(HW_,A##_HARDWARE_SERIAL) == HW_MSerial##N)) diff --git a/Marlin/src/pins/pinsDebug_list.h b/Marlin/src/pins/pinsDebug_list.h index 2cd54ecf18ba..077c94a60f8c 100644 --- a/Marlin/src/pins/pinsDebug_list.h +++ b/Marlin/src/pins/pinsDebug_list.h @@ -2231,6 +2231,80 @@ REPORT_NAME_DIGITAL(__LINE__, TFT_RESET_PIN) #endif +// +// Hardware UART +// +#if SERIAL_IN_USE(1) + #if PIN_EXISTS(UART1_TX) + REPORT_NAME_DIGITAL(__LINE__, UART1_TX_PIN) + #endif + #if PIN_EXISTS(UART1_RX) + REPORT_NAME_DIGITAL(__LINE__, UART1_RX_PIN) + #endif +#endif +#if SERIAL_IN_USE(2) + #if PIN_EXISTS(UART2_TX) + REPORT_NAME_DIGITAL(__LINE__, UART2_TX_PIN) + #endif + #if PIN_EXISTS(UART2_RX) + REPORT_NAME_DIGITAL(__LINE__, UART2_RX_PIN) + #endif +#endif +#if SERIAL_IN_USE(3) + #if PIN_EXISTS(UART3_TX) + REPORT_NAME_DIGITAL(__LINE__, UART3_TX_PIN) + #endif + #if PIN_EXISTS(UART3_RX) + REPORT_NAME_DIGITAL(__LINE__, UART3_RX_PIN) + #endif +#endif +#if SERIAL_IN_USE(4) + #if PIN_EXISTS(UART4_TX) + REPORT_NAME_DIGITAL(__LINE__, UART4_TX_PIN) + #endif + #if PIN_EXISTS(UART4_RX) + REPORT_NAME_DIGITAL(__LINE__, UART4_RX_PIN) + #endif +#endif +#if SERIAL_IN_USE(5) + #if PIN_EXISTS(UART5_TX) + REPORT_NAME_DIGITAL(__LINE__, UART5_TX_PIN) + #endif + #if PIN_EXISTS(UART5_RX) + REPORT_NAME_DIGITAL(__LINE__, UART5_RX_PIN) + #endif +#endif +#if SERIAL_IN_USE(6) + #if PIN_EXISTS(UART6_TX) + REPORT_NAME_DIGITAL(__LINE__, UART6_TX_PIN) + #endif + #if PIN_EXISTS(UART6_RX) + REPORT_NAME_DIGITAL(__LINE__, UART6_RX_PIN) + #endif +#endif + +// +// SDIO +// +#if PIN_EXISTS(SDIO_D0) + REPORT_NAME_DIGITAL(__LINE__, SDIO_D0_PIN) +#endif +#if PIN_EXISTS(SDIO_D1) + REPORT_NAME_DIGITAL(__LINE__, SDIO_D1_PIN) +#endif +#if PIN_EXISTS(SDIO_D2) + REPORT_NAME_DIGITAL(__LINE__, SDIO_D2_PIN) +#endif +#if PIN_EXISTS(SDIO_D3) + REPORT_NAME_DIGITAL(__LINE__, SDIO_D3_PIN) +#endif +#if PIN_EXISTS(SDIO_CK) + REPORT_NAME_DIGITAL(__LINE__, SDIO_CK_PIN) +#endif +#if PIN_EXISTS(SDIO_CMD) + REPORT_NAME_DIGITAL(__LINE__, SDIO_CMD_PIN) +#endif + // // Miscellaneous // diff --git a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h index 11384799a39a..f633ee0983c0 100644 --- a/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h +++ b/Marlin/src/pins/stm32f1/pins_CREALITY_V4.h @@ -173,14 +173,14 @@ * GND | 9 10 | 5V * ------ */ - #define EXP3_01_PIN PC6 - #define EXP3_02_PIN PB2 - #define EXP3_03_PIN PB10 - #define EXP3_04_PIN PB11 - #define EXP3_05_PIN PB14 - #define EXP3_06_PIN PB13 - #define EXP3_07_PIN PB12 - #define EXP3_08_PIN PB15 + #define EXP3_01_PIN PC6 + #define EXP3_02_PIN PB2 + #define EXP3_03_PIN PB10 + #define EXP3_04_PIN PB11 + #define EXP3_05_PIN PB14 + #define EXP3_06_PIN PB13 + #define EXP3_07_PIN PB12 + #define EXP3_08_PIN PB15 #elif EITHER(VET6_12864_LCD, DWIN_VET6_CREALITY_LCD) @@ -194,14 +194,14 @@ * GND | 9 10 | 5V * ------ */ - #define EXP3_01_PIN -1 - #define EXP3_02_PIN PC5 - #define EXP3_03_PIN PB10 - #define EXP3_04_PIN -1 - #define EXP3_05_PIN PA6 - #define EXP3_06_PIN PA5 - #define EXP3_07_PIN PA4 - #define EXP3_08_PIN PA7 + #define EXP3_01_PIN -1 + #define EXP3_02_PIN PC5 + #define EXP3_03_PIN PB10 + #define EXP3_04_PIN -1 + #define EXP3_05_PIN PA6 + #define EXP3_06_PIN PA5 + #define EXP3_07_PIN PA4 + #define EXP3_08_PIN PA7 #elif EITHER(CR10_STOCKDISPLAY, FYSETC_MINI_12864_2_1) #error "Define RET6_12864_LCD or VET6_12864_LCD to select pins for the LCD with the Creality V4 controller." @@ -283,3 +283,26 @@ #define NEOPIXEL_PIN PA13 #endif + +// Pins for documentation and sanity checks only. +// Changing these will not change the pin they are on. + +// Hardware UART pins +#define UART1_TX_PIN PA9 // default uses CH340 RX +#define UART1_RX_PIN PA10 // default uses CH340 TX +#define UART2_TX_PIN PA2 // default uses HEATER_BED_PIN +#define UART2_RX_PIN PA3 // not connected +#define UART3_TX_PIN PB10 // default uses LCD connector +#define UART3_RX_PIN PB11 // default uses LCD connector +#define UART4_TX_PIN PC10 // default uses sdcard SDIO_D2 +#define UART4_RX_PIN PC11 // default uses sdcard SDIO_D3 +#define UART5_TX_PIN PC12 // default uses sdcard SDIO_CK +#define UART5_RX_PIN PD2 // default uses sdcard SDIO_CMD + +// SDIO pins +#define SDIO_D0_PIN PC8 +#define SDIO_D1_PIN PC9 +#define SDIO_D2_PIN PC10 +#define SDIO_D3_PIN PC11 +#define SDIO_CK_PIN PC12 +#define SDIO_CMD_PIN PD2 From bdd5da50988c2bfdae6839bea65747ba3afcadbd Mon Sep 17 00:00:00 2001 From: silycr <32662182+silycr@users.noreply.github.com> Date: Sat, 22 Oct 2022 04:31:46 +1030 Subject: [PATCH 117/243] =?UTF-8?q?=F0=9F=9A=B8=20Probe=20pins=20for=20Chi?= =?UTF-8?q?tu=20V5=20(#24910)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h b/Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h index 53b6797e91d2..f4cecc21c260 100644 --- a/Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h +++ b/Marlin/src/pins/stm32f1/pins_CHITU3D_V5.h @@ -23,6 +23,14 @@ #define BOARD_INFO_NAME "Chitu3D V5" -#define Z_STOP_PIN PA14 +// +// Servos +// +#define SERVO0_PIN PA13 // Z+ (behind FILAMENT) Pinout [+5v|G|S] + +// +// Limit Switches +// +#define Z_STOP_PIN PA14 // Pinout [+12/24v|G|S] #include "pins_CHITU3D_common.h" From c8b2d0c0fd50fb528d995fad782d62752d086a6e Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Fri, 21 Oct 2022 14:03:38 -0400 Subject: [PATCH 118/243] =?UTF-8?q?=E2=9C=A8=20Controllerfan=20PWM=20scali?= =?UTF-8?q?ng,=20kickstart=20(#24873)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 12 ++++++++---- Marlin/src/feature/controllerfan.cpp | 16 ++++++++++++++++ Marlin/src/inc/Conditionals_adv.h | 11 +++++++++++ Marlin/src/inc/SanityCheck.h | 5 +++++ Marlin/src/module/planner.cpp | 16 +++++----------- Marlin/src/module/temperature.cpp | 14 +++++++------- Marlin/src/module/tool_change.cpp | 2 +- 7 files changed, 53 insertions(+), 23 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 47b42aa8dddb..085c5379a911 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -552,10 +552,14 @@ #endif #endif -// When first starting the main fan, run it at full speed for the -// given number of milliseconds. This gets the fan spinning reliably -// before setting a PWM value. (Does not work with software PWM for fan on Sanguinololu) -//#define FAN_KICKSTART_TIME 100 +/** + * Fan Kickstart + * When part cooling or controller fans first start, run at a speed that + * gets it spinning reliably for a short time before setting the requested speed. + * (Does not work on Sanguinololu with FAN_SOFT_PWM.) + */ +//#define FAN_KICKSTART_TIME 100 // (ms) +//#define FAN_KICKSTART_POWER 180 // 64-255 // Some coolers may require a non-zero "off" state. //#define FAN_OFF_PWM 1 diff --git a/Marlin/src/feature/controllerfan.cpp b/Marlin/src/feature/controllerfan.cpp index f42bf52ae40a..2f25832cdc2d 100644 --- a/Marlin/src/feature/controllerfan.cpp +++ b/Marlin/src/feature/controllerfan.cpp @@ -72,6 +72,22 @@ void ControllerFan::update() { ? settings.active_speed : settings.idle_speed ); + speed = CALC_FAN_SPEED(speed); + + #if FAN_KICKSTART_TIME + static millis_t fan_kick_end = 0; + if (speed > FAN_OFF_PWM) { + if (!fan_kick_end) { + fan_kick_end = ms + FAN_KICKSTART_TIME; // May be longer based on slow update interval for controller fn check. Sets minimum + speed = FAN_KICKSTART_POWER; + } + else if (PENDING(ms, fan_kick_end)) + speed = FAN_KICKSTART_POWER; + } + else + fan_kick_end = 0; + #endif + #if ENABLED(FAN_SOFT_PWM) thermalManager.soft_pwm_controller_speed = speed; #else diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index ba8c3587fec0..27185400f951 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -1074,3 +1074,14 @@ #if ANY(DISABLE_INACTIVE_X, DISABLE_INACTIVE_Y, DISABLE_INACTIVE_Z, DISABLE_INACTIVE_I, DISABLE_INACTIVE_J, DISABLE_INACTIVE_K, DISABLE_INACTIVE_U, DISABLE_INACTIVE_V, DISABLE_INACTIVE_W, DISABLE_INACTIVE_E) #define HAS_DISABLE_INACTIVE_AXIS 1 #endif + +// Fan Kickstart +#if FAN_KICKSTART_TIME && !defined(FAN_KICKSTART_POWER) + #define FAN_KICKSTART_POWER 180 +#endif + +#if FAN_MIN_PWM == 0 && FAN_MAX_PWM == 255 + #define CALC_FAN_SPEED(f) (f ?: FAN_OFF_PWM) +#else + #define CALC_FAN_SPEED(f) (f ? map(f, 1, 255, FAN_MIN_PWM, FAN_MAX_PWM) : FAN_OFF_PWM) +#endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 02d798543c1f..679463798a1f 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1513,6 +1513,11 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "To use BED_LIMIT_SWITCHING you must disable PIDTEMPBED." #endif +// Fan Kickstart +#if FAN_KICKSTART_TIME && defined(FAN_KICKSTART_POWER) && !WITHIN(FAN_KICKSTART_POWER, 64, 255) + #error "FAN_KICKSTART_POWER must be an integer from 64 to 255." +#endif + /** * Synchronous M106/M107 checks */ diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 91a994470a31..3263e7660a40 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -1282,16 +1282,10 @@ void Planner::recalculate(TERN_(HINTS_SAFE_EXIT_SPEED, const_float_t safe_exit_s void Planner::sync_fan_speeds(uint8_t (&fan_speed)[FAN_COUNT]) { - #if FAN_MIN_PWM != 0 || FAN_MAX_PWM != 255 - #define CALC_FAN_SPEED(f) (fan_speed[f] ? map(fan_speed[f], 1, 255, FAN_MIN_PWM, FAN_MAX_PWM) : FAN_OFF_PWM) - #else - #define CALC_FAN_SPEED(f) (fan_speed[f] ?: FAN_OFF_PWM) - #endif - #if ENABLED(FAN_SOFT_PWM) - #define _FAN_SET(F) thermalManager.soft_pwm_amount_fan[F] = CALC_FAN_SPEED(F); + #define _FAN_SET(F) thermalManager.soft_pwm_amount_fan[F] = CALC_FAN_SPEED(fan_speed[F]); #else - #define _FAN_SET(F) hal.set_pwm_duty(pin_t(FAN##F##_PIN), CALC_FAN_SPEED(F)); + #define _FAN_SET(F) hal.set_pwm_duty(pin_t(FAN##F##_PIN), CALC_FAN_SPEED(fan_speed[F])); #endif #define FAN_SET(F) do{ kickstart_fan(fan_speed, ms, F); _FAN_SET(F); }while(0) @@ -1306,13 +1300,13 @@ void Planner::recalculate(TERN_(HINTS_SAFE_EXIT_SPEED, const_float_t safe_exit_s void Planner::kickstart_fan(uint8_t (&fan_speed)[FAN_COUNT], const millis_t &ms, const uint8_t f) { static millis_t fan_kick_end[FAN_COUNT] = { 0 }; - if (fan_speed[f]) { + if (fan_speed[f] > FAN_OFF_PWM) { if (fan_kick_end[f] == 0) { fan_kick_end[f] = ms + FAN_KICKSTART_TIME; - fan_speed[f] = 255; + fan_speed[f] = FAN_KICKSTART_POWER; } else if (PENDING(ms, fan_kick_end[f])) - fan_speed[f] = 255; + fan_speed[f] = FAN_KICKSTART_POWER; } else fan_kick_end[f] = 0; diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 349264606aec..7515396fbefb 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -306,19 +306,19 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); #endif #if EITHER(AUTO_POWER_E_FANS, HAS_FANCHECK) - uint8_t Temperature::autofan_speed[HOTENDS]; // = { 0 } + uint8_t Temperature::autofan_speed[HOTENDS] = ARRAY_N_1(HOTENDS, FAN_OFF_PWM); #endif #if ENABLED(AUTO_POWER_CHAMBER_FAN) - uint8_t Temperature::chamberfan_speed; // = 0 + uint8_t Temperature::chamberfan_speed = FAN_OFF_PWM; #endif #if ENABLED(AUTO_POWER_COOLER_FAN) - uint8_t Temperature::coolerfan_speed; // = 0 + uint8_t Temperature::coolerfan_speed = FAN_OFF_PWM; #endif #if BOTH(FAN_SOFT_PWM, USE_CONTROLLER_FAN) - uint8_t Temperature::soft_pwm_controller_speed; + uint8_t Temperature::soft_pwm_controller_speed = FAN_OFF_PWM; #endif // Init fans according to whether they're native PWM or Software PWM @@ -342,11 +342,11 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); // HAS_FAN does not include CONTROLLER_FAN #if HAS_FAN - uint8_t Temperature::fan_speed[FAN_COUNT]; // = { 0 } + uint8_t Temperature::fan_speed[FAN_COUNT] = ARRAY_N_1(FAN_COUNT, FAN_OFF_PWM); #if ENABLED(EXTRA_FAN_SPEED) - Temperature::extra_fan_t Temperature::extra_fan_speed[FAN_COUNT]; + Temperature::extra_fan_t Temperature::extra_fan_speed[FAN_COUNT] = ARRAY_N_1(FAN_COUNT, FAN_OFF_PWM); /** * Handle the M106 P T command: @@ -373,7 +373,7 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); #if EITHER(PROBING_FANS_OFF, ADVANCED_PAUSE_FANS_PAUSE) bool Temperature::fans_paused; // = false; - uint8_t Temperature::saved_fan_speed[FAN_COUNT]; // = { 0 } + uint8_t Temperature::saved_fan_speed[FAN_COUNT] = ARRAY_N_1(FAN_COUNT, FAN_OFF_PWM); #endif #if ENABLED(ADAPTIVE_FAN_SLOWING) diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 4eb72a5b7d1d..80aedd3bdd87 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -917,7 +917,7 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0. #if HAS_FAN && TOOLCHANGE_FS_FAN >= 0 thermalManager.fan_speed[TOOLCHANGE_FS_FAN] = toolchange_settings.fan_speed; gcode.dwell(SEC_TO_MS(toolchange_settings.fan_time)); - thermalManager.fan_speed[TOOLCHANGE_FS_FAN] = 0; + thermalManager.fan_speed[TOOLCHANGE_FS_FAN] = FAN_OFF_PWM; #endif } From 57654498675207180c7a232ff671348441b7046a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 21 Oct 2022 15:41:51 -0500 Subject: [PATCH 119/243] =?UTF-8?q?=F0=9F=94=A8=20gcc-12=20for=20macOS=20n?= =?UTF-8?q?ative?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ini/native.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ini/native.ini b/ini/native.ini index 1905559fd060..15a4d36af8d2 100644 --- a/ini/native.ini +++ b/ini/native.ini @@ -66,11 +66,11 @@ build_flags = ${simulator_linux.build_flags} ${simulator_linux.release_flags} # # MacPorts: -# sudo port install gcc11 glm libsdl2 libsdl2_net +# sudo port install gcc12 glm libsdl2 libsdl2_net # # cd /opt/local/bin # sudo rm -f gcc g++ cc -# sudo ln -s gcc-mp-11 gcc ; sudo ln -s g++-mp-11 g++ ; sudo ln -s g++ cc +# sudo ln -s gcc-mp-12 gcc ; sudo ln -s g++-mp-12 g++ ; sudo ln -s g++ cc # cd - # rehash # From c1f0f26bffb1013e686d74f930287fa9f4cda083 Mon Sep 17 00:00:00 2001 From: tombrazier <68918209+tombrazier@users.noreply.github.com> Date: Fri, 21 Oct 2022 22:34:22 +0100 Subject: [PATCH 120/243] =?UTF-8?q?=F0=9F=9A=80=20ZV=20Input=20Shaping=20(?= =?UTF-8?q?#24797)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 29 ++ .../src/gcode/feature/input_shaping/M593.cpp | 83 ++++++ Marlin/src/gcode/gcode.cpp | 4 + Marlin/src/gcode/gcode.h | 6 + Marlin/src/inc/Conditionals_adv.h | 14 + Marlin/src/inc/SanityCheck.h | 35 ++- Marlin/src/lcd/language/language_en.h | 5 + Marlin/src/lcd/menu/menu_advanced.cpp | 41 ++- Marlin/src/module/planner.cpp | 8 + Marlin/src/module/settings.cpp | 66 +++++ Marlin/src/module/stepper.cpp | 269 +++++++++++++++--- Marlin/src/module/stepper.h | 135 ++++++++- buildroot/tests/mega2560 | 2 +- ini/features.ini | 1 + platformio.ini | 1 + 15 files changed, 657 insertions(+), 42 deletions(-) create mode 100644 Marlin/src/gcode/feature/input_shaping/M593.cpp diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 085c5379a911..01a2bd85c53b 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1055,6 +1055,35 @@ // @section motion +/** + * Input Shaping -- EXPERIMENTAL + * + * Zero Vibration (ZV) Input Shaping for X and/or Y movements. + * + * This option uses a lot of SRAM for the step buffer, which is proportional + * to the largest step rate possible for any axis. If the build fails due to + * low SRAM the buffer size may be reduced by setting smaller values for + * DEFAULT_AXIS_STEPS_PER_UNIT and/or DEFAULT_MAX_FEEDRATE. Runtime editing + * of max feedrate (M203) or resonant frequency (M593) may result feedrate + * being capped to prevent buffer overruns. + * + * Tune with M593 D F: + * + * D Set the zeta/damping factor. If axes (X, Y, etc.) are not specified, set for all axes. + * F Set the frequency. If axes (X, Y, etc.) are not specified, set for all axes. + * T[map] Input Shaping type, 0:ZV, 1:EI, 2:2H EI (not implemented yet) + * X<1> Set the given parameters only for the X axis. + * Y<1> Set the given parameters only for the Y axis. + */ +//#define INPUT_SHAPING +#if ENABLED(INPUT_SHAPING) + #define SHAPING_FREQ_X 40 // (Hz) The dominant resonant frequency of the X axis. + #define SHAPING_FREQ_Y 40 // (Hz) The dominant resonant frequency of the Y axis. + #define SHAPING_ZETA_X 0.3f // Damping ratio of the X axis (range: 0.0 = no damping to 1.0 = critical damping). + #define SHAPING_ZETA_Y 0.3f // Damping ratio of the Y axis (range: 0.0 = no damping to 1.0 = critical damping). + //#define SHAPING_MENU // Add a menu to the LCD to set shaping parameters. +#endif + #define AXIS_RELATIVE_MODES { false, false, false, false } // Add a Duplicate option for well-separated conjoined nozzles diff --git a/Marlin/src/gcode/feature/input_shaping/M593.cpp b/Marlin/src/gcode/feature/input_shaping/M593.cpp new file mode 100644 index 000000000000..84301963cbde --- /dev/null +++ b/Marlin/src/gcode/feature/input_shaping/M593.cpp @@ -0,0 +1,83 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include "../../../inc/MarlinConfig.h" + +#if ENABLED(INPUT_SHAPING) + +#include "../../gcode.h" +#include "../../../module/stepper.h" + +void GcodeSuite::M593_report(const bool forReplay/*=true*/) { + report_heading_etc(forReplay, F("Input Shaping")); + #if HAS_SHAPING_X + SERIAL_ECHO_MSG("M593 X" + " F", stepper.get_shaping_frequency(X_AXIS), + " D", stepper.get_shaping_damping_ratio(X_AXIS) + ); + #endif + #if HAS_SHAPING_Y + SERIAL_ECHO_MSG("M593 Y" + " F", stepper.get_shaping_frequency(Y_AXIS), + " D", stepper.get_shaping_damping_ratio(Y_AXIS) + ); + #endif +} + +/** + * M593: Get or Set Input Shaping Parameters + * D Set the zeta/damping factor. If axes (X, Y, etc.) are not specified, set for all axes. + * F Set the frequency. If axes (X, Y, etc.) are not specified, set for all axes. + * T[map] Input Shaping type, 0:ZV, 1:EI, 2:2H EI (not implemented yet) + * X<1> Set the given parameters only for the X axis. + * Y<1> Set the given parameters only for the Y axis. + */ +void GcodeSuite::M593() { + if (!parser.seen_any()) return M593_report(); + + const bool seen_X = TERN0(HAS_SHAPING_X, parser.seen_test('X')), + seen_Y = TERN0(HAS_SHAPING_Y, parser.seen_test('Y')), + for_X = seen_X || TERN0(HAS_SHAPING_X, (!seen_X && !seen_Y)), + for_Y = seen_Y || TERN0(HAS_SHAPING_Y, (!seen_X && !seen_Y)); + + if (parser.seen('D')) { + const float zeta = parser.value_float(); + if (WITHIN(zeta, 0, 1)) { + if (for_X) stepper.set_shaping_damping_ratio(X_AXIS, zeta); + if (for_Y) stepper.set_shaping_damping_ratio(Y_AXIS, zeta); + } + else + SERIAL_ECHO_MSG("?Zeta (D) value out of range (0-1)"); + } + + if (parser.seen('F')) { + const float freq = parser.value_float(); + if (freq > 0) { + if (for_X) stepper.set_shaping_frequency(X_AXIS, freq); + if (for_Y) stepper.set_shaping_frequency(Y_AXIS, freq); + } + else + SERIAL_ECHO_MSG("?Frequency (F) must be greater than 0"); + } +} + +#endif diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 0667ef0b7be7..ff066ed67837 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -933,6 +933,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 575: M575(); break; // M575: Set serial baudrate #endif + #if ENABLED(INPUT_SHAPING) + case 593: M593(); break; // M593: Set Input Shaping parameters + #endif + #if ENABLED(ADVANCED_PAUSE_FEATURE) case 600: M600(); break; // M600: Pause for Filament Change case 603: M603(); break; // M603: Configure Filament Change diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index e2506e4ed9f3..0ce8ab39025e 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -259,6 +259,7 @@ * M554 - Get or set IP gateway. (Requires enabled Ethernet port) * M569 - Enable stealthChop on an axis. (Requires at least one _DRIVER_TYPE to be TMC2130/2160/2208/2209/5130/5160) * M575 - Change the serial baud rate. (Requires BAUD_RATE_GCODE) + * M593 - Get or set input shaping parameters. (Requires INPUT_SHAPING) * M600 - Pause for filament change: "M600 X Y Z E L". (Requires ADVANCED_PAUSE_FEATURE) * M603 - Configure filament change: "M603 T U L". (Requires ADVANCED_PAUSE_FEATURE) * M605 - Set Dual X-Carriage movement mode: "M605 S [X] [R]". (Requires DUAL_X_CARRIAGE) @@ -1080,6 +1081,11 @@ class GcodeSuite { static void M575(); #endif + #if ENABLED(INPUT_SHAPING) + static void M593(); + static void M593_report(const bool forReplay=true); + #endif + #if ENABLED(ADVANCED_PAUSE_FEATURE) static void M600(); static void M603(); diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 27185400f951..1f8f0ddfb61e 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -1085,3 +1085,17 @@ #else #define CALC_FAN_SPEED(f) (f ? map(f, 1, 255, FAN_MIN_PWM, FAN_MAX_PWM) : FAN_OFF_PWM) #endif + +// Input shaping +#if ENABLED(INPUT_SHAPING) + #if !HAS_Y_AXIS + #undef SHAPING_FREQ_Y + #undef SHAPING_BUFFER_Y + #endif + #ifdef SHAPING_FREQ_X + #define HAS_SHAPING_X 1 + #endif + #ifdef SHAPING_FREQ_Y + #define HAS_SHAPING_Y 1 + #endif +#endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 679463798a1f..06b8f32946ad 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -4238,11 +4238,6 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #endif #endif -// Misc. Cleanup -#undef _TEST_PWM -#undef _NUM_AXES_STR -#undef _LOGICAL_AXES_STR - // JTAG support in the HAL #if ENABLED(DISABLE_DEBUG) && !defined(JTAGSWD_DISABLE) #error "DISABLE_DEBUG is not supported for the selected MCU/Board." @@ -4254,3 +4249,33 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #if ENABLED(XFER_BUILD) && !BOTH(BINARY_FILE_TRANSFER, CUSTOM_FIRMWARE_UPLOAD) #error "BINARY_FILE_TRANSFER and CUSTOM_FIRMWARE_UPLOAD are required for custom upload." #endif + +// Check requirements for Input Shaping +#if ENABLED(INPUT_SHAPING) && defined(__AVR__) + #if HAS_SHAPING_X + #if F_CPU > 16000000 + static_assert((SHAPING_FREQ_X) * 2 * 0x10000 >= (STEPPER_TIMER_RATE), "SHAPING_FREQ_X is below the minimum (20) for AVR 20MHz."); + #else + static_assert((SHAPING_FREQ_X) * 2 * 0x10000 >= (STEPPER_TIMER_RATE), "SHAPING_FREQ_X is below the minimum (16) for AVR 16MHz."); + #endif + #elif HAS_SHAPING_Y + #if F_CPU > 16000000 + static_assert((SHAPING_FREQ_Y) * 2 * 0x10000 >= (STEPPER_TIMER_RATE), "SHAPING_FREQ_Y is below the minimum (20) for AVR 20MHz."); + #else + static_assert((SHAPING_FREQ_Y) * 2 * 0x10000 >= (STEPPER_TIMER_RATE), "SHAPING_FREQ_Y is below the minimum (16) for AVR 16MHz."); + #endif + #endif +#endif + +#if ENABLED(INPUT_SHAPING) + #if ENABLED(DIRECT_STEPPING) + #error "INPUT_SHAPING cannot currently be used with DIRECT_STEPPING." + #elif ENABLED(LASER_FEATURE) + #error "INPUT_SHAPING cannot currently be used with LASER_FEATURE." + #endif +#endif + +// Misc. Cleanup +#undef _TEST_PWM +#undef _NUM_AXES_STR +#undef _LOGICAL_AXES_STR diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index e4f8ef8fb724..c888207ed123 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -399,6 +399,11 @@ namespace Language_en { LSTR MSG_AMAX_EN = _UxGT("Max * Accel"); LSTR MSG_A_RETRACT = _UxGT("Retract Accel"); LSTR MSG_A_TRAVEL = _UxGT("Travel Accel"); + LSTR MSG_INPUT_SHAPING = _UxGT("Input Shaping"); + LSTR MSG_SHAPING_X_FREQ = STR_X _UxGT(" frequency"); + LSTR MSG_SHAPING_Y_FREQ = STR_Y _UxGT(" frequency"); + LSTR MSG_SHAPING_X_ZETA = STR_X _UxGT(" damping"); + LSTR MSG_SHAPING_Y_ZETA = STR_Y _UxGT(" damping"); LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("XY Freq Limit"); LSTR MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Min FR Factor"); LSTR MSG_STEPS_PER_MM = _UxGT("Steps/mm"); diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 5978a8ec1a01..9d6d79efd741 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -31,6 +31,7 @@ #include "menu_item.h" #include "../../MarlinCore.h" #include "../../module/planner.h" +#include "../../module/stepper.h" #if DISABLED(NO_VOLUMETRICS) #include "../../gcode/parser.h" @@ -80,8 +81,6 @@ void menu_backlash(); #if HAS_MOTOR_CURRENT_PWM - #include "../../module/stepper.h" - void menu_pwm() { START_MENU(); BACK_ITEM(MSG_ADVANCED_SETTINGS); @@ -538,6 +537,39 @@ void menu_backlash(); END_MENU(); } + #if ENABLED(SHAPING_MENU) + + void menu_advanced_input_shaping() { + constexpr float min_frequency = TERN(__AVR__, float(STEPPER_TIMER_RATE) / 2 / 0x10000, 1.0f); + + START_MENU(); + BACK_ITEM(MSG_ADVANCED_SETTINGS); + + // M593 F Frequency + #if HAS_SHAPING_X + editable.decimal = stepper.get_shaping_frequency(X_AXIS); + EDIT_ITEM_FAST(float61, MSG_SHAPING_X_FREQ, &editable.decimal, min_frequency, 200.0f, []{ stepper.set_shaping_frequency(X_AXIS, editable.decimal); }); + #endif + #if HAS_SHAPING_Y + editable.decimal = stepper.get_shaping_frequency(Y_AXIS); + EDIT_ITEM_FAST(float61, MSG_SHAPING_Y_FREQ, &editable.decimal, min_frequency, 200.0f, []{ stepper.set_shaping_frequency(Y_AXIS, editable.decimal); }); + #endif + + // M593 D Damping ratio + #if HAS_SHAPING_X + editable.decimal = stepper.get_shaping_damping_ratio(X_AXIS); + EDIT_ITEM_FAST(float42_52, MSG_SHAPING_X_ZETA, &editable.decimal, 0.0f, 1.0f, []{ stepper.set_shaping_damping_ratio(X_AXIS, editable.decimal); }); + #endif + #if HAS_SHAPING_Y + editable.decimal = stepper.get_shaping_damping_ratio(Y_AXIS); + EDIT_ITEM_FAST(float42_52, MSG_SHAPING_Y_ZETA, &editable.decimal, 0.0f, 1.0f, []{ stepper.set_shaping_damping_ratio(Y_AXIS, editable.decimal); }); + #endif + + END_MENU(); + } + + #endif + #if HAS_CLASSIC_JERK void menu_advanced_jerk() { @@ -657,6 +689,11 @@ void menu_advanced_settings() { // M201 - Acceleration items SUBMENU(MSG_ACCELERATION, menu_advanced_acceleration); + // M593 - Acceleration items + #if ENABLED(SHAPING_MENU) + SUBMENU(MSG_INPUT_SHAPING, menu_advanced_input_shaping); + #endif + #if HAS_CLASSIC_JERK // M205 - Max Jerk SUBMENU(MSG_JERK, menu_advanced_jerk); diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 3263e7660a40..dce91606647f 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -2483,6 +2483,14 @@ bool Planner::_populate_block( #endif // XY_FREQUENCY_LIMIT + #if ENABLED(INPUT_SHAPING) + const float top_freq = _MIN(float(0x7FFFFFFFL) + OPTARG(HAS_SHAPING_X, stepper.get_shaping_frequency(X_AXIS)) + OPTARG(HAS_SHAPING_Y, stepper.get_shaping_frequency(Y_AXIS))), + max_factor = (top_freq * float(shaping_dividends - 3) * 2.0f) / block->nominal_rate; + NOMORE(speed_factor, max_factor); + #endif + // Correct the speed if (speed_factor < 1.0f) { current_speed *= speed_factor; diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index cb8fe217e998..f76b5afe74e2 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -577,6 +577,18 @@ typedef struct SettingsDataStruct { MPC_t mpc_constants[HOTENDS]; // M306 #endif + // + // Input Shaping + // + #if HAS_SHAPING_X + float shaping_x_frequency, // M593 X F + shaping_x_zeta; // M593 X D + #endif + #if HAS_SHAPING_Y + float shaping_y_frequency, // M593 Y F + shaping_y_zeta; // M593 Y D + #endif + } SettingsData; //static_assert(sizeof(SettingsData) <= MARLIN_EEPROM_SIZE, "EEPROM too small to contain SettingsData!"); @@ -1602,6 +1614,20 @@ void MarlinSettings::postprocess() { EEPROM_WRITE(thermalManager.temp_hotend[e].constants); #endif + // + // Input Shaping + /// + #if ENABLED(INPUT_SHAPING) + #if HAS_SHAPING_X + EEPROM_WRITE(stepper.get_shaping_frequency(X_AXIS)); + EEPROM_WRITE(stepper.get_shaping_damping_ratio(X_AXIS)); + #endif + #if HAS_SHAPING_Y + EEPROM_WRITE(stepper.get_shaping_frequency(Y_AXIS)); + EEPROM_WRITE(stepper.get_shaping_damping_ratio(Y_AXIS)); + #endif + #endif + // // Report final CRC and Data Size // @@ -2573,6 +2599,27 @@ void MarlinSettings::postprocess() { } #endif + // + // Input Shaping + // + #if HAS_SHAPING_X + { + float _data[2]; + EEPROM_READ(_data); + stepper.set_shaping_frequency(X_AXIS, _data[0]); + stepper.set_shaping_damping_ratio(X_AXIS, _data[1]); + } + #endif + + #if HAS_SHAPING_Y + { + float _data[2]; + EEPROM_READ(_data); + stepper.set_shaping_frequency(Y_AXIS, _data[0]); + stepper.set_shaping_damping_ratio(Y_AXIS, _data[1]); + } + #endif + // // Validate Final Size and CRC // @@ -3343,6 +3390,20 @@ void MarlinSettings::reset() { } #endif + // + // Input Shaping + // + #if ENABLED(INPUT_SHAPING) + #if HAS_SHAPING_X + stepper.set_shaping_frequency(X_AXIS, SHAPING_FREQ_X); + stepper.set_shaping_damping_ratio(X_AXIS, SHAPING_ZETA_X); + #endif + #if HAS_SHAPING_Y + stepper.set_shaping_frequency(Y_AXIS, SHAPING_FREQ_Y); + stepper.set_shaping_damping_ratio(Y_AXIS, SHAPING_ZETA_Y); + #endif + #endif + postprocess(); #if EITHER(EEPROM_CHITCHAT, DEBUG_LEVELING_FEATURE) @@ -3590,6 +3651,11 @@ void MarlinSettings::reset() { // TERN_(HAS_STEALTHCHOP, gcode.M569_report(forReplay)); + // + // Input Shaping + // + TERN_(INPUT_SHAPING, gcode.M593_report(forReplay)); + // // Linear Advance // diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 4ee4c1d1a790..6cc40ccecee9 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -199,7 +199,7 @@ IF_DISABLED(ADAPTIVE_STEP_SMOOTHING, constexpr) uint8_t Stepper::oversampling_fa xyze_long_t Stepper::delta_error{0}; -xyze_ulong_t Stepper::advance_dividend{0}; +xyze_long_t Stepper::advance_dividend{0}; uint32_t Stepper::advance_divisor = 0, Stepper::step_events_completed = 0, // The number of step events executed in the current block Stepper::accelerate_until, // The count at which to stop accelerating @@ -232,6 +232,20 @@ uint32_t Stepper::advance_divisor = 0, Stepper::la_advance_steps = 0; #endif +#if ENABLED(INPUT_SHAPING) + shaping_time_t DelayTimeManager::now = 0; + ParamDelayQueue Stepper::shaping_dividend_queue; + DelayQueue Stepper::shaping_queue; + #if HAS_SHAPING_X + shaping_time_t DelayTimeManager::delay_x; + ShapeParams Stepper::shaping_x; + #endif + #if HAS_SHAPING_Y + shaping_time_t DelayTimeManager::delay_y; + ShapeParams Stepper::shaping_y; + #endif +#endif + #if ENABLED(INTEGRATED_BABYSTEPPING) uint32_t Stepper::nextBabystepISR = BABYSTEP_NEVER; #endif @@ -458,12 +472,10 @@ xyze_int8_t Stepper::count_direction{0}; #define PULSE_LOW_TICK_COUNT hal_timer_t(NS_TO_PULSE_TIMER_TICKS(_MIN_PULSE_LOW_NS - _MIN(_MIN_PULSE_LOW_NS, TIMER_SETUP_NS))) #define USING_TIMED_PULSE() hal_timer_t start_pulse_count = 0 -#define START_TIMED_PULSE(DIR) (start_pulse_count = HAL_timer_get_count(MF_TIMER_PULSE)) -#define AWAIT_TIMED_PULSE(DIR) while (PULSE_##DIR##_TICK_COUNT > HAL_timer_get_count(MF_TIMER_PULSE) - start_pulse_count) { } -#define START_HIGH_PULSE() START_TIMED_PULSE(HIGH) -#define AWAIT_HIGH_PULSE() AWAIT_TIMED_PULSE(HIGH) -#define START_LOW_PULSE() START_TIMED_PULSE(LOW) -#define AWAIT_LOW_PULSE() AWAIT_TIMED_PULSE(LOW) +#define START_TIMED_PULSE() (start_pulse_count = HAL_timer_get_count(MF_TIMER_PULSE)) +#define AWAIT_TIMED_PULSE(DIR) while (PULSE_##DIR##_TICK_COUNT > HAL_timer_get_count(MF_TIMER_PULSE) - start_pulse_count) { /* nada */ } +#define AWAIT_HIGH_PULSE() AWAIT_TIMED_PULSE(HIGH) +#define AWAIT_LOW_PULSE() AWAIT_TIMED_PULSE(LOW) #if MINIMUM_STEPPER_PRE_DIR_DELAY > 0 #define DIR_WAIT_BEFORE() DELAY_NS(MINIMUM_STEPPER_PRE_DIR_DELAY) @@ -559,6 +571,16 @@ void Stepper::disable_all_steppers() { TERN_(EXTENSIBLE_UI, ExtUI::onSteppersDisabled()); } +#define SET_STEP_DIR(A) \ + if (motor_direction(_AXIS(A))) { \ + A##_APPLY_DIR(INVERT_##A##_DIR, false); \ + count_direction[_AXIS(A)] = -1; \ + } \ + else { \ + A##_APPLY_DIR(!INVERT_##A##_DIR, false); \ + count_direction[_AXIS(A)] = 1; \ + } + /** * Set the stepper direction of each axis * @@ -570,16 +592,6 @@ void Stepper::set_directions() { DIR_WAIT_BEFORE(); - #define SET_STEP_DIR(A) \ - if (motor_direction(_AXIS(A))) { \ - A##_APPLY_DIR(INVERT_##A##_DIR, false); \ - count_direction[_AXIS(A)] = -1; \ - } \ - else { \ - A##_APPLY_DIR(!INVERT_##A##_DIR, false); \ - count_direction[_AXIS(A)] = 1; \ - } - TERN_(HAS_X_DIR, SET_STEP_DIR(X)); // A TERN_(HAS_Y_DIR, SET_STEP_DIR(Y)); // B TERN_(HAS_Z_DIR, SET_STEP_DIR(Z)); // C @@ -1467,8 +1479,20 @@ void Stepper::isr() { // Enable ISRs to reduce USART processing latency hal.isr_on(); + #if ENABLED(INPUT_SHAPING) + // Speed limiting should ensure the buffers never get full. But if somehow they do, stutter rather than overflow. + if (!nextMainISR) { + TERN_(HAS_SHAPING_X, if (shaping_dividend_queue.free_count_x() == 0) nextMainISR = shaping_dividend_queue.peek_x() + 1); + TERN_(HAS_SHAPING_Y, if (shaping_dividend_queue.free_count_y() == 0) NOLESS(nextMainISR, shaping_dividend_queue.peek_y() + 1)); + TERN_(HAS_SHAPING_X, if (shaping_queue.free_count_x() < steps_per_isr) NOLESS(nextMainISR, shaping_queue.peek_x() + 1)); + TERN_(HAS_SHAPING_Y, if (shaping_queue.free_count_y() < steps_per_isr) NOLESS(nextMainISR, shaping_queue.peek_y() + 1)); + } + #endif + if (!nextMainISR) pulse_phase_isr(); // 0 = Do coordinated axes Stepper pulses + TERN_(INPUT_SHAPING, shaping_isr()); // Do Shaper stepping, if needed + #if ENABLED(LIN_ADVANCE) if (!nextAdvanceISR) { // 0 = Do Linear Advance E Stepper pulses advance_isr(); @@ -1497,10 +1521,14 @@ 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 - OPTARG(LIN_ADVANCE, nextAdvanceISR) // Come back early for Linear Advance? - OPTARG(INTEGRATED_BABYSTEPPING, nextBabystepISR) // Come back early for Babystepping? + uint32_t(HAL_TIMER_TYPE_MAX), // Come back in a very long time + nextMainISR // Time until the next Pulse / Block phase + OPTARG(HAS_SHAPING_X, shaping_dividend_queue.peek_x()) // Time until next input shaping dividend change for X + OPTARG(HAS_SHAPING_Y, shaping_dividend_queue.peek_y()) // Time until next input shaping dividend change for Y + OPTARG(HAS_SHAPING_X, shaping_queue.peek_x()) // Time until next input shaping echo for X + OPTARG(HAS_SHAPING_Y, shaping_queue.peek_y()) // Time until next input shaping echo for Y + OPTARG(LIN_ADVANCE, nextAdvanceISR) // Come back early for Linear Advance? + OPTARG(INTEGRATED_BABYSTEPPING, nextBabystepISR) // Come back early for Babystepping? ); // @@ -1512,6 +1540,8 @@ void Stepper::isr() { nextMainISR -= interval; + TERN_(INPUT_SHAPING, DelayTimeManager::decrement_delays(interval)); + #if ENABLED(LIN_ADVANCE) if (nextAdvanceISR != LA_ADV_NEVER) nextAdvanceISR -= interval; #endif @@ -1604,11 +1634,19 @@ void Stepper::pulse_phase_isr() { // If we must abort the current block, do so! if (abort_current_block) { abort_current_block = false; - if (current_block) discard_current_block(); + if (current_block) { + discard_current_block(); + #if ENABLED(INPUT_SHAPING) + shaping_dividend_queue.purge(); + shaping_queue.purge(); + TERN_(HAS_SHAPING_X, delta_error.x = 0); + TERN_(HAS_SHAPING_Y, delta_error.y = 0); + #endif + } } // If there is no current block, do nothing - if (!current_block) return; + if (!current_block || step_events_completed >= step_event_count) return; // Skipping step processing causes motion to freeze if (TERN0(FREEZE_FEATURE, frozen)) return; @@ -1627,6 +1665,9 @@ void Stepper::pulse_phase_isr() { #endif xyze_bool_t step_needed{0}; + // Direct Stepping page? + const bool is_page = current_block->is_page(); + do { #define _APPLY_STEP(AXIS, INV, ALWAYS) AXIS ##_APPLY_STEP(INV, ALWAYS) #define _INVERT_STEP_PIN(AXIS) INVERT_## AXIS ##_STEP_PIN @@ -1641,6 +1682,22 @@ void Stepper::pulse_phase_isr() { } \ }while(0) + #define PULSE_PREP_SHAPING(AXIS, DIVIDEND) do{ \ + delta_error[_AXIS(AXIS)] += (DIVIDEND); \ + if ((MAXDIR(AXIS) && delta_error[_AXIS(AXIS)] <= -0x30000000L) || (MINDIR(AXIS) && delta_error[_AXIS(AXIS)] >= 0x30000000L)) { \ + TBI(last_direction_bits, _AXIS(AXIS)); \ + DIR_WAIT_BEFORE(); \ + SET_STEP_DIR(AXIS); \ + DIR_WAIT_AFTER(); \ + } \ + step_needed[_AXIS(AXIS)] = (MAXDIR(AXIS) && delta_error[_AXIS(AXIS)] >= 0x10000000L) || \ + (MINDIR(AXIS) && delta_error[_AXIS(AXIS)] <= -0x10000000L); \ + if (step_needed[_AXIS(AXIS)]) { \ + count_position[_AXIS(AXIS)] += count_direction[_AXIS(AXIS)]; \ + delta_error[_AXIS(AXIS)] += MAXDIR(AXIS) ? -0x20000000L : 0x20000000L; \ + } \ + }while(0) + // Start an active pulse if needed #define PULSE_START(AXIS) do{ \ if (step_needed[_AXIS(AXIS)]) { \ @@ -1655,9 +1712,6 @@ void Stepper::pulse_phase_isr() { } \ }while(0) - // Direct Stepping page? - const bool is_page = current_block->is_page(); - #if ENABLED(DIRECT_STEPPING) // Direct stepping is currently not ready for HAS_I_AXIS if (is_page) { @@ -1765,12 +1819,22 @@ void Stepper::pulse_phase_isr() { #endif // DIRECT_STEPPING if (!is_page) { + TERN_(INPUT_SHAPING, shaping_queue.enqueue()); + // Determine if pulses are needed #if HAS_X_STEP - PULSE_PREP(X); + #if HAS_SHAPING_X + PULSE_PREP_SHAPING(X, advance_dividend.x); + #else + PULSE_PREP(X); + #endif #endif #if HAS_Y_STEP - PULSE_PREP(Y); + #if HAS_SHAPING_Y + PULSE_PREP_SHAPING(Y, advance_dividend.y); + #else + PULSE_PREP(Y); + #endif #endif #if HAS_Z_STEP PULSE_PREP(Z); @@ -1855,7 +1919,7 @@ void Stepper::pulse_phase_isr() { // TODO: need to deal with MINIMUM_STEPPER_PULSE over i2s #if ISR_MULTI_STEPS - START_HIGH_PULSE(); + START_TIMED_PULSE(); AWAIT_HIGH_PULSE(); #endif @@ -1895,12 +1959,62 @@ void Stepper::pulse_phase_isr() { #endif #if ISR_MULTI_STEPS - if (events_to_do) START_LOW_PULSE(); + if (events_to_do) START_TIMED_PULSE(); #endif } while (--events_to_do); } +#if ENABLED(INPUT_SHAPING) + + void Stepper::shaping_isr() { + xyze_bool_t step_needed{0}; + + const bool shapex = TERN0(HAS_SHAPING_X, !shaping_queue.peek_x()), + shapey = TERN0(HAS_SHAPING_Y, !shaping_queue.peek_y()); + + #if HAS_SHAPING_X + if (!shaping_dividend_queue.peek_x()) shaping_x.dividend = shaping_dividend_queue.dequeue_x(); + #endif + #if HAS_SHAPING_Y + if (!shaping_dividend_queue.peek_y()) shaping_y.dividend = shaping_dividend_queue.dequeue_y(); + #endif + + #if HAS_SHAPING_X + if (shapex) { + shaping_queue.dequeue_x(); + PULSE_PREP_SHAPING(X, shaping_x.dividend); + PULSE_START(X); + } + #endif + + #if HAS_SHAPING_Y + if (shapey) { + shaping_queue.dequeue_y(); + PULSE_PREP_SHAPING(Y, shaping_y.dividend); + PULSE_START(Y); + } + #endif + + TERN_(I2S_STEPPER_STREAM, i2s_push_sample()); + + if (shapex || shapey) { + #if ISR_MULTI_STEPS + USING_TIMED_PULSE(); + START_TIMED_PULSE(); + AWAIT_HIGH_PULSE(); + #endif + #if HAS_SHAPING_X + if (shapex) PULSE_STOP(X); + #endif + #if HAS_SHAPING_Y + if (shapey) PULSE_STOP(Y); + #endif + } + } + +#endif // INPUT_SHAPING + // Calculate timer interval, with all limits applied. uint32_t Stepper::calc_timer_interval(uint32_t step_rate) { #ifdef CPU_32_BIT @@ -2365,12 +2479,56 @@ uint32_t Stepper::block_phase_isr() { step_event_count = current_block->step_event_count << oversampling; // Initialize Bresenham delta errors to 1/2 + #if HAS_SHAPING_X + const int32_t old_delta_error_x = delta_error.x; + #endif + #if HAS_SHAPING_Y + const int32_t old_delta_error_y = delta_error.y; + #endif delta_error = TERN_(LIN_ADVANCE, la_delta_error =) -int32_t(step_event_count); // Calculate Bresenham dividends and divisors - advance_dividend = current_block->steps << 1; + advance_dividend = (current_block->steps << 1).asLong(); advance_divisor = step_event_count << 1; + // for input shaped axes, advance_divisor is replaced with 0x40000000 + // and steps are repeated twice so dividends have to be scaled and halved + // and the dividend is directional, i.e. signed + TERN_(HAS_SHAPING_X, advance_dividend.x = (uint64_t(current_block->steps.x) << 29) / step_event_count); + TERN_(HAS_SHAPING_X, if (TEST(current_block->direction_bits, X_AXIS)) advance_dividend.x *= -1); + TERN_(HAS_SHAPING_X, if (!shaping_queue.empty_x()) SET_BIT_TO(current_block->direction_bits, X_AXIS, TEST(last_direction_bits, X_AXIS))); + TERN_(HAS_SHAPING_Y, advance_dividend.y = (uint64_t(current_block->steps.y) << 29) / step_event_count); + TERN_(HAS_SHAPING_Y, if (TEST(current_block->direction_bits, Y_AXIS)) advance_dividend.y *= -1); + TERN_(HAS_SHAPING_Y, if (!shaping_queue.empty_y()) SET_BIT_TO(current_block->direction_bits, Y_AXIS, TEST(last_direction_bits, Y_AXIS))); + + // The scaling operation above introduces rounding errors which must now be removed. + // For this segment, there will be step_event_count calls to the Bresenham logic and the same number of echoes. + // For each pair of calls to the Bresenham logic, delta_error will increase by advance_dividend modulo 0x20000000 + // so (e.g. for x) delta_error.x will end up changing by (advance_dividend.x * step_event_count) % 0x20000000. + // For a divisor which is a power of 2, modulo is the same as as a bitmask, i.e. + // (advance_dividend.x * step_event_count) & 0x1FFFFFFF. + // This segment's final change in delta_error should actually be zero so we need to increase delta_error by + // 0 - ((advance_dividend.x * step_event_count) & 0x1FFFFFFF) + // And this needs to be adjusted to the range -0x10000000 to 0x10000000. + // Adding and subtracting 0x10000000 inside the outside the modulo achieves this. + TERN_(HAS_SHAPING_X, delta_error.x = old_delta_error_x + 0x10000000L - ((0x10000000L + advance_dividend.x * step_event_count) & 0x1FFFFFFFUL)); + TERN_(HAS_SHAPING_Y, delta_error.y = old_delta_error_y + 0x10000000L - ((0x10000000L + advance_dividend.y * step_event_count) & 0x1FFFFFFFUL)); + + // when there is damping, the signal and its echo have different amplitudes + #if ENABLED(HAS_SHAPING_X) + const int32_t echo_x = shaping_x.factor * (advance_dividend.x >> 7); + #endif + #if ENABLED(HAS_SHAPING_Y) + const int32_t echo_y = shaping_y.factor * (advance_dividend.y >> 7); + #endif + + // plan the change of values for advance_dividend for the input shaping echoes + TERN_(INPUT_SHAPING, shaping_dividend_queue.enqueue(TERN0(HAS_SHAPING_X, echo_x), TERN0(HAS_SHAPING_Y, echo_y))); + + // apply the adjustment to the primary signal + TERN_(HAS_SHAPING_X, advance_dividend.x -= echo_x); + TERN_(HAS_SHAPING_Y, advance_dividend.y -= echo_y); + // No step events completed so far step_events_completed = 0; @@ -2485,7 +2643,7 @@ uint32_t Stepper::block_phase_isr() { // Enforce a minimum duration for STEP pulse ON #if ISR_PULSE_CONTROL USING_TIMED_PULSE(); - START_HIGH_PULSE(); + START_TIMED_PULSE(); AWAIT_HIGH_PULSE(); #endif @@ -2816,6 +2974,51 @@ void Stepper::init() { #endif } +#if ENABLED(INPUT_SHAPING) + /** + * Calculate a fixed point factor to apply to the signal and its echo + * when shaping an axis. + */ + void Stepper::set_shaping_damping_ratio(const AxisEnum axis, const float zeta) { + // from the damping ratio, get a factor that can be applied to advance_dividend for fixed point maths + // for ZV, we use amplitudes 1/(1+K) and K/(1+K) where K = exp(-zeta * M_PI / sqrt(1.0f - zeta * zeta)) + // which can be converted to 1:7 fixed point with an excellent fit with a 3rd order polynomial + float shaping_factor; + if (zeta <= 0.0f) shaping_factor = 64.0f; + else if (zeta >= 1.0f) shaping_factor = 0.0f; + else { + shaping_factor = 64.44056192 + -99.02008832 * zeta; + const float zeta2 = zeta * zeta; + shaping_factor += -7.58095488 * zeta2; + const float zeta3 = zeta2 * zeta; + shaping_factor += 43.073216 * zeta3; + } + + const bool was_on = hal.isr_state(); + hal.isr_off(); + TERN_(HAS_SHAPING_X, if (axis == X_AXIS) { shaping_x.factor = floor(shaping_factor); shaping_x.zeta = zeta; }) + TERN_(HAS_SHAPING_Y, if (axis == Y_AXIS) { shaping_y.factor = floor(shaping_factor); shaping_y.zeta = zeta; }) + if (was_on) hal.isr_on(); + } + + float Stepper::get_shaping_damping_ratio(const AxisEnum axis) { + TERN_(HAS_SHAPING_X, if (axis == X_AXIS) return shaping_x.zeta); + TERN_(HAS_SHAPING_Y, if (axis == Y_AXIS) return shaping_y.zeta); + return -1; + } + + void Stepper::set_shaping_frequency(const AxisEnum axis, const float freq) { + TERN_(HAS_SHAPING_X, if (axis == X_AXIS) { DelayTimeManager::set_delay(axis, float(uint32_t(STEPPER_TIMER_RATE) / 2) / freq); shaping_x.frequency = freq; }) + TERN_(HAS_SHAPING_Y, if (axis == Y_AXIS) { DelayTimeManager::set_delay(axis, float(uint32_t(STEPPER_TIMER_RATE) / 2) / freq); shaping_y.frequency = freq; }) + } + + float Stepper::get_shaping_frequency(const AxisEnum axis) { + TERN_(HAS_SHAPING_X, if (axis == X_AXIS) return shaping_x.frequency); + TERN_(HAS_SHAPING_Y, if (axis == Y_AXIS) return shaping_y.frequency); + return -1; + } +#endif + /** * Set the stepper positions directly in steps * @@ -3021,7 +3224,7 @@ void Stepper::report_positions() { #if EXTRA_CYCLES_BABYSTEP > 20 #define _SAVE_START() const hal_timer_t pulse_start = HAL_timer_get_count(MF_TIMER_PULSE) - #define _PULSE_WAIT() while (EXTRA_CYCLES_BABYSTEP > (uint32_t)(HAL_timer_get_count(MF_TIMER_PULSE) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ } + #define _PULSE_WAIT() while (EXTRA_CYCLES_BABYSTEP > uint32_t(HAL_timer_get_count(MF_TIMER_PULSE) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ } #else #define _SAVE_START() NOOP #if EXTRA_CYCLES_BABYSTEP > 0 diff --git a/Marlin/src/module/stepper.h b/Marlin/src/module/stepper.h index 729ab83266b1..5b634c52e476 100644 --- a/Marlin/src/module/stepper.h +++ b/Marlin/src/module/stepper.h @@ -312,6 +312,117 @@ constexpr ena_mask_t enable_overlap[] = { //static_assert(!any_enable_overlap(), "There is some overlap."); +#if ENABLED(INPUT_SHAPING) + + typedef IF::type shaping_time_t; + + // These constexpr are used to calculate the shaping queue buffer sizes + constexpr xyze_float_t max_feedrate = DEFAULT_MAX_FEEDRATE; + constexpr xyze_float_t steps_per_unit = DEFAULT_AXIS_STEPS_PER_UNIT; + constexpr float max_steprate = _MAX(LOGICAL_AXIS_LIST( + max_feedrate.e * steps_per_unit.e, + max_feedrate.x * steps_per_unit.x, + max_feedrate.y * steps_per_unit.y, + max_feedrate.z * steps_per_unit.z, + max_feedrate.i * steps_per_unit.i, + max_feedrate.j * steps_per_unit.j, + max_feedrate.k * steps_per_unit.k, + max_feedrate.u * steps_per_unit.u, + max_feedrate.v * steps_per_unit.v, + max_feedrate.w * steps_per_unit.w + )); + constexpr uint16_t shaping_dividends = max_steprate / _MIN(0x7FFFFFFFL OPTARG(HAS_SHAPING_X, SHAPING_FREQ_X) OPTARG(HAS_SHAPING_Y, SHAPING_FREQ_Y)) / 2 + 3; + constexpr uint16_t shaping_segments = max_steprate / (MIN_STEPS_PER_SEGMENT) / _MIN(0x7FFFFFFFL OPTARG(HAS_SHAPING_X, SHAPING_FREQ_X) OPTARG(HAS_SHAPING_Y, SHAPING_FREQ_Y)) / 2 + 3; + + class DelayTimeManager { + private: + static shaping_time_t now; + #ifdef HAS_SHAPING_X + static shaping_time_t delay_x; + #endif + #ifdef HAS_SHAPING_Y + static shaping_time_t delay_y; + #endif + public: + static void decrement_delays(const shaping_time_t interval) { now += interval; } + static void set_delay(const AxisEnum axis, const shaping_time_t delay) { + TERN_(HAS_SHAPING_X, if (axis == X_AXIS) delay_x = delay); + TERN_(HAS_SHAPING_Y, if (axis == Y_AXIS) delay_y = delay); + } + }; + + template + class DelayQueue : public DelayTimeManager { + protected: + shaping_time_t times[SIZE]; + uint16_t tail = 0 OPTARG(HAS_SHAPING_X, head_x = 0) OPTARG(HAS_SHAPING_Y, head_y = 0); + + public: + void enqueue() { + times[tail] = now; + if (++tail == SIZE) tail = 0; + } + #ifdef HAS_SHAPING_X + shaping_time_t peek_x() { + if (head_x != tail) return times[head_x] + delay_x - now; + else return shaping_time_t(-1); + } + void dequeue_x() { if (++head_x == SIZE) head_x = 0; } + bool empty_x() { return head_x == tail; } + uint16_t free_count_x() { return head_x > tail ? head_x - tail - 1 : head_x + SIZE - tail - 1; } + #endif + #ifdef HAS_SHAPING_Y + shaping_time_t peek_y() { + if (head_y != tail) return times[head_y] + delay_y - now; + else return shaping_time_t(-1); + } + void dequeue_y() { if (++head_y == SIZE) head_y = 0; } + bool empty_y() { return head_y == tail; } + uint16_t free_count_y() { return head_y > tail ? head_y - tail - 1 : head_y + SIZE - tail - 1; } + #endif + void purge() { auto temp = TERN_(HAS_SHAPING_X, head_x) = TERN_(HAS_SHAPING_Y, head_y) = tail; UNUSED(temp);} + }; + + class ParamDelayQueue : public DelayQueue { + private: + #ifdef HAS_SHAPING_X + int32_t params_x[shaping_segments]; + #endif + #ifdef HAS_SHAPING_Y + int32_t params_y[shaping_segments]; + #endif + + public: + void enqueue(const int32_t param_x, const int32_t param_y) { + TERN(HAS_SHAPING_X, params_x[DelayQueue::tail] = param_x, UNUSED(param_x)); + TERN(HAS_SHAPING_Y, params_y[DelayQueue::tail] = param_y, UNUSED(param_y)); + DelayQueue::enqueue(); + } + #ifdef HAS_SHAPING_X + const int32_t dequeue_x() { + const int32_t result = params_x[DelayQueue::head_x]; + DelayQueue::dequeue_x(); + return result; + } + #endif + #ifdef HAS_SHAPING_Y + const int32_t dequeue_y() { + const int32_t result = params_y[DelayQueue::head_y]; + DelayQueue::dequeue_y(); + return result; + } + #endif + }; + + struct ShapeParams { + float frequency; + float zeta; + uint8_t factor; + int32_t dividend; + }; + +#endif // INPUT_SHAPING + // // Stepper class definition // @@ -391,7 +502,7 @@ class Stepper { // Delta error variables for the Bresenham line tracer static xyze_long_t delta_error; - static xyze_ulong_t advance_dividend; + static xyze_long_t advance_dividend; static uint32_t advance_divisor, step_events_completed, // The number of step events executed in the current block accelerate_until, // The point from where we need to stop acceleration @@ -416,6 +527,17 @@ class Stepper { static bool bezier_2nd_half; // If Bézier curve has been initialized or not #endif + #if ENABLED(INPUT_SHAPING) + static ParamDelayQueue shaping_dividend_queue; + static DelayQueue shaping_queue; + #if HAS_SHAPING_X + static ShapeParams shaping_x; + #endif + #if HAS_SHAPING_Y + static ShapeParams shaping_y; + #endif + #endif + #if ENABLED(LIN_ADVANCE) static constexpr uint32_t LA_ADV_NEVER = 0xFFFFFFFF; static uint32_t nextAdvanceISR, @@ -475,6 +597,10 @@ class Stepper { // The stepper block processing ISR phase static uint32_t block_phase_isr(); + #if ENABLED(INPUT_SHAPING) + static void shaping_isr(); + #endif + #if ENABLED(LIN_ADVANCE) // The Linear advance ISR phase static void advance_isr(); @@ -628,6 +754,13 @@ class Stepper { set_directions(); } + #if ENABLED(INPUT_SHAPING) + static void set_shaping_damping_ratio(const AxisEnum axis, const float zeta); + static float get_shaping_damping_ratio(const AxisEnum axis); + static void set_shaping_frequency(const AxisEnum axis, const float freq); + static float get_shaping_frequency(const AxisEnum axis); + #endif + private: // Set the current position in steps diff --git a/buildroot/tests/mega2560 b/buildroot/tests/mega2560 index 86b27790324d..333be2f0faae 100755 --- a/buildroot/tests/mega2560 +++ b/buildroot/tests/mega2560 @@ -80,7 +80,7 @@ opt_set MOTHERBOARD BOARD_AZTEEG_X3_PRO MIXING_STEPPERS 5 LCD_LANGUAGE ru \ FIL_RUNOUT2_PIN 16 FIL_RUNOUT3_PIN 17 FIL_RUNOUT4_PIN 4 FIL_RUNOUT5_PIN 5 opt_enable MIXING_EXTRUDER GRADIENT_MIX GRADIENT_VTOOL CR10_STOCKDISPLAY \ USE_CONTROLLER_FAN CONTROLLER_FAN_EDITABLE CONTROLLER_FAN_IGNORE_Z \ - FILAMENT_RUNOUT_SENSOR ADVANCED_PAUSE_FEATURE NOZZLE_PARK_FEATURE + FILAMENT_RUNOUT_SENSOR ADVANCED_PAUSE_FEATURE NOZZLE_PARK_FEATURE INPUT_SHAPING opt_disable DISABLE_INACTIVE_EXTRUDER exec_test $1 $2 "Azteeg X3 | Mixing Extruder (x5) | Gradient Mix | Greek" "$3" diff --git a/ini/features.ini b/ini/features.ini index 5f30db8a2f08..7c8fd2fd8f33 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -187,6 +187,7 @@ HAS_DUPLICATION_MODE = src_filter=+ PHOTO_GCODE = src_filter=+ CONTROLLER_FAN_EDITABLE = src_filter=+ +INPUT_SHAPING = src_filter=+ GCODE_MACROS = src_filter=+ GRADIENT_MIX = src_filter=+ HAS_SAVED_POSITIONS = src_filter=+ + diff --git a/platformio.ini b/platformio.ini index 751543c8a32b..613f2c963abe 100644 --- a/platformio.ini +++ b/platformio.ini @@ -192,6 +192,7 @@ default_src_filter = + - - + - - - + - - - - From e812540f26fae304764f22023e049dc58a29ca93 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 21 Oct 2022 19:45:20 -0500 Subject: [PATCH 121/243] =?UTF-8?q?=F0=9F=94=A7=20Clean=20up=20unused=20ES?= =?UTF-8?q?P=5FWIFI=20pins?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/Conditionals_post.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 417ce4479a26..21f0eed622da 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -2543,6 +2543,21 @@ #undef TMC_UART_IS #undef ANY_SERIAL_IS +// Clean up unused ESP_WIFI pins +#ifdef ESP_WIFI_MODULE_COM + #if !SERIAL_IN_USE(ESP_WIFI_MODULE_COM) + #undef ESP_WIFI_MODULE_COM + #undef ESP_WIFI_MODULE_BAUDRATE + #undef ESP_WIFI_MODULE_RESET_PIN + #undef ESP_WIFI_MODULE_ENABLE_PIN + #undef ESP_WIFI_MODULE_TXD_PIN + #undef ESP_WIFI_MODULE_RXD_PIN + #undef ESP_WIFI_MODULE_GPIO0_PIN + #undef ESP_WIFI_MODULE_GPIO2_PIN + #undef ESP_WIFI_MODULE_GPIO4_PIN + #endif +#endif + // // Endstops and bed probe // From 44636f3b74c9d5e552dbb49f313ed8b2e17189eb Mon Sep 17 00:00:00 2001 From: kurtis-potier-geofabrica <77456752+kurtis-potier-geofabrica@users.noreply.github.com> Date: Sat, 22 Oct 2022 00:13:56 -0400 Subject: [PATCH 122/243] =?UTF-8?q?=F0=9F=9A=B8=20Up=20to=203=20MAX=20Ther?= =?UTF-8?q?mocouples=20(#24898)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration.h | 4 + Marlin/Configuration_adv.h | 2 + Marlin/src/inc/Conditionals_adv.h | 100 ++++++++++++++++-------- Marlin/src/inc/Conditionals_post.h | 85 ++++++++++++++++++-- Marlin/src/inc/SanityCheck.h | 23 ++++-- Marlin/src/module/temperature.cpp | 121 +++++++++++++++++++++++------ 6 files changed, 261 insertions(+), 74 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 83c1c541e363..87a98298a58e 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -564,6 +564,10 @@ #define MAX31865_SENSOR_OHMS_1 100 #define MAX31865_CALIBRATION_OHMS_1 430 #endif +#if TEMP_SENSOR_IS_MAX_TC(2) + #define MAX31865_SENSOR_OHMS_2 100 + #define MAX31865_CALIBRATION_OHMS_2 430 +#endif #if HAS_E_TEMP_SENSOR #define TEMP_RESIDENCY_TIME 10 // (seconds) Time to wait for hotend to "settle" in M109 diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 01a2bd85c53b..9a54b10b82b1 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -175,6 +175,7 @@ //#define TEMP_SENSOR_FORCE_HW_SPI // Ignore SCK/MOSI/MISO pins; use CS and the default SPI bus. //#define MAX31865_SENSOR_WIRES_0 2 // (2-4) Number of wires for the probe connected to a MAX31865 board. //#define MAX31865_SENSOR_WIRES_1 2 +//#define MAX31865_SENSOR_WIRES_2 2 //#define MAX31865_50HZ_FILTER // Use a 50Hz filter instead of the default 60Hz. //#define MAX31865_USE_READ_ERROR_DETECTION // Treat value spikes (20°C delta in under 1s) as read errors. @@ -185,6 +186,7 @@ //#define MAX31865_WIRE_OHMS_0 0.95f // For 2-wire, set the wire resistances for more accurate readings. //#define MAX31865_WIRE_OHMS_1 0.0f +//#define MAX31865_WIRE_OHMS_2 0.0f /** * Hephestos 2 24V heated bed upgrade kit. diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 1f8f0ddfb61e..dd69e61c9275 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -262,26 +262,72 @@ #undef HEATER_1_MAXTEMP #endif +#if TEMP_SENSOR_IS_MAX_TC(2) + #if TEMP_SENSOR_2 == -5 + #define TEMP_SENSOR_2_IS_MAX31865 1 + #define TEMP_SENSOR_2_MAX_TC_TMIN 0 + #define TEMP_SENSOR_2_MAX_TC_TMAX 1024 + #ifndef MAX31865_SENSOR_WIRES_2 + #define MAX31865_SENSOR_WIRES_2 2 + #endif + #ifndef MAX31865_WIRE_OHMS_2 + #define MAX31865_WIRE_OHMS_2 0.0f + #endif + #elif TEMP_SENSOR_2 == -3 + #define TEMP_SENSOR_2_IS_MAX31855 1 + #define TEMP_SENSOR_2_MAX_TC_TMIN -270 + #define TEMP_SENSOR_2_MAX_TC_TMAX 1800 + #elif TEMP_SENSOR_2 == -2 + #define TEMP_SENSOR_2_IS_MAX6675 1 + #define TEMP_SENSOR_2_MAX_TC_TMIN 0 + #define TEMP_SENSOR_2_MAX_TC_TMAX 1024 + #endif + + #if TEMP_SENSOR_2 != TEMP_SENSOR_0 + #if TEMP_SENSOR_2 == -5 + #error "If MAX31865 Thermocouple (-5) is used for TEMP_SENSOR_2 then TEMP_SENSOR_0 must match." + #elif TEMP_SENSOR_2 == -3 + #error "If MAX31855 Thermocouple (-3) is used for TEMP_SENSOR_2 then TEMP_SENSOR_0 must match." + #elif TEMP_SENSOR_2 == -2 + #error "If MAX6675 Thermocouple (-2) is used for TEMP_SENSOR_2 then TEMP_SENSOR_0 must match." + #endif + #endif +#elif TEMP_SENSOR_2 == -4 + #define TEMP_SENSOR_2_IS_AD8495 1 +#elif TEMP_SENSOR_2 == -1 + #define TEMP_SENSOR_2_IS_AD595 1 +#elif TEMP_SENSOR_2 > 0 + #define TEMP_SENSOR_2_IS_THERMISTOR 1 + #if TEMP_SENSOR_2 == 1000 + #define TEMP_SENSOR_2_IS_CUSTOM 1 + #elif TEMP_SENSOR_2 == 998 || TEMP_SENSOR_2 == 999 + #define TEMP_SENSOR_2_IS_DUMMY 1 + #endif +#else + #undef HEATER_2_MINTEMP + #undef HEATER_2_MAXTEMP +#endif + #if TEMP_SENSOR_IS_MAX_TC(REDUNDANT) #if TEMP_SENSOR_REDUNDANT == -5 - #if !REDUNDANT_TEMP_MATCH(SOURCE, E0) && !REDUNDANT_TEMP_MATCH(SOURCE, E1) - #error "MAX31865 Thermocouples (-5) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_0/TEMP_SENSOR_1 (0/1)." + #if !REDUNDANT_TEMP_MATCH(SOURCE, E0) && !REDUNDANT_TEMP_MATCH(SOURCE, E1) && !REDUNDANT_TEMP_MATCH(SOURCE, E2) + #error "MAX31865 Thermocouples (-5) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_0/TEMP_SENSOR_1/TEMP_SENSOR_2 (0/1/2)." #endif #define TEMP_SENSOR_REDUNDANT_IS_MAX31865 1 #define TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN 0 #define TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX 1024 #elif TEMP_SENSOR_REDUNDANT == -3 - #if !REDUNDANT_TEMP_MATCH(SOURCE, E0) && !REDUNDANT_TEMP_MATCH(SOURCE, E1) - #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_0/TEMP_SENSOR_1 (0/1)." + #if !REDUNDANT_TEMP_MATCH(SOURCE, E0) && !REDUNDANT_TEMP_MATCH(SOURCE, E1) && !REDUNDANT_TEMP_MATCH(SOURCE, E2) + #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_0/TEMP_SENSOR_1/TEMP_SENSOR_2 (0/1/2)." #endif #define TEMP_SENSOR_REDUNDANT_IS_MAX31855 1 #define TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN -270 #define TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX 1800 #elif TEMP_SENSOR_REDUNDANT == -2 - #if !REDUNDANT_TEMP_MATCH(SOURCE, E0) && !REDUNDANT_TEMP_MATCH(SOURCE, E1) - #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_0/TEMP_SENSOR_1 (0/1)." + #if !REDUNDANT_TEMP_MATCH(SOURCE, E0) && !REDUNDANT_TEMP_MATCH(SOURCE, E1) && !REDUNDANT_TEMP_MATCH(SOURCE, E2) + #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_REDUNDANT_SOURCE other than TEMP_SENSOR_0/TEMP_SENSOR_1/TEMP_SENSOR_2 (0/1/2)." #endif #define TEMP_SENSOR_REDUNDANT_IS_MAX6675 1 @@ -302,15 +348,21 @@ #ifndef MAX31865_SENSOR_WIRES_1 #define MAX31865_SENSOR_WIRES_1 2 #endif + #elif REDUNDANT_TEMP_MATCH(SOURCE, E2) + #define TEMP_SENSOR_2_MAX_TC_TMIN TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN + #define TEMP_SENSOR_2_MAX_TC_TMAX TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX + #ifndef MAX31865_SENSOR_WIRES_2 + #define MAX31865_SENSOR_WIRES_2 2 + #endif #endif - #if (TEMP_SENSOR_IS_MAX_TC(0) && TEMP_SENSOR_REDUNDANT != TEMP_SENSOR_0) || (TEMP_SENSOR_IS_MAX_TC(1) && TEMP_SENSOR_REDUNDANT != TEMP_SENSOR_1) + #if (TEMP_SENSOR_IS_MAX_TC(0) && TEMP_SENSOR_REDUNDANT != TEMP_SENSOR_0) || (TEMP_SENSOR_IS_MAX_TC(1) && TEMP_SENSOR_REDUNDANT != TEMP_SENSOR_1) || (TEMP_SENSOR_IS_MAX_TC(2) && TEMP_SENSOR_REDUNDANT != TEMP_SENSOR_2) #if TEMP_SENSOR_REDUNDANT == -5 - #error "If MAX31865 Thermocouple (-5) is used for TEMP_SENSOR_0/TEMP_SENSOR_1 then TEMP_SENSOR_REDUNDANT must match." + #error "If MAX31865 Thermocouple (-5) is used for TEMP_SENSOR_0/TEMP_SENSOR_1/TEMP_SENSOR_2 then TEMP_SENSOR_REDUNDANT must match." #elif TEMP_SENSOR_REDUNDANT == -3 - #error "If MAX31855 Thermocouple (-3) is used for TEMP_SENSOR_0/TEMP_SENSOR_1 then TEMP_SENSOR_REDUNDANT must match." + #error "If MAX31855 Thermocouple (-3) is used for TEMP_SENSOR_0/TEMP_SENSOR_1/TEMP_SENSOR_2 then TEMP_SENSOR_REDUNDANT must match." #elif TEMP_SENSOR_REDUNDANT == -2 - #error "If MAX6675 Thermocouple (-2) is used for TEMP_SENSOR_0/TEMP_SENSOR_1 then TEMP_SENSOR_REDUNDANT must match." + #error "If MAX6675 Thermocouple (-2) is used for TEMP_SENSOR_0/TEMP_SENSOR_1/TEMP_SENSOR_2 then TEMP_SENSOR_REDUNDANT must match." #endif #endif #elif TEMP_SENSOR_REDUNDANT == -4 @@ -326,39 +378,19 @@ #endif #endif -#if TEMP_SENSOR_IS_MAX_TC(0) || TEMP_SENSOR_IS_MAX_TC(1) || TEMP_SENSOR_IS_MAX_TC(REDUNDANT) +#if TEMP_SENSOR_IS_MAX_TC(0) || TEMP_SENSOR_IS_MAX_TC(1) || TEMP_SENSOR_IS_MAX_TC(2) || TEMP_SENSOR_IS_MAX_TC(REDUNDANT) #define HAS_MAX_TC 1 #endif -#if TEMP_SENSOR_0_IS_MAX6675 || TEMP_SENSOR_1_IS_MAX6675 || TEMP_SENSOR_REDUNDANT_IS_MAX6675 +#if TEMP_SENSOR_0_IS_MAX6675 || TEMP_SENSOR_1_IS_MAX6675 || TEMP_SENSOR_2_IS_MAX6675 || TEMP_SENSOR_REDUNDANT_IS_MAX6675 #define HAS_MAX6675 1 #endif -#if TEMP_SENSOR_0_IS_MAX31855 || TEMP_SENSOR_1_IS_MAX31855 || TEMP_SENSOR_REDUNDANT_IS_MAX31855 +#if TEMP_SENSOR_0_IS_MAX31855 || TEMP_SENSOR_1_IS_MAX31855 || TEMP_SENSOR_2_IS_MAX31855 || TEMP_SENSOR_REDUNDANT_IS_MAX31855 #define HAS_MAX31855 1 #endif -#if TEMP_SENSOR_0_IS_MAX31865 || TEMP_SENSOR_1_IS_MAX31865 || TEMP_SENSOR_REDUNDANT_IS_MAX31865 +#if TEMP_SENSOR_0_IS_MAX31865 || TEMP_SENSOR_1_IS_MAX31865 || TEMP_SENSOR_2_IS_MAX31865 || TEMP_SENSOR_REDUNDANT_IS_MAX31865 #define HAS_MAX31865 1 #endif -#if TEMP_SENSOR_2 == -4 - #define TEMP_SENSOR_2_IS_AD8495 1 -#elif TEMP_SENSOR_2 == -3 - #error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_2." -#elif TEMP_SENSOR_2 == -2 - #error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_2." -#elif TEMP_SENSOR_2 == -1 - #define TEMP_SENSOR_2_IS_AD595 1 -#elif TEMP_SENSOR_2 > 0 - #define TEMP_SENSOR_2_IS_THERMISTOR 1 - #if TEMP_SENSOR_2 == 1000 - #define TEMP_SENSOR_2_IS_CUSTOM 1 - #elif TEMP_SENSOR_2 == 998 || TEMP_SENSOR_2 == 999 - #define TEMP_SENSOR_2_IS_DUMMY 1 - #endif -#else - #undef HEATER_2_MINTEMP - #undef HEATER_2_MAXTEMP -#endif - #if TEMP_SENSOR_3 == -4 #define TEMP_SENSOR_3_IS_AD8495 1 #elif TEMP_SENSOR_3 == -3 diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 21f0eed622da..5f540393921d 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -723,19 +723,19 @@ #define TEMP_0_SCK_PIN MAX31855_SCK_PIN #endif - #elif TEMP_SENSOR_1_IS_MAX31865 - #if !PIN_EXISTS(TEMP_1_MISO) // DO + #elif TEMP_SENSOR_0_IS_MAX31865 + #if !PIN_EXISTS(TEMP_0_MISO) // DO #if PIN_EXISTS(MAX31865_MISO) - #define TEMP_1_MISO_PIN MAX31865_MISO_PIN + #define TEMP_0_MISO_PIN MAX31865_MISO_PIN #elif PIN_EXISTS(MAX31865_DO) - #define TEMP_1_MISO_PIN MAX31865_DO_PIN + #define TEMP_0_MISO_PIN MAX31865_DO_PIN #endif #endif - #if !PIN_EXISTS(TEMP_1_SCK) && PIN_EXISTS(MAX31865_SCK) - #define TEMP_1_SCK_PIN MAX31865_SCK_PIN + #if !PIN_EXISTS(TEMP_0_SCK) && PIN_EXISTS(MAX31865_SCK) + #define TEMP_0_SCK_PIN MAX31865_SCK_PIN #endif - #if !PIN_EXISTS(TEMP_1_MOSI) && PIN_EXISTS(MAX31865_MOSI) // MOSI for '65 only - #define TEMP_1_MOSI_PIN MAX31865_MOSI_PIN + #if !PIN_EXISTS(TEMP_0_MOSI) && PIN_EXISTS(MAX31865_MOSI) // MOSI for '65 only + #define TEMP_0_MOSI_PIN MAX31865_MOSI_PIN #endif #endif @@ -819,6 +819,75 @@ #endif // TEMP_SENSOR_IS_MAX_TC(1) + #if TEMP_SENSOR_IS_MAX_TC(2) || (TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E2)) + + #if !PIN_EXISTS(TEMP_2_CS) // SS3, CS3 + #if PIN_EXISTS(MAX6675_SS3) + #define TEMP_2_CS_PIN MAX6675_SS3_PIN + #elif PIN_EXISTS(MAX6675_CS) + #define TEMP_2_CS_PIN MAX6675_CS3_PIN + #elif PIN_EXISTS(MAX31855_SS3) + #define TEMP_2_CS_PIN MAX31855_SS3_PIN + #elif PIN_EXISTS(MAX31855_CS3) + #define TEMP_2_CS_PIN MAX31855_CS3_PIN + #elif PIN_EXISTS(MAX31865_SS3) + #define TEMP_2_CS_PIN MAX31865_SS3_PIN + #elif PIN_EXISTS(MAX31865_CS3) + #define TEMP_2_CS_PIN MAX31865_CS3_PIN + #endif + #endif + + #if TEMP_SENSOR_2_IS_MAX6675 + #if !PIN_EXISTS(TEMP_2_MISO) // DO + #if PIN_EXISTS(MAX6675_MISO) + #define TEMP_2_MISO_PIN MAX6675_MISO_PIN + #elif PIN_EXISTS(MAX6675_DO) + #define TEMP_2_MISO_PIN MAX6675_DO_PIN + #endif + #endif + #if !PIN_EXISTS(TEMP_2_SCK) && PIN_EXISTS(MAX6675_SCK) + #define TEMP_2_SCK_PIN MAX6675_SCK_PIN + #endif + + #elif TEMP_SENSOR_2_IS_MAX31855 + #if !PIN_EXISTS(TEMP_2_MISO) // DO + #if PIN_EXISTS(MAX31855_MISO) + #define TEMP_2_MISO_PIN MAX31855_MISO_PIN + #elif PIN_EXISTS(MAX31855_DO) + #define TEMP_2_MISO_PIN MAX31855_DO_PIN + #endif + #endif + #if !PIN_EXISTS(TEMP_2_SCK) && PIN_EXISTS(MAX31855_SCK) + #define TEMP_2_SCK_PIN MAX31855_SCK_PIN + #endif + + #elif TEMP_SENSOR_2_IS_MAX31865 + #if !PIN_EXISTS(TEMP_2_MISO) // DO + #if PIN_EXISTS(MAX31865_MISO) + #define TEMP_2_MISO_PIN MAX31865_MISO_PIN + #elif PIN_EXISTS(MAX31865_DO) + #define TEMP_2_MISO_PIN MAX31865_DO_PIN + #endif + #endif + #if !PIN_EXISTS(TEMP_2_SCK) && PIN_EXISTS(MAX31865_SCK) + #define TEMP_2_SCK_PIN MAX31865_SCK_PIN + #endif + #if !PIN_EXISTS(TEMP_2_MOSI) && PIN_EXISTS(MAX31865_MOSI) // MOSI for '65 only + #define TEMP_2_MOSI_PIN MAX31865_MOSI_PIN + #endif + #endif + + // Software SPI - enable if MISO/SCK are defined. + #if PIN_EXISTS(TEMP_2_MISO) && PIN_EXISTS(TEMP_2_SCK) && DISABLED(TEMP_SENSOR_2_FORCE_HW_SPI) + #if TEMP_SENSOR_2_IS_MAX31865 && !PIN_EXISTS(TEMP_2_MOSI) + #error "TEMP_SENSOR_2 MAX31865 requires TEMP_2_MOSI_PIN defined for Software SPI. To use Hardware SPI instead, undefine MISO/SCK or enable TEMP_SENSOR_2_FORCE_HW_SPI." + #else + #define TEMP_SENSOR_2_HAS_SPI_PINS 1 + #endif + #endif + + #endif // TEMP_SENSOR_IS_MAX_TC(2) + // // User-defined thermocouple libraries // diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 06b8f32946ad..744e68a5bb0d 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -416,17 +416,17 @@ #elif defined(CHDK) #error "CHDK is now CHDK_PIN." #elif ANY_PIN( \ - MAX6675_SS, MAX6675_SS2, MAX6675_CS, MAX6675_CS2, \ - MAX31855_SS, MAX31855_SS2, MAX31855_CS, MAX31855_CS2, \ - MAX31865_SS, MAX31865_SS2, MAX31865_CS, MAX31865_CS2) - #warning "MAX*_SS_PIN, MAX*_SS2_PIN, MAX*_CS_PIN, and MAX*_CS2_PIN are deprecated and will be removed in a future version. Please use TEMP_0_CS_PIN/TEMP_1_CS_PIN instead." + MAX6675_SS, MAX6675_SS2, MAX6675_SS3, MAX6675_CS, MAX6675_CS2, MAX6675_CS3,\ + MAX31855_SS, MAX31855_SS2, MAX31855_SS3, MAX31855_CS, MAX31855_CS2, MAX31855_CS3, \ + MAX31865_SS, MAX31865_SS2, MAX31865_SS3, MAX31865_CS, MAX31865_CS2, MAX31865_CS3) + #warning "MAX*_SS_PIN, MAX*_SS2_PIN, MAX*_SS3_PIN, MAX*_CS_PIN, MAX*_CS2_PIN, and MAX*_CS3_PIN, are deprecated and will be removed in a future version. Please use TEMP_0_CS_PIN/TEMP_1_CS_PIN/TEMP_2_CS_PIN instead." #elif ANY_PIN(MAX6675_SCK, MAX31855_SCK, MAX31865_SCK) - #warning "MAX*_SCK_PIN is deprecated and will be removed in a future version. Please use TEMP_0_SCK_PIN/TEMP_1_SCK_PIN instead." + #warning "MAX*_SCK_PIN is deprecated and will be removed in a future version. Please use TEMP_0_SCK_PIN/TEMP_1_SCK_PIN/TEMP_2_SCK_PIN instead." #elif ANY_PIN(MAX6675_MISO, MAX6675_DO, MAX31855_MISO, MAX31855_DO, MAX31865_MISO, MAX31865_DO) - #warning "MAX*_MISO_PIN and MAX*_DO_PIN are deprecated and will be removed in a future version. Please use TEMP_0_MISO_PIN/TEMP_1_MISO_PIN instead." + #warning "MAX*_MISO_PIN and MAX*_DO_PIN are deprecated and will be removed in a future version. Please use TEMP_0_MISO_PIN/TEMP_1_MISO_PIN/TEMP_2_MISO_PIN instead." #elif PIN_EXISTS(MAX31865_MOSI) - #warning "MAX31865_MOSI_PIN is deprecated and will be removed in a future version. Please use TEMP_0_MOSI_PIN/TEMP_1_MOSI_PIN instead." -#elif ANY_PIN(THERMO_CS1_PIN, THERMO_CS2_PIN, THERMO_DO_PIN, THERMO_SCK_PIN) + #warning "MAX31865_MOSI_PIN is deprecated and will be removed in a future version. Please use TEMP_0_MOSI_PIN/TEMP_1_MOSI_PIN/TEMP_2_MOSI_PIN instead." +#elif ANY_PIN(THERMO_CS1_PIN, THERMO_CS2_PIN, THERMO_CS3_PIN, THERMO_DO_PIN, THERMO_SCK_PIN) #error "THERMO_*_PIN is now TEMP_n_CS_PIN, TEMP_n_SCK_PIN, TEMP_n_MOSI_PIN, TEMP_n_MISO_PIN." #elif defined(MAX31865_SENSOR_OHMS) #error "MAX31865_SENSOR_OHMS is now MAX31865_SENSOR_OHMS_0." @@ -2340,6 +2340,13 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #error "MAX31865_SENSOR_OHMS_1 and MAX31865_CALIBRATION_OHMS_1 must be set if TEMP_SENSOR_1/TEMP_SENSOR_REDUNDANT is MAX31865." #endif #endif +#if TEMP_SENSOR_2_IS_MAX31865 || (TEMP_SENSOR_REDUNDANT_IS_MAX31865 && REDUNDANT_TEMP_MATCH(SOURCE, E2)) + #if !defined(MAX31865_SENSOR_WIRES_2) || !WITHIN(MAX31865_SENSOR_WIRES_2, 2, 4) + #error "MAX31865_SENSOR_WIRES_2 must be defined as an integer between 2 and 4." + #elif !defined(MAX31865_SENSOR_OHMS_2) || !defined(MAX31865_CALIBRATION_OHMS_2) + #error "MAX31865_SENSOR_OHMS_2 and MAX31865_CALIBRATION_OHMS_2 must be set if TEMP_SENSOR_2/TEMP_SENSOR_REDUNDANT is MAX31865." + #endif +#endif /** * Redundant temperature sensor config diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 7515396fbefb..8843582f4e67 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -113,13 +113,16 @@ // 3. CS, MISO, and SCK pins w/ FORCE_HW_SPI: Hardware SPI on the default bus, ignoring MISO, SCK. // #if TEMP_SENSOR_IS_ANY_MAX_TC(0) && TEMP_SENSOR_0_HAS_SPI_PINS && DISABLED(TEMP_SENSOR_FORCE_HW_SPI) - #define TEMP_SENSOR_0_USES_SW_SPI 1 + #define TEMP_SENSOR_0_USES_SW_SPI 1 #endif #if TEMP_SENSOR_IS_ANY_MAX_TC(1) && TEMP_SENSOR_1_HAS_SPI_PINS && DISABLED(TEMP_SENSOR_FORCE_HW_SPI) - #define TEMP_SENSOR_1_USES_SW_SPI 1 + #define TEMP_SENSOR_1_USES_SW_SPI 1 +#endif +#if TEMP_SENSOR_IS_ANY_MAX_TC(2) && TEMP_SENSOR_2_HAS_SPI_PINS && DISABLED(TEMP_SENSOR_FORCE_HW_SPI) + #define TEMP_SENSOR_2_USES_SW_SPI 1 #endif -#if (TEMP_SENSOR_0_USES_SW_SPI || TEMP_SENSOR_1_USES_SW_SPI) && !HAS_MAXTC_LIBRARIES +#if (TEMP_SENSOR_0_USES_SW_SPI || TEMP_SENSOR_1_USES_SW_SPI || TEMP_SENSOR_2_USES_SW_SPI) && !HAS_MAXTC_LIBRARIES #include "../libs/private_spi.h" #define HAS_MAXTC_SW_SPI 1 @@ -130,12 +133,18 @@ #if PIN_EXISTS(TEMP_0_MOSI) #define SW_SPI_MOSI_PIN TEMP_0_MOSI_PIN #endif - #else + #elif TEMP_SENSOR_1_USES_SW_SPI #define SW_SPI_SCK_PIN TEMP_1_SCK_PIN #define SW_SPI_MISO_PIN TEMP_1_MISO_PIN #if PIN_EXISTS(TEMP_1_MOSI) #define SW_SPI_MOSI_PIN TEMP_1_MOSI_PIN #endif + #elif TEMP_SENSOR_2_USES_SW_SPI + #define SW_SPI_SCK_PIN TEMP_2_SCK_PIN + #define SW_SPI_MISO_PIN TEMP_2_MISO_PIN + #if PIN_EXISTS(TEMP_2_MOSI) + #define SW_SPI_MOSI_PIN TEMP_2_MOSI_PIN + #endif #endif #ifndef SW_SPI_MOSI_PIN #define SW_SPI_MOSI_PIN SD_MOSI_PIN @@ -256,6 +265,9 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); #if TEMP_SENSOR_IS_MAX(1, 6675) MAXTC_INIT(1, 6675); #endif + #if TEMP_SENSOR_IS_MAX(2, 6675) + MAXTC_INIT(2, 6675); + #endif #endif #if HAS_MAX31855_LIBRARY @@ -265,12 +277,16 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); #if TEMP_SENSOR_IS_MAX(1, 31855) MAXTC_INIT(1, 31855); #endif + #if TEMP_SENSOR_IS_MAX(2, 31855) + MAXTC_INIT(2, 31855); + #endif #endif // MAX31865 always uses a library, unlike '55 & 6675 #if HAS_MAX31865 #define _MAX31865_0_SW TEMP_SENSOR_0_USES_SW_SPI #define _MAX31865_1_SW TEMP_SENSOR_1_USES_SW_SPI + #define _MAX31865_2_SW TEMP_SENSOR_2_USES_SW_SPI #if TEMP_SENSOR_IS_MAX(0, 31865) MAXTC_INIT(0, 31865); @@ -278,9 +294,13 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); #if TEMP_SENSOR_IS_MAX(1, 31865) MAXTC_INIT(1, 31865); #endif + #if TEMP_SENSOR_IS_MAX(2, 31865) + MAXTC_INIT(2, 31865); + #endif #undef _MAX31865_0_SW #undef _MAX31865_1_SW + #undef _MAX31865_2_SW #endif #undef MAXTC_INIT @@ -541,6 +561,7 @@ volatile bool Temperature::raw_temps_ready = false; #endif #if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1 + #define MULTI_MAX_CONSECUTIVE_LOW_TEMP_ERR 1 uint8_t Temperature::consecutive_low_temperature_error[HOTENDS] = { 0 }; #endif @@ -1866,6 +1887,10 @@ void Temperature::task() { if (degHotend(1) > _MIN(HEATER_1_MAXTEMP, TEMP_SENSOR_1_MAX_TC_TMAX - 1.0)) max_temp_error(H_E1); if (degHotend(1) < _MAX(HEATER_1_MINTEMP, TEMP_SENSOR_1_MAX_TC_TMIN + .01)) min_temp_error(H_E1); #endif + #if TEMP_SENSOR_IS_MAX_TC(2) + if (degHotend(2) > _MIN(HEATER_2_MAXTEMP, TEMP_SENSOR_2_MAX_TC_TMAX - 1.0)) max_temp_error(H_E2); + if (degHotend(2) < _MAX(HEATER_2_MINTEMP, TEMP_SENSOR_2_MAX_TC_TMIN + .01)) min_temp_error(H_E2); + #endif #if TEMP_SENSOR_IS_MAX_TC(REDUNDANT) if (degRedundant() > TEMP_SENSOR_REDUNDANT_MAX_TC_TMAX - 1.0) max_temp_error(H_REDUNDANT); if (degRedundant() < TEMP_SENSOR_REDUNDANT_MAX_TC_TMIN + .01) min_temp_error(H_REDUNDANT); @@ -2112,6 +2137,15 @@ void Temperature::task() { case 2: #if TEMP_SENSOR_2_IS_CUSTOM return user_thermistor_to_deg_c(CTI_HOTEND_2, raw); + #elif TEMP_SENSOR_IS_MAX_TC(2) + #if TEMP_SENSOR_0_IS_MAX31865 + return TERN(LIB_INTERNAL_MAX31865, + max31865_2.temperature(raw), + max31865_2.temperature(MAX31865_SENSOR_OHMS_2, MAX31865_CALIBRATION_OHMS_2) + ); + #else + return (int16_t)raw * 0.25; + #endif #elif TEMP_SENSOR_2_IS_AD595 return TEMP_AD595(raw); #elif TEMP_SENSOR_2_IS_AD8495 @@ -2281,6 +2315,8 @@ void Temperature::task() { return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_0.temperature(raw), (int16_t)raw * 0.25); #elif TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E1) return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_1.temperature(raw), (int16_t)raw * 0.25); + #elif TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E2) + return TERN(TEMP_SENSOR_REDUNDANT_IS_MAX31865, max31865_2.temperature(raw), (int16_t)raw * 0.25); #elif TEMP_SENSOR_REDUNDANT_IS_THERMISTOR SCAN_THERMISTOR_TABLE(TEMPTABLE_REDUNDANT, TEMPTABLE_REDUNDANT_LEN); #elif TEMP_SENSOR_REDUNDANT_IS_AD595 @@ -2316,6 +2352,9 @@ void Temperature::updateTemperaturesFromRawValues() { #if TEMP_SENSOR_IS_MAX_TC(1) temp_hotend[1].setraw(READ_MAX_TC(1)); #endif + #if TEMP_SENSOR_IS_MAX_TC(2) + temp_hotend[2].setraw(READ_MAX_TC(2)); + #endif #if TEMP_SENSOR_IS_MAX_TC(REDUNDANT) temp_redundant.setraw(READ_MAX_TC(HEATER_ID(TEMP_SENSOR_REDUNDANT_SOURCE))); #endif @@ -2347,9 +2386,14 @@ void Temperature::updateTemperaturesFromRawValues() { #else , TEMPDIR(1) #endif - #if HOTENDS > 2 + #if TEMP_SENSOR_IS_ANY_MAX_TC(2) + , 0 + #else + , TEMPDIR(2) + #endif + #if HOTENDS > 3 #define _TEMPDIR(N) , TEMPDIR(N) - REPEAT_S(2, HOTENDS, _TEMPDIR) + REPEAT_S(3, HOTENDS, _TEMPDIR) #endif #endif }; @@ -2362,15 +2406,12 @@ void Temperature::updateTemperaturesFromRawValues() { const bool heater_on = temp_hotend[e].target > 0; if (heater_on && ((neg && r > temp_range[e].raw_min) || (pos && r < temp_range[e].raw_min))) { - #if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1 - if (++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED) - #endif - min_temp_error((heater_id_t)e); + if (TERN1(MULTI_MAX_CONSECUTIVE_LOW_TEMP_ERR, ++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED)) + min_temp_error((heater_id_t)e); + } + else { + TERN_(MULTI_MAX_CONSECUTIVE_LOW_TEMP_ERR, consecutive_low_temperature_error[e] = 0); } - #if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1 - else - consecutive_low_temperature_error[e] = 0; - #endif } #endif // HAS_HOTEND @@ -2432,6 +2473,9 @@ void Temperature::init() { #if TEMP_SENSOR_IS_ANY_MAX_TC(1) && PIN_EXISTS(TEMP_1_CS) OUT_WRITE(TEMP_1_CS_PIN, HIGH); #endif + #if TEMP_SENSOR_IS_ANY_MAX_TC(2) && PIN_EXISTS(TEMP_2_CS) + OUT_WRITE(TEMP_2_CS_PIN, HIGH); + #endif // Setup objects for library-based polling of MAX TCs #if HAS_MAXTC_LIBRARIES @@ -2459,6 +2503,18 @@ void Temperature::init() { OPTARG(LIB_INTERNAL_MAX31865, MAX31865_SENSOR_OHMS_1, MAX31865_CALIBRATION_OHMS_1, MAX31865_WIRE_OHMS_1) ); #endif + + #if TEMP_SENSOR_IS_MAX(2, 6675) && HAS_MAX6675_LIBRARY + max6675_2.begin(); + #elif TEMP_SENSOR_IS_MAX(2, 31855) && HAS_MAX31855_LIBRARY + max31855_2.begin(); + #elif TEMP_SENSOR_IS_MAX(2, 31865) + max31865_2.begin( + MAX31865_WIRES(MAX31865_SENSOR_WIRES_2) // MAX31865_2WIRE, MAX31865_3WIRE, MAX31865_4WIRE + OPTARG(LIB_INTERNAL_MAX31865, MAX31865_SENSOR_OHMS_2, MAX31865_CALIBRATION_OHMS_2, MAX31865_WIRE_OHMS_2) + ); + #endif + #undef MAX31865_WIRES #undef _MAX31865_WIRES #endif @@ -2491,6 +2547,15 @@ void Temperature::init() { #endif )); #endif + #if PIN_EXISTS(TEMP_2_TR_ENABLE) + OUT_WRITE(TEMP_2_TR_ENABLE_PIN, ( + #if TEMP_SENSOR_IS_ANY_MAX_TC(2) + HIGH + #else + LOW + #endif + )); + #endif #if ENABLED(MPCTEMP) HOTEND_LOOP() temp_hotend[e].modeled_block_temp = NAN; @@ -3009,25 +3074,29 @@ void Temperature::disable_all_heaters() { // Needed to return the correct temp when this is called between readings static raw_adc_t max_tc_temp_previous[MAX_TC_COUNT] = { 0 }; #define THERMO_TEMP(I) max_tc_temp_previous[I] - #define THERMO_SEL(A,B) (hindex ? (B) : (A)) - #define MAXTC_CS_WRITE(V) do{ switch (hindex) { case 1: WRITE(TEMP_1_CS_PIN, V); break; default: WRITE(TEMP_0_CS_PIN, V); } }while(0) + #define THERMO_SEL(A,B,C) (hindex > 1 ? (C) : hindex == 1 ? (B) : (A)) + #define MAXTC_CS_WRITE(V) do{ switch (hindex) { case 1: WRITE(TEMP_1_CS_PIN, V); break; case 2: WRITE(TEMP_2_CS_PIN, V); break; default: WRITE(TEMP_0_CS_PIN, V); } }while(0) #else // When we have only 1 max tc, THERMO_SEL will pick the appropriate sensor // variable, and MAXTC_*() macros will be hardcoded to the correct CS pin. constexpr uint8_t hindex = 0; #define THERMO_TEMP(I) max_tc_temp #if TEMP_SENSOR_IS_ANY_MAX_TC(0) - #define THERMO_SEL(A,B) A + #define THERMO_SEL(A,B,C) A #define MAXTC_CS_WRITE(V) WRITE(TEMP_0_CS_PIN, V) - #else - #define THERMO_SEL(A,B) B + #elif TEMP_SENSOR_IS_ANY_MAX_TC(1) + #define THERMO_SEL(A,B,C) B #define MAXTC_CS_WRITE(V) WRITE(TEMP_1_CS_PIN, V) + #elif TEMP_SENSOR_IS_ANY_MAX_TC(2) + #define THERMO_SEL(A,B,C) C + #define MAXTC_CS_WRITE(V) WRITE(TEMP_2_CS_PIN, V) #endif #endif static TERN(HAS_MAX31855, uint32_t, uint16_t) max_tc_temp = THERMO_SEL( TEMP_SENSOR_0_MAX_TC_TMAX, - TEMP_SENSOR_1_MAX_TC_TMAX + TEMP_SENSOR_1_MAX_TC_TMAX, + TEMP_SENSOR_2_MAX_TC_TMAX ); static uint8_t max_tc_errors[MAX_TC_COUNT] = { 0 }; @@ -3062,17 +3131,17 @@ void Temperature::disable_all_heaters() { MAXTC_CS_WRITE(HIGH); // Disable MAXTC #else #if HAS_MAX6675_LIBRARY - MAX6675 &max6675ref = THERMO_SEL(max6675_0, max6675_1); + MAX6675 &max6675ref = THERMO_SEL(max6675_0, max6675_1, max6675_2); max_tc_temp = max6675ref.readRaw16(); #endif #if HAS_MAX31855_LIBRARY - MAX31855 &max855ref = THERMO_SEL(max31855_0, max31855_1); + MAX31855 &max855ref = THERMO_SEL(max31855_0, max31855_1, max31855_2); max_tc_temp = max855ref.readRaw32(); #endif #if HAS_MAX31865 - MAX31865 &max865ref = THERMO_SEL(max31865_0, max31865_1); + MAX31865 &max865ref = THERMO_SEL(max31865_0, max31865_1, max31865_2); max_tc_temp = TERN(LIB_INTERNAL_MAX31865, max865ref.readRaw(), max865ref.readRTD_with_Fault()); #endif #endif @@ -3117,7 +3186,7 @@ void Temperature::disable_all_heaters() { #endif // Set thermocouple above max temperature (TMAX) - max_tc_temp = THERMO_SEL(TEMP_SENSOR_0_MAX_TC_TMAX, TEMP_SENSOR_1_MAX_TC_TMAX) << (MAX_TC_DISCARD_BITS + 1); + max_tc_temp = THERMO_SEL(TEMP_SENSOR_0_MAX_TC_TMAX, TEMP_SENSOR_1_MAX_TC_TMAX, TEMP_SENSOR_2_MAX_TC_TMAX) << (MAX_TC_DISCARD_BITS + 1); } } else { @@ -3155,6 +3224,10 @@ void Temperature::update_raw_temperatures() { temp_hotend[1].update(); #endif + #if HAS_TEMP_ADC_2 && !TEMP_SENSOR_IS_MAX_TC(2) + temp_hotend[2].update(); + #endif + #if HAS_TEMP_ADC_REDUNDANT && !TEMP_SENSOR_IS_MAX_TC(REDUNDANT) temp_redundant.update(); #endif From 4ce2f1e5babba8dcee160ffbbd6d907f0c934355 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 22 Oct 2022 23:35:31 -0500 Subject: [PATCH 123/243] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20M593=20report?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/feature/input_shaping/M593.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Marlin/src/gcode/feature/input_shaping/M593.cpp b/Marlin/src/gcode/feature/input_shaping/M593.cpp index 84301963cbde..e1e99ca51b7a 100644 --- a/Marlin/src/gcode/feature/input_shaping/M593.cpp +++ b/Marlin/src/gcode/feature/input_shaping/M593.cpp @@ -30,13 +30,14 @@ void GcodeSuite::M593_report(const bool forReplay/*=true*/) { report_heading_etc(forReplay, F("Input Shaping")); #if HAS_SHAPING_X - SERIAL_ECHO_MSG("M593 X" + SERIAL_ECHOLNPGM(" M593 X" " F", stepper.get_shaping_frequency(X_AXIS), " D", stepper.get_shaping_damping_ratio(X_AXIS) ); #endif #if HAS_SHAPING_Y - SERIAL_ECHO_MSG("M593 Y" + TERN_(HAS_SHAPING_X, report_echo_start(forReplay)); + SERIAL_ECHOLNPGM(" M593 Y" " F", stepper.get_shaping_frequency(Y_AXIS), " D", stepper.get_shaping_damping_ratio(Y_AXIS) ); From d87d7474c932949e74248c562921b2b85e063999 Mon Sep 17 00:00:00 2001 From: Manuel McLure Date: Mon, 24 Oct 2022 14:25:47 -0700 Subject: [PATCH 124/243] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20spurious=20"bad=20?= =?UTF-8?q?command"=20(#24923)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/bedlevel/ubl/ubl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/feature/bedlevel/ubl/ubl.cpp b/Marlin/src/feature/bedlevel/ubl/ubl.cpp index 2aa50be34d26..f2af1445b1f0 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl.cpp @@ -260,7 +260,7 @@ bool unified_bed_leveling::sanity_check() { */ void GcodeSuite::M1004() { - #define ALIGN_GCODE TERN(Z_STEPPER_AUTO_ALIGN, "G34", "") + #define ALIGN_GCODE TERN(Z_STEPPER_AUTO_ALIGN, "G34\n", "") #define PROBE_GCODE TERN(HAS_BED_PROBE, "G29P1\nG29P3", "G29P4R") #if HAS_HOTEND @@ -280,7 +280,7 @@ bool unified_bed_leveling::sanity_check() { #endif process_subcommands_now(FPSTR(G28_STR)); // Home - process_subcommands_now(F(ALIGN_GCODE "\n" // Align multi z axis if available + process_subcommands_now(F(ALIGN_GCODE // Align multi z axis if available PROBE_GCODE "\n" // Build mesh with available hardware "G29P3\nG29P3")); // Ensure mesh is complete by running smart fill twice From a9969d92ea17cb454353df466e579fa229ffe8c8 Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Mon, 24 Oct 2022 17:44:52 -0400 Subject: [PATCH 125/243] =?UTF-8?q?=F0=9F=90=9B=20Fix=20FTDUI=20Status=20S?= =?UTF-8?q?creen=20Timeout=20(#24899)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/Conditionals_post.h | 4 ++-- .../ftdi_eve_touch_ui/generic/base_screen.cpp | 18 +++++++++++------- .../ftdi_eve_touch_ui/generic/base_screen.h | 2 +- Marlin/src/lcd/marlinui.cpp | 4 ++-- Marlin/src/lcd/marlinui.h | 8 ++++---- Marlin/src/lcd/menu/menu.cpp | 6 +++--- 6 files changed, 23 insertions(+), 19 deletions(-) diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 5f540393921d..9f41390db904 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -3689,13 +3689,13 @@ #endif #endif -#if HAS_MARLINUI_MENU +#if EITHER(HAS_MARLINUI_MENU, TOUCH_UI_FTDI_EVE) // LCD timeout to status screen default is 15s #ifndef LCD_TIMEOUT_TO_STATUS #define LCD_TIMEOUT_TO_STATUS 15000 #endif #if LCD_TIMEOUT_TO_STATUS - #define SCREENS_CAN_TIME_OUT 1 + #define HAS_SCREEN_TIMEOUT 1 #endif #endif diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_screen.cpp index 0a8bebea3c9d..4e5a3fec2f9b 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_screen.cpp @@ -45,15 +45,16 @@ bool BaseScreen::buttonStyleCallback(CommandProcessor &cmd, uint8_t tag, uint8_t return false; } - #if SCREENS_CAN_TIME_OUT + #if HAS_SCREEN_TIMEOUT if (EventLoop::get_pressed_tag() != 0) { + #if ENABLED(TOUCH_UI_DEBUG) + SERIAL_ECHO_MSG("buttonStyleCallback, resetting timeout"); + #endif reset_menu_timeout(); } #endif - if (buttonIsPressed(tag)) { - options = OPT_FLAT; - } + if (buttonIsPressed(tag)) options = OPT_FLAT; if (style & cmd.STYLE_DISABLED) { cmd.tag(0); @@ -65,7 +66,10 @@ bool BaseScreen::buttonStyleCallback(CommandProcessor &cmd, uint8_t tag, uint8_t } void BaseScreen::onIdle() { - #if SCREENS_CAN_TIME_OUT + #if HAS_SCREEN_TIMEOUT + if (EventLoop::get_pressed_tag() != 0) + reset_menu_timeout(); + if ((millis() - last_interaction) > LCD_TIMEOUT_TO_STATUS) { reset_menu_timeout(); #if ENABLED(TOUCH_UI_DEBUG) @@ -77,10 +81,10 @@ void BaseScreen::onIdle() { } void BaseScreen::reset_menu_timeout() { - TERN_(SCREENS_CAN_TIME_OUT, last_interaction = millis()); + TERN_(HAS_SCREEN_TIMEOUT, last_interaction = millis()); } -#if SCREENS_CAN_TIME_OUT +#if HAS_SCREEN_TIMEOUT uint32_t BaseScreen::last_interaction; #endif diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_screen.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_screen.h index 030fa51a2aaf..4b29bf1e4190 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_screen.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/base_screen.h @@ -27,7 +27,7 @@ class BaseScreen : public UIScreen { protected: - #if SCREENS_CAN_TIME_OUT + #if HAS_SCREEN_TIMEOUT static uint32_t last_interaction; #endif diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index c885e838453e..0dfe60d8e424 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -316,7 +316,7 @@ void MarlinUI::init() { #endif #endif - #if SCREENS_CAN_TIME_OUT + #if HAS_SCREEN_TIMEOUT bool MarlinUI::defer_return_to_status; millis_t MarlinUI::return_to_status_ms = 0; #endif @@ -1171,7 +1171,7 @@ void MarlinUI::init() { NOLESS(max_display_update_time, millis() - ms); } - #if SCREENS_CAN_TIME_OUT + #if HAS_SCREEN_TIMEOUT // Return to Status Screen after a timeout if (on_status_screen() || defer_return_to_status) reset_status_timeout(ms); diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index b1a98248bb71..ec19f8bd34ba 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -545,7 +545,7 @@ class MarlinUI { #endif static void reset_status_timeout(const millis_t ms) { - TERN(SCREENS_CAN_TIME_OUT, return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS, UNUSED(ms)); + TERN(HAS_SCREEN_TIMEOUT, return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS, UNUSED(ms)); } #if HAS_MARLINUI_MENU @@ -596,11 +596,11 @@ class MarlinUI { #endif FORCE_INLINE static bool screen_is_sticky() { - return TERN1(SCREENS_CAN_TIME_OUT, defer_return_to_status); + return TERN1(HAS_SCREEN_TIMEOUT, defer_return_to_status); } FORCE_INLINE static void defer_status_screen(const bool defer=true) { - TERN(SCREENS_CAN_TIME_OUT, defer_return_to_status = defer, UNUSED(defer)); + TERN(HAS_SCREEN_TIMEOUT, defer_return_to_status = defer, UNUSED(defer)); } static void goto_previous_screen_no_defer() { @@ -778,7 +778,7 @@ class MarlinUI { private: - #if SCREENS_CAN_TIME_OUT + #if HAS_SCREEN_TIMEOUT static millis_t return_to_status_ms; static bool defer_return_to_status; #else diff --git a/Marlin/src/lcd/menu/menu.cpp b/Marlin/src/lcd/menu/menu.cpp index 7ae1078f4deb..6389383d287a 100644 --- a/Marlin/src/lcd/menu/menu.cpp +++ b/Marlin/src/lcd/menu/menu.cpp @@ -61,7 +61,7 @@ typedef struct { screenFunc_t menu_function; // The screen's function uint32_t encoder_position; // The position of the encoder int8_t top_line, items; // The amount of scroll, and the number of items - #if SCREENS_CAN_TIME_OUT + #if HAS_SCREEN_TIMEOUT bool sticky; // The screen is sticky #endif } menuPosition; @@ -89,7 +89,7 @@ void MarlinUI::return_to_status() { goto_screen(status_screen); } void MarlinUI::push_current_screen() { if (screen_history_depth < COUNT(screen_history)) - screen_history[screen_history_depth++] = { currentScreen, encoderPosition, encoderTopLine, screen_items OPTARG(SCREENS_CAN_TIME_OUT, screen_is_sticky()) }; + screen_history[screen_history_depth++] = { currentScreen, encoderPosition, encoderTopLine, screen_items OPTARG(HAS_SCREEN_TIMEOUT, screen_is_sticky()) }; } void MarlinUI::_goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, const bool is_back/*=false*/)) { @@ -102,7 +102,7 @@ void MarlinUI::_goto_previous_screen(TERN_(TURBO_BACK_MENU_ITEM, const bool is_b is_back ? 0 : sh.top_line, sh.items ); - defer_status_screen(TERN_(SCREENS_CAN_TIME_OUT, sh.sticky)); + defer_status_screen(TERN_(HAS_SCREEN_TIMEOUT, sh.sticky)); } else return_to_status(); From 9a4715f31a43216e97f52fd2c1adf49a2cc2a710 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Tue, 25 Oct 2022 10:47:23 +1300 Subject: [PATCH 126/243] =?UTF-8?q?=F0=9F=90=9B=20Fix=20move=5Fextruder=5F?= =?UTF-8?q?servo=20(#24908)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/module/tool_change.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index 80aedd3bdd87..cd18462be39e 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -115,7 +115,7 @@ void move_extruder_servo(const uint8_t e) { planner.synchronize(); - if ((EXTRUDERS & 1) && e < EXTRUDERS - 1) { + if (e < EXTRUDERS) { servo[_SERVO_NR(e)].move(servo_angles[_SERVO_NR(e)][e & 1]); safe_delay(500); } From 1540e8e1d4545005413fe8bd7f6aaf2eef958aa6 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 24 Oct 2022 17:04:55 -0500 Subject: [PATCH 127/243] =?UTF-8?q?=F0=9F=A9=B9=20Allow=20for=20last=20non?= =?UTF-8?q?-servo=20extruder?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/module/tool_change.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index cd18462be39e..a0939d155abb 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -115,7 +115,8 @@ void move_extruder_servo(const uint8_t e) { planner.synchronize(); - if (e < EXTRUDERS) { + constexpr bool evenExtruders = !(EXTRUDERS & 1); + if (evenExtruders || e < EXTRUDERS - 1) { servo[_SERVO_NR(e)].move(servo_angles[_SERVO_NR(e)][e & 1]); safe_delay(500); } From d9ffae65787f2c37484f424ff5171c80210d659f Mon Sep 17 00:00:00 2001 From: Justin Hartmann Date: Sat, 29 Oct 2022 19:37:36 -0400 Subject: [PATCH 128/243] =?UTF-8?q?=F0=9F=A9=B9=20Buttons=20Followup=20(#2?= =?UTF-8?q?4935)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to #24878 --- Marlin/src/lcd/buttons.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Marlin/src/lcd/buttons.h b/Marlin/src/lcd/buttons.h index cb6348dc2d60..67b7aa3944f1 100644 --- a/Marlin/src/lcd/buttons.h +++ b/Marlin/src/lcd/buttons.h @@ -191,19 +191,19 @@ #define _BUTTON_PRESSED_UP false #endif #if BUTTON_EXISTS(DOWN) - #define _BUTTON_PRESSED_DWN _BUTTON_PRESSED(DOWN) + #define _BUTTON_PRESSED_DOWN _BUTTON_PRESSED(DOWN) #else - #define _BUTTON_PRESSED_DWN false + #define _BUTTON_PRESSED_DOWN false #endif #if BUTTON_EXISTS(LEFT) - #define _BUTTON_PRESSED_LFT _BUTTON_PRESSED(LEFT) + #define _BUTTON_PRESSED_LEFT _BUTTON_PRESSED(LEFT) #else - #define _BUTTON_PRESSED_LFT false + #define _BUTTON_PRESSED_LEFT false #endif #if BUTTON_EXISTS(RIGHT) - #define _BUTTON_PRESSED_RT _BUTTON_PRESSED(RIGHT) + #define _BUTTON_PRESSED_RIGHT _BUTTON_PRESSED(RIGHT) #else - #define _BUTTON_PRESSED_RT false + #define _BUTTON_PRESSED_RIGHT false #endif #if BUTTON_EXISTS(BACK) #define _BUTTON_PRESSED_BACK _BUTTON_PRESSED(BACK) From 9f5b0b85670f5684357b8a9a1dd39a87de513b13 Mon Sep 17 00:00:00 2001 From: Keith Bennett <13375512+thisiskeithb@users.noreply.github.com> Date: Sat, 29 Oct 2022 16:39:26 -0700 Subject: [PATCH 129/243] =?UTF-8?q?=F0=9F=94=A7=20Update=20Display=20Sleep?= =?UTF-8?q?=20LCD=20Check=20(#24934)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/SanityCheck.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 744e68a5bb0d..63b719f1c261 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -3118,7 +3118,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS * Display Sleep is not supported by these common displays */ #if HAS_DISPLAY_SLEEP - #if ANY(IS_U8GLIB_LM6059_AF, IS_U8GLIB_ST7565_64128, REPRAPWORLD_GRAPHICAL_LCD, FYSETC_MINI, CR10_STOCKDISPLAY, ENDER2_STOCKDISPLAY, MINIPANEL) + #if ANY(IS_U8GLIB_LM6059_AF, IS_U8GLIB_ST7565_64128, REPRAPWORLD_GRAPHICAL_LCD, FYSETC_MINI_12864, CR10_STOCKDISPLAY, MINIPANEL) #error "DISPLAY_SLEEP_MINUTES is not supported by your display." #elif !WITHIN(DISPLAY_SLEEP_MINUTES, 0, 255) #error "DISPLAY_SLEEP_MINUTES must be between 0 and 255." From cbdafd36e02f9fd39b60adb86ce95bea951f5092 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Sun, 30 Oct 2022 12:42:36 +1300 Subject: [PATCH 130/243] =?UTF-8?q?=F0=9F=93=8C=20Remove=20unused=20RX/TX?= =?UTF-8?q?=20pins=20(#24932)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/pins/pins_postprocess.h | 70 ++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/Marlin/src/pins/pins_postprocess.h b/Marlin/src/pins/pins_postprocess.h index c3c217557beb..7656037f3da9 100644 --- a/Marlin/src/pins/pins_postprocess.h +++ b/Marlin/src/pins/pins_postprocess.h @@ -307,6 +307,76 @@ #define E7_CS_PIN -1 #endif +// +// Destroy stepper driver RX and TX pins when set to -1 +// +#if !PIN_EXISTS(Z2_SERIAL_TX) + #undef Z2_SERIAL_TX_PIN +#endif +#if !PIN_EXISTS(Z2_SERIAL_RX) + #undef Z2_SERIAL_RX_PIN +#endif +#if !PIN_EXISTS(Z3_SERIAL_TX) + #undef Z3_SERIAL_TX_PIN +#endif +#if !PIN_EXISTS(Z3_SERIAL_RX) + #undef Z3_SERIAL_RX_PIN +#endif +#if !PIN_EXISTS(Z4_SERIAL_TX) + #undef Z4_SERIAL_TX_PIN +#endif +#if !PIN_EXISTS(Z4_SERIAL_RX) + #undef Z4_SERIAL_RX_PIN +#endif +#if !PIN_EXISTS(X2_SERIAL_TX) + #undef X2_SERIAL_TX_PIN +#endif +#if !PIN_EXISTS(X2_SERIAL_RX) + #undef X2_SERIAL_RX_PIN +#endif +#if !PIN_EXISTS(Y2_SERIAL_TX) + #undef Y2_SERIAL_TX_PIN +#endif +#if !PIN_EXISTS(Y2_SERIAL_RX) + #undef Y2_SERIAL_RX_PIN +#endif +#if !PIN_EXISTS(I_SERIAL_TX) + #undef I_SERIAL_TX_PIN +#endif +#if !PIN_EXISTS(I_SERIAL_RX) + #undef I_SERIAL_RX_PIN +#endif +#if !PIN_EXISTS(J_SERIAL_TX) + #undef J_SERIAL_TX_PIN +#endif +#if !PIN_EXISTS(J_SERIAL_RX) + #undef J_SERIAL_RX_PIN +#endif +#if !PIN_EXISTS(K_SERIAL_TX) + #undef K_SERIAL_TX_PIN +#endif +#if !PIN_EXISTS(K_SERIAL_RX) + #undef K_SERIAL_RX_PIN +#endif +#if !PIN_EXISTS(U_SERIAL_TX) + #undef U_SERIAL_TX_PIN +#endif +#if !PIN_EXISTS(U_SERIAL_RX) + #undef U_SERIAL_RX_PIN +#endif +#if !PIN_EXISTS(V_SERIAL_TX) + #undef V_SERIAL_TX_PIN +#endif +#if !PIN_EXISTS(V_SERIAL_RX) + #undef V_SERIAL_RX_PIN +#endif +#if !PIN_EXISTS(W_SERIAL_TX) + #undef W_SERIAL_TX_PIN +#endif +#if !PIN_EXISTS(W_SERIAL_RX) + #undef W_SERIAL_RX_PIN +#endif + #ifndef FAN_PIN #define FAN_PIN -1 #endif From ddec5faf5abddef5e5cb233b6f3cd31ce2e82d53 Mon Sep 17 00:00:00 2001 From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Date: Sun, 30 Oct 2022 01:45:33 +0200 Subject: [PATCH 131/243] =?UTF-8?q?=F0=9F=8C=90=20Update=20Italian=20langu?= =?UTF-8?q?age=20(#24915)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/language/language_it.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Marlin/src/lcd/language/language_it.h b/Marlin/src/lcd/language/language_it.h index 0c1b3a8cee35..1fcf07dbc79d 100644 --- a/Marlin/src/lcd/language/language_it.h +++ b/Marlin/src/lcd/language/language_it.h @@ -178,7 +178,7 @@ namespace Language_it { LSTR MSG_MESH_AMAX = _UxGT("Massimizza area"); LSTR MSG_MESH_CENTER = _UxGT("Area centrale"); LSTR MSG_MESH_EDIT_Z = _UxGT("Valore di Z"); - LSTR MSG_MESH_CANCEL = _UxGT("Mesh cancellato"); + LSTR MSG_MESH_CANCEL = _UxGT("Mesh cancellata"); LSTR MSG_CUSTOM_COMMANDS = _UxGT("Comandi personaliz."); LSTR MSG_M48_TEST = _UxGT("Test sonda M48"); LSTR MSG_M48_POINT = _UxGT("Punto M48"); @@ -251,6 +251,7 @@ namespace Language_it { LSTR MSG_UBL_SMART_FILLIN = _UxGT("Riempimento Smart"); LSTR MSG_UBL_FILLIN_MESH = _UxGT("Riempimento Mesh"); LSTR MSG_UBL_MESH_FILLED = _UxGT("Pts mancanti riempiti"); + LSTR MSG_UBL_MESH_INVALID = _UxGT("Mesh non valida"); LSTR MSG_UBL_INVALIDATE_ALL = _UxGT("Invalida Tutto"); LSTR MSG_UBL_INVALIDATE_CLOSEST = _UxGT("Invalid.Punto Vicino"); LSTR MSG_UBL_FINE_TUNE_ALL = _UxGT("Ritocca Tutto"); @@ -395,6 +396,11 @@ namespace Language_it { LSTR MSG_AMAX_EN = _UxGT("Acc.Massima *"); LSTR MSG_A_RETRACT = _UxGT("A-Ritrazione"); LSTR MSG_A_TRAVEL = _UxGT("A-Spostamento"); + LSTR MSG_INPUT_SHAPING = _UxGT("Input Shaping"); + LSTR MSG_SHAPING_X_FREQ = _UxGT("Frequenza ") STR_X; + LSTR MSG_SHAPING_Y_FREQ = _UxGT("Frequenza ") STR_Y; + LSTR MSG_SHAPING_X_ZETA = _UxGT("Smorzamento ") STR_X; + LSTR MSG_SHAPING_Y_ZETA = _UxGT("Smorzamento ") STR_Y; LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("Frequenza max"); LSTR MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Feed min"); LSTR MSG_STEPS_PER_MM = _UxGT("Passi/mm"); @@ -414,6 +420,12 @@ namespace Language_it { LSTR MSG_FILAMENT_DIAM_E = _UxGT("Diam. filo *"); LSTR MSG_FILAMENT_UNLOAD = _UxGT("Rimuovi mm"); LSTR MSG_FILAMENT_LOAD = _UxGT("Carica mm"); + LSTR MSG_SEGMENTS_PER_SECOND = _UxGT("Segmenti/Sec"); + LSTR MSG_DRAW_MIN_X = _UxGT("Min X area disegno"); + LSTR MSG_DRAW_MAX_X = _UxGT("Max X area disegno"); + LSTR MSG_DRAW_MIN_Y = _UxGT("Min Y area disegno"); + LSTR MSG_DRAW_MAX_Y = _UxGT("Max Y area disegno"); + LSTR MSG_MAX_BELT_LEN = _UxGT("Lungh.max cinghia"); LSTR MSG_ADVANCE_K = _UxGT("K Avanzamento"); LSTR MSG_ADVANCE_K_E = _UxGT("K Avanzamento *"); LSTR MSG_CONTRAST = _UxGT("Contrasto LCD"); @@ -506,9 +518,10 @@ namespace Language_it { LSTR MSG_TOOL_CHANGE = _UxGT("Cambio utensile"); LSTR MSG_TOOL_CHANGE_ZLIFT = _UxGT("Risalita Z"); LSTR MSG_SINGLENOZZLE_PRIME_SPEED = _UxGT("Velocità innesco"); + LSTR MSG_SINGLENOZZLE_WIPE_RETRACT = _UxGT("Ritrazione pulizia"); LSTR MSG_SINGLENOZZLE_RETRACT_SPEED = _UxGT("Velocità ritrazione"); LSTR MSG_FILAMENT_PARK_ENABLED = _UxGT("Parcheggia testa"); - LSTR MSG_SINGLENOZZLE_UNRETRACT_SPEED = _UxGT("Recover Speed"); + LSTR MSG_SINGLENOZZLE_UNRETRACT_SPEED = _UxGT("Veloc. di recupero"); LSTR MSG_SINGLENOZZLE_FAN_SPEED = _UxGT("Velocità ventola"); LSTR MSG_SINGLENOZZLE_FAN_TIME = _UxGT("Tempo ventola"); LSTR MSG_TOOL_MIGRATION_ON = _UxGT("Auto ON"); From 38375cf7a75f7b7f6686737fd1651b440267709b Mon Sep 17 00:00:00 2001 From: InsanityAutomation <38436470+InsanityAutomation@users.noreply.github.com> Date: Sat, 29 Oct 2022 23:35:12 -0400 Subject: [PATCH 132/243] =?UTF-8?q?=E2=9C=A8=20Tenlog=20MB1V23=20IDEX=20bo?= =?UTF-8?q?ard=20(#24896)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Makefile | 16 +- Marlin/src/core/boards.h | 15 +- Marlin/src/pins/pins.h | 2 + Marlin/src/pins/ramps/pins_TENLOG_MB1_V23.h | 155 ++++++++++++++++++++ 4 files changed, 174 insertions(+), 14 deletions(-) create mode 100644 Marlin/src/pins/ramps/pins_TENLOG_MB1_V23.h diff --git a/Marlin/Makefile b/Marlin/Makefile index c72c1d589607..ca7cacaa6acb 100644 --- a/Marlin/Makefile +++ b/Marlin/Makefile @@ -307,20 +307,22 @@ else ifeq ($(HARDWARE_MOTHERBOARD),1154) else ifeq ($(HARDWARE_MOTHERBOARD),1155) # Tenlog D3 Hero IDEX printer else ifeq ($(HARDWARE_MOTHERBOARD),1156) -# Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Fan, Bed) +# Tenlog D3,5,6 Pro IDEX printers else ifeq ($(HARDWARE_MOTHERBOARD),1157) -# Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Hotend2, Bed) +# Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Fan, Bed) else ifeq ($(HARDWARE_MOTHERBOARD),1158) -# Ramps S 1.2 by Sakul.cz (Power outputs: Hotend, Fan0, Fan1, Bed) +# Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Hotend2, Bed) else ifeq ($(HARDWARE_MOTHERBOARD),1159) -# Longer LK1 PRO / Alfawise U20 Pro (PRO version) +# Ramps S 1.2 by Sakul.cz (Power outputs: Hotend, Fan0, Fan1, Bed) else ifeq ($(HARDWARE_MOTHERBOARD),1160) -# Longer LKx PRO / Alfawise Uxx Pro (PRO version) +# Longer LK1 PRO / Alfawise U20 Pro (PRO version) else ifeq ($(HARDWARE_MOTHERBOARD),1161) -# Zonestar zrib V5.3 (Chinese RAMPS replica) +# Longer LKx PRO / Alfawise Uxx Pro (PRO version) else ifeq ($(HARDWARE_MOTHERBOARD),1162) -# Pxmalion Core I3 +# Zonestar zrib V5.3 (Chinese RAMPS replica) else ifeq ($(HARDWARE_MOTHERBOARD),1163) +# Pxmalion Core I3 +else ifeq ($(HARDWARE_MOTHERBOARD),1164) # # RAMBo and derivatives diff --git a/Marlin/src/core/boards.h b/Marlin/src/core/boards.h index c993b9df0e3c..b5f5b037f9ee 100644 --- a/Marlin/src/core/boards.h +++ b/Marlin/src/core/boards.h @@ -110,13 +110,14 @@ #define BOARD_COPYMASTER_3D 1154 // Copymaster 3D #define BOARD_ORTUR_4 1155 // Ortur 4 #define BOARD_TENLOG_D3_HERO 1156 // Tenlog D3 Hero IDEX printer -#define BOARD_RAMPS_S_12_EEFB 1157 // Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Fan, Bed) -#define BOARD_RAMPS_S_12_EEEB 1158 // Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Hotend2, Bed) -#define BOARD_RAMPS_S_12_EFFB 1159 // Ramps S 1.2 by Sakul.cz (Power outputs: Hotend, Fan0, Fan1, Bed) -#define BOARD_LONGER3D_LK1_PRO 1160 // Longer LK1 PRO / Alfawise U20 Pro (PRO version) -#define BOARD_LONGER3D_LKx_PRO 1161 // Longer LKx PRO / Alfawise Uxx Pro (PRO version) -#define BOARD_ZRIB_V53 1162 // Zonestar zrib V5.3 (Chinese RAMPS replica) -#define BOARD_PXMALION_CORE_I3 1163 // Pxmalion Core I3 +#define BOARD_TENLOG_MB1_V23 1157 // Tenlog D3, D5, D6 IDEX Printer +#define BOARD_RAMPS_S_12_EEFB 1158 // Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Fan, Bed) +#define BOARD_RAMPS_S_12_EEEB 1159 // Ramps S 1.2 by Sakul.cz (Power outputs: Hotend0, Hotend1, Hotend2, Bed) +#define BOARD_RAMPS_S_12_EFFB 1160 // Ramps S 1.2 by Sakul.cz (Power outputs: Hotend, Fan0, Fan1, Bed) +#define BOARD_LONGER3D_LK1_PRO 1161 // Longer LK1 PRO / Alfawise U20 Pro (PRO version) +#define BOARD_LONGER3D_LKx_PRO 1162 // Longer LKx PRO / Alfawise Uxx Pro (PRO version) +#define BOARD_ZRIB_V53 1163 // Zonestar zrib V5.3 (Chinese RAMPS replica) +#define BOARD_PXMALION_CORE_I3 1164 // Pxmalion Core I3 // // RAMBo and derivatives diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 046957e1ba90..909ae992a991 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -195,6 +195,8 @@ #include "ramps/pins_ORTUR_4.h" // ATmega2560 env:mega2560 #elif MB(TENLOG_D3_HERO) #include "ramps/pins_TENLOG_D3_HERO.h" // ATmega2560 env:mega2560 +#elif MB(TENLOG_MB1_V23) + #include "ramps/pins_TENLOG_MB1_V23.h" // ATmega2560 env:mega2560 #elif MB(MKS_GEN_L_V21) #include "ramps/pins_MKS_GEN_L_V21.h" // ATmega2560 env:mega2560 #elif MB(RAMPS_S_12_EEFB, RAMPS_S_12_EEEB, RAMPS_S_12_EFFB) diff --git a/Marlin/src/pins/ramps/pins_TENLOG_MB1_V23.h b/Marlin/src/pins/ramps/pins_TENLOG_MB1_V23.h new file mode 100644 index 000000000000..b3f7d5f216b5 --- /dev/null +++ b/Marlin/src/pins/ramps/pins_TENLOG_MB1_V23.h @@ -0,0 +1,155 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +/** + * Tenlog pin assignments + */ + +#define REQUIRE_MEGA2560 +#include "env_validate.h" + +#if HOTENDS > 2 || E_STEPPERS > 2 + #error "Tenlog supports up to 2 hotends / E steppers." +#endif + +#define BOARD_INFO_NAME "Tenlog MB1 V2.3" +#define DEFAULT_MACHINE_NAME BOARD_INFO_NAME + +// +// Limit Switches +// +#define X_MIN_PIN 3 +#define X_MAX_PIN 2 +#define Y_MIN_PIN 14 +//#define Y_MAX_PIN 15 // Connected to "DJ" plug on extruder heads +#define Z_MIN_PIN 18 +#if ENABLED(BLTOUCH) + #define SERVO0_PIN 19 +#else + #define Z_MAX_PIN 19 +#endif + +// +// Steppers +// +#define X_STEP_PIN 54 +#define X_DIR_PIN 55 +#define X_ENABLE_PIN 38 + +#define X2_STEP_PIN 36 +#define X2_DIR_PIN 34 +#define X2_ENABLE_PIN 30 + +#define Y_STEP_PIN 60 +#define Y_DIR_PIN 61 +#define Y_ENABLE_PIN 56 + +#define Z_STEP_PIN 46 +#define Z_DIR_PIN 48 +#define Z_ENABLE_PIN 62 + +#define Z2_STEP_PIN 65 +#define Z2_DIR_PIN 66 +#define Z2_ENABLE_PIN 64 + +#define E0_STEP_PIN 57 +#define E0_DIR_PIN 58 +#define E0_ENABLE_PIN 59 + +#define E1_STEP_PIN 26 +#define E1_DIR_PIN 28 +#define E1_ENABLE_PIN 24 + +// +// Temperature Sensors +// +#define TEMP_0_PIN 15 // Analog Input +#define TEMP_1_PIN 13 // Analog Input +#define TEMP_BED_PIN 14 // Analog Input + +// +// Heaters / Fans +// +#define HEATER_0_PIN 11 +#define HEATER_1_PIN 10 +#define HEATER_BED_PIN 8 + +#define FAN_PIN 9 +#define FAN2_PIN 5 // Normally this would be a servo pin + +//#define NUM_RUNOUT_SENSORS 0 +#define FIL_RUNOUT_PIN 15 +//#define FIL_RUNOUT2_PIN 21 + +// +// PSU and Powerloss Recovery +// +#if ENABLED(PSU_CONTROL) + #define PS_ON_PIN 40 // The M80/M81 PSU pin for boards v2.1-2.3 +#endif + +// +// Misc. Functions +// +//#define CASE_LIGHT_PIN 5 +//#ifndef LED_PIN +// #define LED_PIN 13 +//#endif + +#if HAS_CUTTER + //#define SPINDLE_LASER_PWM_PIN -1 // Hardware PWM + //#define SPINDLE_LASER_ENA_PIN 4 // Pullup! +#endif + +// Use the RAMPS 1.4 Analog input 5 on the AUX2 connector +//#define FILWIDTH_PIN 5 // Analog Input + +#define SDSS 53 +#define SD_DETECT_PIN 49 + +// +// LCD / Controller +// + +//#if IS_RRD_SC + +//#ifndef BEEPER_PIN +// #define BEEPER_PIN -1 +//#endif + +#define LCD_PINS_RS -1 +#define LCD_PINS_ENABLE -1 +#define LCD_PINS_D4 -1 +#define LCD_PINS_D5 -1 +#define LCD_PINS_D6 -1 +#define LCD_PINS_D7 -1 + +//#define BTN_EN1 31 +//#define BTN_EN2 33 +//#define BTN_ENC 35 + +//#ifndef KILL_PIN +// #define KILL_PIN 41 +//#endif + +//#endif // IS_RRD_SC From 4737af7d70f5660f6e5617bd6ce1080875d6bd28 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Sun, 30 Oct 2022 16:45:08 +1300 Subject: [PATCH 133/243] =?UTF-8?q?=F0=9F=93=8C=20ZRIB=20V52-V53=20Servo?= =?UTF-8?q?=20Pins=20(#24880)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/pins/ramps/pins_ZRIB_V52.h | 19 +++++++++++-------- Marlin/src/pins/ramps/pins_ZRIB_V53.h | 12 +++--------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/Marlin/src/pins/ramps/pins_ZRIB_V52.h b/Marlin/src/pins/ramps/pins_ZRIB_V52.h index 2df789cd6f7f..44e0beaa9fb9 100644 --- a/Marlin/src/pins/ramps/pins_ZRIB_V52.h +++ b/Marlin/src/pins/ramps/pins_ZRIB_V52.h @@ -47,6 +47,16 @@ #define E2_DIR_PIN 5 #define E2_ENABLE_PIN 22 +// +// Servos / XS3 Connector +// +#ifndef SERVO0_PIN + #define SERVO0_PIN 65 // PWM +#endif +#ifndef SERVO1_PIN + #define SERVO1_PIN 66 // PWM +#endif + #include "pins_MKS_BASE_common.h" // ... RAMPS /** @@ -78,20 +88,13 @@ * | GND | * ========== * - * XS3 Connector + * Servos / XS3 Connector * ================= * | 65 | GND | 5V | (65) PK3 ** Pin86 ** A11 * |----|-----|----| * | 66 | GND | 5V | (66) PK4 ** Pin85 ** A12 * ================= * - * Servos Connector - * ================= - * | 11 | GND | 5V | (11) PB5 ** Pin24 ** PWM11 - * |----|-----|----| - * | 12 | GND | 5V | (12) PB6 ** Pin25 ** PWM12 - * ================= - * * ICSP * ================= * | 5V | 51 | GND | (51) PB2 ** Pin21 ** SPI_MOSI diff --git a/Marlin/src/pins/ramps/pins_ZRIB_V53.h b/Marlin/src/pins/ramps/pins_ZRIB_V53.h index cae71f7a8f6e..7a5cf1479166 100644 --- a/Marlin/src/pins/ramps/pins_ZRIB_V53.h +++ b/Marlin/src/pins/ramps/pins_ZRIB_V53.h @@ -62,10 +62,10 @@ // Servos / XS3 Connector // #ifndef SERVO0_PIN - #define SERVO0_PIN 11 // Analog Output + #define SERVO0_PIN 65 // PWM #endif #ifndef SERVO1_PIN - #define SERVO1_PIN 12 // Analog Output + #define SERVO1_PIN 66 // PWM #endif // @@ -424,18 +424,12 @@ * |--------| Power * | GND | * ========== - * XS3 Connector + * Servos / XS3 Connector * ================= * | 65 | GND | 5V | (65) PK3 ** Pin86 ** A11 * |----|-----|----| * | 66 | GND | 5V | (66) PK4 ** Pin85 ** A12 * ================= - * XS3/Servos Connector - * ================= - * | 11 | GND | 5V | (11) PB5 ** Pin24 ** PWM11 - * |----|-----|----| - * | 12 | GND | 5V | (12) PB6 ** Pin25 ** PWM12 - * ================= * ICSP * ================= * | 5V | 51 | GND | (51) PB2 ** Pin21 ** SPI_MOSI From 2778b007656e2993d7be08ba854f29eb620ab96d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 30 Oct 2022 15:41:19 -0500 Subject: [PATCH 134/243] =?UTF-8?q?=F0=9F=8E=A8=20Format=20some=20lib-uhs3?= =?UTF-8?q?=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../USB_HOST_SHIELD/USB_HOST_SHIELD_INLINE.h | 1664 ++++++++--------- 1 file changed, 831 insertions(+), 833 deletions(-) diff --git a/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/USB_HOST_SHIELD_INLINE.h b/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/USB_HOST_SHIELD_INLINE.h index 6cfc0152d058..57352a351873 100644 --- a/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/USB_HOST_SHIELD_INLINE.h +++ b/Marlin/src/sd/usb_flashdrive/lib-uhs3/UHS_host/USB_HOST_SHIELD/USB_HOST_SHIELD_INLINE.h @@ -1,270 +1,272 @@ -/* Copyright (C) 2015-2016 Andrew J. Kroll - and -Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. - -This software may be distributed and modified under the terms of the GNU -General Public License version 2 (GPL2) as publishe7d by the Free Software -Foundation and appearing in the file GPL2.TXT included in the packaging of -this file. Please note that GPL2 Section 2[b] requires that all works based -on this software must also be made publicly available under the terms of -the GPL2 ("Copyleft"). - -Contact information -------------------- - -Circuits At Home, LTD -Web : https://www.circuitsathome.com -e-mail : support@circuitsathome.com +/* + * Copyright (C) 2015-2016 Andrew J. Kroll + * and + * Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. + * + * This software may be distributed and modified under the terms of the GNU + * General Public License version 2 (GPL2) as publishe7d by the Free Software + * Foundation and appearing in the file GPL2.TXT included in the packaging of + * this file. Please note that GPL2 Section 2[b] requires that all works based + * on this software must also be made publicly available under the terms of + * the GPL2 ("Copyleft"). + * + * Contact information + * ------------------- + * + * Circuits At Home, LTD + * Web : https://www.circuitsathome.com + * e-mail : support@circuitsathome.com + * */ #if defined(USB_HOST_SHIELD_H) && !defined(USB_HOST_SHIELD_LOADED) #define USB_HOST_SHIELD_LOADED + #include #ifndef digitalPinToInterrupt -#error digitalPinToInterrupt not defined, complain to your board maintainer. + #error digitalPinToInterrupt not defined, complain to your board maintainer. #endif #if USB_HOST_SHIELD_USE_ISR -// allow two slots. this makes the maximum allowed shield count TWO -// for AVRs this is limited to pins 2 and 3 ONLY -// for all other boards, one odd and one even pin number is allowed. -static MAX3421E_HOST *ISReven; -static MAX3421E_HOST *ISRodd; + // allow two slots. this makes the maximum allowed shield count TWO + // for AVRs this is limited to pins 2 and 3 ONLY + // for all other boards, one odd and one even pin number is allowed. + static MAX3421E_HOST *ISReven; + static MAX3421E_HOST *ISRodd; -static void UHS_NI call_ISReven() { - ISReven->ISRTask(); -} + static void UHS_NI call_ISReven() { + ISReven->ISRTask(); + } -static void UHS_NI call_ISRodd() { - UHS_PIN_WRITE(LED_BUILTIN, HIGH); - ISRodd->ISRTask(); -} + static void UHS_NI call_ISRodd() { + UHS_PIN_WRITE(LED_BUILTIN, HIGH); + ISRodd->ISRTask(); + } #endif void UHS_NI MAX3421E_HOST::resume_host() { - // Used on MCU that lack control of IRQ priority (AVR). - // Resumes ISRs. - // NOTE: you must track the state yourself! -#ifdef __AVR__ - noInterrupts(); - if(irq_pin & 1) { - ISRodd = this; - attachInterrupt(UHS_GET_DPI(irq_pin), call_ISRodd, IRQ_SENSE); - } else { - ISReven = this; - attachInterrupt(UHS_GET_DPI(irq_pin), call_ISReven, IRQ_SENSE); - } - interrupts(); -#endif - + // Used on MCU that lack control of IRQ priority (AVR). + // Resumes ISRs. + // NOTE: you must track the state yourself! + #ifdef __AVR__ + noInterrupts(); + if (irq_pin & 1) { + ISRodd = this; + attachInterrupt(UHS_GET_DPI(irq_pin), call_ISRodd, IRQ_SENSE); + } else { + ISReven = this; + attachInterrupt(UHS_GET_DPI(irq_pin), call_ISReven, IRQ_SENSE); + } + interrupts(); + #endif } + /* write single byte into MAX3421e register */ void UHS_NI MAX3421E_HOST::regWr(uint8_t reg, uint8_t data) { - SPIclass.beginTransaction(MAX3421E_SPI_Settings); - MARLIN_UHS_WRITE_SS(LOW); - SPIclass.transfer(reg | 0x02); - SPIclass.transfer(data); - MARLIN_UHS_WRITE_SS(HIGH); - SPIclass.endTransaction(); + SPIclass.beginTransaction(MAX3421E_SPI_Settings); + MARLIN_UHS_WRITE_SS(LOW); + SPIclass.transfer(reg | 0x02); + SPIclass.transfer(data); + MARLIN_UHS_WRITE_SS(HIGH); + SPIclass.endTransaction(); } - /* multiple-byte write */ /* returns a pointer to memory position after last written */ uint8_t* UHS_NI MAX3421E_HOST::bytesWr(uint8_t reg, uint8_t nbytes, uint8_t *data_p) { - SPIclass.beginTransaction(MAX3421E_SPI_Settings); - MARLIN_UHS_WRITE_SS(LOW); - SPIclass.transfer(reg | 0x02); - //printf("%2.2x :", reg); - - while(nbytes) { - SPIclass.transfer(*data_p); - //printf("%2.2x ", *data_p); - nbytes--; - data_p++; // advance data pointer - } - MARLIN_UHS_WRITE_SS(HIGH); - SPIclass.endTransaction(); - //printf("\r\n"); - return (data_p); + SPIclass.beginTransaction(MAX3421E_SPI_Settings); + MARLIN_UHS_WRITE_SS(LOW); + SPIclass.transfer(reg | 0x02); + //printf("%2.2x :", reg); + + while (nbytes) { + SPIclass.transfer(*data_p); + //printf("%2.2x ", *data_p); + nbytes--; + data_p++; // advance data pointer + } + MARLIN_UHS_WRITE_SS(HIGH); + SPIclass.endTransaction(); + //printf("\r\n"); + return (data_p); } + /* GPIO write */ /*GPIO byte is split between 2 registers, so two writes are needed to write one byte */ /* GPOUT bits are in the low nybble. 0-3 in IOPINS1, 4-7 in IOPINS2 */ void UHS_NI MAX3421E_HOST::gpioWr(uint8_t data) { - regWr(rIOPINS1, data); - data >>= 4; - regWr(rIOPINS2, data); - return; + regWr(rIOPINS1, data); + data >>= 4; + regWr(rIOPINS2, data); + return; } /* single host register read */ uint8_t UHS_NI MAX3421E_HOST::regRd(uint8_t reg) { - SPIclass.beginTransaction(MAX3421E_SPI_Settings); - MARLIN_UHS_WRITE_SS(LOW); - SPIclass.transfer(reg); - uint8_t rv = SPIclass.transfer(0); - MARLIN_UHS_WRITE_SS(HIGH); - SPIclass.endTransaction(); - return (rv); + SPIclass.beginTransaction(MAX3421E_SPI_Settings); + MARLIN_UHS_WRITE_SS(LOW); + SPIclass.transfer(reg); + uint8_t rv = SPIclass.transfer(0); + MARLIN_UHS_WRITE_SS(HIGH); + SPIclass.endTransaction(); + return (rv); } /* multiple-byte register read */ /* returns a pointer to a memory position after last read */ uint8_t* UHS_NI MAX3421E_HOST::bytesRd(uint8_t reg, uint8_t nbytes, uint8_t *data_p) { - SPIclass.beginTransaction(MAX3421E_SPI_Settings); - MARLIN_UHS_WRITE_SS(LOW); - SPIclass.transfer(reg); - while(nbytes) { - *data_p++ = SPIclass.transfer(0); - nbytes--; - } - MARLIN_UHS_WRITE_SS(HIGH); - SPIclass.endTransaction(); - return ( data_p); + SPIclass.beginTransaction(MAX3421E_SPI_Settings); + MARLIN_UHS_WRITE_SS(LOW); + SPIclass.transfer(reg); + while (nbytes) { + *data_p++ = SPIclass.transfer(0); + nbytes--; + } + MARLIN_UHS_WRITE_SS(HIGH); + SPIclass.endTransaction(); + return ( data_p); } /* GPIO read. See gpioWr for explanation */ /* GPIN pins are in high nybbles of IOPINS1, IOPINS2 */ uint8_t UHS_NI MAX3421E_HOST::gpioRd() { - uint8_t gpin = 0; - gpin = regRd(rIOPINS2); //pins 4-7 - gpin &= 0xF0; //clean lower nybble - gpin |= (regRd(rIOPINS1) >> 4); //shift low bits and OR with upper from previous operation. - return ( gpin); + uint8_t gpin = 0; + gpin = regRd(rIOPINS2); // pins 4-7 + gpin &= 0xF0; // clean lower nybble + gpin |= (regRd(rIOPINS1) >> 4); // shift low bits and OR with upper from previous operation. + return (gpin); } /* reset MAX3421E. Returns number of microseconds it took for PLL to stabilize after reset - or zero if PLL haven't stabilized in 65535 cycles */ +or zero if PLL haven't stabilized in 65535 cycles */ uint16_t UHS_NI MAX3421E_HOST::reset() { - uint16_t i = 0; - - // Initiate chip reset - regWr(rUSBCTL, bmCHIPRES); - regWr(rUSBCTL, 0x00); - - int32_t now; - uint32_t expires = micros() + 65535; - - // Enable full-duplex SPI so we can read rUSBIRQ - regWr(rPINCTL, bmFDUPSPI); - while((int32_t)(micros() - expires) < 0L) { - if((regRd(rUSBIRQ) & bmOSCOKIRQ)) { - break; - } - } - now = (int32_t)(micros() - expires); - if(now < 0L) { - i = 65535 + now; // Note this subtracts, as now is negative - } - return (i); + uint16_t i = 0; + + // Initiate chip reset + regWr(rUSBCTL, bmCHIPRES); + regWr(rUSBCTL, 0x00); + + int32_t now; + uint32_t expires = micros() + 65535; + + // Enable full-duplex SPI so we can read rUSBIRQ + regWr(rPINCTL, bmFDUPSPI); + while ((int32_t)(micros() - expires) < 0L) { + if ((regRd(rUSBIRQ) & bmOSCOKIRQ)) { + break; + } + } + now = (int32_t)(micros() - expires); + if (now < 0L) { + i = 65535 + now; // Note this subtracts, as now is negative + } + return (i); } void UHS_NI MAX3421E_HOST::VBUS_changed() { - /* modify USB task state because Vbus changed or unknown */ - uint8_t speed = 1; - //printf("\r\n\r\n\r\n\r\nSTATE %2.2x -> ", usb_task_state); - switch(vbusState) { - case LSHOST: // Low speed - - speed = 0; - // Intentional fall-through - case FSHOST: // Full speed - // Start device initialization if we are not initializing - // Resets to the device cause an IRQ - // usb_task_state == UHS_USB_HOST_STATE_RESET_NOT_COMPLETE; - //if((usb_task_state & UHS_USB_HOST_STATE_MASK) != UHS_USB_HOST_STATE_DETACHED) { - ReleaseChildren(); - if(!doingreset) { - if(usb_task_state == UHS_USB_HOST_STATE_RESET_NOT_COMPLETE) { - usb_task_state = UHS_USB_HOST_STATE_WAIT_BUS_READY; - } else if(usb_task_state != UHS_USB_HOST_STATE_WAIT_BUS_READY) { - usb_task_state = UHS_USB_HOST_STATE_DEBOUNCE; - } - } - sof_countdown = 0; - break; - case SE1: //illegal state - sof_countdown = 0; - doingreset = false; - ReleaseChildren(); - usb_task_state = UHS_USB_HOST_STATE_ILLEGAL; - break; - case SE0: //disconnected - default: - sof_countdown = 0; - doingreset = false; - ReleaseChildren(); - usb_task_state = UHS_USB_HOST_STATE_IDLE; - break; + /* modify USB task state because Vbus changed or unknown */ + uint8_t speed = 1; + //printf("\r\n\r\n\r\n\r\nSTATE %2.2x -> ", usb_task_state); + switch (vbusState) { + case LSHOST: // Low speed + speed = 0; + // Intentional fall-through + case FSHOST: // Full speed + // Start device initialization if we are not initializing + // Resets to the device cause an IRQ + // usb_task_state == UHS_USB_HOST_STATE_RESET_NOT_COMPLETE; + //if ((usb_task_state & UHS_USB_HOST_STATE_MASK) != UHS_USB_HOST_STATE_DETACHED) { + ReleaseChildren(); + if (!doingreset) { + if (usb_task_state == UHS_USB_HOST_STATE_RESET_NOT_COMPLETE) { + usb_task_state = UHS_USB_HOST_STATE_WAIT_BUS_READY; + } else if (usb_task_state != UHS_USB_HOST_STATE_WAIT_BUS_READY) { + usb_task_state = UHS_USB_HOST_STATE_DEBOUNCE; } - usb_host_speed = speed; - //printf("0x%2.2x\r\n\r\n\r\n\r\n", usb_task_state); - return; -}; + } + sof_countdown = 0; + break; + case SE1: // illegal state + sof_countdown = 0; + doingreset = false; + ReleaseChildren(); + usb_task_state = UHS_USB_HOST_STATE_ILLEGAL; + break; + case SE0: // disconnected + default: + sof_countdown = 0; + doingreset = false; + ReleaseChildren(); + usb_task_state = UHS_USB_HOST_STATE_IDLE; + break; + } + usb_host_speed = speed; + //printf("0x%2.2x\r\n\r\n\r\n\r\n", usb_task_state); + return; +} /** - * Probe bus to determine device presence and speed, - * then switch host to detected speed. + * Probe bus to determine device presence and speed, + * then switch host to detected speed. */ void UHS_NI MAX3421E_HOST::busprobe() { - uint8_t bus_sample; - uint8_t tmpdata; - bus_sample = regRd(rHRSL); //Get J,K status - bus_sample &= (bmJSTATUS | bmKSTATUS); //zero the rest of the byte - switch(bus_sample) { //start full-speed or low-speed host - case(bmJSTATUS): - // Serial.println("J"); - if((regRd(rMODE) & bmLOWSPEED) == 0) { - regWr(rMODE, MODE_FS_HOST); // start full-speed host - vbusState = FSHOST; - } else { - regWr(rMODE, MODE_LS_HOST); // start low-speed host - vbusState = LSHOST; - } - #ifdef USB_HOST_MANUAL_POLL - enable_frame_irq(true); - #endif - tmpdata = regRd(rMODE) | bmSOFKAENAB; // start SOF generation - regWr(rHIRQ, bmFRAMEIRQ); // see data sheet. - regWr(rMODE, tmpdata); - break; - case(bmKSTATUS): - // Serial.println("K"); - if((regRd(rMODE) & bmLOWSPEED) == 0) { - regWr(rMODE, MODE_LS_HOST); // start low-speed host - vbusState = LSHOST; - } else { - regWr(rMODE, MODE_FS_HOST); // start full-speed host - vbusState = FSHOST; - } - #ifdef USB_HOST_MANUAL_POLL - enable_frame_irq(true); - #endif - tmpdata = regRd(rMODE) | bmSOFKAENAB; // start SOF generation - regWr(rHIRQ, bmFRAMEIRQ); // see data sheet. - regWr(rMODE, tmpdata); - break; - case(bmSE1): //illegal state - // Serial.println("I"); - regWr(rMODE, bmDPPULLDN | bmDMPULLDN | bmHOST); - vbusState = SE1; - // sofevent = false; - break; - case(bmSE0): //disconnected state - // Serial.println("D"); - regWr(rMODE, bmDPPULLDN | bmDMPULLDN | bmHOST); - vbusState = SE0; - // sofevent = false; - break; - }//end switch( bus_sample ) + uint8_t bus_sample; + uint8_t tmpdata; + bus_sample = regRd(rHRSL); // Get J,K status + bus_sample &= (bmJSTATUS | bmKSTATUS); // zero the rest of the byte + switch (bus_sample) { // start full-speed or low-speed host + case bmJSTATUS: + // Serial.println("J"); + if ((regRd(rMODE) & bmLOWSPEED) == 0) { + regWr(rMODE, MODE_FS_HOST); // start full-speed host + vbusState = FSHOST; + } else { + regWr(rMODE, MODE_LS_HOST); // start low-speed host + vbusState = LSHOST; + } + #ifdef USB_HOST_MANUAL_POLL + enable_frame_irq(true); + #endif + tmpdata = regRd(rMODE) | bmSOFKAENAB; // start SOF generation + regWr(rHIRQ, bmFRAMEIRQ); // see data sheet. + regWr(rMODE, tmpdata); + break; + case bmKSTATUS: + // Serial.println("K"); + if ((regRd(rMODE) & bmLOWSPEED) == 0) { + regWr(rMODE, MODE_LS_HOST); // start low-speed host + vbusState = LSHOST; + } else { + regWr(rMODE, MODE_FS_HOST); // start full-speed host + vbusState = FSHOST; + } + #ifdef USB_HOST_MANUAL_POLL + enable_frame_irq(true); + #endif + tmpdata = regRd(rMODE) | bmSOFKAENAB; // start SOF generation + regWr(rHIRQ, bmFRAMEIRQ); // see data sheet. + regWr(rMODE, tmpdata); + break; + case bmSE1: // illegal state + // Serial.println("I"); + regWr(rMODE, bmDPPULLDN | bmDMPULLDN | bmHOST); + vbusState = SE1; + // sofevent = false; + break; + case bmSE0: // disconnected state + // Serial.println("D"); + regWr(rMODE, bmDPPULLDN | bmDMPULLDN | bmHOST); + vbusState = SE0; + // sofevent = false; + break; + } // end switch ( bus_sample ) } /** @@ -274,146 +276,145 @@ void UHS_NI MAX3421E_HOST::busprobe() { * @return 0 on success, -1 on error */ int16_t UHS_NI MAX3421E_HOST::Init(int16_t mseconds) { - usb_task_state = UHS_USB_HOST_STATE_INITIALIZE; //set up state machine - // Serial.print("MAX3421E 'this' USB Host @ 0x"); - // Serial.println((uint32_t)this, HEX); - // Serial.print("MAX3421E 'this' USB Host Address Pool @ 0x"); - // Serial.println((uint32_t)GetAddressPool(), HEX); - Init_dyn_SWI(); - UHS_printf_HELPER_init(); - noInterrupts(); -#ifdef ARDUINO_AVR_ADK - // For Mega ADK, which has a Max3421e on-board, - // set MAX_RESET to output mode, and then set it to HIGH - // PORTJ bit 2 - if(irq_pin == 54) { - DDRJ |= 0x04; // output - PORTJ |= 0x04; // HIGH - } -#endif - SPIclass.begin(); -#ifdef ARDUINO_AVR_ADK - if(irq_pin == 54) { - DDRE &= ~0x20; // input - PORTE |= 0x20; // pullup - } else -#endif - pinMode(irq_pin, INPUT_PULLUP); - //UHS_PIN_WRITE(irq_pin, HIGH); - pinMode(ss_pin, OUTPUT); - MARLIN_UHS_WRITE_SS(HIGH); - -#ifdef USB_HOST_SHIELD_TIMING_PIN - pinMode(USB_HOST_SHIELD_TIMING_PIN, OUTPUT); - // My counter/timer can't work on an inverted gate signal - // so we gate using a high pulse -- AJK - UHS_PIN_WRITE(USB_HOST_SHIELD_TIMING_PIN, LOW); -#endif - interrupts(); - -#if USB_HOST_SHIELD_USE_ISR - int intr = digitalPinToInterrupt(irq_pin); - if(intr == NOT_AN_INTERRUPT) { -#ifdef ARDUINO_AVR_ADK - if(irq_pin == 54) - intr = 6; - else -#endif - return (-2); - } - SPIclass.usingInterrupt(intr); -#else - SPIclass.usingInterrupt(255); -#endif -#ifndef NO_AUTO_SPEED - // test to get to reset acceptance. - uint32_t spd = UHS_MAX3421E_SPD; -again: - MAX3421E_SPI_Settings = SPISettings(spd, MSBFIRST, SPI_MODE0); - if(reset() == 0) { - MAX_HOST_DEBUG(PSTR("Fail SPI speed %lu\r\n"), spd); - if(spd > 1999999) { - spd -= 1000000; - goto again; - } - return (-1); - } else { - // reset passes, does 64k? - uint8_t sample_wr = 0; - uint8_t sample_rd = 0; - uint8_t gpinpol_copy = regRd(rGPINPOL); - for(uint16_t j = 0; j < 65535; j++) { - regWr(rGPINPOL, sample_wr); - sample_rd = regRd(rGPINPOL); - if(sample_rd != sample_wr) { - MAX_HOST_DEBUG(PSTR("Fail SPI speed %lu\r\n"), spd); - if(spd > 1999999) { - spd -= 1000000; - goto again; - } - return (-1); - } - sample_wr++; - } - regWr(rGPINPOL, gpinpol_copy); - } - - MAX_HOST_DEBUG(PSTR("Pass SPI speed %lu\r\n"), spd); -#endif - - if(reset() == 0) { //OSCOKIRQ hasn't asserted in time - MAX_HOST_DEBUG(PSTR("OSCOKIRQ hasn't asserted in time")); - return ( -1); - } - - /* MAX3421E - full-duplex SPI, interrupt kind, vbus off */ - regWr(rPINCTL, (bmFDUPSPI | bmIRQ_SENSE | GPX_VBDET)); - - // Delay a minimum of 1 second to ensure any capacitors are drained. - // 1 second is required to make sure we do not smoke a Microdrive! - if(mseconds != INT16_MIN) { - if(mseconds < 1000) mseconds = 1000; - delay(mseconds); // We can't depend on SOF timer here. - } - - regWr(rMODE, bmDPPULLDN | bmDMPULLDN | bmHOST); // set pull-downs, Host - - // Enable interrupts on the MAX3421e - regWr(rHIEN, IRQ_CHECK_MASK); - // Enable interrupt pin on the MAX3421e, set pulse width for edge - regWr(rCPUCTL, (bmIE | bmPULSEWIDTH)); - - /* check if device is connected */ - regWr(rHCTL, bmSAMPLEBUS); // sample USB bus - while(!(regRd(rHCTL) & bmSAMPLEBUS)); //wait for sample operation to finish - - busprobe(); //check if anything is connected - VBUS_changed(); - - // GPX pin on. This is done here so that a change is detected if we have a switch connected. - /* MAX3421E - full-duplex SPI, interrupt kind, vbus on */ - regWr(rPINCTL, (bmFDUPSPI | bmIRQ_SENSE)); - regWr(rHIRQ, bmBUSEVENTIRQ); // see data sheet. - regWr(rHCTL, bmBUSRST); // issue bus reset to force generate yet another possible IRQ - - -#if USB_HOST_SHIELD_USE_ISR - // Attach ISR to service IRQ from MAX3421e - noInterrupts(); - if(irq_pin & 1) { - ISRodd = this; - attachInterrupt(UHS_GET_DPI(irq_pin), call_ISRodd, IRQ_SENSE); - } else { - ISReven = this; - attachInterrupt(UHS_GET_DPI(irq_pin), call_ISReven, IRQ_SENSE); + usb_task_state = UHS_USB_HOST_STATE_INITIALIZE; //set up state machine + //Serial.print("MAX3421E 'this' USB Host @ 0x"); + //Serial.println((uint32_t)this, HEX); + //Serial.print("MAX3421E 'this' USB Host Address Pool @ 0x"); + //Serial.println((uint32_t)GetAddressPool(), HEX); + Init_dyn_SWI(); + UHS_printf_HELPER_init(); + noInterrupts(); + #ifdef ARDUINO_AVR_ADK + // For Mega ADK, which has a Max3421e on-board, + // set MAX_RESET to output mode, and then set it to HIGH + // PORTJ bit 2 + if (irq_pin == 54) { + DDRJ |= 0x04; // output + PORTJ |= 0x04; // HIGH + } + #endif + SPIclass.begin(); + #ifdef ARDUINO_AVR_ADK + if (irq_pin == 54) { + DDRE &= ~0x20; // input + PORTE |= 0x20; // pullup + } else + #endif + pinMode(irq_pin, INPUT_PULLUP); + //UHS_PIN_WRITE(irq_pin, HIGH); + pinMode(ss_pin, OUTPUT); + MARLIN_UHS_WRITE_SS(HIGH); + + #ifdef USB_HOST_SHIELD_TIMING_PIN + pinMode(USB_HOST_SHIELD_TIMING_PIN, OUTPUT); + // My counter/timer can't work on an inverted gate signal + // so we gate using a high pulse -- AJK + UHS_PIN_WRITE(USB_HOST_SHIELD_TIMING_PIN, LOW); + #endif + interrupts(); + + #if USB_HOST_SHIELD_USE_ISR + int intr = digitalPinToInterrupt(irq_pin); + if (intr == NOT_AN_INTERRUPT) { + #ifdef ARDUINO_AVR_ADK + if (irq_pin == 54) + intr = 6; + else + #endif + return (-2); + } + SPIclass.usingInterrupt(intr); + #else + SPIclass.usingInterrupt(255); + #endif + #ifndef NO_AUTO_SPEED + // test to get to reset acceptance. + uint32_t spd = UHS_MAX3421E_SPD; + again: + MAX3421E_SPI_Settings = SPISettings(spd, MSBFIRST, SPI_MODE0); + if (reset() == 0) { + MAX_HOST_DEBUG(PSTR("Fail SPI speed %lu\r\n"), spd); + if (spd > 1999999) { + spd -= 1000000; + goto again; + } + return (-1); + } else { + // reset passes, does 64k? + uint8_t sample_wr = 0; + uint8_t sample_rd = 0; + uint8_t gpinpol_copy = regRd(rGPINPOL); + for (uint16_t j = 0; j < 65535; j++) { + regWr(rGPINPOL, sample_wr); + sample_rd = regRd(rGPINPOL); + if (sample_rd != sample_wr) { + MAX_HOST_DEBUG(PSTR("Fail SPI speed %lu\r\n"), spd); + if (spd > 1999999) { + spd -= 1000000; + goto again; + } + return (-1); } - interrupts(); -#endif - //printf("\r\nrPINCTL 0x%2.2X\r\n", rPINCTL); - //printf("rCPUCTL 0x%2.2X\r\n", rCPUCTL); - //printf("rHIEN 0x%2.2X\r\n", rHIEN); - //printf("irq_pin %i\r\n", irq_pin); - return 0; + sample_wr++; + } + regWr(rGPINPOL, gpinpol_copy); + } + + MAX_HOST_DEBUG(PSTR("Pass SPI speed %lu\r\n"), spd); + #endif + + if (reset() == 0) { // OSCOKIRQ hasn't asserted in time + MAX_HOST_DEBUG(PSTR("OSCOKIRQ hasn't asserted in time")); + return ( -1); + } + + /* MAX3421E - full-duplex SPI, interrupt kind, vbus off */ + regWr(rPINCTL, (bmFDUPSPI | bmIRQ_SENSE | GPX_VBDET)); + + // Delay a minimum of 1 second to ensure any capacitors are drained. + // 1 second is required to make sure we do not smoke a Microdrive! + if (mseconds != INT16_MIN) { + if (mseconds < 1000) mseconds = 1000; + delay(mseconds); // We can't depend on SOF timer here. + } + + regWr(rMODE, bmDPPULLDN | bmDMPULLDN | bmHOST); // set pull-downs, Host + + // Enable interrupts on the MAX3421e + regWr(rHIEN, IRQ_CHECK_MASK); + // Enable interrupt pin on the MAX3421e, set pulse width for edge + regWr(rCPUCTL, (bmIE | bmPULSEWIDTH)); + + /* check if device is connected */ + regWr(rHCTL, bmSAMPLEBUS); // sample USB bus + while (!(regRd(rHCTL) & bmSAMPLEBUS)); // wait for sample operation to finish + + busprobe(); // check if anything is connected + VBUS_changed(); + + // GPX pin on. This is done here so that a change is detected if we have a switch connected. + /* MAX3421E - full-duplex SPI, interrupt kind, vbus on */ + regWr(rPINCTL, (bmFDUPSPI | bmIRQ_SENSE)); + regWr(rHIRQ, bmBUSEVENTIRQ); // see data sheet. + regWr(rHCTL, bmBUSRST); // issue bus reset to force generate yet another possible IRQ + + #if USB_HOST_SHIELD_USE_ISR + // Attach ISR to service IRQ from MAX3421e + noInterrupts(); + if (irq_pin & 1) { + ISRodd = this; + attachInterrupt(UHS_GET_DPI(irq_pin), call_ISRodd, IRQ_SENSE); + } else { + ISReven = this; + attachInterrupt(UHS_GET_DPI(irq_pin), call_ISReven, IRQ_SENSE); + } + interrupts(); + #endif + //printf("\r\nrPINCTL 0x%2.2X\r\n", rPINCTL); + //printf("rCPUCTL 0x%2.2X\r\n", rCPUCTL); + //printf("rHIEN 0x%2.2X\r\n", rHIEN); + //printf("irq_pin %i\r\n", irq_pin); + return 0; } /** @@ -426,41 +427,41 @@ int16_t UHS_NI MAX3421E_HOST::Init(int16_t mseconds) { * @return 0 on success */ uint8_t UHS_NI MAX3421E_HOST::SetAddress(uint8_t addr, uint8_t ep, UHS_EpInfo **ppep, uint16_t &nak_limit) { - UHS_Device *p = addrPool.GetUsbDevicePtr(addr); + UHS_Device *p = addrPool.GetUsbDevicePtr(addr); - if(!p) - return UHS_HOST_ERROR_NO_ADDRESS_IN_POOL; + if (!p) + return UHS_HOST_ERROR_NO_ADDRESS_IN_POOL; - if(!p->epinfo) - return UHS_HOST_ERROR_NULL_EPINFO; + if (!p->epinfo) + return UHS_HOST_ERROR_NULL_EPINFO; - *ppep = getEpInfoEntry(addr, ep); + *ppep = getEpInfoEntry(addr, ep); - if(!*ppep) - return UHS_HOST_ERROR_NO_ENDPOINT_IN_TABLE; + if (!*ppep) + return UHS_HOST_ERROR_NO_ENDPOINT_IN_TABLE; - nak_limit = (0x0001UL << (((*ppep)->bmNakPower > UHS_USB_NAK_MAX_POWER) ? UHS_USB_NAK_MAX_POWER : (*ppep)->bmNakPower)); - nak_limit--; - /* - USBTRACE2("\r\nAddress: ", addr); - USBTRACE2(" EP: ", ep); - USBTRACE2(" NAK Power: ",(*ppep)->bmNakPower); - USBTRACE2(" NAK Limit: ", nak_limit); - USBTRACE("\r\n"); - */ - regWr(rPERADDR, addr); //set peripheral address + nak_limit = (0x0001UL << (((*ppep)->bmNakPower > UHS_USB_NAK_MAX_POWER) ? UHS_USB_NAK_MAX_POWER : (*ppep)->bmNakPower)); + nak_limit--; + /* + USBTRACE2("\r\nAddress: ", addr); + USBTRACE2(" EP: ", ep); + USBTRACE2(" NAK Power: ",(*ppep)->bmNakPower); + USBTRACE2(" NAK Limit: ", nak_limit); + USBTRACE("\r\n"); + */ + regWr(rPERADDR, addr); // set peripheral address - uint8_t mode = regRd(rMODE); + uint8_t mode = regRd(rMODE); - //Serial.print("\r\nMode: "); - //Serial.println( mode, HEX); - //Serial.print("\r\nLS: "); - //Serial.println(p->speed, HEX); + //Serial.print("\r\nMode: "); + //Serial.println( mode, HEX); + //Serial.print("\r\nLS: "); + //Serial.println(p->speed, HEX); - // Set bmLOWSPEED and bmHUBPRE in case of low-speed device, reset them otherwise - regWr(rMODE, (p->speed) ? mode & ~(bmHUBPRE | bmLOWSPEED) : mode | bmLOWSPEED | hub_present); + // Set bmLOWSPEED and bmHUBPRE in case of low-speed device, reset them otherwise + regWr(rMODE, (p->speed) ? mode & ~(bmHUBPRE | bmLOWSPEED) : mode | bmLOWSPEED | hub_present); - return 0; + return 0; } /** @@ -473,71 +474,70 @@ uint8_t UHS_NI MAX3421E_HOST::SetAddress(uint8_t addr, uint8_t ep, UHS_EpInfo ** * @return 0 on success */ uint8_t UHS_NI MAX3421E_HOST::InTransfer(UHS_EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, uint8_t *data) { - uint8_t rcode = 0; - uint8_t pktsize; - - uint16_t nbytes = *nbytesptr; - MAX_HOST_DEBUG(PSTR("Requesting %i bytes "), nbytes); - uint8_t maxpktsize = pep->maxPktSize; - - *nbytesptr = 0; - regWr(rHCTL, (pep->bmRcvToggle) ? bmRCVTOG1 : bmRCVTOG0); //set toggle value - - // use a 'break' to exit this loop - while(1) { - rcode = dispatchPkt(MAX3421E_tokIN, pep->epAddr, nak_limit); //IN packet to EP-'endpoint'. Function takes care of NAKS. -#if 0 - // This issue should be resolved now. - if(rcode == UHS_HOST_ERROR_TOGERR) { - //MAX_HOST_DEBUG(PSTR("toggle wrong\r\n")); - // yes, we flip it wrong here so that next time it is actually correct! - pep->bmRcvToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1; - regWr(rHCTL, (pep->bmRcvToggle) ? bmRCVTOG1 : bmRCVTOG0); //set toggle value - continue; - } -#endif - if(rcode) { - //MAX_HOST_DEBUG(PSTR(">>>>>>>> Problem! dispatchPkt %2.2x\r\n"), rcode); - break; //should be 0, indicating ACK. Else return error code. - } - /* check for RCVDAVIRQ and generate error if not present */ - /* the only case when absence of RCVDAVIRQ makes sense is when toggle error occurred. Need to add handling for that */ - if((regRd(rHIRQ) & bmRCVDAVIRQ) == 0) { - //MAX_HOST_DEBUG(PSTR(">>>>>>>> Problem! NO RCVDAVIRQ!\r\n")); - rcode = 0xF0; //receive error - break; - } - pktsize = regRd(rRCVBC); //number of received bytes - MAX_HOST_DEBUG(PSTR("Got %i bytes \r\n"), pktsize); - - if(pktsize > nbytes) { //certain devices send more than asked - //MAX_HOST_DEBUG(PSTR(">>>>>>>> Warning: wanted %i bytes but got %i.\r\n"), nbytes, pktsize); - pktsize = nbytes; - } - - int16_t mem_left = (int16_t)nbytes - *((int16_t*)nbytesptr); - - if(mem_left < 0) - mem_left = 0; - - data = bytesRd(rRCVFIFO, ((pktsize > mem_left) ? mem_left : pktsize), data); - - regWr(rHIRQ, bmRCVDAVIRQ); // Clear the IRQ & free the buffer - *nbytesptr += pktsize; // add this packet's byte count to total transfer length - - /* The transfer is complete under two conditions: */ - /* 1. The device sent a short packet (L.T. maxPacketSize) */ - /* 2. 'nbytes' have been transferred. */ - if((pktsize < maxpktsize) || (*nbytesptr >= nbytes)) // have we transferred 'nbytes' bytes? - { - // Save toggle value - pep->bmRcvToggle = ((regRd(rHRSL) & bmRCVTOGRD)) ? 1 : 0; - //MAX_HOST_DEBUG(PSTR("\r\n")); - rcode = 0; - break; - } // if - } //while( 1 ) - return ( rcode); + uint8_t rcode = 0; + uint8_t pktsize; + + uint16_t nbytes = *nbytesptr; + MAX_HOST_DEBUG(PSTR("Requesting %i bytes "), nbytes); + uint8_t maxpktsize = pep->maxPktSize; + + *nbytesptr = 0; + regWr(rHCTL, (pep->bmRcvToggle) ? bmRCVTOG1 : bmRCVTOG0); // set toggle value + + // use a 'break' to exit this loop + while (1) { + rcode = dispatchPkt(MAX3421E_tokIN, pep->epAddr, nak_limit); // IN packet to EP-'endpoint'. Function takes care of NAKS. + #if 0 + // This issue should be resolved now. + if (rcode == UHS_HOST_ERROR_TOGERR) { + //MAX_HOST_DEBUG(PSTR("toggle wrong\r\n")); + // yes, we flip it wrong here so that next time it is actually correct! + pep->bmRcvToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1; + regWr(rHCTL, (pep->bmRcvToggle) ? bmRCVTOG1 : bmRCVTOG0); // set toggle value + continue; + } + #endif + if (rcode) { + //MAX_HOST_DEBUG(PSTR(">>>>>>>> Problem! dispatchPkt %2.2x\r\n"), rcode); + break; // should be 0, indicating ACK. Else return error code. + } + /* check for RCVDAVIRQ and generate error if not present */ + /* the only case when absence of RCVDAVIRQ makes sense is when toggle error occurred. Need to add handling for that */ + if ((regRd(rHIRQ) & bmRCVDAVIRQ) == 0) { + //MAX_HOST_DEBUG(PSTR(">>>>>>>> Problem! NO RCVDAVIRQ!\r\n")); + rcode = 0xF0; // receive error + break; + } + pktsize = regRd(rRCVBC); // number of received bytes + MAX_HOST_DEBUG(PSTR("Got %i bytes \r\n"), pktsize); + + if (pktsize > nbytes) { // certain devices send more than asked + //MAX_HOST_DEBUG(PSTR(">>>>>>>> Warning: wanted %i bytes but got %i.\r\n"), nbytes, pktsize); + pktsize = nbytes; + } + + int16_t mem_left = (int16_t)nbytes - *((int16_t*)nbytesptr); + + if (mem_left < 0) + mem_left = 0; + + data = bytesRd(rRCVFIFO, ((pktsize > mem_left) ? mem_left : pktsize), data); + + regWr(rHIRQ, bmRCVDAVIRQ); // Clear the IRQ & free the buffer + *nbytesptr += pktsize; // add this packet's byte count to total transfer length + + /* The transfer is complete under two conditions: */ + /* 1. The device sent a short packet (L.T. maxPacketSize) */ + /* 2. 'nbytes' have been transferred. */ + if ((pktsize < maxpktsize) || (*nbytesptr >= nbytes)) { // have we transferred 'nbytes' bytes? + // Save toggle value + pep->bmRcvToggle = ((regRd(rHRSL) & bmRCVTOGRD)) ? 1 : 0; + //MAX_HOST_DEBUG(PSTR("\r\n")); + rcode = 0; + break; + } // if + } // while( 1 ) + return (rcode); } /** @@ -550,72 +550,72 @@ uint8_t UHS_NI MAX3421E_HOST::InTransfer(UHS_EpInfo *pep, uint16_t nak_limit, ui * @return 0 on success */ uint8_t UHS_NI MAX3421E_HOST::OutTransfer(UHS_EpInfo *pep, uint16_t nak_limit, uint16_t nbytes, uint8_t *data) { - uint8_t rcode = UHS_HOST_ERROR_NONE; - uint8_t retry_count; - uint8_t *data_p = data; //local copy of the data pointer - uint16_t bytes_tosend; - uint16_t nak_count; - uint16_t bytes_left = nbytes; - - uint8_t maxpktsize = pep->maxPktSize; - - if(maxpktsize < 1 || maxpktsize > 64) - return UHS_HOST_ERROR_BAD_MAX_PACKET_SIZE; - - unsigned long timeout = millis() + UHS_HOST_TRANSFER_MAX_MS; - - regWr(rHCTL, (pep->bmSndToggle) ? bmSNDTOG1 : bmSNDTOG0); //set toggle value - - while(bytes_left) { - SYSTEM_OR_SPECIAL_YIELD(); - retry_count = 0; - nak_count = 0; - bytes_tosend = (bytes_left >= maxpktsize) ? maxpktsize : bytes_left; - bytesWr(rSNDFIFO, bytes_tosend, data_p); //filling output FIFO - regWr(rSNDBC, bytes_tosend); //set number of bytes - regWr(rHXFR, (MAX3421E_tokOUT | pep->epAddr)); //dispatch packet - while(!(regRd(rHIRQ) & bmHXFRDNIRQ)); //wait for the completion IRQ - regWr(rHIRQ, bmHXFRDNIRQ); //clear IRQ - rcode = (regRd(rHRSL) & 0x0F); - - while(rcode && ((long)(millis() - timeout) < 0L)) { - switch(rcode) { - case UHS_HOST_ERROR_NAK: - nak_count++; - if(nak_limit && (nak_count == nak_limit)) - goto breakout; - break; - case UHS_HOST_ERROR_TIMEOUT: - retry_count++; - if(retry_count == UHS_HOST_TRANSFER_RETRY_MAXIMUM) - goto breakout; - break; - case UHS_HOST_ERROR_TOGERR: - // yes, we flip it wrong here so that next time it is actually correct! - pep->bmSndToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1; - regWr(rHCTL, (pep->bmSndToggle) ? bmSNDTOG1 : bmSNDTOG0); //set toggle value - break; - default: - goto breakout; - }//switch( rcode - - /* process NAK according to Host out NAK bug */ - regWr(rSNDBC, 0); - regWr(rSNDFIFO, *data_p); - regWr(rSNDBC, bytes_tosend); - regWr(rHXFR, (MAX3421E_tokOUT | pep->epAddr)); //dispatch packet - while(!(regRd(rHIRQ) & bmHXFRDNIRQ)); //wait for the completion IRQ - regWr(rHIRQ, bmHXFRDNIRQ); //clear IRQ - rcode = (regRd(rHRSL) & 0x0F); - SYSTEM_OR_SPECIAL_YIELD(); - }//while( rcode && .... - bytes_left -= bytes_tosend; - data_p += bytes_tosend; - }//while( bytes_left... -breakout: - - pep->bmSndToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 1 : 0; //bmSNDTOG1 : bmSNDTOG0; //update toggle - return ( rcode); //should be 0 in all cases + uint8_t rcode = UHS_HOST_ERROR_NONE; + uint8_t retry_count; + uint8_t *data_p = data; // local copy of the data pointer + uint16_t bytes_tosend; + uint16_t nak_count; + uint16_t bytes_left = nbytes; + + uint8_t maxpktsize = pep->maxPktSize; + + if (maxpktsize < 1 || maxpktsize > 64) + return UHS_HOST_ERROR_BAD_MAX_PACKET_SIZE; + + unsigned long timeout = millis() + UHS_HOST_TRANSFER_MAX_MS; + + regWr(rHCTL, (pep->bmSndToggle) ? bmSNDTOG1 : bmSNDTOG0); // set toggle value + + while (bytes_left) { + SYSTEM_OR_SPECIAL_YIELD(); + retry_count = 0; + nak_count = 0; + bytes_tosend = (bytes_left >= maxpktsize) ? maxpktsize : bytes_left; + bytesWr(rSNDFIFO, bytes_tosend, data_p); // filling output FIFO + regWr(rSNDBC, bytes_tosend); // set number of bytes + regWr(rHXFR, (MAX3421E_tokOUT | pep->epAddr)); // dispatch packet + while (!(regRd(rHIRQ) & bmHXFRDNIRQ)); // wait for the completion IRQ + regWr(rHIRQ, bmHXFRDNIRQ); // clear IRQ + rcode = (regRd(rHRSL) & 0x0F); + + while (rcode && ((long)(millis() - timeout) < 0L)) { + switch (rcode) { + case UHS_HOST_ERROR_NAK: + nak_count++; + if (nak_limit && (nak_count == nak_limit)) + goto breakout; + break; + case UHS_HOST_ERROR_TIMEOUT: + retry_count++; + if (retry_count == UHS_HOST_TRANSFER_RETRY_MAXIMUM) + goto breakout; + break; + case UHS_HOST_ERROR_TOGERR: + // yes, we flip it wrong here so that next time it is actually correct! + pep->bmSndToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1; + regWr(rHCTL, (pep->bmSndToggle) ? bmSNDTOG1 : bmSNDTOG0); // set toggle value + break; + default: + goto breakout; + } // switch (rcode + + /* process NAK according to Host out NAK bug */ + regWr(rSNDBC, 0); + regWr(rSNDFIFO, *data_p); + regWr(rSNDBC, bytes_tosend); + regWr(rHXFR, (MAX3421E_tokOUT | pep->epAddr)); // dispatch packet + while (!(regRd(rHIRQ) & bmHXFRDNIRQ)); // wait for the completion IRQ + regWr(rHIRQ, bmHXFRDNIRQ); // clear IRQ + rcode = (regRd(rHRSL) & 0x0F); + SYSTEM_OR_SPECIAL_YIELD(); + } // while (rcode && .... + bytes_left -= bytes_tosend; + data_p += bytes_tosend; + } // while (bytes_left... + breakout: + + pep->bmSndToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 1 : 0; // bmSNDTOG1 : bmSNDTOG0; // update toggle + return (rcode); // should be 0 in all cases } /** @@ -633,45 +633,44 @@ uint8_t UHS_NI MAX3421E_HOST::OutTransfer(UHS_EpInfo *pep, uint16_t nak_limit, u /* return codes 0x00-0x0F are HRSLT( 0x00 being success ), 0xFF means timeout */ uint8_t UHS_NI MAX3421E_HOST::dispatchPkt(uint8_t token, uint8_t ep, uint16_t nak_limit) { - unsigned long timeout = millis() + UHS_HOST_TRANSFER_MAX_MS; - uint8_t tmpdata; - uint8_t rcode = UHS_HOST_ERROR_NONE; - uint8_t retry_count = 0; - uint16_t nak_count = 0; - - for(;;) { - regWr(rHXFR, (token | ep)); //launch the transfer - while((long)(millis() - timeout) < 0L) //wait for transfer completion - { - SYSTEM_OR_SPECIAL_YIELD(); - tmpdata = regRd(rHIRQ); - - if(tmpdata & bmHXFRDNIRQ) { - regWr(rHIRQ, bmHXFRDNIRQ); //clear the interrupt - //rcode = 0x00; - break; - }//if( tmpdata & bmHXFRDNIRQ - - }//while ( millis() < timeout - - rcode = (regRd(rHRSL) & 0x0F); //analyze transfer result - - switch(rcode) { - case UHS_HOST_ERROR_NAK: - nak_count++; - if(nak_limit && (nak_count == nak_limit)) - return (rcode); - delayMicroseconds(200); - break; - case UHS_HOST_ERROR_TIMEOUT: - retry_count++; - if(retry_count == UHS_HOST_TRANSFER_RETRY_MAXIMUM) - return (rcode); - break; - default: - return (rcode); - }//switch( rcode - } + unsigned long timeout = millis() + UHS_HOST_TRANSFER_MAX_MS; + uint8_t tmpdata; + uint8_t rcode = UHS_HOST_ERROR_NONE; + uint8_t retry_count = 0; + uint16_t nak_count = 0; + + for (;;) { + regWr(rHXFR, (token | ep)); // launch the transfer + while (long(millis() - timeout) < 0L) { // wait for transfer completion + SYSTEM_OR_SPECIAL_YIELD(); + tmpdata = regRd(rHIRQ); + + if (tmpdata & bmHXFRDNIRQ) { + regWr(rHIRQ, bmHXFRDNIRQ); // clear the interrupt + //rcode = 0x00; + break; + } // if (tmpdata & bmHXFRDNIRQ + + } // while (millis() < timeout + + rcode = (regRd(rHRSL) & 0x0F); // analyze transfer result + + switch (rcode) { + case UHS_HOST_ERROR_NAK: + nak_count++; + if (nak_limit && (nak_count == nak_limit)) + return (rcode); + delayMicroseconds(200); + break; + case UHS_HOST_ERROR_TIMEOUT: + retry_count++; + if (retry_count == UHS_HOST_TRANSFER_RETRY_MAXIMUM) + return (rcode); + break; + default: + return (rcode); + } // switch (rcode) + } } // @@ -679,325 +678,324 @@ uint8_t UHS_NI MAX3421E_HOST::dispatchPkt(uint8_t token, uint8_t ep, uint16_t na // UHS_EpInfo * UHS_NI MAX3421E_HOST::ctrlReqOpen(uint8_t addr, uint64_t Request, uint8_t *dataptr) { - uint8_t rcode; - UHS_EpInfo *pep = NULL; - uint16_t nak_limit = 0; - rcode = SetAddress(addr, 0, &pep, nak_limit); - - if(!rcode) { - - bytesWr(rSUDFIFO, 8, (uint8_t*)(&Request)); //transfer to setup packet FIFO - - rcode = dispatchPkt(MAX3421E_tokSETUP, 0, nak_limit); //dispatch packet - if(!rcode) { - if(dataptr != NULL) { - if(((Request)/* bmReqType*/ & 0x80) == 0x80) { - pep->bmRcvToggle = 1; //bmRCVTOG1; - } else { - pep->bmSndToggle = 1; //bmSNDTOG1; - } - } - } else { - pep = NULL; - } + uint8_t rcode; + UHS_EpInfo *pep = NULL; + uint16_t nak_limit = 0; + rcode = SetAddress(addr, 0, &pep, nak_limit); + + if (!rcode) { + + bytesWr(rSUDFIFO, 8, (uint8_t*)(&Request)); // transfer to setup packet FIFO + + rcode = dispatchPkt(MAX3421E_tokSETUP, 0, nak_limit); // dispatch packet + if (!rcode) { + if (dataptr != NULL) { + if (((Request)/* bmReqType*/ & 0x80) == 0x80) { + pep->bmRcvToggle = 1; //bmRCVTOG1; + } else { + pep->bmSndToggle = 1; //bmSNDTOG1; } - return pep; + } + } else { + pep = NULL; + } + } + return pep; } uint8_t UHS_NI MAX3421E_HOST::ctrlReqRead(UHS_EpInfo *pep, uint16_t *left, uint16_t *read, uint16_t nbytes, uint8_t *dataptr) { - *read = 0; - uint16_t nak_limit = 0; - MAX_HOST_DEBUG(PSTR("ctrlReqRead left: %i\r\n"), *left); - if(*left) { -again: - *read = nbytes; - uint8_t rcode = InTransfer(pep, nak_limit, read, dataptr); - if(rcode == UHS_HOST_ERROR_TOGERR) { - // yes, we flip it wrong here so that next time it is actually correct! - pep->bmRcvToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1; - goto again; - } - - if(rcode) { - MAX_HOST_DEBUG(PSTR("ctrlReqRead ERROR: %2.2x, left: %i, read %i\r\n"), rcode, *left, *read); - return rcode; - } - *left -= *read; - MAX_HOST_DEBUG(PSTR("ctrlReqRead left: %i, read %i\r\n"), *left, *read); - } - return 0; + *read = 0; + uint16_t nak_limit = 0; + MAX_HOST_DEBUG(PSTR("ctrlReqRead left: %i\r\n"), *left); + if (*left) { + again: + *read = nbytes; + uint8_t rcode = InTransfer(pep, nak_limit, read, dataptr); + if (rcode == UHS_HOST_ERROR_TOGERR) { + // yes, we flip it wrong here so that next time it is actually correct! + pep->bmRcvToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1; + goto again; + } + + if (rcode) { + MAX_HOST_DEBUG(PSTR("ctrlReqRead ERROR: %2.2x, left: %i, read %i\r\n"), rcode, *left, *read); + return rcode; + } + *left -= *read; + MAX_HOST_DEBUG(PSTR("ctrlReqRead left: %i, read %i\r\n"), *left, *read); + } + return 0; } uint8_t UHS_NI MAX3421E_HOST::ctrlReqClose(UHS_EpInfo *pep, uint8_t bmReqType, uint16_t left, uint16_t nbytes, uint8_t *dataptr) { - uint8_t rcode = 0; - - //MAX_HOST_DEBUG(PSTR("Closing")); - if(((bmReqType & 0x80) == 0x80) && pep && left && dataptr) { - MAX_HOST_DEBUG(PSTR("ctrlReqRead Sinking %i\r\n"), left); - // If reading, sink the rest of the data. - while(left) { - uint16_t read = nbytes; - rcode = InTransfer(pep, 0, &read, dataptr); - if(rcode == UHS_HOST_ERROR_TOGERR) { - // yes, we flip it wrong here so that next time it is actually correct! - pep->bmRcvToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1; - continue; - } - if(rcode) break; - left -= read; - if(read < nbytes) break; - } - } - if(!rcode) { - // Serial.println("Dispatching"); - rcode = dispatchPkt(((bmReqType & 0x80) == 0x80) ? MAX3421E_tokOUTHS : MAX3421E_tokINHS, 0, 0); //GET if direction - // } else { - // Serial.println("Bypassed Dispatch"); - } - return rcode; + uint8_t rcode = 0; + + //MAX_HOST_DEBUG(PSTR("Closing")); + if (((bmReqType & 0x80) == 0x80) && pep && left && dataptr) { + MAX_HOST_DEBUG(PSTR("ctrlReqRead Sinking %i\r\n"), left); + // If reading, sink the rest of the data. + while (left) { + uint16_t read = nbytes; + rcode = InTransfer(pep, 0, &read, dataptr); + if (rcode == UHS_HOST_ERROR_TOGERR) { + // yes, we flip it wrong here so that next time it is actually correct! + pep->bmRcvToggle = (regRd(rHRSL) & bmSNDTOGRD) ? 0 : 1; + continue; + } + if (rcode) break; + left -= read; + if (read < nbytes) break; + } + } + if (!rcode) { + //Serial.println("Dispatching"); + rcode = dispatchPkt(((bmReqType & 0x80) == 0x80) ? MAX3421E_tokOUTHS : MAX3421E_tokINHS, 0, 0); //GET if direction + //} else { + //Serial.println("Bypassed Dispatch"); + } + return rcode; } /** * Bottom half of the ISR task */ void UHS_NI MAX3421E_HOST::ISRbottom() { - uint8_t x; - // Serial.print("Enter "); - // Serial.print((uint32_t)this,HEX); - // Serial.print(" "); - // Serial.println(usb_task_state, HEX); - - DDSB(); - if(condet) { - VBUS_changed(); -#if USB_HOST_SHIELD_USE_ISR - noInterrupts(); -#endif - condet = false; -#if USB_HOST_SHIELD_USE_ISR - interrupts(); -#endif - } - switch(usb_task_state) { - case UHS_USB_HOST_STATE_INITIALIZE: - // should never happen... - MAX_HOST_DEBUG(PSTR("UHS_USB_HOST_STATE_INITIALIZE\r\n")); - busprobe(); - VBUS_changed(); - break; - case UHS_USB_HOST_STATE_DEBOUNCE: - MAX_HOST_DEBUG(PSTR("UHS_USB_HOST_STATE_DEBOUNCE\r\n")); - // This seems to not be needed. The host controller has debounce built in. - sof_countdown = UHS_HOST_DEBOUNCE_DELAY_MS; - usb_task_state = UHS_USB_HOST_STATE_DEBOUNCE_NOT_COMPLETE; - break; - case UHS_USB_HOST_STATE_DEBOUNCE_NOT_COMPLETE: - MAX_HOST_DEBUG(PSTR("UHS_USB_HOST_STATE_DEBOUNCE_NOT_COMPLETE\r\n")); - if(!sof_countdown) usb_task_state = UHS_USB_HOST_STATE_RESET_DEVICE; - break; - case UHS_USB_HOST_STATE_RESET_DEVICE: - MAX_HOST_DEBUG(PSTR("UHS_USB_HOST_STATE_RESET_DEVICE\r\n")); - busevent = true; - usb_task_state = UHS_USB_HOST_STATE_RESET_NOT_COMPLETE; - regWr(rHIRQ, bmBUSEVENTIRQ); // see data sheet. - regWr(rHCTL, bmBUSRST); // issue bus reset - break; - case UHS_USB_HOST_STATE_RESET_NOT_COMPLETE: - MAX_HOST_DEBUG(PSTR("UHS_USB_HOST_STATE_RESET_NOT_COMPLETE\r\n")); - if(!busevent) usb_task_state = UHS_USB_HOST_STATE_WAIT_BUS_READY; - break; - case UHS_USB_HOST_STATE_WAIT_BUS_READY: - MAX_HOST_DEBUG(PSTR("UHS_USB_HOST_STATE_WAIT_BUS_READY\r\n")); - usb_task_state = UHS_USB_HOST_STATE_CONFIGURING; - break; // don't fall through - - case UHS_USB_HOST_STATE_CONFIGURING: - usb_task_state = UHS_USB_HOST_STATE_CHECK; - x = Configuring(0, 1, usb_host_speed); - usb_error = x; - if(usb_task_state == UHS_USB_HOST_STATE_CHECK) { - if(x) { - MAX_HOST_DEBUG(PSTR("Error 0x%2.2x"), x); - if(x == UHS_HOST_ERROR_JERR) { - usb_task_state = UHS_USB_HOST_STATE_IDLE; - } else if(x != UHS_HOST_ERROR_DEVICE_INIT_INCOMPLETE) { - usb_error = x; - usb_task_state = UHS_USB_HOST_STATE_ERROR; - } - } else - usb_task_state = UHS_USB_HOST_STATE_CONFIGURING_DONE; - } - break; - - case UHS_USB_HOST_STATE_CHECK: - // Serial.println((uint32_t)__builtin_return_address(0), HEX); - break; - case UHS_USB_HOST_STATE_CONFIGURING_DONE: - usb_task_state = UHS_USB_HOST_STATE_RUNNING; - break; - #ifdef USB_HOST_MANUAL_POLL - case UHS_USB_HOST_STATE_RUNNING: - case UHS_USB_HOST_STATE_ERROR: - case UHS_USB_HOST_STATE_IDLE: - case UHS_USB_HOST_STATE_ILLEGAL: - enable_frame_irq(false); - break; - #else - case UHS_USB_HOST_STATE_RUNNING: - Poll_Others(); - for(x = 0; (usb_task_state == UHS_USB_HOST_STATE_RUNNING) && (x < UHS_HOST_MAX_INTERFACE_DRIVERS); x++) { - if(devConfig[x]) { - if(devConfig[x]->bPollEnable) devConfig[x]->Poll(); - } - } - // fall thru - #endif - default: - // Do nothing - break; - } // switch( usb_task_state ) - DDSB(); -#if USB_HOST_SHIELD_USE_ISR - if(condet) { - VBUS_changed(); - noInterrupts(); - condet = false; - interrupts(); + uint8_t x; + // Serial.print("Enter "); + // Serial.print((uint32_t)this,HEX); + // Serial.print(" "); + // Serial.println(usb_task_state, HEX); + + DDSB(); + if (condet) { + VBUS_changed(); + #if USB_HOST_SHIELD_USE_ISR + noInterrupts(); + #endif + condet = false; + #if USB_HOST_SHIELD_USE_ISR + interrupts(); + #endif + } + switch (usb_task_state) { + case UHS_USB_HOST_STATE_INITIALIZE: + // should never happen... + MAX_HOST_DEBUG(PSTR("UHS_USB_HOST_STATE_INITIALIZE\r\n")); + busprobe(); + VBUS_changed(); + break; + case UHS_USB_HOST_STATE_DEBOUNCE: + MAX_HOST_DEBUG(PSTR("UHS_USB_HOST_STATE_DEBOUNCE\r\n")); + // This seems to not be needed. The host controller has debounce built in. + sof_countdown = UHS_HOST_DEBOUNCE_DELAY_MS; + usb_task_state = UHS_USB_HOST_STATE_DEBOUNCE_NOT_COMPLETE; + break; + case UHS_USB_HOST_STATE_DEBOUNCE_NOT_COMPLETE: + MAX_HOST_DEBUG(PSTR("UHS_USB_HOST_STATE_DEBOUNCE_NOT_COMPLETE\r\n")); + if (!sof_countdown) usb_task_state = UHS_USB_HOST_STATE_RESET_DEVICE; + break; + case UHS_USB_HOST_STATE_RESET_DEVICE: + MAX_HOST_DEBUG(PSTR("UHS_USB_HOST_STATE_RESET_DEVICE\r\n")); + busevent = true; + usb_task_state = UHS_USB_HOST_STATE_RESET_NOT_COMPLETE; + regWr(rHIRQ, bmBUSEVENTIRQ); // see data sheet. + regWr(rHCTL, bmBUSRST); // issue bus reset + break; + case UHS_USB_HOST_STATE_RESET_NOT_COMPLETE: + MAX_HOST_DEBUG(PSTR("UHS_USB_HOST_STATE_RESET_NOT_COMPLETE\r\n")); + if (!busevent) usb_task_state = UHS_USB_HOST_STATE_WAIT_BUS_READY; + break; + case UHS_USB_HOST_STATE_WAIT_BUS_READY: + MAX_HOST_DEBUG(PSTR("UHS_USB_HOST_STATE_WAIT_BUS_READY\r\n")); + usb_task_state = UHS_USB_HOST_STATE_CONFIGURING; + break; // don't fall through + + case UHS_USB_HOST_STATE_CONFIGURING: + usb_task_state = UHS_USB_HOST_STATE_CHECK; + x = Configuring(0, 1, usb_host_speed); + usb_error = x; + if (usb_task_state == UHS_USB_HOST_STATE_CHECK) { + if (x) { + MAX_HOST_DEBUG(PSTR("Error 0x%2.2x"), x); + if (x == UHS_HOST_ERROR_JERR) { + usb_task_state = UHS_USB_HOST_STATE_IDLE; + } else if (x != UHS_HOST_ERROR_DEVICE_INIT_INCOMPLETE) { + usb_error = x; + usb_task_state = UHS_USB_HOST_STATE_ERROR; + } + } else + usb_task_state = UHS_USB_HOST_STATE_CONFIGURING_DONE; + } + break; + + case UHS_USB_HOST_STATE_CHECK: + // Serial.println((uint32_t)__builtin_return_address(0), HEX); + break; + case UHS_USB_HOST_STATE_CONFIGURING_DONE: + usb_task_state = UHS_USB_HOST_STATE_RUNNING; + break; + + #ifdef USB_HOST_MANUAL_POLL + case UHS_USB_HOST_STATE_RUNNING: + case UHS_USB_HOST_STATE_ERROR: + case UHS_USB_HOST_STATE_IDLE: + case UHS_USB_HOST_STATE_ILLEGAL: + enable_frame_irq(false); + break; + #else + case UHS_USB_HOST_STATE_RUNNING: + Poll_Others(); + for (x = 0; (usb_task_state == UHS_USB_HOST_STATE_RUNNING) && (x < UHS_HOST_MAX_INTERFACE_DRIVERS); x++) { + if (devConfig[x]) { + if (devConfig[x]->bPollEnable) devConfig[x]->Poll(); + } } -#endif -#ifdef USB_HOST_SHIELD_TIMING_PIN - // My counter/timer can't work on an inverted gate signal - // so we gate using a high pulse -- AJK - UHS_PIN_WRITE(USB_HOST_SHIELD_TIMING_PIN, LOW); -#endif - //usb_task_polling_disabled--; - EnablePoll(); - DDSB(); + // fall thru + #endif + default: + // Do nothing + break; + } // switch ( usb_task_state ) + DDSB(); + #if USB_HOST_SHIELD_USE_ISR + if (condet) { + VBUS_changed(); + noInterrupts(); + condet = false; + interrupts(); + } + #endif + #ifdef USB_HOST_SHIELD_TIMING_PIN + // My counter/timer can't work on an inverted gate signal + // so we gate using a high pulse -- AJK + UHS_PIN_WRITE(USB_HOST_SHIELD_TIMING_PIN, LOW); + #endif + //usb_task_polling_disabled--; + EnablePoll(); + DDSB(); } /* USB main task. Services the MAX3421e */ #if !USB_HOST_SHIELD_USE_ISR - -void UHS_NI MAX3421E_HOST::ISRTask() { -} -void UHS_NI MAX3421E_HOST::Task() + void UHS_NI MAX3421E_HOST::ISRTask() {} + void UHS_NI MAX3421E_HOST::Task() #else - -void UHS_NI MAX3421E_HOST::Task() { -#ifdef USB_HOST_MANUAL_POLL - if(usb_task_state == UHS_USB_HOST_STATE_RUNNING) { - noInterrupts(); - for(uint8_t x = 0; x < UHS_HOST_MAX_INTERFACE_DRIVERS; x++) - if(devConfig[x] && devConfig[x]->bPollEnable) - devConfig[x]->Poll(); - interrupts(); - } -#endif -} - -void UHS_NI MAX3421E_HOST::ISRTask() -#endif -{ - DDSB(); - -#ifndef SWI_IRQ_NUM - suspend_host(); -#if USB_HOST_SHIELD_USE_ISR - // Enable interrupts + void UHS_NI MAX3421E_HOST::Task() { + #ifdef USB_HOST_MANUAL_POLL + if (usb_task_state == UHS_USB_HOST_STATE_RUNNING) { + noInterrupts(); + for (uint8_t x = 0; x < UHS_HOST_MAX_INTERFACE_DRIVERS; x++) + if (devConfig[x] && devConfig[x]->bPollEnable) + devConfig[x]->Poll(); interrupts(); -#endif -#endif + } + #endif + } - counted = false; - if(!MARLIN_UHS_READ_IRQ()) { - uint8_t HIRQALL = regRd(rHIRQ); //determine interrupt source - uint8_t HIRQ = HIRQALL & IRQ_CHECK_MASK; - uint8_t HIRQ_sendback = 0x00; - - if((HIRQ & bmCONDETIRQ) || (HIRQ & bmBUSEVENTIRQ)) { - MAX_HOST_DEBUG - (PSTR("\r\nBEFORE CDIRQ %s BEIRQ %s resetting %s state 0x%2.2x\r\n"), - (HIRQ & bmCONDETIRQ) ? "T" : "F", - (HIRQ & bmBUSEVENTIRQ) ? "T" : "F", - doingreset ? "T" : "F", - usb_task_state - ); - } - // ALWAYS happens BEFORE or WITH CONDETIRQ - if(HIRQ & bmBUSEVENTIRQ) { - HIRQ_sendback |= bmBUSEVENTIRQ; - if(!doingreset) condet = true; - busprobe(); - busevent = false; - } - - if(HIRQ & bmCONDETIRQ) { - HIRQ_sendback |= bmCONDETIRQ; - if(!doingreset) condet = true; - busprobe(); - } - -#if 1 - if((HIRQ & bmCONDETIRQ) || (HIRQ & bmBUSEVENTIRQ)) { - MAX_HOST_DEBUG - (PSTR("\r\nAFTER CDIRQ %s BEIRQ %s resetting %s state 0x%2.2x\r\n"), - (HIRQ & bmCONDETIRQ) ? "T" : "F", - (HIRQ & bmBUSEVENTIRQ) ? "T" : "F", - doingreset ? "T" : "F", - usb_task_state - ); - } + void UHS_NI MAX3421E_HOST::ISRTask() #endif - - if(HIRQ & bmFRAMEIRQ) { - HIRQ_sendback |= bmFRAMEIRQ; - if(sof_countdown) { - sof_countdown--; - counted = true; - } - sofevent = false; - } - - //MAX_HOST_DEBUG(PSTR("\r\n%s%s%s\r\n"), - // sof_countdown ? "T" : "F", - // counted ? "T" : "F", - // usb_task_polling_disabled? "T" : "F"); - DDSB(); - regWr(rHIRQ, HIRQ_sendback); -#ifndef SWI_IRQ_NUM - resume_host(); -#if USB_HOST_SHIELD_USE_ISR +{ + DDSB(); + + #ifndef SWI_IRQ_NUM + suspend_host(); + #if USB_HOST_SHIELD_USE_ISR + // Enable interrupts + interrupts(); + #endif + #endif + + counted = false; + if (!MARLIN_UHS_READ_IRQ()) { + uint8_t HIRQALL = regRd(rHIRQ); // determine interrupt source + uint8_t HIRQ = HIRQALL & IRQ_CHECK_MASK; + uint8_t HIRQ_sendback = 0x00; + + if ((HIRQ & bmCONDETIRQ) || (HIRQ & bmBUSEVENTIRQ)) { + MAX_HOST_DEBUG + (PSTR("\r\nBEFORE CDIRQ %s BEIRQ %s resetting %s state 0x%2.2x\r\n"), + (HIRQ & bmCONDETIRQ) ? "T" : "F", + (HIRQ & bmBUSEVENTIRQ) ? "T" : "F", + doingreset ? "T" : "F", + usb_task_state + ); + } + // ALWAYS happens BEFORE or WITH CONDETIRQ + if (HIRQ & bmBUSEVENTIRQ) { + HIRQ_sendback |= bmBUSEVENTIRQ; + if (!doingreset) condet = true; + busprobe(); + busevent = false; + } + + if (HIRQ & bmCONDETIRQ) { + HIRQ_sendback |= bmCONDETIRQ; + if (!doingreset) condet = true; + busprobe(); + } + + #if 1 + if ((HIRQ & bmCONDETIRQ) || (HIRQ & bmBUSEVENTIRQ)) { + MAX_HOST_DEBUG + (PSTR("\r\nAFTER CDIRQ %s BEIRQ %s resetting %s state 0x%2.2x\r\n"), + (HIRQ & bmCONDETIRQ) ? "T" : "F", + (HIRQ & bmBUSEVENTIRQ) ? "T" : "F", + doingreset ? "T" : "F", + usb_task_state + ); + } + #endif + + if (HIRQ & bmFRAMEIRQ) { + HIRQ_sendback |= bmFRAMEIRQ; + if (sof_countdown) { + sof_countdown--; + counted = true; + } + sofevent = false; + } + + //MAX_HOST_DEBUG(PSTR("\r\n%s%s%s\r\n"), + // sof_countdown ? "T" : "F", + // counted ? "T" : "F", + // usb_task_polling_disabled? "T" : "F"); + DDSB(); + regWr(rHIRQ, HIRQ_sendback); + #ifndef SWI_IRQ_NUM + resume_host(); + #if USB_HOST_SHIELD_USE_ISR // Disable interrupts noInterrupts(); -#endif -#endif - if(!sof_countdown && !counted && !usb_task_polling_disabled) { - DisablePoll(); - //usb_task_polling_disabled++; -#ifdef USB_HOST_SHIELD_TIMING_PIN - // My counter/timer can't work on an inverted gate signal - // so we gate using a high pulse -- AJK - UHS_PIN_WRITE(USB_HOST_SHIELD_TIMING_PIN, HIGH); -#endif - -#ifdef SWI_IRQ_NUM - // MAX_HOST_DEBUG(PSTR("--------------- Doing SWI ----------------")); - exec_SWI(this); -#else -#if USB_HOST_SHIELD_USE_ISR - // Enable interrupts - interrupts(); -#endif /* USB_HOST_SHIELD_USE_ISR */ - ISRbottom(); -#endif /* SWI_IRQ_NUM */ - } - } + #endif + #endif + if (!sof_countdown && !counted && !usb_task_polling_disabled) { + DisablePoll(); + //usb_task_polling_disabled++; + #ifdef USB_HOST_SHIELD_TIMING_PIN + // My counter/timer can't work on an inverted gate signal + // so we gate using a high pulse -- AJK + UHS_PIN_WRITE(USB_HOST_SHIELD_TIMING_PIN, HIGH); + #endif + + #ifdef SWI_IRQ_NUM + //MAX_HOST_DEBUG(PSTR("--------------- Doing SWI ----------------")); + exec_SWI(this); + #else + #if USB_HOST_SHIELD_USE_ISR + // Enable interrupts + interrupts(); + #endif + ISRbottom(); + #endif /* SWI_IRQ_NUM */ + } + } } #if 0 -DDSB(); + DDSB(); #endif + #else -#error "Never include USB_HOST_SHIELD_INLINE.h, include UHS_host.h instead" + #error "Never include USB_HOST_SHIELD_INLINE.h, include UHS_host.h instead" #endif From a121c80e1a31cc696f425238ee82a22a1f8fd647 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 1 Nov 2022 17:14:18 -0500 Subject: [PATCH 135/243] =?UTF-8?q?=F0=9F=8E=A8=20Update=20SAMD51=20header?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/SAMD51/HAL.cpp | 9 +++++++-- Marlin/src/HAL/SAMD51/HAL.h | 9 +++++++-- Marlin/src/HAL/SAMD51/HAL_SPI.cpp | 9 +++++++-- Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.cpp | 9 +++++++-- Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.h | 9 +++++++-- Marlin/src/HAL/SAMD51/SAMD51.h | 9 +++++++-- Marlin/src/HAL/SAMD51/Servo.cpp | 9 +++++++-- Marlin/src/HAL/SAMD51/ServoTimers.h | 9 +++++++-- Marlin/src/HAL/SAMD51/eeprom_flash.cpp | 9 +++++++-- Marlin/src/HAL/SAMD51/eeprom_qspi.cpp | 9 +++++++-- Marlin/src/HAL/SAMD51/eeprom_wired.cpp | 9 +++++++-- Marlin/src/HAL/SAMD51/endstop_interrupts.h | 9 +++++++-- Marlin/src/HAL/SAMD51/fastio.h | 9 +++++++-- Marlin/src/HAL/SAMD51/inc/SanityCheck.h | 10 ++++++++-- Marlin/src/HAL/SAMD51/pinsDebug.h | 9 +++++++-- Marlin/src/HAL/SAMD51/spi_pins.h | 9 +++++++-- Marlin/src/HAL/SAMD51/timers.cpp | 9 +++++++-- Marlin/src/HAL/SAMD51/timers.h | 9 +++++++-- 18 files changed, 127 insertions(+), 36 deletions(-) diff --git a/Marlin/src/HAL/SAMD51/HAL.cpp b/Marlin/src/HAL/SAMD51/HAL.cpp index bd1c98bfa1d9..8c102b643da8 100644 --- a/Marlin/src/HAL/SAMD51/HAL.cpp +++ b/Marlin/src/HAL/SAMD51/HAL.cpp @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,6 +19,10 @@ * along with this program. If not, see . * */ + +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ #ifdef __SAMD51__ #include "../../inc/MarlinConfig.h" diff --git a/Marlin/src/HAL/SAMD51/HAL.h b/Marlin/src/HAL/SAMD51/HAL.h index 79ba8021f4fd..fe29d6c7f42d 100644 --- a/Marlin/src/HAL/SAMD51/HAL.h +++ b/Marlin/src/HAL/SAMD51/HAL.h @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,6 +21,10 @@ */ #pragma once +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ + #define CPU_32_BIT #include "../shared/Marduino.h" diff --git a/Marlin/src/HAL/SAMD51/HAL_SPI.cpp b/Marlin/src/HAL/SAMD51/HAL_SPI.cpp index 77f4d5ecd513..58fdfe9499a1 100644 --- a/Marlin/src/HAL/SAMD51/HAL_SPI.cpp +++ b/Marlin/src/HAL/SAMD51/HAL_SPI.cpp @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +20,10 @@ * */ +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ + /** * Hardware and software SPI implementations are included in this file. * diff --git a/Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.cpp b/Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.cpp index a16ea2f75821..baa7a38503de 100644 --- a/Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.cpp +++ b/Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.cpp @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,6 +19,10 @@ * along with this program. If not, see . * */ + +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ #ifdef ADAFRUIT_GRAND_CENTRAL_M4 /** diff --git a/Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.h b/Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.h index ac5a3793983e..1044d9fcd0ef 100644 --- a/Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.h +++ b/Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.h @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,6 +21,10 @@ */ #pragma once +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ + #include "../../core/serial_hook.h" typedef Serial1Class UartT; diff --git a/Marlin/src/HAL/SAMD51/SAMD51.h b/Marlin/src/HAL/SAMD51/SAMD51.h index 783956140d58..8cc19d7155c6 100644 --- a/Marlin/src/HAL/SAMD51/SAMD51.h +++ b/Marlin/src/HAL/SAMD51/SAMD51.h @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,6 +21,10 @@ */ #pragma once +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ + #define SYNC(sc) while (sc) { \ asm(""); \ } diff --git a/Marlin/src/HAL/SAMD51/Servo.cpp b/Marlin/src/HAL/SAMD51/Servo.cpp index 665322fe24bc..e533eee30155 100644 --- a/Marlin/src/HAL/SAMD51/Servo.cpp +++ b/Marlin/src/HAL/SAMD51/Servo.cpp @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,6 +20,10 @@ * */ +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ + /** * This comes from Arduino library which at the moment is buggy and uncompilable */ diff --git a/Marlin/src/HAL/SAMD51/ServoTimers.h b/Marlin/src/HAL/SAMD51/ServoTimers.h index 948d515356fb..47e0a190aac9 100644 --- a/Marlin/src/HAL/SAMD51/ServoTimers.h +++ b/Marlin/src/HAL/SAMD51/ServoTimers.h @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,6 +21,10 @@ */ #pragma once +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ + #define _useTimer1 #define _useTimer2 diff --git a/Marlin/src/HAL/SAMD51/eeprom_flash.cpp b/Marlin/src/HAL/SAMD51/eeprom_flash.cpp index 871bf22b7fc4..7d5518956c7a 100644 --- a/Marlin/src/HAL/SAMD51/eeprom_flash.cpp +++ b/Marlin/src/HAL/SAMD51/eeprom_flash.cpp @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,6 +19,10 @@ * along with this program. If not, see . * */ + +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ #ifdef __SAMD51__ #include "../../inc/MarlinConfig.h" diff --git a/Marlin/src/HAL/SAMD51/eeprom_qspi.cpp b/Marlin/src/HAL/SAMD51/eeprom_qspi.cpp index faa763719707..1c82ede04032 100644 --- a/Marlin/src/HAL/SAMD51/eeprom_qspi.cpp +++ b/Marlin/src/HAL/SAMD51/eeprom_qspi.cpp @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,6 +19,10 @@ * along with this program. If not, see . * */ + +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ #ifdef __SAMD51__ #include "../../inc/MarlinConfig.h" diff --git a/Marlin/src/HAL/SAMD51/eeprom_wired.cpp b/Marlin/src/HAL/SAMD51/eeprom_wired.cpp index 3481fe539c3e..7a03d4eaa34c 100644 --- a/Marlin/src/HAL/SAMD51/eeprom_wired.cpp +++ b/Marlin/src/HAL/SAMD51/eeprom_wired.cpp @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,6 +19,10 @@ * along with this program. If not, see . * */ + +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ #ifdef __SAMD51__ #include "../../inc/MarlinConfig.h" diff --git a/Marlin/src/HAL/SAMD51/endstop_interrupts.h b/Marlin/src/HAL/SAMD51/endstop_interrupts.h index 2f02f404f5f1..e0e811c3a018 100644 --- a/Marlin/src/HAL/SAMD51/endstop_interrupts.h +++ b/Marlin/src/HAL/SAMD51/endstop_interrupts.h @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,6 +21,10 @@ */ #pragma once +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ + /** * Endstop interrupts for ATMEL SAMD51 based targets. * diff --git a/Marlin/src/HAL/SAMD51/fastio.h b/Marlin/src/HAL/SAMD51/fastio.h index 79aede579044..0acf48131796 100644 --- a/Marlin/src/HAL/SAMD51/fastio.h +++ b/Marlin/src/HAL/SAMD51/fastio.h @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,6 +21,10 @@ */ #pragma once +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ + /** * Fast IO functions for SAMD51 */ diff --git a/Marlin/src/HAL/SAMD51/inc/SanityCheck.h b/Marlin/src/HAL/SAMD51/inc/SanityCheck.h index 1b876c947dc7..ae1bc2f3efd5 100644 --- a/Marlin/src/HAL/SAMD51/inc/SanityCheck.h +++ b/Marlin/src/HAL/SAMD51/inc/SanityCheck.h @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,6 +19,11 @@ * along with this program. If not, see . * */ +#pragma once + +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ /** * Test SAMD51 specific configuration values for errors at compile-time. diff --git a/Marlin/src/HAL/SAMD51/pinsDebug.h b/Marlin/src/HAL/SAMD51/pinsDebug.h index 639c4cd66eb9..94f91c77bcce 100644 --- a/Marlin/src/HAL/SAMD51/pinsDebug.h +++ b/Marlin/src/HAL/SAMD51/pinsDebug.h @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,6 +21,10 @@ */ #pragma once +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ + #define NUMBER_PINS_TOTAL PINS_COUNT #define digitalRead_mod(p) extDigitalRead(p) diff --git a/Marlin/src/HAL/SAMD51/spi_pins.h b/Marlin/src/HAL/SAMD51/spi_pins.h index 2a667bcaa1ce..f1e4fd430246 100644 --- a/Marlin/src/HAL/SAMD51/spi_pins.h +++ b/Marlin/src/HAL/SAMD51/spi_pins.h @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,6 +21,10 @@ */ #pragma once +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ + #ifdef ADAFRUIT_GRAND_CENTRAL_M4 /* diff --git a/Marlin/src/HAL/SAMD51/timers.cpp b/Marlin/src/HAL/SAMD51/timers.cpp index 1ad0e360736a..7a211eb36a69 100644 --- a/Marlin/src/HAL/SAMD51/timers.cpp +++ b/Marlin/src/HAL/SAMD51/timers.cpp @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,6 +19,10 @@ * along with this program. If not, see . * */ + +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ #ifdef __SAMD51__ // -------------------------------------------------------------------------- diff --git a/Marlin/src/HAL/SAMD51/timers.h b/Marlin/src/HAL/SAMD51/timers.h index 86e980c56690..86c324189223 100644 --- a/Marlin/src/HAL/SAMD51/timers.h +++ b/Marlin/src/HAL/SAMD51/timers.h @@ -1,8 +1,9 @@ /** * Marlin 3D Printer Firmware - * * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] - * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,6 +21,10 @@ */ #pragma once +/** + * SAMD51 HAL developed by Giuliano Zaro (AKA GMagician) + */ + #include // -------------------------------------------------------------------------- From ac5464c37c4ea0a728ca76934ba61c46e7f1ba68 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 3 Nov 2022 21:29:22 -0500 Subject: [PATCH 136/243] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Mor?= =?UTF-8?q?e=20direct=20encoder=20spin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/buttons.h | 7 ------- Marlin/src/lcd/e3v2/common/encoder.cpp | 24 ++++++++++++------------ Marlin/src/lcd/marlinui.cpp | 8 ++++---- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/Marlin/src/lcd/buttons.h b/Marlin/src/lcd/buttons.h index 67b7aa3944f1..58471239bbfb 100644 --- a/Marlin/src/lcd/buttons.h +++ b/Marlin/src/lcd/buttons.h @@ -38,13 +38,6 @@ #define HAS_SLOW_BUTTONS 1 #endif -#if HAS_ENCODER_WHEEL - #define ENCODER_PHASE_0 0 - #define ENCODER_PHASE_1 2 - #define ENCODER_PHASE_2 3 - #define ENCODER_PHASE_3 1 -#endif - #if EITHER(HAS_DIGITAL_BUTTONS, HAS_DWIN_E3V2) // Wheel spin pins where BA is 00, 10, 11, 01 (1 bit always changes) #define BLEN_A 0 diff --git a/Marlin/src/lcd/e3v2/common/encoder.cpp b/Marlin/src/lcd/e3v2/common/encoder.cpp index f14d63e7b5b3..5081e27690f2 100644 --- a/Marlin/src/lcd/e3v2/common/encoder.cpp +++ b/Marlin/src/lcd/e3v2/common/encoder.cpp @@ -96,21 +96,21 @@ EncoderState Encoder_ReceiveAnalyze() { } if (newbutton != lastEncoderBits) { switch (newbutton) { - case ENCODER_PHASE_0: - if (lastEncoderBits == ENCODER_PHASE_3) temp_diff++; - else if (lastEncoderBits == ENCODER_PHASE_1) temp_diff--; + case 0: + if (lastEncoderBits == 1) temp_diff++; + else if (lastEncoderBits == 2) temp_diff--; break; - case ENCODER_PHASE_1: - if (lastEncoderBits == ENCODER_PHASE_0) temp_diff++; - else if (lastEncoderBits == ENCODER_PHASE_2) temp_diff--; + case 2: + if (lastEncoderBits == 0) temp_diff++; + else if (lastEncoderBits == 3) temp_diff--; break; - case ENCODER_PHASE_2: - if (lastEncoderBits == ENCODER_PHASE_1) temp_diff++; - else if (lastEncoderBits == ENCODER_PHASE_3) temp_diff--; + case 3: + if (lastEncoderBits == 2) temp_diff++; + else if (lastEncoderBits == 1) temp_diff--; break; - case ENCODER_PHASE_3: - if (lastEncoderBits == ENCODER_PHASE_2) temp_diff++; - else if (lastEncoderBits == ENCODER_PHASE_0) temp_diff--; + case 1: + if (lastEncoderBits == 3) temp_diff++; + else if (lastEncoderBits == 0) temp_diff--; break; } lastEncoderBits = newbutton; diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 0dfe60d8e424..5991806b7b72 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -1382,10 +1382,10 @@ void MarlinUI::init() { if (buttons & EN_B) enc |= B10; if (enc != lastEncoderBits) { switch (enc) { - case ENCODER_PHASE_0: ENCODER_SPIN(ENCODER_PHASE_3, ENCODER_PHASE_1); break; - case ENCODER_PHASE_1: ENCODER_SPIN(ENCODER_PHASE_0, ENCODER_PHASE_2); break; - case ENCODER_PHASE_2: ENCODER_SPIN(ENCODER_PHASE_1, ENCODER_PHASE_3); break; - case ENCODER_PHASE_3: ENCODER_SPIN(ENCODER_PHASE_2, ENCODER_PHASE_0); break; + case 0: ENCODER_SPIN(1, 2); break; + case 2: ENCODER_SPIN(0, 3); break; + case 3: ENCODER_SPIN(2, 1); break; + case 1: ENCODER_SPIN(3, 0); break; } #if BOTH(HAS_MARLINUI_MENU, AUTO_BED_LEVELING_UBL) external_encoder(); From 7feeffdf06170244ff0586d09b745eb25a7e542a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 4 Nov 2022 20:00:56 -0500 Subject: [PATCH 137/243] =?UTF-8?q?=F0=9F=A9=B9=20leds.update=20needed=20f?= =?UTF-8?q?or=20reset=5Ftimeout?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to #23590 --- Marlin/src/feature/leds/leds.h | 14 ++++++++------ buildroot/tests/rambo | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Marlin/src/feature/leds/leds.h b/Marlin/src/feature/leds/leds.h index 8649dd014fbf..572fd0dfac4e 100644 --- a/Marlin/src/feature/leds/leds.h +++ b/Marlin/src/feature/leds/leds.h @@ -107,6 +107,13 @@ typedef struct LEDColor { class LEDLights { public: + #if ANY(LED_CONTROL_MENU, PRINTER_EVENT_LEDS, CASE_LIGHT_IS_COLOR_LED) + static LEDColor color; // last non-off color + static bool lights_on; // the last set color was "on" + #else + static constexpr bool lights_on = true; + #endif + LEDLights() {} // ctor static void setup(); // init() @@ -142,15 +149,10 @@ class LEDLights { static LEDColor get_color() { return lights_on ? color : LEDColorOff(); } #endif - #if ANY(LED_CONTROL_MENU, PRINTER_EVENT_LEDS, CASE_LIGHT_IS_COLOR_LED) - static LEDColor color; // last non-off color - static bool lights_on; // the last set color was "on" - #endif - #if ENABLED(LED_CONTROL_MENU) static void toggle(); // swap "off" with color #endif - #if EITHER(LED_CONTROL_MENU, CASE_LIGHT_USE_RGB_LED) + #if EITHER(LED_CONTROL_MENU, CASE_LIGHT_USE_RGB_LED) || LED_POWEROFF_TIMEOUT > 0 static void update() { set_color(color); } #endif diff --git a/buildroot/tests/rambo b/buildroot/tests/rambo index de6cdc71297b..9a017c971fbb 100755 --- a/buildroot/tests/rambo +++ b/buildroot/tests/rambo @@ -32,7 +32,7 @@ opt_enable USE_ZMAX_PLUG REPRAP_DISCOUNT_SMART_CONTROLLER LCD_PROGRESS_BAR LCD_P SKEW_CORRECTION SKEW_CORRECTION_FOR_Z SKEW_CORRECTION_GCODE \ BACKLASH_COMPENSATION BACKLASH_GCODE BAUD_RATE_GCODE BEZIER_CURVE_SUPPORT \ FWRETRACT ARC_P_CIRCLES CNC_WORKSPACE_PLANES CNC_COORDINATE_SYSTEMS \ - PSU_CONTROL PS_OFF_CONFIRM PS_OFF_SOUND POWER_OFF_WAIT_FOR_COOLDOWN \ + PSU_CONTROL LED_POWEROFF_TIMEOUT PS_OFF_CONFIRM PS_OFF_SOUND POWER_OFF_WAIT_FOR_COOLDOWN \ POWER_LOSS_RECOVERY POWER_LOSS_PIN POWER_LOSS_STATE POWER_LOSS_RECOVER_ZHOME POWER_LOSS_ZHOME_POS \ SLOW_PWM_HEATERS THERMAL_PROTECTION_CHAMBER LIN_ADVANCE ADVANCE_K_EXTRA \ HOST_ACTION_COMMANDS HOST_PROMPT_SUPPORT PINS_DEBUGGING MAX7219_DEBUG M114_DETAIL From fc2f3cdf4079596a84f0e8ac88e9f8dfc295f03f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 4 Nov 2022 20:10:59 -0500 Subject: [PATCH 138/243] =?UTF-8?q?=F0=9F=A9=B9=20MAX=20Thermocouple=20fol?= =?UTF-8?q?lowup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to #24898 --- Marlin/src/inc/Conditionals_LCD.h | 7 +++++-- Marlin/src/module/temperature.cpp | 14 ++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index b21eca30b292..c1b43d2fc0c6 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -1020,8 +1020,11 @@ #endif // Helper macros for extruder and hotend arrays -#define EXTRUDER_LOOP() for (int8_t e = 0; e < EXTRUDERS; e++) -#define HOTEND_LOOP() for (int8_t e = 0; e < HOTENDS; e++) +#define _EXTRUDER_LOOP(E) for (int8_t E = 0; E < EXTRUDERS; E++) +#define EXTRUDER_LOOP() _EXTRUDER_LOOP(e) +#define _HOTEND_LOOP(H) for (int8_t H = 0; H < HOTENDS; H++) +#define HOTEND_LOOP() _HOTEND_LOOP(e) + #define ARRAY_BY_EXTRUDERS(V...) ARRAY_N(EXTRUDERS, V) #define ARRAY_BY_EXTRUDERS1(v1) ARRAY_N_1(EXTRUDERS, v1) #define ARRAY_BY_HOTENDS(V...) ARRAY_N(HOTENDS, V) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 8843582f4e67..37996a80eadc 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -2374,7 +2374,7 @@ void Temperature::updateTemperaturesFromRawValues() { TERN_(HAS_POWER_MONITOR, power_monitor.capture_values()); #if HAS_HOTEND - static constexpr int8_t temp_dir[] = { + static constexpr int8_t temp_dir[HOTENDS] = { #if TEMP_SENSOR_IS_ANY_MAX_TC(0) 0 #else @@ -2386,19 +2386,21 @@ void Temperature::updateTemperaturesFromRawValues() { #else , TEMPDIR(1) #endif + #endif + #if HOTENDS > 2 #if TEMP_SENSOR_IS_ANY_MAX_TC(2) , 0 #else , TEMPDIR(2) #endif - #if HOTENDS > 3 - #define _TEMPDIR(N) , TEMPDIR(N) - REPEAT_S(3, HOTENDS, _TEMPDIR) - #endif + #endif + #if HOTENDS > 3 + #define _TEMPDIR(N) , TEMPDIR(N) + REPEAT_S(3, HOTENDS, _TEMPDIR) #endif }; - LOOP_L_N(e, COUNT(temp_dir)) { + HOTEND_LOOP() { const raw_adc_t r = temp_hotend[e].getraw(); const bool neg = temp_dir[e] < 0, pos = temp_dir[e] > 0; if ((neg && r < temp_range[e].raw_max) || (pos && r > temp_range[e].raw_max)) From 7002e72f1c48b5cf01d6e9c90e72d8cab785d107 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 6 Nov 2022 23:49:38 -0600 Subject: [PATCH 139/243] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20EEPROM=20write=20f?= =?UTF-8?q?or=20!LIN=5FADVANCE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #24963 Followup to #24821 --- Marlin/src/module/settings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index f76b5afe74e2..a090b140adee 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -1421,7 +1421,7 @@ void MarlinSettings::postprocess() { EEPROM_WRITE(planner.extruder_advance_K); #else dummyf = 0; - for (uint8_t q = _MAX(EXTRUDERS, 1); q--;) EEPROM_WRITE(dummyf); + for (uint8_t q = DISTINCT_E; q--;) EEPROM_WRITE(dummyf); #endif } From 379d388b0763ab5295a1c887d0c39eb7cd88bb8b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 11 Nov 2022 16:09:26 -0600 Subject: [PATCH 140/243] =?UTF-8?q?=F0=9F=8E=A8=20Prefer=20axis=20element?= =?UTF-8?q?=20over=20index?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/e3v2/creality/dwin.cpp | 8 ++++---- Marlin/src/lcd/e3v2/jyersui/dwin.cpp | 16 ++++++++-------- Marlin/src/lcd/e3v2/proui/dwin.cpp | 16 ++++++++-------- .../generic/move_axis_screen.cpp | 2 +- .../src/lcd/extui/mks_ui/draw_jerk_settings.cpp | 8 ++++---- Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp | 16 ++++++++-------- 6 files changed, 33 insertions(+), 33 deletions(-) diff --git a/Marlin/src/lcd/e3v2/creality/dwin.cpp b/Marlin/src/lcd/e3v2/creality/dwin.cpp index 1232c8e0c91c..08d928684a6f 100644 --- a/Marlin/src/lcd/e3v2/creality/dwin.cpp +++ b/Marlin/src/lcd/e3v2/creality/dwin.cpp @@ -3395,11 +3395,11 @@ void Draw_Max_Accel_Menu() { Draw_Back_First(); LOOP_L_N(i, 3 + ENABLED(HAS_HOTEND)) Draw_Menu_Line(i + 1, ICON_MaxSpeedJerkX + i); - Draw_Edit_Float3(1, planner.max_jerk[X_AXIS] * MINUNITMULT); - Draw_Edit_Float3(2, planner.max_jerk[Y_AXIS] * MINUNITMULT); - Draw_Edit_Float3(3, planner.max_jerk[Z_AXIS] * MINUNITMULT); + Draw_Edit_Float3(1, planner.max_jerk.x * MINUNITMULT); + Draw_Edit_Float3(2, planner.max_jerk.y * MINUNITMULT); + Draw_Edit_Float3(3, planner.max_jerk.z * MINUNITMULT); #if HAS_HOTEND - Draw_Edit_Float3(4, planner.max_jerk[E_AXIS] * MINUNITMULT); + Draw_Edit_Float3(4, planner.max_jerk.e * MINUNITMULT); #endif } #endif diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index 21f93c6b98d4..cba90c7ac581 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -2465,35 +2465,35 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/ case JERK_X: if (draw) { Draw_Menu_Item(row, ICON_MaxSpeedJerkX, F("X Axis")); - Draw_Float(planner.max_jerk[X_AXIS], row, false, 10); + Draw_Float(planner.max_jerk.x, row, false, 10); } else - Modify_Value(planner.max_jerk[X_AXIS], 0, default_max_jerk[X_AXIS] * 2, 10); + Modify_Value(planner.max_jerk.x, 0, default_max_jerk[X_AXIS] * 2, 10); break; case JERK_Y: if (draw) { Draw_Menu_Item(row, ICON_MaxSpeedJerkY, F("Y Axis")); - Draw_Float(planner.max_jerk[Y_AXIS], row, false, 10); + Draw_Float(planner.max_jerk.y, row, false, 10); } else - Modify_Value(planner.max_jerk[Y_AXIS], 0, default_max_jerk[Y_AXIS] * 2, 10); + Modify_Value(planner.max_jerk.y, 0, default_max_jerk[Y_AXIS] * 2, 10); break; case JERK_Z: if (draw) { Draw_Menu_Item(row, ICON_MaxSpeedJerkZ, F("Z Axis")); - Draw_Float(planner.max_jerk[Z_AXIS], row, false, 10); + Draw_Float(planner.max_jerk.z, row, false, 10); } else - Modify_Value(planner.max_jerk[Z_AXIS], 0, default_max_jerk[Z_AXIS] * 2, 10); + Modify_Value(planner.max_jerk.z, 0, default_max_jerk[Z_AXIS] * 2, 10); break; #if HAS_HOTEND case JERK_E: if (draw) { Draw_Menu_Item(row, ICON_MaxSpeedJerkE, F("Extruder")); - Draw_Float(planner.max_jerk[E_AXIS], row, false, 10); + Draw_Float(planner.max_jerk.e, row, false, 10); } else - Modify_Value(planner.max_jerk[E_AXIS], 0, default_max_jerk[E_AXIS] * 2, 10); + Modify_Value(planner.max_jerk.e, 0, default_max_jerk[E_AXIS] * 2, 10); break; #endif } diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp index 06768ed18f95..fcceb2d52d51 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -2654,11 +2654,11 @@ void SetMaxAccelZ() { HMI_value.axis = Z_AXIS, SetIntOnClick(MIN_MAXACCELERATION #if HAS_CLASSIC_JERK void ApplyMaxJerk() { planner.set_max_jerk(HMI_value.axis, MenuData.Value / MINUNITMULT); } - void SetMaxJerkX() { HMI_value.axis = X_AXIS, SetFloatOnClick(MIN_MAXJERK, max_jerk_edit_values[X_AXIS], UNITFDIGITS, planner.max_jerk[X_AXIS], ApplyMaxJerk); } - void SetMaxJerkY() { HMI_value.axis = Y_AXIS, SetFloatOnClick(MIN_MAXJERK, max_jerk_edit_values[Y_AXIS], UNITFDIGITS, planner.max_jerk[Y_AXIS], ApplyMaxJerk); } - void SetMaxJerkZ() { HMI_value.axis = Z_AXIS, SetFloatOnClick(MIN_MAXJERK, max_jerk_edit_values[Z_AXIS], UNITFDIGITS, planner.max_jerk[Z_AXIS], ApplyMaxJerk); } + void SetMaxJerkX() { HMI_value.axis = X_AXIS, SetFloatOnClick(MIN_MAXJERK, max_jerk_edit_values[X_AXIS], UNITFDIGITS, planner.max_jerk.x, ApplyMaxJerk); } + void SetMaxJerkY() { HMI_value.axis = Y_AXIS, SetFloatOnClick(MIN_MAXJERK, max_jerk_edit_values[Y_AXIS], UNITFDIGITS, planner.max_jerk.y, ApplyMaxJerk); } + void SetMaxJerkZ() { HMI_value.axis = Z_AXIS, SetFloatOnClick(MIN_MAXJERK, max_jerk_edit_values[Z_AXIS], UNITFDIGITS, planner.max_jerk.z, ApplyMaxJerk); } #if HAS_HOTEND - void SetMaxJerkE() { HMI_value.axis = E_AXIS; SetFloatOnClick(MIN_MAXJERK, max_jerk_edit_values[E_AXIS], UNITFDIGITS, planner.max_jerk[E_AXIS], ApplyMaxJerk); } + void SetMaxJerkE() { HMI_value.axis = E_AXIS; SetFloatOnClick(MIN_MAXJERK, max_jerk_edit_values[E_AXIS], UNITFDIGITS, planner.max_jerk.e, ApplyMaxJerk); } #endif #endif @@ -3641,11 +3641,11 @@ void Draw_MaxAccel_Menu() { SetMenuTitle({1, 16, 28, 13}, GET_TEXT_F(MSG_JERK)); MenuItemsPrepare(5); BACK_ITEM(Draw_Motion_Menu); - EDIT_ITEM_F(ICON_MaxSpeedJerkX, MSG_VA_JERK, onDrawMaxJerkX, SetMaxJerkX, &planner.max_jerk[X_AXIS]); - EDIT_ITEM_F(ICON_MaxSpeedJerkY, MSG_VB_JERK, onDrawMaxJerkY, SetMaxJerkY, &planner.max_jerk[Y_AXIS]); - EDIT_ITEM_F(ICON_MaxSpeedJerkZ, MSG_VC_JERK, onDrawMaxJerkZ, SetMaxJerkZ, &planner.max_jerk[Z_AXIS]); + EDIT_ITEM_F(ICON_MaxSpeedJerkX, MSG_VA_JERK, onDrawMaxJerkX, SetMaxJerkX, &planner.max_jerk.x); + EDIT_ITEM_F(ICON_MaxSpeedJerkY, MSG_VB_JERK, onDrawMaxJerkY, SetMaxJerkY, &planner.max_jerk.y); + EDIT_ITEM_F(ICON_MaxSpeedJerkZ, MSG_VC_JERK, onDrawMaxJerkZ, SetMaxJerkZ, &planner.max_jerk.z); #if HAS_HOTEND - EDIT_ITEM_F(ICON_MaxSpeedJerkE, MSG_VE_JERK, onDrawMaxJerkE, SetMaxJerkE, &planner.max_jerk[E_AXIS]); + EDIT_ITEM_F(ICON_MaxSpeedJerkE, MSG_VE_JERK, onDrawMaxJerkE, SetMaxJerkE, &planner.max_jerk.e); #endif } CurrentMenu->draw(); diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/move_axis_screen.cpp b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/move_axis_screen.cpp index a3c3b503d89c..e077eb371ac0 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/move_axis_screen.cpp +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/generic/move_axis_screen.cpp @@ -113,7 +113,7 @@ bool BaseMoveAxisScreen::onTouchHeld(uint8_t tag) { void BaseMoveAxisScreen::raiseZtoTop() { constexpr xyze_feedrate_t homing_feedrate = HOMING_FEEDRATE_MM_M; - setAxisPosition_mm(Z_MAX_POS - 5, Z, homing_feedrate[Z_AXIS]); + setAxisPosition_mm(Z_MAX_POS - 5, Z, homing_feedrate.z); } float BaseMoveAxisScreen::getManualFeedrate(uint8_t axis, float increment_mm) { diff --git a/Marlin/src/lcd/extui/mks_ui/draw_jerk_settings.cpp b/Marlin/src/lcd/extui/mks_ui/draw_jerk_settings.cpp index a680976d96e1..a070cae15f4e 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_jerk_settings.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_jerk_settings.cpp @@ -74,16 +74,16 @@ static void event_handler(lv_obj_t *obj, lv_event_t event) { void lv_draw_jerk_settings() { scr = lv_screen_create(JERK_UI, machine_menu.JerkConfTitle); - dtostrf(planner.max_jerk[X_AXIS], 1, 1, public_buf_l); + dtostrf(planner.max_jerk.x, 1, 1, public_buf_l); lv_screen_menu_item_1_edit(scr, machine_menu.X_Jerk, PARA_UI_POS_X, PARA_UI_POS_Y, event_handler, ID_JERK_X, 0, public_buf_l); - dtostrf(planner.max_jerk[Y_AXIS], 1, 1, public_buf_l); + dtostrf(planner.max_jerk.y, 1, 1, public_buf_l); lv_screen_menu_item_1_edit(scr, machine_menu.Y_Jerk, PARA_UI_POS_X, PARA_UI_POS_Y * 2, event_handler, ID_JERK_Y, 1, public_buf_l); - dtostrf(planner.max_jerk[Z_AXIS], 1, 1, public_buf_l); + dtostrf(planner.max_jerk.z, 1, 1, public_buf_l); lv_screen_menu_item_1_edit(scr, machine_menu.Z_Jerk, PARA_UI_POS_X, PARA_UI_POS_Y * 3, event_handler, ID_JERK_Z, 2, public_buf_l); - dtostrf(planner.max_jerk[E_AXIS], 1, 1, public_buf_l); + dtostrf(planner.max_jerk.e, 1, 1, public_buf_l); lv_screen_menu_item_1_edit(scr, machine_menu.E_Jerk, PARA_UI_POS_X, PARA_UI_POS_Y * 4, event_handler, ID_JERK_E, 3, public_buf_l); lv_big_button_create(scr, "F:/bmp_back70x40.bin", common_menu.text_back, PARA_UI_BACK_POS_X, PARA_UI_BACK_POS_Y, event_handler, ID_JERK_RETURN, true); diff --git a/Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp b/Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp index deed03724881..850a409a1857 100644 --- a/Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp +++ b/Marlin/src/lcd/extui/mks_ui/draw_number_key.cpp @@ -119,22 +119,22 @@ static void disp_key_value() { case XJerk: #if HAS_CLASSIC_JERK - dtostrf(planner.max_jerk[X_AXIS], 1, 1, public_buf_m); + dtostrf(planner.max_jerk.x, 1, 1, public_buf_m); #endif break; case YJerk: #if HAS_CLASSIC_JERK - dtostrf(planner.max_jerk[Y_AXIS], 1, 1, public_buf_m); + dtostrf(planner.max_jerk.y, 1, 1, public_buf_m); #endif break; case ZJerk: #if HAS_CLASSIC_JERK - dtostrf(planner.max_jerk[Z_AXIS], 1, 1, public_buf_m); + dtostrf(planner.max_jerk.z, 1, 1, public_buf_m); #endif break; case EJerk: #if HAS_CLASSIC_JERK - dtostrf(planner.max_jerk[E_AXIS], 1, 1, public_buf_m); + dtostrf(planner.max_jerk.e, 1, 1, public_buf_m); #endif break; @@ -307,10 +307,10 @@ static void set_value_confirm() { case ZMaxFeedRate: planner.settings.max_feedrate_mm_s[Z_AXIS] = atof(key_value); break; case E0MaxFeedRate: planner.settings.max_feedrate_mm_s[E_AXIS] = atof(key_value); break; case E1MaxFeedRate: planner.settings.max_feedrate_mm_s[E_AXIS_N(1)] = atof(key_value); break; - case XJerk: TERN_(HAS_CLASSIC_JERK, planner.max_jerk[X_AXIS] = atof(key_value)); break; - case YJerk: TERN_(HAS_CLASSIC_JERK, planner.max_jerk[Y_AXIS] = atof(key_value)); break; - case ZJerk: TERN_(HAS_CLASSIC_JERK, planner.max_jerk[Z_AXIS] = atof(key_value)); break; - case EJerk: TERN_(HAS_CLASSIC_JERK, planner.max_jerk[E_AXIS] = atof(key_value)); break; + case XJerk: TERN_(HAS_CLASSIC_JERK, planner.max_jerk.x = atof(key_value)); break; + case YJerk: TERN_(HAS_CLASSIC_JERK, planner.max_jerk.y = atof(key_value)); break; + case ZJerk: TERN_(HAS_CLASSIC_JERK, planner.max_jerk.z = atof(key_value)); break; + case EJerk: TERN_(HAS_CLASSIC_JERK, planner.max_jerk.e = atof(key_value)); break; case Xstep: planner.settings.axis_steps_per_mm[X_AXIS] = atof(key_value); planner.refresh_positioning(); break; case Ystep: planner.settings.axis_steps_per_mm[Y_AXIS] = atof(key_value); planner.refresh_positioning(); break; case Zstep: planner.settings.axis_steps_per_mm[Z_AXIS] = atof(key_value); planner.refresh_positioning(); break; From c9fa680db94ead330d59be954b032f755dbacce9 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 11 Nov 2022 20:35:07 -0600 Subject: [PATCH 141/243] =?UTF-8?q?=F0=9F=90=9B=20Fix=20Anycubic=20/=20Tri?= =?UTF-8?q?gorilla=20pins,=20etc.=20(#24971)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/powerloss.h | 3 + Marlin/src/gcode/config/M43.cpp | 11 +- Marlin/src/gcode/feature/advance/M900.cpp | 1 + Marlin/src/inc/Conditionals_post.h | 510 ++---------------- .../lcd/extui/anycubic_chiron/chiron_tft.cpp | 11 - Marlin/src/pins/pinsDebug_list.h | 3 + Marlin/src/pins/pins_postprocess.h | 491 +++++++++++++++++ Marlin/src/pins/ramps/pins_RAMPS.h | 12 +- Marlin/src/pins/ramps/pins_TRIGORILLA_14.h | 104 ++-- 9 files changed, 606 insertions(+), 540 deletions(-) diff --git a/Marlin/src/feature/powerloss.h b/Marlin/src/feature/powerloss.h index 33d9dc007c0d..4bf0c06e2d7e 100644 --- a/Marlin/src/feature/powerloss.h +++ b/Marlin/src/feature/powerloss.h @@ -153,6 +153,9 @@ class PrintJobRecovery { static void prepare(); static void setup() { + #if PIN_EXISTS(OUTAGECON) + OUT_WRITE(OUTAGECON_PIN, HIGH); + #endif #if PIN_EXISTS(POWER_LOSS) #if ENABLED(POWER_LOSS_PULLUP) SET_INPUT_PULLUP(POWER_LOSS_PIN); diff --git a/Marlin/src/gcode/config/M43.cpp b/Marlin/src/gcode/config/M43.cpp index cff143d5711a..5807844012b5 100644 --- a/Marlin/src/gcode/config/M43.cpp +++ b/Marlin/src/gcode/config/M43.cpp @@ -313,9 +313,16 @@ void GcodeSuite::M43() { // 'P' Get the range of pins to test or watch uint8_t first_pin = PARSED_PIN_INDEX('P', 0), - last_pin = parser.seenval('P') ? first_pin : (NUMBER_PINS_TOTAL) - 1; + last_pin = parser.seenval('L') ? PARSED_PIN_INDEX('L', 0) : parser.seenval('P') ? first_pin : (NUMBER_PINS_TOTAL) - 1; - if (first_pin > last_pin) return; + NOMORE(first_pin, (NUMBER_PINS_TOTAL) - 1); + NOMORE(last_pin, (NUMBER_PINS_TOTAL) - 1); + + if (first_pin > last_pin) { + const uint8_t f = first_pin; + first_pin = last_pin; + last_pin = f; + } // 'I' to ignore protected pins const bool ignore_protection = parser.boolval('I'); diff --git a/Marlin/src/gcode/feature/advance/M900.cpp b/Marlin/src/gcode/feature/advance/M900.cpp index 50d968627b6f..8c0da41801cc 100644 --- a/Marlin/src/gcode/feature/advance/M900.cpp +++ b/Marlin/src/gcode/feature/advance/M900.cpp @@ -50,6 +50,7 @@ void GcodeSuite::M900() { #if EXTRUDERS < 2 constexpr uint8_t tool_index = 0; + UNUSED(tool_index); #else const uint8_t tool_index = parser.intval('T', active_extruder); if (tool_index >= EXTRUDERS) { diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 9f41390db904..1e0daeb567f6 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -926,56 +926,8 @@ #define X2_MAX_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING #elif X2_USE_ENDSTOP == _ZMAX_ #define X2_MAX_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING - #else - #define X2_MAX_ENDSTOP_INVERTING false #endif #endif - #if !defined(X2_MAX_PIN) && !defined(X2_STOP_PIN) - #if X2_USE_ENDSTOP == _XMIN_ - #define X2_MAX_PIN X_MIN_PIN - #elif X2_USE_ENDSTOP == _XMAX_ - #define X2_MAX_PIN X_MAX_PIN - #elif X2_USE_ENDSTOP == _XSTOP_ - #define X2_MAX_PIN X_STOP_PIN - #elif X2_USE_ENDSTOP == _YMIN_ - #define X2_MAX_PIN Y_MIN_PIN - #elif X2_USE_ENDSTOP == _YMAX_ - #define X2_MAX_PIN Y_MAX_PIN - #elif X2_USE_ENDSTOP == _YSTOP_ - #define X2_MAX_PIN Y_STOP_PIN - #elif X2_USE_ENDSTOP == _ZMIN_ - #define X2_MAX_PIN Z_MIN_PIN - #elif X2_USE_ENDSTOP == _ZMAX_ - #define X2_MAX_PIN Z_MAX_PIN - #elif X2_USE_ENDSTOP == _ZSTOP_ - #define X2_MAX_PIN Z_STOP_PIN - #elif X2_USE_ENDSTOP == _XDIAG_ - #define X2_MAX_PIN X_DIAG_PIN - #elif X2_USE_ENDSTOP == _YDIAG_ - #define X2_MAX_PIN Y_DIAG_PIN - #elif X2_USE_ENDSTOP == _ZDIAG_ - #define X2_MAX_PIN Z_DIAG_PIN - #elif X2_USE_ENDSTOP == _E0DIAG_ - #define X2_MAX_PIN E0_DIAG_PIN - #elif X2_USE_ENDSTOP == _E1DIAG_ - #define X2_MAX_PIN E1_DIAG_PIN - #elif X2_USE_ENDSTOP == _E2DIAG_ - #define X2_MAX_PIN E2_DIAG_PIN - #elif X2_USE_ENDSTOP == _E3DIAG_ - #define X2_MAX_PIN E3_DIAG_PIN - #elif X2_USE_ENDSTOP == _E4DIAG_ - #define X2_MAX_PIN E4_DIAG_PIN - #elif X2_USE_ENDSTOP == _E5DIAG_ - #define X2_MAX_PIN E5_DIAG_PIN - #elif X2_USE_ENDSTOP == _E6DIAG_ - #define X2_MAX_PIN E6_DIAG_PIN - #elif X2_USE_ENDSTOP == _E7DIAG_ - #define X2_MAX_PIN E7_DIAG_PIN - #endif - #endif - #ifndef X2_MIN_ENDSTOP_INVERTING - #define X2_MIN_ENDSTOP_INVERTING false - #endif #else #ifndef X2_MIN_ENDSTOP_INVERTING #if X2_USE_ENDSTOP == _XMIN_ @@ -990,56 +942,14 @@ #define X2_MIN_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING #elif X2_USE_ENDSTOP == _ZMAX_ #define X2_MIN_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING - #else - #define X2_MIN_ENDSTOP_INVERTING false #endif #endif - #if !defined(X2_MIN_PIN) && !defined(X2_STOP_PIN) - #if X2_USE_ENDSTOP == _XMIN_ - #define X2_MIN_PIN X_MIN_PIN - #elif X2_USE_ENDSTOP == _XMAX_ - #define X2_MIN_PIN X_MAX_PIN - #elif X2_USE_ENDSTOP == _XSTOP_ - #define X2_MIN_PIN X_STOP_PIN - #elif X2_USE_ENDSTOP == _YMIN_ - #define X2_MIN_PIN Y_MIN_PIN - #elif X2_USE_ENDSTOP == _YMAX_ - #define X2_MIN_PIN Y_MAX_PIN - #elif X2_USE_ENDSTOP == _YSTOP_ - #define X2_MIN_PIN Y_STOP_PIN - #elif X2_USE_ENDSTOP == _ZMIN_ - #define X2_MIN_PIN Z_MIN_PIN - #elif X2_USE_ENDSTOP == _ZMAX_ - #define X2_MIN_PIN Z_MAX_PIN - #elif X2_USE_ENDSTOP == _ZSTOP_ - #define X2_MIN_PIN Z_STOP_PIN - #elif X2_USE_ENDSTOP == _XDIAG_ - #define X2_MIN_PIN X_DIAG_PIN - #elif X2_USE_ENDSTOP == _YDIAG_ - #define X2_MIN_PIN Y_DIAG_PIN - #elif X2_USE_ENDSTOP == _ZDIAG_ - #define X2_MIN_PIN Z_DIAG_PIN - #elif X2_USE_ENDSTOP == _E0DIAG_ - #define X2_MIN_PIN E0_DIAG_PIN - #elif X2_USE_ENDSTOP == _E1DIAG_ - #define X2_MIN_PIN E1_DIAG_PIN - #elif X2_USE_ENDSTOP == _E2DIAG_ - #define X2_MIN_PIN E2_DIAG_PIN - #elif X2_USE_ENDSTOP == _E3DIAG_ - #define X2_MIN_PIN E3_DIAG_PIN - #elif X2_USE_ENDSTOP == _E4DIAG_ - #define X2_MIN_PIN E4_DIAG_PIN - #elif X2_USE_ENDSTOP == _E5DIAG_ - #define X2_MIN_PIN E5_DIAG_PIN - #elif X2_USE_ENDSTOP == _E6DIAG_ - #define X2_MIN_PIN E6_DIAG_PIN - #elif X2_USE_ENDSTOP == _E7DIAG_ - #define X2_MIN_PIN E7_DIAG_PIN - #endif - #endif - #ifndef X2_MAX_ENDSTOP_INVERTING - #define X2_MAX_ENDSTOP_INVERTING false - #endif + #endif + #ifndef X2_MAX_ENDSTOP_INVERTING + #define X2_MAX_ENDSTOP_INVERTING false + #endif + #ifndef X2_MIN_ENDSTOP_INVERTING + #define X2_MIN_ENDSTOP_INVERTING false #endif #endif @@ -1061,56 +971,8 @@ #define Y2_MAX_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING #elif Y2_USE_ENDSTOP == _ZMAX_ #define Y2_MAX_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING - #else - #define Y2_MAX_ENDSTOP_INVERTING false - #endif - #endif - #if !defined(Y2_MAX_PIN) && !defined(Y2_STOP_PIN) - #if Y2_USE_ENDSTOP == _XMIN_ - #define Y2_MAX_PIN X_MIN_PIN - #elif Y2_USE_ENDSTOP == _XMAX_ - #define Y2_MAX_PIN X_MAX_PIN - #elif Y2_USE_ENDSTOP == _XSTOP_ - #define Y2_MAX_PIN X_STOP_PIN - #elif Y2_USE_ENDSTOP == _YMIN_ - #define Y2_MAX_PIN Y_MIN_PIN - #elif Y2_USE_ENDSTOP == _YMAX_ - #define Y2_MAX_PIN Y_MAX_PIN - #elif Y2_USE_ENDSTOP == _YSTOP_ - #define Y2_MAX_PIN Y_STOP_PIN - #elif Y2_USE_ENDSTOP == _ZMIN_ - #define Y2_MAX_PIN Z_MIN_PIN - #elif Y2_USE_ENDSTOP == _ZMAX_ - #define Y2_MAX_PIN Z_MAX_PIN - #elif Y2_USE_ENDSTOP == _ZSTOP_ - #define Y2_MAX_PIN Z_STOP_PIN - #elif Y2_USE_ENDSTOP == _XDIAG_ - #define Y2_MAX_PIN X_DIAG_PIN - #elif Y2_USE_ENDSTOP == _YDIAG_ - #define Y2_MAX_PIN Y_DIAG_PIN - #elif Y2_USE_ENDSTOP == _ZDIAG_ - #define Y2_MAX_PIN Z_DIAG_PIN - #elif Y2_USE_ENDSTOP == _E0DIAG_ - #define Y2_MAX_PIN E0_DIAG_PIN - #elif Y2_USE_ENDSTOP == _E1DIAG_ - #define Y2_MAX_PIN E1_DIAG_PIN - #elif Y2_USE_ENDSTOP == _E2DIAG_ - #define Y2_MAX_PIN E2_DIAG_PIN - #elif Y2_USE_ENDSTOP == _E3DIAG_ - #define Y2_MAX_PIN E3_DIAG_PIN - #elif Y2_USE_ENDSTOP == _E4DIAG_ - #define Y2_MAX_PIN E4_DIAG_PIN - #elif Y2_USE_ENDSTOP == _E5DIAG_ - #define Y2_MAX_PIN E5_DIAG_PIN - #elif Y2_USE_ENDSTOP == _E6DIAG_ - #define Y2_MAX_PIN E6_DIAG_PIN - #elif Y2_USE_ENDSTOP == _E7DIAG_ - #define Y2_MAX_PIN E7_DIAG_PIN #endif #endif - #ifndef Y2_MIN_ENDSTOP_INVERTING - #define Y2_MIN_ENDSTOP_INVERTING false - #endif #else #ifndef Y2_MIN_ENDSTOP_INVERTING #if Y2_USE_ENDSTOP == _XMIN_ @@ -1125,56 +987,14 @@ #define Y2_MIN_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING #elif Y2_USE_ENDSTOP == _ZMAX_ #define Y2_MIN_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING - #else - #define Y2_MIN_ENDSTOP_INVERTING false - #endif - #endif - #if !defined(Y2_MIN_PIN) && !defined(Y2_STOP_PIN) - #if Y2_USE_ENDSTOP == _XMIN_ - #define Y2_MIN_PIN X_MIN_PIN - #elif Y2_USE_ENDSTOP == _XMAX_ - #define Y2_MIN_PIN X_MAX_PIN - #elif Y2_USE_ENDSTOP == _XSTOP_ - #define Y2_MIN_PIN X_STOP_PIN - #elif Y2_USE_ENDSTOP == _YMIN_ - #define Y2_MIN_PIN Y_MIN_PIN - #elif Y2_USE_ENDSTOP == _YMAX_ - #define Y2_MIN_PIN Y_MAX_PIN - #elif Y2_USE_ENDSTOP == _YSTOP_ - #define Y2_MIN_PIN Y_STOP_PIN - #elif Y2_USE_ENDSTOP == _ZMIN_ - #define Y2_MIN_PIN Z_MIN_PIN - #elif Y2_USE_ENDSTOP == _ZMAX_ - #define Y2_MIN_PIN Z_MAX_PIN - #elif Y2_USE_ENDSTOP == _ZSTOP_ - #define Y2_MIN_PIN Z_STOP_PIN - #elif Y2_USE_ENDSTOP == _XDIAG_ - #define Y2_MIN_PIN X_DIAG_PIN - #elif Y2_USE_ENDSTOP == _YDIAG_ - #define Y2_MIN_PIN Y_DIAG_PIN - #elif Y2_USE_ENDSTOP == _ZDIAG_ - #define Y2_MIN_PIN Z_DIAG_PIN - #elif Y2_USE_ENDSTOP == _E0DIAG_ - #define Y2_MIN_PIN E0_DIAG_PIN - #elif Y2_USE_ENDSTOP == _E1DIAG_ - #define Y2_MIN_PIN E1_DIAG_PIN - #elif Y2_USE_ENDSTOP == _E2DIAG_ - #define Y2_MIN_PIN E2_DIAG_PIN - #elif Y2_USE_ENDSTOP == _E3DIAG_ - #define Y2_MIN_PIN E3_DIAG_PIN - #elif Y2_USE_ENDSTOP == _E4DIAG_ - #define Y2_MIN_PIN E4_DIAG_PIN - #elif Y2_USE_ENDSTOP == _E5DIAG_ - #define Y2_MIN_PIN E5_DIAG_PIN - #elif Y2_USE_ENDSTOP == _E6DIAG_ - #define Y2_MIN_PIN E6_DIAG_PIN - #elif Y2_USE_ENDSTOP == _E7DIAG_ - #define Y2_MIN_PIN E7_DIAG_PIN #endif #endif - #ifndef Y2_MAX_ENDSTOP_INVERTING - #define Y2_MAX_ENDSTOP_INVERTING false - #endif + #endif + #ifndef Y2_MAX_ENDSTOP_INVERTING + #define Y2_MAX_ENDSTOP_INVERTING false + #endif + #ifndef Y2_MIN_ENDSTOP_INVERTING + #define Y2_MIN_ENDSTOP_INVERTING false #endif #endif @@ -1197,56 +1017,8 @@ #define Z2_MAX_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING #elif Z2_USE_ENDSTOP == _ZMAX_ #define Z2_MAX_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING - #else - #define Z2_MAX_ENDSTOP_INVERTING false - #endif - #endif - #if !defined(Z2_MAX_PIN) && !defined(Z2_STOP_PIN) - #if Z2_USE_ENDSTOP == _XMIN_ - #define Z2_MAX_PIN X_MIN_PIN - #elif Z2_USE_ENDSTOP == _XMAX_ - #define Z2_MAX_PIN X_MAX_PIN - #elif Z2_USE_ENDSTOP == _XSTOP_ - #define Z2_MAX_PIN X_STOP_PIN - #elif Z2_USE_ENDSTOP == _YMIN_ - #define Z2_MAX_PIN Y_MIN_PIN - #elif Z2_USE_ENDSTOP == _YMAX_ - #define Z2_MAX_PIN Y_MAX_PIN - #elif Z2_USE_ENDSTOP == _YSTOP_ - #define Z2_MAX_PIN Y_STOP_PIN - #elif Z2_USE_ENDSTOP == _ZMIN_ - #define Z2_MAX_PIN Z_MIN_PIN - #elif Z2_USE_ENDSTOP == _ZMAX_ - #define Z2_MAX_PIN Z_MAX_PIN - #elif Z2_USE_ENDSTOP == _ZSTOP_ - #define Z2_MAX_PIN Z_STOP_PIN - #elif Z2_USE_ENDSTOP == _XDIAG_ - #define Z2_MAX_PIN X_DIAG_PIN - #elif Z2_USE_ENDSTOP == _YDIAG_ - #define Z2_MAX_PIN Y_DIAG_PIN - #elif Z2_USE_ENDSTOP == _ZDIAG_ - #define Z2_MAX_PIN Z_DIAG_PIN - #elif Z2_USE_ENDSTOP == _E0DIAG_ - #define Z2_MAX_PIN E0_DIAG_PIN - #elif Z2_USE_ENDSTOP == _E1DIAG_ - #define Z2_MAX_PIN E1_DIAG_PIN - #elif Z2_USE_ENDSTOP == _E2DIAG_ - #define Z2_MAX_PIN E2_DIAG_PIN - #elif Z2_USE_ENDSTOP == _E3DIAG_ - #define Z2_MAX_PIN E3_DIAG_PIN - #elif Z2_USE_ENDSTOP == _E4DIAG_ - #define Z2_MAX_PIN E4_DIAG_PIN - #elif Z2_USE_ENDSTOP == _E5DIAG_ - #define Z2_MAX_PIN E5_DIAG_PIN - #elif Z2_USE_ENDSTOP == _E6DIAG_ - #define Z2_MAX_PIN E6_DIAG_PIN - #elif Z2_USE_ENDSTOP == _E7DIAG_ - #define Z2_MAX_PIN E7_DIAG_PIN #endif #endif - #ifndef Z2_MIN_ENDSTOP_INVERTING - #define Z2_MIN_ENDSTOP_INVERTING false - #endif #else #ifndef Z2_MIN_ENDSTOP_INVERTING #if Z2_USE_ENDSTOP == _XMIN_ @@ -1261,56 +1033,14 @@ #define Z2_MIN_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING #elif Z2_USE_ENDSTOP == _ZMAX_ #define Z2_MIN_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING - #else - #define Z2_MIN_ENDSTOP_INVERTING false #endif #endif - #ifndef Z2_MIN_PIN - #if Z2_USE_ENDSTOP == _XMIN_ - #define Z2_MIN_PIN X_MIN_PIN - #elif Z2_USE_ENDSTOP == _XMAX_ - #define Z2_MIN_PIN X_MAX_PIN - #elif Z2_USE_ENDSTOP == _XSTOP_ - #define Z2_MIN_PIN X_STOP_PIN - #elif Z2_USE_ENDSTOP == _YMIN_ - #define Z2_MIN_PIN Y_MIN_PIN - #elif Z2_USE_ENDSTOP == _YMAX_ - #define Z2_MIN_PIN Y_MAX_PIN - #elif Z2_USE_ENDSTOP == _YSTOP_ - #define Z2_MIN_PIN Y_STOP_PIN - #elif Z2_USE_ENDSTOP == _ZMIN_ - #define Z2_MIN_PIN Z_MIN_PIN - #elif Z2_USE_ENDSTOP == _ZMAX_ - #define Z2_MIN_PIN Z_MAX_PIN - #elif Z2_USE_ENDSTOP == _ZSTOP_ - #define Z2_MIN_PIN Z_STOP_PIN - #elif Z2_USE_ENDSTOP == _XDIAG_ - #define Z2_MIN_PIN X_DIAG_PIN - #elif Z2_USE_ENDSTOP == _YDIAG_ - #define Z2_MIN_PIN Y_DIAG_PIN - #elif Z2_USE_ENDSTOP == _ZDIAG_ - #define Z2_MIN_PIN Z_DIAG_PIN - #elif Z2_USE_ENDSTOP == _E0DIAG_ - #define Z2_MIN_PIN E0_DIAG_PIN - #elif Z2_USE_ENDSTOP == _E1DIAG_ - #define Z2_MIN_PIN E1_DIAG_PIN - #elif Z2_USE_ENDSTOP == _E2DIAG_ - #define Z2_MIN_PIN E2_DIAG_PIN - #elif Z2_USE_ENDSTOP == _E3DIAG_ - #define Z2_MIN_PIN E3_DIAG_PIN - #elif Z2_USE_ENDSTOP == _E4DIAG_ - #define Z2_MIN_PIN E4_DIAG_PIN - #elif Z2_USE_ENDSTOP == _E5DIAG_ - #define Z2_MIN_PIN E5_DIAG_PIN - #elif Z2_USE_ENDSTOP == _E6DIAG_ - #define Z2_MIN_PIN E6_DIAG_PIN - #elif Z2_USE_ENDSTOP == _E7DIAG_ - #define Z2_MIN_PIN E7_DIAG_PIN - #endif - #endif - #ifndef Z2_MAX_ENDSTOP_INVERTING - #define Z2_MAX_ENDSTOP_INVERTING false - #endif + #endif + #ifndef Z2_MAX_ENDSTOP_INVERTING + #define Z2_MAX_ENDSTOP_INVERTING false + #endif + #ifndef Z2_MIN_ENDSTOP_INVERTING + #define Z2_MIN_ENDSTOP_INVERTING false #endif #if NUM_Z_STEPPERS >= 3 @@ -1328,56 +1058,8 @@ #define Z3_MAX_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING #elif Z3_USE_ENDSTOP == _ZMAX_ #define Z3_MAX_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING - #else - #define Z3_MAX_ENDSTOP_INVERTING false #endif #endif - #ifndef Z3_MAX_PIN - #if Z3_USE_ENDSTOP == _XMIN_ - #define Z3_MAX_PIN X_MIN_PIN - #elif Z3_USE_ENDSTOP == _XMAX_ - #define Z3_MAX_PIN X_MAX_PIN - #elif Z3_USE_ENDSTOP == _XSTOP_ - #define Z3_MAX_PIN X_STOP_PIN - #elif Z3_USE_ENDSTOP == _YMIN_ - #define Z3_MAX_PIN Y_MIN_PIN - #elif Z3_USE_ENDSTOP == _YMAX_ - #define Z3_MAX_PIN Y_MAX_PIN - #elif Z3_USE_ENDSTOP == _YSTOP_ - #define Z3_MAX_PIN Y_STOP_PIN - #elif Z3_USE_ENDSTOP == _ZMIN_ - #define Z3_MAX_PIN Z_MIN_PIN - #elif Z3_USE_ENDSTOP == _ZMAX_ - #define Z3_MAX_PIN Z_MAX_PIN - #elif Z3_USE_ENDSTOP == _ZSTOP_ - #define Z3_MAX_PIN Z_STOP_PIN - #elif Z3_USE_ENDSTOP == _XDIAG_ - #define Z3_MAX_PIN X_DIAG_PIN - #elif Z3_USE_ENDSTOP == _YDIAG_ - #define Z3_MAX_PIN Y_DIAG_PIN - #elif Z3_USE_ENDSTOP == _ZDIAG_ - #define Z3_MAX_PIN Z_DIAG_PIN - #elif Z3_USE_ENDSTOP == _E0DIAG_ - #define Z3_MAX_PIN E0_DIAG_PIN - #elif Z3_USE_ENDSTOP == _E1DIAG_ - #define Z3_MAX_PIN E1_DIAG_PIN - #elif Z3_USE_ENDSTOP == _E2DIAG_ - #define Z3_MAX_PIN E2_DIAG_PIN - #elif Z3_USE_ENDSTOP == _E3DIAG_ - #define Z3_MAX_PIN E3_DIAG_PIN - #elif Z3_USE_ENDSTOP == _E4DIAG_ - #define Z3_MAX_PIN E4_DIAG_PIN - #elif Z3_USE_ENDSTOP == _E5DIAG_ - #define Z3_MAX_PIN E5_DIAG_PIN - #elif Z3_USE_ENDSTOP == _E6DIAG_ - #define Z3_MAX_PIN E6_DIAG_PIN - #elif Z3_USE_ENDSTOP == _E7DIAG_ - #define Z3_MAX_PIN E7_DIAG_PIN - #endif - #endif - #ifndef Z3_MIN_ENDSTOP_INVERTING - #define Z3_MIN_ENDSTOP_INVERTING false - #endif #else #ifndef Z3_MIN_ENDSTOP_INVERTING #if Z3_USE_ENDSTOP == _XMIN_ @@ -1392,56 +1074,14 @@ #define Z3_MIN_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING #elif Z3_USE_ENDSTOP == _ZMAX_ #define Z3_MIN_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING - #else - #define Z3_MIN_ENDSTOP_INVERTING false - #endif - #endif - #ifndef Z3_MIN_PIN - #if Z3_USE_ENDSTOP == _XMIN_ - #define Z3_MIN_PIN X_MIN_PIN - #elif Z3_USE_ENDSTOP == _XMAX_ - #define Z3_MIN_PIN X_MAX_PIN - #elif Z3_USE_ENDSTOP == _XSTOP_ - #define Z3_MIN_PIN X_STOP_PIN - #elif Z3_USE_ENDSTOP == _YMIN_ - #define Z3_MIN_PIN Y_MIN_PIN - #elif Z3_USE_ENDSTOP == _YMAX_ - #define Z3_MIN_PIN Y_MAX_PIN - #elif Z3_USE_ENDSTOP == _YSTOP_ - #define Z3_MIN_PIN Y_STOP_PIN - #elif Z3_USE_ENDSTOP == _ZMIN_ - #define Z3_MIN_PIN Z_MIN_PIN - #elif Z3_USE_ENDSTOP == _ZMAX_ - #define Z3_MIN_PIN Z_MAX_PIN - #elif Z3_USE_ENDSTOP == _ZSTOP_ - #define Z3_MIN_PIN Z_STOP_PIN - #elif Z3_USE_ENDSTOP == _XDIAG_ - #define Z3_MIN_PIN X_DIAG_PIN - #elif Z3_USE_ENDSTOP == _YDIAG_ - #define Z3_MIN_PIN Y_DIAG_PIN - #elif Z3_USE_ENDSTOP == _ZDIAG_ - #define Z3_MIN_PIN Z_DIAG_PIN - #elif Z3_USE_ENDSTOP == _E0DIAG_ - #define Z3_MIN_PIN E0_DIAG_PIN - #elif Z3_USE_ENDSTOP == _E1DIAG_ - #define Z3_MIN_PIN E1_DIAG_PIN - #elif Z3_USE_ENDSTOP == _E2DIAG_ - #define Z3_MIN_PIN E2_DIAG_PIN - #elif Z3_USE_ENDSTOP == _E3DIAG_ - #define Z3_MIN_PIN E3_DIAG_PIN - #elif Z3_USE_ENDSTOP == _E4DIAG_ - #define Z3_MIN_PIN E4_DIAG_PIN - #elif Z3_USE_ENDSTOP == _E5DIAG_ - #define Z3_MIN_PIN E5_DIAG_PIN - #elif Z3_USE_ENDSTOP == _E6DIAG_ - #define Z3_MIN_PIN E6_DIAG_PIN - #elif Z3_USE_ENDSTOP == _E7DIAG_ - #define Z3_MIN_PIN E7_DIAG_PIN #endif #endif - #ifndef Z3_MAX_ENDSTOP_INVERTING - #define Z3_MAX_ENDSTOP_INVERTING false - #endif + #endif + #ifndef Z3_MAX_ENDSTOP_INVERTING + #define Z3_MAX_ENDSTOP_INVERTING false + #endif + #ifndef Z3_MIN_ENDSTOP_INVERTING + #define Z3_MIN_ENDSTOP_INVERTING false #endif #endif @@ -1460,56 +1100,8 @@ #define Z4_MAX_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING #elif Z4_USE_ENDSTOP == _ZMAX_ #define Z4_MAX_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING - #else - #define Z4_MAX_ENDSTOP_INVERTING false - #endif - #endif - #ifndef Z4_MAX_PIN - #if Z4_USE_ENDSTOP == _XMIN_ - #define Z4_MAX_PIN X_MIN_PIN - #elif Z4_USE_ENDSTOP == _XMAX_ - #define Z4_MAX_PIN X_MAX_PIN - #elif Z4_USE_ENDSTOP == _XSTOP_ - #define Z4_MAX_PIN X_STOP_PIN - #elif Z4_USE_ENDSTOP == _YMIN_ - #define Z4_MAX_PIN Y_MIN_PIN - #elif Z4_USE_ENDSTOP == _YMAX_ - #define Z4_MAX_PIN Y_MAX_PIN - #elif Z4_USE_ENDSTOP == _YSTOP_ - #define Z4_MAX_PIN Y_STOP_PIN - #elif Z4_USE_ENDSTOP == _ZMIN_ - #define Z4_MAX_PIN Z_MIN_PIN - #elif Z4_USE_ENDSTOP == _ZMAX_ - #define Z4_MAX_PIN Z_MAX_PIN - #elif Z4_USE_ENDSTOP == _ZSTOP_ - #define Z4_MAX_PIN Z_STOP_PIN - #elif Z4_USE_ENDSTOP == _XDIAG_ - #define Z4_MAX_PIN X_DIAG_PIN - #elif Z4_USE_ENDSTOP == _YDIAG_ - #define Z4_MAX_PIN Y_DIAG_PIN - #elif Z4_USE_ENDSTOP == _ZDIAG_ - #define Z4_MAX_PIN Z_DIAG_PIN - #elif Z4_USE_ENDSTOP == _E0DIAG_ - #define Z4_MAX_PIN E0_DIAG_PIN - #elif Z4_USE_ENDSTOP == _E1DIAG_ - #define Z4_MAX_PIN E1_DIAG_PIN - #elif Z4_USE_ENDSTOP == _E2DIAG_ - #define Z4_MAX_PIN E2_DIAG_PIN - #elif Z4_USE_ENDSTOP == _E3DIAG_ - #define Z4_MAX_PIN E3_DIAG_PIN - #elif Z4_USE_ENDSTOP == _E4DIAG_ - #define Z4_MAX_PIN E4_DIAG_PIN - #elif Z4_USE_ENDSTOP == _E5DIAG_ - #define Z4_MAX_PIN E5_DIAG_PIN - #elif Z4_USE_ENDSTOP == _E6DIAG_ - #define Z4_MAX_PIN E6_DIAG_PIN - #elif Z4_USE_ENDSTOP == _E7DIAG_ - #define Z4_MAX_PIN E7_DIAG_PIN #endif #endif - #ifndef Z4_MIN_ENDSTOP_INVERTING - #define Z4_MIN_ENDSTOP_INVERTING false - #endif #else #ifndef Z4_MIN_ENDSTOP_INVERTING #if Z4_USE_ENDSTOP == _XMIN_ @@ -1524,56 +1116,14 @@ #define Z4_MIN_ENDSTOP_INVERTING Z_MIN_ENDSTOP_INVERTING #elif Z4_USE_ENDSTOP == _ZMAX_ #define Z4_MIN_ENDSTOP_INVERTING Z_MAX_ENDSTOP_INVERTING - #else - #define Z4_MIN_ENDSTOP_INVERTING false - #endif - #endif - #ifndef Z4_MIN_PIN - #if Z4_USE_ENDSTOP == _XMIN_ - #define Z4_MIN_PIN X_MIN_PIN - #elif Z4_USE_ENDSTOP == _XMAX_ - #define Z4_MIN_PIN X_MAX_PIN - #elif Z4_USE_ENDSTOP == _XSTOP_ - #define Z4_MIN_PIN X_STOP_PIN - #elif Z4_USE_ENDSTOP == _YMIN_ - #define Z4_MIN_PIN Y_MIN_PIN - #elif Z4_USE_ENDSTOP == _YMAX_ - #define Z4_MIN_PIN Y_MAX_PIN - #elif Z4_USE_ENDSTOP == _YSTOP_ - #define Z4_MIN_PIN Y_STOP_PIN - #elif Z4_USE_ENDSTOP == _ZMIN_ - #define Z4_MIN_PIN Z_MIN_PIN - #elif Z4_USE_ENDSTOP == _ZMAX_ - #define Z4_MIN_PIN Z_MAX_PIN - #elif Z4_USE_ENDSTOP == _ZSTOP_ - #define Z4_MIN_PIN Z_STOP_PIN - #elif Z4_USE_ENDSTOP == _XDIAG_ - #define Z4_MIN_PIN X_DIAG_PIN - #elif Z4_USE_ENDSTOP == _YDIAG_ - #define Z4_MIN_PIN Y_DIAG_PIN - #elif Z4_USE_ENDSTOP == _ZDIAG_ - #define Z4_MIN_PIN Z_DIAG_PIN - #elif Z4_USE_ENDSTOP == _E0DIAG_ - #define Z4_MIN_PIN E0_DIAG_PIN - #elif Z4_USE_ENDSTOP == _E1DIAG_ - #define Z4_MIN_PIN E1_DIAG_PIN - #elif Z4_USE_ENDSTOP == _E2DIAG_ - #define Z4_MIN_PIN E2_DIAG_PIN - #elif Z4_USE_ENDSTOP == _E3DIAG_ - #define Z4_MIN_PIN E3_DIAG_PIN - #elif Z4_USE_ENDSTOP == _E4DIAG_ - #define Z4_MIN_PIN E4_DIAG_PIN - #elif Z4_USE_ENDSTOP == _E5DIAG_ - #define Z4_MIN_PIN E5_DIAG_PIN - #elif Z4_USE_ENDSTOP == _E6DIAG_ - #define Z4_MIN_PIN E6_DIAG_PIN - #elif Z4_USE_ENDSTOP == _E7DIAG_ - #define Z4_MIN_PIN E7_DIAG_PIN #endif #endif - #ifndef Z4_MAX_ENDSTOP_INVERTING - #define Z4_MAX_ENDSTOP_INVERTING false - #endif + #endif + #ifndef Z4_MAX_ENDSTOP_INVERTING + #define Z4_MAX_ENDSTOP_INVERTING false + #endif + #ifndef Z4_MIN_ENDSTOP_INVERTING + #define Z4_MIN_ENDSTOP_INVERTING false #endif #endif diff --git a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp index 285729cc15d2..4be023df0aaa 100644 --- a/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp +++ b/Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp @@ -72,17 +72,6 @@ void ChironTFT::Startup() { live_Zoffset = 0.0; file_menu = AC_menu_file; - // Setup pins for powerloss detection - // Two IO pins are connected on the Trigorilla Board - // On a power interruption the OUTAGECON_PIN goes low. - - #if ENABLED(POWER_LOSS_RECOVERY) - OUT_WRITE(OUTAGECON_PIN, HIGH); - #endif - - // Filament runout is handled by Marlin settings in Configuration.h - // opt_set FIL_RUNOUT_STATE HIGH // Pin state indicating that filament is NOT present. - // opt_enable FIL_RUNOUT_PULLUP TFTSer.begin(115200); // Wait for the TFT panel to initialize and finish the animation diff --git a/Marlin/src/pins/pinsDebug_list.h b/Marlin/src/pins/pinsDebug_list.h index 077c94a60f8c..39e07c739a23 100644 --- a/Marlin/src/pins/pinsDebug_list.h +++ b/Marlin/src/pins/pinsDebug_list.h @@ -883,6 +883,9 @@ #if PIN_EXISTS(SAFE_POWER) REPORT_NAME_DIGITAL(__LINE__, SAFE_POWER_PIN) #endif +#if PIN_EXISTS(OUTAGECON) + REPORT_NAME_DIGITAL(__LINE__, OUTAGECON_PIN) +#endif #if PIN_EXISTS(POWER_LOSS) REPORT_NAME_DIGITAL(__LINE__, POWER_LOSS_PIN) #endif diff --git a/Marlin/src/pins/pins_postprocess.h b/Marlin/src/pins/pins_postprocess.h index 7656037f3da9..1e5265b5966e 100644 --- a/Marlin/src/pins/pins_postprocess.h +++ b/Marlin/src/pins/pins_postprocess.h @@ -1857,6 +1857,497 @@ #undef Z4_MAX_PIN #endif +/** + * X_DUAL_ENDSTOPS endstop reassignment + */ +#if ENABLED(X_DUAL_ENDSTOPS) + #if X_HOME_TO_MAX + #ifndef X2_MAX_PIN + #if PIN_EXISTS(X2_STOP) + #define X2_MAX_PIN X2_STOP_PIN + #elif X2_USE_ENDSTOP == _XMIN_ + #define X2_MAX_PIN X_MIN_PIN + #elif X2_USE_ENDSTOP == _XMAX_ + #define X2_MAX_PIN X_MAX_PIN + #elif X2_USE_ENDSTOP == _XSTOP_ + #define X2_MAX_PIN X_STOP_PIN + #elif X2_USE_ENDSTOP == _YMIN_ + #define X2_MAX_PIN Y_MIN_PIN + #elif X2_USE_ENDSTOP == _YMAX_ + #define X2_MAX_PIN Y_MAX_PIN + #elif X2_USE_ENDSTOP == _YSTOP_ + #define X2_MAX_PIN Y_STOP_PIN + #elif X2_USE_ENDSTOP == _ZMIN_ + #define X2_MAX_PIN Z_MIN_PIN + #elif X2_USE_ENDSTOP == _ZMAX_ + #define X2_MAX_PIN Z_MAX_PIN + #elif X2_USE_ENDSTOP == _ZSTOP_ + #define X2_MAX_PIN Z_STOP_PIN + #elif X2_USE_ENDSTOP == _XDIAG_ + #define X2_MAX_PIN X_DIAG_PIN + #elif X2_USE_ENDSTOP == _YDIAG_ + #define X2_MAX_PIN Y_DIAG_PIN + #elif X2_USE_ENDSTOP == _ZDIAG_ + #define X2_MAX_PIN Z_DIAG_PIN + #elif X2_USE_ENDSTOP == _E0DIAG_ + #define X2_MAX_PIN E0_DIAG_PIN + #elif X2_USE_ENDSTOP == _E1DIAG_ + #define X2_MAX_PIN E1_DIAG_PIN + #elif X2_USE_ENDSTOP == _E2DIAG_ + #define X2_MAX_PIN E2_DIAG_PIN + #elif X2_USE_ENDSTOP == _E3DIAG_ + #define X2_MAX_PIN E3_DIAG_PIN + #elif X2_USE_ENDSTOP == _E4DIAG_ + #define X2_MAX_PIN E4_DIAG_PIN + #elif X2_USE_ENDSTOP == _E5DIAG_ + #define X2_MAX_PIN E5_DIAG_PIN + #elif X2_USE_ENDSTOP == _E6DIAG_ + #define X2_MAX_PIN E6_DIAG_PIN + #elif X2_USE_ENDSTOP == _E7DIAG_ + #define X2_MAX_PIN E7_DIAG_PIN + #endif + #endif + #else + #ifndef X2_MIN_PIN + #if PIN_EXISTS(X2_STOP) + #define X2_MIN_PIN X2_STOP_PIN + #elif X2_USE_ENDSTOP == _XMIN_ + #define X2_MIN_PIN X_MIN_PIN + #elif X2_USE_ENDSTOP == _XMAX_ + #define X2_MIN_PIN X_MAX_PIN + #elif X2_USE_ENDSTOP == _XSTOP_ + #define X2_MIN_PIN X_STOP_PIN + #elif X2_USE_ENDSTOP == _YMIN_ + #define X2_MIN_PIN Y_MIN_PIN + #elif X2_USE_ENDSTOP == _YMAX_ + #define X2_MIN_PIN Y_MAX_PIN + #elif X2_USE_ENDSTOP == _YSTOP_ + #define X2_MIN_PIN Y_STOP_PIN + #elif X2_USE_ENDSTOP == _ZMIN_ + #define X2_MIN_PIN Z_MIN_PIN + #elif X2_USE_ENDSTOP == _ZMAX_ + #define X2_MIN_PIN Z_MAX_PIN + #elif X2_USE_ENDSTOP == _ZSTOP_ + #define X2_MIN_PIN Z_STOP_PIN + #elif X2_USE_ENDSTOP == _XDIAG_ + #define X2_MIN_PIN X_DIAG_PIN + #elif X2_USE_ENDSTOP == _YDIAG_ + #define X2_MIN_PIN Y_DIAG_PIN + #elif X2_USE_ENDSTOP == _ZDIAG_ + #define X2_MIN_PIN Z_DIAG_PIN + #elif X2_USE_ENDSTOP == _E0DIAG_ + #define X2_MIN_PIN E0_DIAG_PIN + #elif X2_USE_ENDSTOP == _E1DIAG_ + #define X2_MIN_PIN E1_DIAG_PIN + #elif X2_USE_ENDSTOP == _E2DIAG_ + #define X2_MIN_PIN E2_DIAG_PIN + #elif X2_USE_ENDSTOP == _E3DIAG_ + #define X2_MIN_PIN E3_DIAG_PIN + #elif X2_USE_ENDSTOP == _E4DIAG_ + #define X2_MIN_PIN E4_DIAG_PIN + #elif X2_USE_ENDSTOP == _E5DIAG_ + #define X2_MIN_PIN E5_DIAG_PIN + #elif X2_USE_ENDSTOP == _E6DIAG_ + #define X2_MIN_PIN E6_DIAG_PIN + #elif X2_USE_ENDSTOP == _E7DIAG_ + #define X2_MIN_PIN E7_DIAG_PIN + #endif + #endif + #endif +#endif + +/** + * Y_DUAL_ENDSTOPS endstop reassignment + */ +#if ENABLED(Y_DUAL_ENDSTOPS) + #if Y_HOME_TO_MAX + #ifndef Y2_MAX_PIN + #if PIN_EXISTS(Y2_STOP) + #define Y2_MAX_PIN Y2_STOP_PIN + #elif Y2_USE_ENDSTOP == _XMIN_ + #define Y2_MAX_PIN X_MIN_PIN + #elif Y2_USE_ENDSTOP == _XMAX_ + #define Y2_MAX_PIN X_MAX_PIN + #elif Y2_USE_ENDSTOP == _XSTOP_ + #define Y2_MAX_PIN X_STOP_PIN + #elif Y2_USE_ENDSTOP == _YMIN_ + #define Y2_MAX_PIN Y_MIN_PIN + #elif Y2_USE_ENDSTOP == _YMAX_ + #define Y2_MAX_PIN Y_MAX_PIN + #elif Y2_USE_ENDSTOP == _YSTOP_ + #define Y2_MAX_PIN Y_STOP_PIN + #elif Y2_USE_ENDSTOP == _ZMIN_ + #define Y2_MAX_PIN Z_MIN_PIN + #elif Y2_USE_ENDSTOP == _ZMAX_ + #define Y2_MAX_PIN Z_MAX_PIN + #elif Y2_USE_ENDSTOP == _ZSTOP_ + #define Y2_MAX_PIN Z_STOP_PIN + #elif Y2_USE_ENDSTOP == _XDIAG_ + #define Y2_MAX_PIN X_DIAG_PIN + #elif Y2_USE_ENDSTOP == _YDIAG_ + #define Y2_MAX_PIN Y_DIAG_PIN + #elif Y2_USE_ENDSTOP == _ZDIAG_ + #define Y2_MAX_PIN Z_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E0DIAG_ + #define Y2_MAX_PIN E0_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E1DIAG_ + #define Y2_MAX_PIN E1_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E2DIAG_ + #define Y2_MAX_PIN E2_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E3DIAG_ + #define Y2_MAX_PIN E3_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E4DIAG_ + #define Y2_MAX_PIN E4_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E5DIAG_ + #define Y2_MAX_PIN E5_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E6DIAG_ + #define Y2_MAX_PIN E6_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E7DIAG_ + #define Y2_MAX_PIN E7_DIAG_PIN + #endif + #endif + #else + #ifndef Y2_MIN_PIN + #if PIN_EXISTS(Y2_STOP) + #define Y2_MIN_PIN Y2_STOP_PIN + #elif Y2_USE_ENDSTOP == _XMIN_ + #define Y2_MIN_PIN X_MIN_PIN + #elif Y2_USE_ENDSTOP == _XMAX_ + #define Y2_MIN_PIN X_MAX_PIN + #elif Y2_USE_ENDSTOP == _XSTOP_ + #define Y2_MIN_PIN X_STOP_PIN + #elif Y2_USE_ENDSTOP == _YMIN_ + #define Y2_MIN_PIN Y_MIN_PIN + #elif Y2_USE_ENDSTOP == _YMAX_ + #define Y2_MIN_PIN Y_MAX_PIN + #elif Y2_USE_ENDSTOP == _YSTOP_ + #define Y2_MIN_PIN Y_STOP_PIN + #elif Y2_USE_ENDSTOP == _ZMIN_ + #define Y2_MIN_PIN Z_MIN_PIN + #elif Y2_USE_ENDSTOP == _ZMAX_ + #define Y2_MIN_PIN Z_MAX_PIN + #elif Y2_USE_ENDSTOP == _ZSTOP_ + #define Y2_MIN_PIN Z_STOP_PIN + #elif Y2_USE_ENDSTOP == _XDIAG_ + #define Y2_MIN_PIN X_DIAG_PIN + #elif Y2_USE_ENDSTOP == _YDIAG_ + #define Y2_MIN_PIN Y_DIAG_PIN + #elif Y2_USE_ENDSTOP == _ZDIAG_ + #define Y2_MIN_PIN Z_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E0DIAG_ + #define Y2_MIN_PIN E0_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E1DIAG_ + #define Y2_MIN_PIN E1_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E2DIAG_ + #define Y2_MIN_PIN E2_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E3DIAG_ + #define Y2_MIN_PIN E3_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E4DIAG_ + #define Y2_MIN_PIN E4_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E5DIAG_ + #define Y2_MIN_PIN E5_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E6DIAG_ + #define Y2_MIN_PIN E6_DIAG_PIN + #elif Y2_USE_ENDSTOP == _E7DIAG_ + #define Y2_MIN_PIN E7_DIAG_PIN + #endif + #endif + #endif +#endif + +/** + * Z_MULTI_ENDSTOPS endstop reassignment + */ +#if ENABLED(Z_MULTI_ENDSTOPS) + + #if Z_HOME_TO_MAX + #ifndef Z2_MAX_PIN + #if PIN_EXISTS(Z2_STOP) + #define Z2_MAX_PIN Z2_STOP_PIN + #elif Z2_USE_ENDSTOP == _XMIN_ + #define Z2_MAX_PIN X_MIN_PIN + #elif Z2_USE_ENDSTOP == _XMAX_ + #define Z2_MAX_PIN X_MAX_PIN + #elif Z2_USE_ENDSTOP == _XSTOP_ + #define Z2_MAX_PIN X_STOP_PIN + #elif Z2_USE_ENDSTOP == _YMIN_ + #define Z2_MAX_PIN Y_MIN_PIN + #elif Z2_USE_ENDSTOP == _YMAX_ + #define Z2_MAX_PIN Y_MAX_PIN + #elif Z2_USE_ENDSTOP == _YSTOP_ + #define Z2_MAX_PIN Y_STOP_PIN + #elif Z2_USE_ENDSTOP == _ZMIN_ + #define Z2_MAX_PIN Z_MIN_PIN + #elif Z2_USE_ENDSTOP == _ZMAX_ + #define Z2_MAX_PIN Z_MAX_PIN + #elif Z2_USE_ENDSTOP == _ZSTOP_ + #define Z2_MAX_PIN Z_STOP_PIN + #elif Z2_USE_ENDSTOP == _XDIAG_ + #define Z2_MAX_PIN X_DIAG_PIN + #elif Z2_USE_ENDSTOP == _YDIAG_ + #define Z2_MAX_PIN Y_DIAG_PIN + #elif Z2_USE_ENDSTOP == _ZDIAG_ + #define Z2_MAX_PIN Z_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E0DIAG_ + #define Z2_MAX_PIN E0_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E1DIAG_ + #define Z2_MAX_PIN E1_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E2DIAG_ + #define Z2_MAX_PIN E2_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E3DIAG_ + #define Z2_MAX_PIN E3_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E4DIAG_ + #define Z2_MAX_PIN E4_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E5DIAG_ + #define Z2_MAX_PIN E5_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E6DIAG_ + #define Z2_MAX_PIN E6_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E7DIAG_ + #define Z2_MAX_PIN E7_DIAG_PIN + #endif + #endif + #else + #ifndef Z2_MIN_PIN + #if PIN_EXISTS(Z2_STOP) + #define Z2_MIN_PIN Z2_STOP_PIN + #elif Z2_USE_ENDSTOP == _XMIN_ + #define Z2_MIN_PIN X_MIN_PIN + #elif Z2_USE_ENDSTOP == _XMAX_ + #define Z2_MIN_PIN X_MAX_PIN + #elif Z2_USE_ENDSTOP == _XSTOP_ + #define Z2_MIN_PIN X_STOP_PIN + #elif Z2_USE_ENDSTOP == _YMIN_ + #define Z2_MIN_PIN Y_MIN_PIN + #elif Z2_USE_ENDSTOP == _YMAX_ + #define Z2_MIN_PIN Y_MAX_PIN + #elif Z2_USE_ENDSTOP == _YSTOP_ + #define Z2_MIN_PIN Y_STOP_PIN + #elif Z2_USE_ENDSTOP == _ZMIN_ + #define Z2_MIN_PIN Z_MIN_PIN + #elif Z2_USE_ENDSTOP == _ZMAX_ + #define Z2_MIN_PIN Z_MAX_PIN + #elif Z2_USE_ENDSTOP == _ZSTOP_ + #define Z2_MIN_PIN Z_STOP_PIN + #elif Z2_USE_ENDSTOP == _XDIAG_ + #define Z2_MIN_PIN X_DIAG_PIN + #elif Z2_USE_ENDSTOP == _YDIAG_ + #define Z2_MIN_PIN Y_DIAG_PIN + #elif Z2_USE_ENDSTOP == _ZDIAG_ + #define Z2_MIN_PIN Z_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E0DIAG_ + #define Z2_MIN_PIN E0_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E1DIAG_ + #define Z2_MIN_PIN E1_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E2DIAG_ + #define Z2_MIN_PIN E2_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E3DIAG_ + #define Z2_MIN_PIN E3_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E4DIAG_ + #define Z2_MIN_PIN E4_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E5DIAG_ + #define Z2_MIN_PIN E5_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E6DIAG_ + #define Z2_MIN_PIN E6_DIAG_PIN + #elif Z2_USE_ENDSTOP == _E7DIAG_ + #define Z2_MIN_PIN E7_DIAG_PIN + #endif + #endif + #endif + + #if NUM_Z_STEPPERS >= 3 + #if Z_HOME_TO_MAX + #ifndef Z3_MAX_PIN + #if PIN_EXISTS(Z3_STOP) + #define Z3_MAX_PIN Z3_STOP_PIN + #elif Z3_USE_ENDSTOP == _XMIN_ + #define Z3_MAX_PIN X_MIN_PIN + #elif Z3_USE_ENDSTOP == _XMAX_ + #define Z3_MAX_PIN X_MAX_PIN + #elif Z3_USE_ENDSTOP == _XSTOP_ + #define Z3_MAX_PIN X_STOP_PIN + #elif Z3_USE_ENDSTOP == _YMIN_ + #define Z3_MAX_PIN Y_MIN_PIN + #elif Z3_USE_ENDSTOP == _YMAX_ + #define Z3_MAX_PIN Y_MAX_PIN + #elif Z3_USE_ENDSTOP == _YSTOP_ + #define Z3_MAX_PIN Y_STOP_PIN + #elif Z3_USE_ENDSTOP == _ZMIN_ + #define Z3_MAX_PIN Z_MIN_PIN + #elif Z3_USE_ENDSTOP == _ZMAX_ + #define Z3_MAX_PIN Z_MAX_PIN + #elif Z3_USE_ENDSTOP == _ZSTOP_ + #define Z3_MAX_PIN Z_STOP_PIN + #elif Z3_USE_ENDSTOP == _XDIAG_ + #define Z3_MAX_PIN X_DIAG_PIN + #elif Z3_USE_ENDSTOP == _YDIAG_ + #define Z3_MAX_PIN Y_DIAG_PIN + #elif Z3_USE_ENDSTOP == _ZDIAG_ + #define Z3_MAX_PIN Z_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E0DIAG_ + #define Z3_MAX_PIN E0_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E1DIAG_ + #define Z3_MAX_PIN E1_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E2DIAG_ + #define Z3_MAX_PIN E2_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E3DIAG_ + #define Z3_MAX_PIN E3_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E4DIAG_ + #define Z3_MAX_PIN E4_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E5DIAG_ + #define Z3_MAX_PIN E5_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E6DIAG_ + #define Z3_MAX_PIN E6_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E7DIAG_ + #define Z3_MAX_PIN E7_DIAG_PIN + #endif + #endif + #else + #ifndef Z3_MIN_PIN + #if PIN_EXISTS(Z3_STOP) + #define Z3_MIN_PIN Z3_STOP_PIN + #elif Z3_USE_ENDSTOP == _XMIN_ + #define Z3_MIN_PIN X_MIN_PIN + #elif Z3_USE_ENDSTOP == _XMAX_ + #define Z3_MIN_PIN X_MAX_PIN + #elif Z3_USE_ENDSTOP == _XSTOP_ + #define Z3_MIN_PIN X_STOP_PIN + #elif Z3_USE_ENDSTOP == _YMIN_ + #define Z3_MIN_PIN Y_MIN_PIN + #elif Z3_USE_ENDSTOP == _YMAX_ + #define Z3_MIN_PIN Y_MAX_PIN + #elif Z3_USE_ENDSTOP == _YSTOP_ + #define Z3_MIN_PIN Y_STOP_PIN + #elif Z3_USE_ENDSTOP == _ZMIN_ + #define Z3_MIN_PIN Z_MIN_PIN + #elif Z3_USE_ENDSTOP == _ZMAX_ + #define Z3_MIN_PIN Z_MAX_PIN + #elif Z3_USE_ENDSTOP == _ZSTOP_ + #define Z3_MIN_PIN Z_STOP_PIN + #elif Z3_USE_ENDSTOP == _XDIAG_ + #define Z3_MIN_PIN X_DIAG_PIN + #elif Z3_USE_ENDSTOP == _YDIAG_ + #define Z3_MIN_PIN Y_DIAG_PIN + #elif Z3_USE_ENDSTOP == _ZDIAG_ + #define Z3_MIN_PIN Z_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E0DIAG_ + #define Z3_MIN_PIN E0_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E1DIAG_ + #define Z3_MIN_PIN E1_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E2DIAG_ + #define Z3_MIN_PIN E2_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E3DIAG_ + #define Z3_MIN_PIN E3_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E4DIAG_ + #define Z3_MIN_PIN E4_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E5DIAG_ + #define Z3_MIN_PIN E5_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E6DIAG_ + #define Z3_MIN_PIN E6_DIAG_PIN + #elif Z3_USE_ENDSTOP == _E7DIAG_ + #define Z3_MIN_PIN E7_DIAG_PIN + #endif + #endif + #endif + #endif + + #if NUM_Z_STEPPERS >= 4 + #if Z_HOME_TO_MAX + #ifndef Z4_MAX_PIN + #if PIN_EXISTS(Z4_STOP) + #define Z4_MAX_PIN Z4_STOP_PIN + #elif Z4_USE_ENDSTOP == _XMIN_ + #define Z4_MAX_PIN X_MIN_PIN + #elif Z4_USE_ENDSTOP == _XMAX_ + #define Z4_MAX_PIN X_MAX_PIN + #elif Z4_USE_ENDSTOP == _XSTOP_ + #define Z4_MAX_PIN X_STOP_PIN + #elif Z4_USE_ENDSTOP == _YMIN_ + #define Z4_MAX_PIN Y_MIN_PIN + #elif Z4_USE_ENDSTOP == _YMAX_ + #define Z4_MAX_PIN Y_MAX_PIN + #elif Z4_USE_ENDSTOP == _YSTOP_ + #define Z4_MAX_PIN Y_STOP_PIN + #elif Z4_USE_ENDSTOP == _ZMIN_ + #define Z4_MAX_PIN Z_MIN_PIN + #elif Z4_USE_ENDSTOP == _ZMAX_ + #define Z4_MAX_PIN Z_MAX_PIN + #elif Z4_USE_ENDSTOP == _ZSTOP_ + #define Z4_MAX_PIN Z_STOP_PIN + #elif Z4_USE_ENDSTOP == _XDIAG_ + #define Z4_MAX_PIN X_DIAG_PIN + #elif Z4_USE_ENDSTOP == _YDIAG_ + #define Z4_MAX_PIN Y_DIAG_PIN + #elif Z4_USE_ENDSTOP == _ZDIAG_ + #define Z4_MAX_PIN Z_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E0DIAG_ + #define Z4_MAX_PIN E0_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E1DIAG_ + #define Z4_MAX_PIN E1_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E2DIAG_ + #define Z4_MAX_PIN E2_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E3DIAG_ + #define Z4_MAX_PIN E3_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E4DIAG_ + #define Z4_MAX_PIN E4_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E5DIAG_ + #define Z4_MAX_PIN E5_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E6DIAG_ + #define Z4_MAX_PIN E6_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E7DIAG_ + #define Z4_MAX_PIN E7_DIAG_PIN + #endif + #endif + #else + #ifndef Z4_MIN_PIN + #if PIN_EXISTS(Z4_STOP) + #define Z4_MIN_PIN Z4_STOP_PIN + #elif Z4_USE_ENDSTOP == _XMIN_ + #define Z4_MIN_PIN X_MIN_PIN + #elif Z4_USE_ENDSTOP == _XMAX_ + #define Z4_MIN_PIN X_MAX_PIN + #elif Z4_USE_ENDSTOP == _XSTOP_ + #define Z4_MIN_PIN X_STOP_PIN + #elif Z4_USE_ENDSTOP == _YMIN_ + #define Z4_MIN_PIN Y_MIN_PIN + #elif Z4_USE_ENDSTOP == _YMAX_ + #define Z4_MIN_PIN Y_MAX_PIN + #elif Z4_USE_ENDSTOP == _YSTOP_ + #define Z4_MIN_PIN Y_STOP_PIN + #elif Z4_USE_ENDSTOP == _ZMIN_ + #define Z4_MIN_PIN Z_MIN_PIN + #elif Z4_USE_ENDSTOP == _ZMAX_ + #define Z4_MIN_PIN Z_MAX_PIN + #elif Z4_USE_ENDSTOP == _ZSTOP_ + #define Z4_MIN_PIN Z_STOP_PIN + #elif Z4_USE_ENDSTOP == _XDIAG_ + #define Z4_MIN_PIN X_DIAG_PIN + #elif Z4_USE_ENDSTOP == _YDIAG_ + #define Z4_MIN_PIN Y_DIAG_PIN + #elif Z4_USE_ENDSTOP == _ZDIAG_ + #define Z4_MIN_PIN Z_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E0DIAG_ + #define Z4_MIN_PIN E0_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E1DIAG_ + #define Z4_MIN_PIN E1_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E2DIAG_ + #define Z4_MIN_PIN E2_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E3DIAG_ + #define Z4_MIN_PIN E3_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E4DIAG_ + #define Z4_MIN_PIN E4_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E5DIAG_ + #define Z4_MIN_PIN E5_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E6DIAG_ + #define Z4_MIN_PIN E6_DIAG_PIN + #elif Z4_USE_ENDSTOP == _E7DIAG_ + #define Z4_MIN_PIN E7_DIAG_PIN + #endif + #endif + #endif + #endif + +#endif // Z_MULTI_ENDSTOPS + // // Default DOGLCD SPI delays // diff --git a/Marlin/src/pins/ramps/pins_RAMPS.h b/Marlin/src/pins/ramps/pins_RAMPS.h index a0edb01a2a36..7b0ae64cfcf0 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS.h +++ b/Marlin/src/pins/ramps/pins_RAMPS.h @@ -233,16 +233,22 @@ #define HEATER_0_PIN MOSFET_A_PIN #if FET_ORDER_EFB // Hotend, Fan, Bed - #define HEATER_BED_PIN MOSFET_C_PIN + #ifndef HEATER_BED_PIN + #define HEATER_BED_PIN MOSFET_C_PIN + #endif #elif FET_ORDER_EEF // Hotend, Hotend, Fan #define HEATER_1_PIN MOSFET_B_PIN #elif FET_ORDER_EEB // Hotend, Hotend, Bed #define HEATER_1_PIN MOSFET_B_PIN - #define HEATER_BED_PIN MOSFET_C_PIN + #ifndef HEATER_BED_PIN + #define HEATER_BED_PIN MOSFET_C_PIN + #endif #elif FET_ORDER_EFF // Hotend, Fan, Fan #define FAN1_PIN MOSFET_C_PIN #elif DISABLED(FET_ORDER_SF) // Not Spindle, Fan (i.e., "EFBF" or "EFBE") - #define HEATER_BED_PIN MOSFET_C_PIN + #ifndef HEATER_BED_PIN + #define HEATER_BED_PIN MOSFET_C_PIN + #endif #if EITHER(HAS_MULTI_HOTEND, HEATERS_PARALLEL) #define HEATER_1_PIN MOSFET_D_PIN #else diff --git a/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h b/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h index b685ff0094d0..1156804b7c0e 100644 --- a/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h +++ b/Marlin/src/pins/ramps/pins_TRIGORILLA_14.h @@ -40,78 +40,94 @@ // // PWM FETS // -#if EITHER(FET_ORDER_EEF, FET_ORDER_EEB) - #define MOSFET_B_PIN 45 // HEATER1 -#elif FET_ORDER_EFB - #define MOSFET_B_PIN 9 // FAN0 -#else - #define MOSFET_B_PIN 7 // FAN1 -#endif - -#if FET_ORDER_EEB - #define MOSFET_C_PIN 8 // BED -#elif FET_ORDER_EFB - #if DISABLED(ANYCUBIC_LCD_CHIRON) - #define MOSFET_C_PIN 8 - #else - #define MOSFET_C_PIN 45 - #endif -#else // EEF, EFF - #define MOSFET_C_PIN 9 -#endif - -#if FET_ORDER_EEB - #define FAN_PIN 9 // Override pin 4 in pins_RAMPS.h -#endif +#define MOSFET_B_PIN 45 // HEATER1 // // Heaters / Fans // -#if ANY(FET_ORDER_EEF, FET_ORDER_EEB, FET_ORDER_EFB) - #define FAN1_PIN 7 -#endif -#define FAN2_PIN 44 +#define FAN_PIN 9 // FAN0 +#define FAN1_PIN 7 // FAN1 +#define FAN2_PIN 44 // FAN2 #ifndef E0_AUTO_FAN_PIN - #define E0_AUTO_FAN_PIN 44 // Used in Anycubic Kossel example config -#endif -#if ENABLED(ANYCUBIC_LCD_I3MEGA) - #define CONTROLLER_FAN_PIN 7 + #define E0_AUTO_FAN_PIN FAN2_PIN #endif // -// AnyCubic standard pin mappings +// AnyCubic pin mappings +// +// Define the appropriate mapping option in Configuration.h: +// - TRIGORILLA_MAPPING_CHIRON +// - TRIGORILLA_MAPPING_I3MEGA // -// On most printers, endstops are NOT all wired to the appropriate pins on the Trigorilla board. -// For instance, on a Chiron, Y axis goes to an aux connector. -// There are also other things that have been wired in creative ways. -// To enable PIN definitions for a specific printer model, #define the appropriate symbol after -// MOTHERBOARD in Configuration.h // // Limit Switches // //#define ANYCUBIC_4_MAX_PRO_ENDSTOPS - #if ENABLED(ANYCUBIC_4_MAX_PRO_ENDSTOPS) #define X_MAX_PIN 43 #define Y_STOP_PIN 19 -#elif EITHER(ANYCUBIC_LCD_CHIRON, ANYCUBIC_LCD_I3MEGA) - #define Y_STOP_PIN 42 - #define Z2_MIN_PIN 43 +#elif EITHER(TRIGORILLA_MAPPING_CHIRON, TRIGORILLA_MAPPING_I3MEGA) + // Chiron uses AUX header for Y and Z endstops + #define Y_STOP_PIN 42 // AUX + #define Z_STOP_PIN 43 // AUX + #define Z2_MIN_PIN 18 // Z- + #ifndef Z_MIN_PROBE_PIN #define Z_MIN_PROBE_PIN 2 #endif - #ifndef FIL_RUNOUT_PIN - #if ENABLED(ANYCUBIC_LCD_CHIRON) + + #define CONTROLLER_FAN_PIN FAN1_PIN + + #if ENABLED(POWER_LOSS_RECOVERY) + #define OUTAGETEST_PIN 79 + #define OUTAGECON_PIN 58 + #endif + + #if ENABLED(TRIGORILLA_MAPPING_CHIRON) + #ifndef FIL_RUNOUT_PIN #define FIL_RUNOUT_PIN 33 - #else + #endif + + // Chiron swaps the Z stepper connections + #define Z_STEP_PIN 36 + #define Z_DIR_PIN 34 + #define Z_ENABLE_PIN 30 + #define Z_CS_PIN 44 + + #define Z2_STEP_PIN 46 + #define Z2_DIR_PIN 48 + #define Z2_ENABLE_PIN 62 + #define Z2_CS_PIN 40 + + #define HEATER_BED_PIN MOSFET_B_PIN // HEATER1 + #else + #ifndef FIL_RUNOUT_PIN #define FIL_RUNOUT_PIN 19 #endif #endif +#endif + +#if EITHER(ANYCUBIC_LCD_CHIRON, ANYCUBIC_LCD_I3MEGA) #define BEEPER_PIN 31 #define SD_DETECT_PIN 49 #endif +#if HAS_TMC_UART + #ifndef X_SERIAL_TX_PIN + #define X_SERIAL_TX_PIN SERVO1_PIN + #endif + #ifndef Y_SERIAL_TX_PIN + #define Y_SERIAL_TX_PIN SERVO0_PIN + #endif + #ifndef Z_SERIAL_TX_PIN + #define Z_SERIAL_TX_PIN SERVO3_PIN + #endif + #ifndef E0_SERIAL_TX_PIN + #define E0_SERIAL_TX_PIN SERVO2_PIN + #endif +#endif + #include "pins_RAMPS.h" // From 0de4ec4099c17403ea3f1ac0e42d8234e74614c2 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Mon, 14 Nov 2022 17:45:28 +1300 Subject: [PATCH 142/243] =?UTF-8?q?=F0=9F=A9=B9=20Allow=20max=20endstops?= =?UTF-8?q?=20MKS=20Monster=208=20V2=20(#24944)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V1.h | 2 ++ Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h | 8 +++++++- Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_common.h | 2 -- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V1.h b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V1.h index 7163625e4042..50fe790dc34d 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V1.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V1.h @@ -26,7 +26,9 @@ // // Limit Switches // +#define X_MIN_PIN PA14 #define X_MAX_PIN PA13 +#define Y_MIN_PIN PA15 #define Y_MAX_PIN PC5 // diff --git a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h index 9c012999b375..b3d6d48d9f54 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h @@ -23,6 +23,12 @@ #define BOARD_INFO_NAME "MKS Monster8 V2" +// +// Limit Switches +// +#define X_STOP_PIN PA14 +#define Y_STOP_PIN PA15 + // // Steppers // @@ -52,6 +58,6 @@ #define WIFI_RESET_PIN PD14 // MKS ESP WIFI RESET PIN #endif -#define NEOPIXEL_PIN PC5 +#define NEOPIXEL_PIN PC5 #include "pins_MKS_MONSTER8_common.h" diff --git a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_common.h b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_common.h index 8a9b72225d79..b1031de8d5b7 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_common.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_common.h @@ -64,8 +64,6 @@ #define E4_DIAG_PIN -1 // Driver7 diag signal is not connected // Limit Switches for endstops -#define X_MIN_PIN PA14 -#define Y_MIN_PIN PA15 #define Z_MIN_PIN PB13 #define Z_MAX_PIN PB12 From 6ea192abe95f1b3341828bb2dc4ea56df19bdff4 Mon Sep 17 00:00:00 2001 From: Pascal de Bruijn Date: Mon, 14 Nov 2022 05:59:25 +0100 Subject: [PATCH 143/243] =?UTF-8?q?=F0=9F=9A=B8=20M306:=20Indicate=20MPC?= =?UTF-8?q?=20Autotune=20(#24949)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/temp/M306.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Marlin/src/gcode/temp/M306.cpp b/Marlin/src/gcode/temp/M306.cpp index 7978922ff4c0..c6b700eac3b6 100644 --- a/Marlin/src/gcode/temp/M306.cpp +++ b/Marlin/src/gcode/temp/M306.cpp @@ -25,6 +25,7 @@ #if ENABLED(MPCTEMP) #include "../gcode.h" +#include "../../lcd/marlinui.h" #include "../../module/temperature.h" /** @@ -42,7 +43,12 @@ */ void GcodeSuite::M306() { - if (parser.seen_test('T')) { thermalManager.MPC_autotune(); return; } + if (parser.seen_test('T')) { + LCD_MESSAGE(MSG_MPC_AUTOTUNE); + thermalManager.MPC_autotune(); + ui.reset_status(); + return; + } if (parser.seen("ACFPRH")) { const heater_id_t hid = (heater_id_t)parser.intval('E', 0); From 847391cfc15c2d4490d24f2a7356c551e776fbeb Mon Sep 17 00:00:00 2001 From: Justin Hartmann Date: Mon, 14 Nov 2022 00:50:02 -0500 Subject: [PATCH 144/243] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20Overlord=20compile?= =?UTF-8?q?=20(#24947)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/leds/leds.cpp | 12 ------------ Marlin/src/feature/leds/leds.h | 12 ++++++++++++ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Marlin/src/feature/leds/leds.cpp b/Marlin/src/feature/leds/leds.cpp index 1c6d9ab09044..3753235ab5e7 100644 --- a/Marlin/src/feature/leds/leds.cpp +++ b/Marlin/src/feature/leds/leds.cpp @@ -30,18 +30,6 @@ #include "leds.h" -#if ENABLED(BLINKM) - #include "blinkm.h" -#endif - -#if ENABLED(PCA9632) - #include "pca9632.h" -#endif - -#if ENABLED(PCA9533) - #include "pca9533.h" -#endif - #if EITHER(CASE_LIGHT_USE_RGB_LED, CASE_LIGHT_USE_NEOPIXEL) #include "../../feature/caselight.h" #endif diff --git a/Marlin/src/feature/leds/leds.h b/Marlin/src/feature/leds/leds.h index 572fd0dfac4e..c6137b45c355 100644 --- a/Marlin/src/feature/leds/leds.h +++ b/Marlin/src/feature/leds/leds.h @@ -40,6 +40,18 @@ #undef _NEOPIXEL_INCLUDE_ #endif +#if ENABLED(BLINKM) + #include "blinkm.h" +#endif + +#if ENABLED(PCA9533) + #include "pca9533.h" +#endif + +#if ENABLED(PCA9632) + #include "pca9632.h" +#endif + /** * LEDcolor type for use with leds.set_color */ From 30a885a7ef7c6eafd10c13eda39c0d365388cc02 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 14 Nov 2022 02:26:31 -0600 Subject: [PATCH 145/243] =?UTF-8?q?=F0=9F=90=9B=20Fix=20M808=20starting=20?= =?UTF-8?q?count?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reported by adcurtin on Discord --- Marlin/src/feature/repeat.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/feature/repeat.cpp b/Marlin/src/feature/repeat.cpp index 165f71fd0fae..fed7ac0908a0 100644 --- a/Marlin/src/feature/repeat.cpp +++ b/Marlin/src/feature/repeat.cpp @@ -42,7 +42,7 @@ void Repeat::add_marker(const uint32_t sdpos, const uint16_t count) { SERIAL_ECHO_MSG("!Too many markers."); else { marker[index].sdpos = sdpos; - marker[index].counter = count ?: -1; + marker[index].counter = count ? count - 1 : -1; index++; DEBUG_ECHOLNPGM("Add Marker ", index, " at ", sdpos, " (", count, ")"); } From 968f04defbb137db94c5a8424e0af26723b1ba72 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Mon, 14 Nov 2022 21:35:24 +1300 Subject: [PATCH 146/243] =?UTF-8?q?=F0=9F=A9=B9=20Fix=202=20thermocouples?= =?UTF-8?q?=20(#24982)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to #24898 --- Marlin/src/module/temperature.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 37996a80eadc..8742cf36dfb4 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -3076,8 +3076,13 @@ void Temperature::disable_all_heaters() { // Needed to return the correct temp when this is called between readings static raw_adc_t max_tc_temp_previous[MAX_TC_COUNT] = { 0 }; #define THERMO_TEMP(I) max_tc_temp_previous[I] - #define THERMO_SEL(A,B,C) (hindex > 1 ? (C) : hindex == 1 ? (B) : (A)) - #define MAXTC_CS_WRITE(V) do{ switch (hindex) { case 1: WRITE(TEMP_1_CS_PIN, V); break; case 2: WRITE(TEMP_2_CS_PIN, V); break; default: WRITE(TEMP_0_CS_PIN, V); } }while(0) + #if MAX_TC_COUNT > 2 + #define THERMO_SEL(A,B,C) (hindex > 1 ? (C) : hindex == 1 ? (B) : (A)) + #define MAXTC_CS_WRITE(V) do{ switch (hindex) { case 1: WRITE(TEMP_1_CS_PIN, V); break; case 2: WRITE(TEMP_2_CS_PIN, V); break; default: WRITE(TEMP_0_CS_PIN, V); } }while(0) + #elif MAX_TC_COUNT > 1 + #define THERMO_SEL(A,B,C) ( hindex == 1 ? (B) : (A)) + #define MAXTC_CS_WRITE(V) do{ switch (hindex) { case 1: WRITE(TEMP_1_CS_PIN, V); break; default: WRITE(TEMP_0_CS_PIN, V); } }while(0) + #endif #else // When we have only 1 max tc, THERMO_SEL will pick the appropriate sensor // variable, and MAXTC_*() macros will be hardcoded to the correct CS pin. From 473d2b888ad642d8129cc44b6ba436882ff704c8 Mon Sep 17 00:00:00 2001 From: Marcio T Date: Mon, 21 Nov 2022 16:25:56 -0700 Subject: [PATCH 147/243] Fix FAST_PWM_FAN / TouchUI with NO_MOTION_BEFORE_HOMING (#25005) Fix regressions from #20323, #23463 --- Marlin/src/HAL/AVR/fast_pwm.cpp | 10 +++++----- Marlin/src/lcd/extui/ui_api.cpp | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Marlin/src/HAL/AVR/fast_pwm.cpp b/Marlin/src/HAL/AVR/fast_pwm.cpp index 0a384172c32a..e440315e0032 100644 --- a/Marlin/src/HAL/AVR/fast_pwm.cpp +++ b/Marlin/src/HAL/AVR/fast_pwm.cpp @@ -146,11 +146,11 @@ void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t f_desired) { LIMIT(res_pc_temp, 1U, maxtop); // Calculate frequencies of test prescaler and resolution values - const uint32_t f_diff = _MAX(f, f_desired) - _MIN(f, f_desired), - f_fast_temp = (F_CPU) / (p * (1 + res_fast_temp)), - f_fast_diff = _MAX(f_fast_temp, f_desired) - _MIN(f_fast_temp, f_desired), - f_pc_temp = (F_CPU) / (2 * p * res_pc_temp), - f_pc_diff = _MAX(f_pc_temp, f_desired) - _MIN(f_pc_temp, f_desired); + const int f_diff = ABS(f - int(f_desired)), + f_fast_temp = (F_CPU) / (p * (1 + res_fast_temp)), + f_fast_diff = ABS(f_fast_temp - int(f_desired)), + f_pc_temp = (F_CPU) / (2 * p * res_pc_temp), + f_pc_diff = ABS(f_pc_temp - int(f_desired)); if (f_fast_diff < f_diff && f_fast_diff <= f_pc_diff) { // FAST values are closest to desired f // Set the Wave Generation Mode to FAST PWM diff --git a/Marlin/src/lcd/extui/ui_api.cpp b/Marlin/src/lcd/extui/ui_api.cpp index 967fb1021d19..4422e8115d8a 100644 --- a/Marlin/src/lcd/extui/ui_api.cpp +++ b/Marlin/src/lcd/extui/ui_api.cpp @@ -375,9 +375,9 @@ namespace ExtUI { bool canMove(const axis_t axis) { switch (axis) { #if IS_KINEMATIC || ENABLED(NO_MOTION_BEFORE_HOMING) - case X: return axis_should_home(X_AXIS); - OPTCODE(HAS_Y_AXIS, case Y: return axis_should_home(Y_AXIS)) - OPTCODE(HAS_Z_AXIS, case Z: return axis_should_home(Z_AXIS)) + case X: return !axis_should_home(X_AXIS); + OPTCODE(HAS_Y_AXIS, case Y: return !axis_should_home(Y_AXIS)) + OPTCODE(HAS_Z_AXIS, case Z: return !axis_should_home(Z_AXIS)) #else case X: case Y: case Z: return true; #endif From 9772f7806bf83d000f761c79e177a9e21573223e Mon Sep 17 00:00:00 2001 From: phigjm <39876427+phigjm@users.noreply.github.com> Date: Tue, 22 Nov 2022 00:41:14 +0100 Subject: [PATCH 148/243] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20SERVICE=5FINTERVAL?= =?UTF-8?q?=20reset=20(#24888)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/module/printcounter.cpp | 6 +++--- Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h | 4 ++-- Marlin/src/sd/cardreader.cpp | 18 +++++++++--------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Marlin/src/module/printcounter.cpp b/Marlin/src/module/printcounter.cpp index ad6f4eff6803..3b6239c667ee 100644 --- a/Marlin/src/module/printcounter.cpp +++ b/Marlin/src/module/printcounter.cpp @@ -314,13 +314,13 @@ void PrintCounter::reset() { void PrintCounter::resetServiceInterval(const int index) { switch (index) { #if SERVICE_INTERVAL_1 > 0 - case 1: data.nextService1 = SERVICE_INTERVAL_SEC_1; + case 1: data.nextService1 = SERVICE_INTERVAL_SEC_1; break; #endif #if SERVICE_INTERVAL_2 > 0 - case 2: data.nextService2 = SERVICE_INTERVAL_SEC_2; + case 2: data.nextService2 = SERVICE_INTERVAL_SEC_2; break; #endif #if SERVICE_INTERVAL_3 > 0 - case 3: data.nextService3 = SERVICE_INTERVAL_SEC_3; + case 3: data.nextService3 = SERVICE_INTERVAL_SEC_3; break; #endif } saveStats(); diff --git a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h index b3d6d48d9f54..13e912d970e8 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h @@ -53,8 +53,8 @@ // //#define WIFI_SERIAL 1// USART1 #if ENABLED(MKS_WIFI_MODULE) - #define WIFI_IO0_PIN PB14 // MKS ESP WIFI IO0 PIN - #define WIFI_IO1_PIN PB15 // MKS ESP WIFI IO1 PIN + #define WIFI_IO0_PIN PB14 // MKS ESP WIFI IO0 PIN + #define WIFI_IO1_PIN PB15 // MKS ESP WIFI IO1 PIN #define WIFI_RESET_PIN PD14 // MKS ESP WIFI RESET PIN #endif diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 085ae9541c9c..07255f7e7fe2 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -330,15 +330,15 @@ void CardReader::printListing(SdFile parent, const char * const prepend, const SERIAL_CHAR(' '); SERIAL_ECHO(p.fileSize); if (includeTime) { - SERIAL_CHAR(' '); - uint16_t crmodDate = p.lastWriteDate, crmodTime = p.lastWriteTime; - if (crmodDate < p.creationDate || (crmodDate == p.creationDate && crmodTime < p.creationTime)) { - crmodDate = p.creationDate; - crmodTime = p.creationTime; - } - SERIAL_ECHOPGM("0x", hex_word(crmodDate)); - print_hex_word(crmodTime); - } + SERIAL_CHAR(' '); + uint16_t crmodDate = p.lastWriteDate, crmodTime = p.lastWriteTime; + if (crmodDate < p.creationDate || (crmodDate == p.creationDate && crmodTime < p.creationTime)) { + crmodDate = p.creationDate; + crmodTime = p.creationTime; + } + SERIAL_ECHOPGM("0x", hex_word(crmodDate)); + print_hex_word(crmodTime); + } #if ENABLED(LONG_FILENAME_HOST_SUPPORT) if (includeLong) { SERIAL_CHAR(' '); From d05419a8d9c5b025d40b560869c9fc9baefc4f67 Mon Sep 17 00:00:00 2001 From: EvilGremlin <22657714+EvilGremlin@users.noreply.github.com> Date: Tue, 22 Nov 2022 02:45:57 +0300 Subject: [PATCH 149/243] =?UTF-8?q?=F0=9F=94=A7=20Check=20Delta=20homing?= =?UTF-8?q?=20direction=20(#24865)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/SanityCheck.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 63b719f1c261..7f663791f8d2 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1644,8 +1644,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS * Delta requirements */ #if ENABLED(DELTA) - #if NONE(USE_XMAX_PLUG, USE_YMAX_PLUG, USE_ZMAX_PLUG) - #error "You probably want to use Max Endstops for DELTA!" + #if ANY(X_HOME_TO_MIN, Y_HOME_TO_MIN, Z_HOME_TO_MIN) + #error "DELTA kinematics require homing "XYZ" axes to MAX. Set [XYZ]_HOME_DIR to 1." #elif ENABLED(ENABLE_LEVELING_FADE_HEIGHT) && DISABLED(AUTO_BED_LEVELING_BILINEAR) && !UBL_SEGMENTED #error "ENABLE_LEVELING_FADE_HEIGHT on DELTA requires AUTO_BED_LEVELING_BILINEAR or AUTO_BED_LEVELING_UBL." #elif ENABLED(DELTA_AUTO_CALIBRATION) && !(HAS_BED_PROBE || HAS_MARLINUI_MENU) From 505d73d2bae31662ac833f316d934239b392e93d Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Tue, 22 Nov 2022 12:47:27 +1300 Subject: [PATCH 150/243] =?UTF-8?q?=F0=9F=90=9B=20MKS=5FMINI=5F12864=20on?= =?UTF-8?q?=20SKR=201.3=20needs=20FORCE=5FSOFT=5FSPI=20(#24850)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h index 031a42f7989c..243aca7a72ea 100644 --- a/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h +++ b/Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_3.h @@ -423,6 +423,7 @@ #define DOGLCD_A0 EXP1_07_PIN #define DOGLCD_SCK EXP2_02_PIN #define DOGLCD_MOSI EXP2_06_PIN + #define FORCE_SOFT_SPI #elif ENABLED(ENDER2_STOCKDISPLAY) From db60e0e7dc829a8dee94736f4be15aa5bb6fe4d4 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Sat, 26 Nov 2022 14:17:24 +1300 Subject: [PATCH 151/243] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20planner=20typo=20(?= =?UTF-8?q?#24977)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/module/planner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index dce91606647f..0128d90f0fb5 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -2167,7 +2167,7 @@ bool Planner::_populate_block( sq(steps_dist_mm.x), + sq(steps_dist_mm.y), + sq(steps_dist_mm.z), + sq(steps_dist_mm.i), + sq(steps_dist_mm.j), + sq(steps_dist_mm.k), + sq(steps_dist_mm.u), + sq(steps_dist_mm.v), + sq(steps_dist_mm.w) - ); + ) #elif ENABLED(FOAMCUTTER_XYUV) #if HAS_J_AXIS // Special 5 axis kinematics. Return the largest distance move from either X/Y or I/J plane From 19b73a6f2927fc982af70891cb4025f4acd6d36c Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Sat, 26 Nov 2022 16:40:24 +1300 Subject: [PATCH 152/243] =?UTF-8?q?=F0=9F=93=BA=20FYSETC=5FMINI=5F12864=5F?= =?UTF-8?q?2=5F1=20with=20BTT=5FSKR=5FE3=5FDIP=20(#24986)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h | 123 ++++++++++++++---- 1 file changed, 97 insertions(+), 26 deletions(-) diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h index f9c9de4f031e..075258991ddd 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h @@ -166,19 +166,28 @@ * EXP1 */ +#define EXP1_01_PIN PA15 +#define EXP1_02_PIN PB6 +#define EXP1_03_PIN PA9 +#define EXP1_04_PIN -1 // RESET +#define EXP1_05_PIN PA10 +#define EXP1_06_PIN PB9 +#define EXP1_07_PIN PB8 +#define EXP1_08_PIN PB7 + #if HAS_WIRED_LCD #if ENABLED(CR10_STOCKDISPLAY) - #define BEEPER_PIN PA15 + #define BEEPER_PIN EXP1_01_PIN - #define BTN_ENC PB6 - #define BTN_EN1 PA9 - #define BTN_EN2 PA10 + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN - #define LCD_PINS_RS PB8 - #define LCD_PINS_ENABLE PB7 - #define LCD_PINS_D4 PB9 + #define LCD_PINS_RS EXP1_07_PIN + #define LCD_PINS_ENABLE EXP1_08_PIN + #define LCD_PINS_D4 EXP1_06_PIN #elif ENABLED(ZONESTAR_LCD) // ANET A8 LCD Controller - Must convert to 3.3V - CONNECTING TO 5V WILL DAMAGE THE BOARD! @@ -186,12 +195,12 @@ #error "CAUTION! ZONESTAR_LCD requires wiring modifications. See 'pins_BTT_SKR_MINI_E3_DIP.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" #endif - #define LCD_PINS_RS PB9 - #define LCD_PINS_ENABLE PB6 - #define LCD_PINS_D4 PB8 - #define LCD_PINS_D5 PA10 - #define LCD_PINS_D6 PA9 - #define LCD_PINS_D7 PA15 + #define LCD_PINS_RS EXP1_06_PIN + #define LCD_PINS_ENABLE EXP1_02_PIN + #define LCD_PINS_D4 EXP1_07_PIN + #define LCD_PINS_D5 EXP1_05_PIN + #define LCD_PINS_D6 EXP1_03_PIN + #define LCD_PINS_D7 EXP1_01_PIN #define ADC_KEYPAD_PIN PA1 // Repurpose servo pin for ADC - CONNECTING TO 5V WILL DAMAGE THE BOARD! #elif EITHER(MKS_MINI_12864, ENDER2_STOCKDISPLAY) @@ -207,19 +216,81 @@ * EXP1 */ - #define BTN_ENC PB6 - #define BTN_EN1 PA9 - #define BTN_EN2 PA10 + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN - #define DOGLCD_CS PB8 - #define DOGLCD_A0 PB9 - #define DOGLCD_SCK PA15 - #define DOGLCD_MOSI PB7 + #define DOGLCD_CS EXP1_07_PIN + #define DOGLCD_A0 EXP1_06_PIN + #define DOGLCD_SCK EXP1_01_PIN + #define DOGLCD_MOSI EXP1_08_PIN #define FORCE_SOFT_SPI #define LCD_BACKLIGHT_PIN -1 + #elif ENABLED(FYSETC_MINI_12864_2_1) + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! FYSETC_MINI_12864_2_1 and it's clones require wiring modifications. See 'pins_BTT_SKR_MINI_E3_DIP.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + #if SD_CONNECTION_IS(LCD) + #error "The LCD SD Card is not supported with this configuration." + #endif + + /** + * FYSETC_MINI_12864_2_1 / MKS_MINI_12864_V3 / BTT_MINI_12864_V1 display pinout + * + * Board Display + * ------ ------ + * (NEOPIXEL) PA15 | 1 2 | PB6 (BTN_ENC) 5V |10 9 | GND + * (BTN_EN2) PA9 | 3 4 | RESET -- | 8 7 | -- + * (BTN_EN1) PA10 5 6 | PB9 (LCD_RESET) NEOPIXEL | 6 5 LCD RESET + * (LCD_A0) PB8 | 7 8 | PB7 (LCD_CS) LCD_A0 | 4 3 | LCD_CS + * GND | 9 10 | 5V BTN_ENC | 2 1 | BEEP + * ------ ------ + * EXP1 EXP1 + * + * + * ----- ------ + * | 1 | RST -- |10 9 | -- + * | 2 | PA3 RX2 RESET_BTN | 8 7 | SD_DETECT + * | 3 | PA2 TX2 LCD_MOSI | 6 5 EN2 + * | 4 | GND -- | 4 3 | EN1 + * | 5 | 5V LCD_SCK | 2 1 | -- + * ----- ------ + * TFT EXP2 + + * + * Needs custom cable. + * + * BOARD EXP1 NEOPIXEL <--> LCD EXP1 NEOPIXEL + * BOARD EXP1 BTN_ENC <--> LCD EXP1 BTN_ENC + * BOARD EXP1 BTN_EN2 <--> LCD EXP2 EN2 + * BOARD EXP1 RESET <--> LCD EXP2 RESET_BTN + * BOARD EXP1 BTN_EN1 <--> LCD EXP2 EN1 + * BOARD EXP1 LCD_RESET <--> LCD EXP1 LCD RESET + * BOARD EXP1 LCD_A0 <--> LCD EXP1 LCD_A0 + * BOARD EXP1 LCD_CS <--> LCD EXP1 LCD_CS + * BOARD TFT RX2 <--> LCD EXP2 LCD_MOSI + * BOARD TFT TX2 <--> LCD EXP2 LCD_SCK + */ + + #define NEOPIXEL_PIN EXP1_01_PIN + #define BTN_ENC EXP1_02_PIN + #define BTN_EN1 EXP1_03_PIN + #define BTN_EN2 EXP1_05_PIN + #define LCD_RESET_PIN EXP1_06_PIN + #define BEEPER_PIN -1 + #define DOGLCD_A0 EXP1_07_PIN + #define DOGLCD_CS EXP1_08_PIN + + #define DOGLCD_SCK PA2 + #define DOGLCD_MOSI PA3 + + #define LCD_BACKLIGHT_PIN -1 + #define FORCE_SOFT_SPI + #else - #error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, MKS_MINI_12864, and MKS_LCD12864A/B are currently supported on the BIGTREE_SKR_E3_DIP." + #error "Only CR10_STOCKDISPLAY, ZONESTAR_LCD, ENDER2_STOCKDISPLAY, MKS_MINI_12864, FYSETC_MINI_12864_2_1 and MKS_LCD12864A/B are currently supported on the BIGTREE_SKR_E3_DIP." #endif #endif // HAS_WIRED_LCD @@ -260,10 +331,10 @@ #define CLCD_SPI_BUS 1 // SPI1 connector - #define BEEPER_PIN PB6 + #define BEEPER_PIN EXP1_02_PIN - #define CLCD_MOD_RESET PA9 - #define CLCD_SPI_CS PB8 + #define CLCD_MOD_RESET EXP1_03_PIN + #define CLCD_SPI_CS EXP1_07_PIN #endif // TOUCH_UI_FTDI_EVE && LCD_FYSETC_TFT81050 @@ -281,8 +352,8 @@ #define SD_MISO_PIN PA6 #define SD_MOSI_PIN PA7 #elif SD_CONNECTION_IS(LCD) && BOTH(TOUCH_UI_FTDI_EVE, LCD_FYSETC_TFT81050) - #define SD_DETECT_PIN PA15 - #define SD_SS_PIN PA10 + #define SD_DETECT_PIN EXP1_01_PIN + #define SD_SS_PIN EXP1_05_PIN #elif SD_CONNECTION_IS(CUSTOM_CABLE) #error "SD CUSTOM_CABLE is not compatible with SKR E3 DIP." #endif From 8fd42eeeb60198c08bf48bb3d6c4369df666c22d Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Sat, 26 Nov 2022 04:41:49 +0100 Subject: [PATCH 153/243] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20Fix=20Robin=20nano?= =?UTF-8?q?=20env=20typo=20(#24993)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/pins/pins.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index 909ae992a991..ef73b3c8c001 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -516,7 +516,7 @@ #elif MB(MKS_ROBIN_NANO) #include "stm32f1/pins_MKS_ROBIN_NANO.h" // STM32F1 env:mks_robin_nano_v1v2 env:mks_robin_nano_v1v2_maple env:mks_robin_nano_v1v2_usbmod #elif MB(MKS_ROBIN_NANO_V2) - #include "stm32f1/pins_MKS_ROBIN_NANO_V2.h" // STM32F1 env:mks_robin_nano_v1v2 env:mks_robin_nano3_v1v2_maple + #include "stm32f1/pins_MKS_ROBIN_NANO_V2.h" // STM32F1 env:mks_robin_nano_v1v2 env:mks_robin_nano_v1v2_maple #elif MB(MKS_ROBIN_LITE) #include "stm32f1/pins_MKS_ROBIN_LITE.h" // STM32F1 env:mks_robin_lite env:mks_robin_lite_maple #elif MB(MKS_ROBIN_LITE3) From b8ba9d60bb7f12d059d62382dc09abf40537de16 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Sat, 26 Nov 2022 19:21:47 +1300 Subject: [PATCH 154/243] =?UTF-8?q?=F0=9F=94=A7=20Fix=20TPARA=20(=E2=80=A6?= =?UTF-8?q?SCARA,=20DELTA)=20settings=20(#25016)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration.h | 32 +++++++++---------- .../src/feature/bedlevel/ubl/ubl_motion.cpp | 4 +-- Marlin/src/inc/Conditionals_post.h | 6 ++-- Marlin/src/inc/SanityCheck.h | 2 ++ Marlin/src/module/scara.cpp | 2 +- Marlin/src/module/settings.cpp | 6 +--- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 87a98298a58e..7f625c04f85e 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -879,7 +879,7 @@ //#define POLARGRAPH #if ENABLED(POLARGRAPH) #define POLARGRAPH_MAX_BELT_LEN 1035.0 - #define POLAR_SEGMENTS_PER_SECOND 5 + #define DEFAULT_SEGMENTS_PER_SECOND 5 #endif // @section delta @@ -891,28 +891,28 @@ // Make delta curves from many straight lines (linear interpolation). // This is a trade-off between visible corners (not enough segments) // and processor overload (too many expensive sqrt calls). - #define DELTA_SEGMENTS_PER_SECOND 200 + #define DEFAULT_SEGMENTS_PER_SECOND 200 // After homing move down to a height where XY movement is unconstrained //#define DELTA_HOME_TO_SAFE_ZONE // Delta calibration menu - // uncomment to add three points calibration menu option. + // Add three-point calibration to the MarlinUI menu. // See http://minow.blogspot.com/index.html#4918805519571907051 //#define DELTA_CALIBRATION_MENU - // uncomment to add G33 Delta Auto-Calibration (Enable EEPROM_SETTINGS to store results) + // G33 Delta Auto-Calibration. Enable EEPROM_SETTINGS to store results. //#define DELTA_AUTO_CALIBRATION - // NOTE NB all values for DELTA_* values MUST be floating point, so always have a decimal point in them - #if ENABLED(DELTA_AUTO_CALIBRATION) - // set the default number of probe points : n*n (1 -> 7) + // Default number of probe points : n*n (1 -> 7) #define DELTA_CALIBRATION_DEFAULT_POINTS 4 #endif + // NOTE: All values for DELTA_* values MUST be floating point, so always have a decimal point in them + #if EITHER(DELTA_AUTO_CALIBRATION, DELTA_CALIBRATION_MENU) - // Set the steprate for papertest probing + // Step size for paper-test probing #define PROBE_MANUALLY_STEP 0.05 // (mm) #endif @@ -957,7 +957,7 @@ //#define MP_SCARA #if EITHER(MORGAN_SCARA, MP_SCARA) // If movement is choppy try lowering this value - #define SCARA_SEGMENTS_PER_SECOND 200 + #define DEFAULT_SEGMENTS_PER_SECOND 200 // Length of inner and outer support arms. Measure arm lengths precisely. #define SCARA_LINKAGE_1 150 // (mm) @@ -993,18 +993,18 @@ // Enable for TPARA kinematics and configure below //#define AXEL_TPARA #if ENABLED(AXEL_TPARA) - #define DEBUG_ROBOT_KINEMATICS - #define ROBOT_SEGMENTS_PER_SECOND 200 + #define DEBUG_TPARA_KINEMATICS + #define DEFAULT_SEGMENTS_PER_SECOND 200 // Length of inner and outer support arms. Measure arm lengths precisely. - #define ROBOT_LINKAGE_1 120 // (mm) - #define ROBOT_LINKAGE_2 120 // (mm) + #define TPARA_LINKAGE_1 120 // (mm) + #define TPARA_LINKAGE_2 120 // (mm) // SCARA tower offset (position of Tower relative to bed zero position) // This needs to be reasonably accurate as it defines the printbed position in the SCARA space. - #define ROBOT_OFFSET_X 0 // (mm) - #define ROBOT_OFFSET_Y 0 // (mm) - #define ROBOT_OFFSET_Z 0 // (mm) + #define TPARA_OFFSET_X 0 // (mm) + #define TPARA_OFFSET_Y 0 // (mm) + #define TPARA_OFFSET_Z 0 // (mm) #define SCARA_FEEDRATE_SCALING // Convert XY feedrate from mm/s to degrees/s on the fly diff --git a/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp b/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp index 56c48650f1eb..96c30a0efd89 100644 --- a/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp +++ b/Marlin/src/feature/bedlevel/ubl/ubl_motion.cpp @@ -336,9 +336,9 @@ #if IS_SCARA #define DELTA_SEGMENT_MIN_LENGTH 0.25 // SCARA minimum segment size is 0.25mm #elif ENABLED(DELTA) - #define DELTA_SEGMENT_MIN_LENGTH 0.10 // mm (still subject to DELTA_SEGMENTS_PER_SECOND) + #define DELTA_SEGMENT_MIN_LENGTH 0.10 // mm (still subject to DEFAULT_SEGMENTS_PER_SECOND) #elif ENABLED(POLARGRAPH) - #define DELTA_SEGMENT_MIN_LENGTH 0.10 // mm (still subject to DELTA_SEGMENTS_PER_SECOND) + #define DELTA_SEGMENT_MIN_LENGTH 0.10 // mm (still subject to DEFAULT_SEGMENTS_PER_SECOND) #else // CARTESIAN #ifdef LEVELED_SEGMENT_LENGTH #define DELTA_SEGMENT_MIN_LENGTH LEVELED_SEGMENT_LENGTH diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 1e0daeb567f6..f6e76d1a6ef2 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -275,10 +275,12 @@ */ #if IS_SCARA #undef SLOWDOWN - #if DISABLED(AXEL_TPARA) + #if ENABLED(AXEL_TPARA) + #define SCARA_PRINTABLE_RADIUS (TPARA_LINKAGE_1 + TPARA_LINKAGE_2) + #else #define QUICK_HOME + #define SCARA_PRINTABLE_RADIUS (SCARA_LINKAGE_1 + SCARA_LINKAGE_2) #endif - #define SCARA_PRINTABLE_RADIUS (SCARA_LINKAGE_1 + SCARA_LINKAGE_2) #endif /** diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 7f663791f8d2..2d8c7ca1c602 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -654,6 +654,8 @@ #error "SHOW_SD_PERCENT is now SHOW_PROGRESS_PERCENT." #elif defined(EXTRA_LIN_ADVANCE_K) #error "EXTRA_LIN_ADVANCE_K is now ADVANCE_K_EXTRA." +#elif defined(POLAR_SEGMENTS_PER_SECOND) || defined(DELTA_SEGMENTS_PER_SECOND) || defined(SCARA_SEGMENTS_PER_SECOND) || defined(TPARA_SEGMENTS_PER_SECOND) + #error "(POLAR|DELTA|SCARA|TPARA)_SEGMENTS_PER_SECOND is now DEFAULT_SEGMENTS_PER_SECOND." #endif // L64xx stepper drivers have been removed diff --git a/Marlin/src/module/scara.cpp b/Marlin/src/module/scara.cpp index bc42b85fbe13..4c42ace884de 100644 --- a/Marlin/src/module/scara.cpp +++ b/Marlin/src/module/scara.cpp @@ -37,7 +37,7 @@ #include "../MarlinCore.h" #endif -float segments_per_second = TERN(AXEL_TPARA, TPARA_SEGMENTS_PER_SECOND, SCARA_SEGMENTS_PER_SECOND); +float segments_per_second = DEFAULT_SEGMENTS_PER_SECOND; #if EITHER(MORGAN_SCARA, MP_SCARA) diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index a090b140adee..5d1ef71d66f6 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -3044,11 +3044,7 @@ void MarlinSettings::reset() { // #if IS_KINEMATIC - segments_per_second = ( - TERN_(DELTA, DELTA_SEGMENTS_PER_SECOND) - TERN_(IS_SCARA, SCARA_SEGMENTS_PER_SECOND) - TERN_(POLARGRAPH, POLAR_SEGMENTS_PER_SECOND) - ); + segments_per_second = DEFAULT_SEGMENTS_PER_SECOND; #if ENABLED(DELTA) const abc_float_t adj = DELTA_ENDSTOP_ADJ, dta = DELTA_TOWER_ANGLE_TRIM, ddr = DELTA_DIAGONAL_ROD_TRIM_TOWER; delta_height = DELTA_HEIGHT; From b9bed1ca6908f2e2be9d867b008e1b9e3ac49ef4 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Sat, 26 Nov 2022 08:23:24 +0100 Subject: [PATCH 155/243] =?UTF-8?q?=F0=9F=9A=B8=20COLOR=5FUI=20sleep=20tim?= =?UTF-8?q?eout=20/=20setting=20(#24994)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/marlinui.cpp | 24 ++++++++++++++-------- Marlin/src/lcd/menu/menu_configuration.cpp | 2 +- Marlin/src/lcd/tft/touch.cpp | 22 +++++++++++--------- Marlin/src/lcd/tft/touch.h | 2 +- Marlin/src/module/settings.cpp | 2 +- 5 files changed, 31 insertions(+), 21 deletions(-) diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 5991806b7b72..cdda7ca85abf 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -196,12 +196,15 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; uint8_t MarlinUI::sleep_timeout_minutes; // Initialized by settings.load() millis_t MarlinUI::screen_timeout_millis = 0; - #if DISABLED(TFT_COLOR_UI) - void MarlinUI::refresh_screen_timeout() { - screen_timeout_millis = sleep_timeout_minutes ? millis() + sleep_timeout_minutes * 60UL * 1000UL : 0; - sleep_display(false); - } + void MarlinUI::refresh_screen_timeout() { + screen_timeout_millis = sleep_timeout_minutes ? millis() + sleep_timeout_minutes * 60UL * 1000UL : 0; + sleep_display(false); + } + + #if !HAS_TOUCH_SLEEP && !HAS_MARLINUI_U8GLIB // without DOGM (COLOR_UI) + void MarlinUI::sleep_display(const bool sleep) {} // if unimplemented #endif + #endif void MarlinUI::init() { @@ -731,6 +734,11 @@ void MarlinUI::init() { void MarlinUI::wakeup_screen() { TERN(HAS_TOUCH_BUTTONS, touchBt.wakeUp(), touch.wakeUp()); } + #if HAS_DISPLAY_SLEEP && !HAS_MARLINUI_U8GLIB // without DOGM (COLOR_UI) + void MarlinUI::sleep_display(const bool sleep) { + if (!sleep) wakeup_screen(); // relay extra wake up events + } + #endif #endif void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) { @@ -1071,7 +1079,7 @@ void MarlinUI::init() { #if LCD_BACKLIGHT_TIMEOUT_MINS refresh_backlight_timeout(); - #elif HAS_DISPLAY_SLEEP && DISABLED(TFT_COLOR_UI) + #elif HAS_DISPLAY_SLEEP refresh_screen_timeout(); #endif @@ -1184,9 +1192,9 @@ void MarlinUI::init() { WRITE(LCD_BACKLIGHT_PIN, LOW); // Backlight off backlight_off_ms = 0; } - #elif HAS_DISPLAY_SLEEP && DISABLED(TFT_COLOR_UI) + #elif HAS_DISPLAY_SLEEP if (screen_timeout_millis && ELAPSED(ms, screen_timeout_millis)) - sleep_display(true); + sleep_display(); #endif // Change state of drawing flag between screen updates diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 1ac12656dd36..7ae199dfd6e9 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -550,7 +550,7 @@ void menu_configuration() { // #if LCD_BACKLIGHT_TIMEOUT_MINS EDIT_ITEM(uint8, MSG_SCREEN_TIMEOUT, &ui.backlight_timeout_minutes, ui.backlight_timeout_min, ui.backlight_timeout_max, ui.refresh_backlight_timeout); - #elif HAS_DISPLAY_SLEEP && DISABLED(TFT_COLOR_UI) + #elif HAS_DISPLAY_SLEEP EDIT_ITEM(uint8, MSG_SCREEN_TIMEOUT, &ui.sleep_timeout_minutes, ui.sleep_timeout_min, ui.sleep_timeout_max, ui.refresh_screen_timeout); #endif diff --git a/Marlin/src/lcd/tft/touch.cpp b/Marlin/src/lcd/tft/touch.cpp index 824b2699247b..6bfc0a8abde4 100644 --- a/Marlin/src/lcd/tft/touch.cpp +++ b/Marlin/src/lcd/tft/touch.cpp @@ -43,7 +43,7 @@ int16_t Touch::x, Touch::y; touch_control_t Touch::controls[]; touch_control_t *Touch::current_control; uint16_t Touch::controls_count; -millis_t Touch::last_touch_ms = 0, +millis_t Touch::next_touch_ms = 0, Touch::time_to_hold, Touch::repeat_delay, Touch::touch_time; @@ -83,8 +83,8 @@ void Touch::idle() { // Return if Touch::idle is called within the same millisecond const millis_t now = millis(); - if (last_touch_ms == now) return; - last_touch_ms = now; + if (now <= next_touch_ms) return; + next_touch_ms = now; if (get_point(&_x, &_y)) { #if HAS_RESUME_CONTINUE @@ -97,18 +97,18 @@ void Touch::idle() { } #endif - ui.reset_status_timeout(last_touch_ms); + ui.reset_status_timeout(now); if (touch_time) { #if ENABLED(TOUCH_SCREEN_CALIBRATION) - if (touch_control_type == NONE && ELAPSED(last_touch_ms, touch_time + TOUCH_SCREEN_HOLD_TO_CALIBRATE_MS) && ui.on_status_screen()) + if (touch_control_type == NONE && ELAPSED(now, touch_time + TOUCH_SCREEN_HOLD_TO_CALIBRATE_MS) && ui.on_status_screen()) ui.goto_screen(touch_screen_calibration); #endif return; } - if (time_to_hold == 0) time_to_hold = last_touch_ms + MINIMUM_HOLD_TIME; - if (PENDING(last_touch_ms, time_to_hold)) return; + if (time_to_hold == 0) time_to_hold = now + MINIMUM_HOLD_TIME; + if (PENDING(now, time_to_hold)) return; if (x != 0 && y != 0) { if (current_control) { @@ -133,7 +133,7 @@ void Touch::idle() { } if (!current_control) - touch_time = last_touch_ms; + touch_time = now; } x = _x; y = _y; @@ -252,8 +252,8 @@ void Touch::touch(touch_control_t *control) { void Touch::hold(touch_control_t *control, millis_t delay) { current_control = control; if (delay) { - repeat_delay = delay > MIN_REPEAT_DELAY ? delay : MIN_REPEAT_DELAY; - time_to_hold = last_touch_ms + repeat_delay; + repeat_delay = _MAX(delay, MIN_REPEAT_DELAY); + time_to_hold = next_touch_ms + repeat_delay; } ui.refresh(); } @@ -301,6 +301,8 @@ bool Touch::get_point(int16_t *x, int16_t *y) { #elif PIN_EXISTS(TFT_BACKLIGHT) WRITE(TFT_BACKLIGHT_PIN, HIGH); #endif + next_touch_ms = millis() + 100; + safe_delay(20); } next_sleep_ms = millis() + SEC_TO_MS(ui.sleep_timeout_minutes * 60); } diff --git a/Marlin/src/lcd/tft/touch.h b/Marlin/src/lcd/tft/touch.h index 6021a840b65e..fd5d9fd73737 100644 --- a/Marlin/src/lcd/tft/touch.h +++ b/Marlin/src/lcd/tft/touch.h @@ -103,7 +103,7 @@ class Touch { static touch_control_t *current_control; static uint16_t controls_count; - static millis_t last_touch_ms, time_to_hold, repeat_delay, touch_time; + static millis_t next_touch_ms, time_to_hold, repeat_delay, touch_time; static TouchControlType touch_control_type; static bool get_point(int16_t *x, int16_t *y); diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 5d1ef71d66f6..921b0d91cb2a 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -658,7 +658,7 @@ void MarlinSettings::postprocess() { #if LCD_BACKLIGHT_TIMEOUT_MINS ui.refresh_backlight_timeout(); - #elif HAS_DISPLAY_SLEEP && DISABLED(TFT_COLOR_UI) + #elif HAS_DISPLAY_SLEEP ui.refresh_screen_timeout(); #endif } From b6051fe847a5aa70c51c3cde29f47c1add29fb29 Mon Sep 17 00:00:00 2001 From: Thomas Buck Date: Sun, 27 Nov 2022 01:59:13 +0100 Subject: [PATCH 156/243] =?UTF-8?q?=F0=9F=9A=B8=20Optional=20Cutter/Laser?= =?UTF-8?q?=20status=20for=20HD44780=20(#25003)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/power_monitor.cpp | 6 +- Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp | 4 +- Marlin/src/lcd/HD44780/marlinui_HD44780.cpp | 184 +++++++++++++------- Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp | 19 +- Marlin/src/lcd/dogm/lcdprint_u8g.cpp | 2 +- Marlin/src/lcd/dogm/marlinui_DOGM.cpp | 24 +-- Marlin/src/lcd/dogm/status_screen_DOGM.cpp | 26 +-- Marlin/src/lcd/dogm/u8g_fontutf8.cpp | 2 +- Marlin/src/lcd/dogm/u8g_fontutf8.h | 2 +- Marlin/src/lcd/e3v2/marlinui/ui_common.cpp | 8 +- Marlin/src/lcd/language/language_en.h | 1 + Marlin/src/lcd/lcdprint.cpp | 2 +- Marlin/src/lcd/menu/menu_bed_corners.cpp | 2 +- Marlin/src/lcd/menu/menu_configuration.cpp | 2 +- Marlin/src/lcd/menu/menu_password.cpp | 4 +- Marlin/src/lcd/menu/menu_spindle_laser.cpp | 2 +- Marlin/src/lcd/menu/menu_tune.cpp | 4 +- buildroot/tests/BIGTREE_SKR_PRO | 2 +- buildroot/tests/mega2560 | 6 +- 19 files changed, 178 insertions(+), 124 deletions(-) diff --git a/Marlin/src/feature/power_monitor.cpp b/Marlin/src/feature/power_monitor.cpp index 5a9db1ec24a1..e3c3e58fc412 100644 --- a/Marlin/src/feature/power_monitor.cpp +++ b/Marlin/src/feature/power_monitor.cpp @@ -53,7 +53,7 @@ PowerMonitor power_monitor; // Single instance - this calls the constructor void PowerMonitor::draw_current() { const float amps = getAmps(); lcd_put_u8str(amps < 100 ? ftostr31ns(amps) : ui16tostr4rj((uint16_t)amps)); - lcd_put_lchar('A'); + lcd_put_u8str(F("A")); } #endif @@ -61,7 +61,7 @@ PowerMonitor power_monitor; // Single instance - this calls the constructor void PowerMonitor::draw_voltage() { const float volts = getVolts(); lcd_put_u8str(volts < 100 ? ftostr31ns(volts) : ui16tostr4rj((uint16_t)volts)); - lcd_put_lchar('V'); + lcd_put_u8str(F("V")); } #endif @@ -69,7 +69,7 @@ PowerMonitor power_monitor; // Single instance - this calls the constructor void PowerMonitor::draw_power() { const float power = getPower(); lcd_put_u8str(power < 100 ? ftostr31ns(power) : ui16tostr4rj((uint16_t)power)); - lcd_put_lchar('W'); + lcd_put_u8str(F("W")); } #endif diff --git a/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp b/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp index fe31c21e3959..48f5f97133db 100644 --- a/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp +++ b/Marlin/src/lcd/HD44780/lcdprint_hd44780.cpp @@ -56,9 +56,9 @@ typedef struct _hd44780_charmap_t { } hd44780_charmap_t; #ifdef __AVR__ - #define IV(a) U##a + #define IV(a) lchar_t(U##a) #else - #define IV(a) L##a + #define IV(a) lchar_t(L##a) #endif static const hd44780_charmap_t g_hd44780_charmap_device[] PROGMEM = { diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index ba222897fccf..ffbca8def607 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -58,6 +58,10 @@ #include "../../feature/bedlevel/bedlevel.h" #endif +#if HAS_CUTTER + #include "../../feature/spindle_laser.h" +#endif + // // Create LCD instance and chipset-specific information // @@ -406,7 +410,7 @@ void MarlinUI::clear_lcd() { lcd.clear(); } void lcd_erase_line(const lcd_uint_t line) { lcd_moveto(0, line); for (uint8_t i = LCD_WIDTH + 1; --i;) - lcd_put_lchar(' '); + lcd_put_u8str(F(" ")); } // Scroll the PSTR 'text' in a 'len' wide field for 'time' milliseconds at position col,line @@ -414,7 +418,7 @@ void MarlinUI::clear_lcd() { lcd.clear(); } uint8_t slen = utf8_strlen(ftxt); if (slen < len) { lcd_put_u8str_max(col, line, ftxt, len); - for (; slen < len; ++slen) lcd_put_lchar(' '); + for (; slen < len; ++slen) lcd_put_u8str(F(" ")); safe_delay(time); } else { @@ -426,7 +430,7 @@ void MarlinUI::clear_lcd() { lcd.clear(); } lcd_put_u8str_max_P(col, line, p, len); // Fill with spaces - for (uint8_t ix = slen - i; ix < len; ++ix) lcd_put_lchar(' '); + for (uint8_t ix = slen - i; ix < len; ++ix) lcd_put_u8str(F(" ")); // Delay safe_delay(dly); @@ -440,9 +444,9 @@ void MarlinUI::clear_lcd() { lcd.clear(); } static void logo_lines(FSTR_P const extra) { int16_t indent = (LCD_WIDTH - 8 - utf8_strlen(extra)) / 2; - lcd_put_lchar(indent, 0, '\x00'); lcd_put_u8str(F( "------" )); lcd_put_lchar('\x01'); + lcd_put_lchar(indent, 0, '\x00'); lcd_put_u8str(F( "------" )); lcd_put_u8str(F("\x01")); lcd_put_u8str(indent, 1, F("|Marlin|")); lcd_put_u8str(extra); - lcd_put_lchar(indent, 2, '\x02'); lcd_put_u8str(F( "------" )); lcd_put_lchar('\x03'); + lcd_put_lchar(indent, 2, '\x02'); lcd_put_u8str(F( "------" )); lcd_put_u8str(F("\x03")); } void MarlinUI::show_bootscreen() { @@ -522,7 +526,15 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const lcd_put_u8str(value); } - +/** + * @brief Draw current and target for a heater/cooler + * @details Print at the current LCD position the current/target for a single heater, + * blinking the target temperature of an idle heater has timed out. + * + * @param heater_id The heater ID, such as 0, 1, ..., H_BED, H_CHAMBER, etc. + * @param prefix A char to draw in front (e.g., a thermometer or icon) + * @param blink Flag to show the blink state instead of the regular state + */ FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char prefix, const bool blink) { #if HAS_HEATED_BED const bool isBed = TERN(HAS_HEATED_CHAMBER, heater_id == H_BED, heater_id < 0); @@ -535,75 +547,74 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char pr if (prefix >= 0) lcd_put_lchar(prefix); lcd_put_u8str(t1 < 0 ? "err" : i16tostr3rj(t1)); - lcd_put_lchar('/'); + lcd_put_u8str(F("/")); #if !HEATER_IDLE_HANDLER UNUSED(blink); #else - if (!blink && thermalManager.heater_idle[thermalManager.idle_index_for_id(heater_id)].timed_out) { - lcd_put_lchar(' '); - if (t2 >= 10) lcd_put_lchar(' '); - if (t2 >= 100) lcd_put_lchar(' '); - } + if (!blink && thermalManager.heater_idle[thermalManager.idle_index_for_id(heater_id)].timed_out) + lcd_put_u8str(F(" ")); else #endif lcd_put_u8str(i16tostr3left(t2)); if (prefix >= 0) { lcd_put_lchar(LCD_STR_DEGREE[0]); - lcd_put_lchar(' '); - if (t2 < 10) lcd_put_lchar(' '); + lcd_put_u8str(F(" ")); + if (t2 < 10) lcd_put_u8str(F(" ")); } } #if HAS_COOLER -FORCE_INLINE void _draw_cooler_status(const char prefix, const bool blink) { - const celsius_t t2 = thermalManager.degTargetCooler(); - if (prefix >= 0) lcd_put_lchar(prefix); + FORCE_INLINE void _draw_cooler_status(const char prefix, const bool blink) { + const celsius_t t2 = thermalManager.degTargetCooler(); - lcd_put_u8str(i16tostr3rj(thermalManager.wholeDegCooler())); - lcd_put_lchar('/'); + if (prefix >= 0) lcd_put_lchar(prefix); - #if !HEATER_IDLE_HANDLER - UNUSED(blink); - #else - if (!blink && thermalManager.heater_idle[thermalManager.idle_index_for_id(heater_id)].timed_out) { - lcd_put_lchar(' '); - if (t2 >= 10) lcd_put_lchar(' '); - if (t2 >= 100) lcd_put_lchar(' '); - } - else - #endif - lcd_put_u8str(i16tostr3left(t2)); + lcd_put_u8str(i16tostr3rj(thermalManager.wholeDegCooler())); + lcd_put_u8str(F("/")); - if (prefix >= 0) { - lcd_put_lchar(LCD_STR_DEGREE[0]); - lcd_put_lchar(' '); - if (t2 < 10) lcd_put_lchar(' '); + #if !HEATER_IDLE_HANDLER + UNUSED(blink); + #else + if (!blink && thermalManager.heater_idle[thermalManager.idle_index_for_id(heater_id)].timed_out) { + lcd_put_u8str(F(" ")); + if (t2 >= 10) lcd_put_u8str(F(" ")); + if (t2 >= 100) lcd_put_u8str(F(" ")); + } + else + #endif + lcd_put_u8str(i16tostr3left(t2)); + + if (prefix >= 0) { + lcd_put_lchar(LCD_STR_DEGREE[0]); + lcd_put_u8str(F(" ")); + if (t2 < 10) lcd_put_u8str(F(" ")); + } } -} -#endif + +#endif // HAS_COOLER #if ENABLED(LASER_COOLANT_FLOW_METER) FORCE_INLINE void _draw_flowmeter_status() { - lcd_put_u8str("~"); + lcd_put_u8str(F("~")); lcd_put_u8str(ftostr11ns(cooler.flowrate)); - lcd_put_lchar('L'); + lcd_put_u8str(F("L")); } #endif #if ENABLED(I2C_AMMETER) FORCE_INLINE void _draw_ammeter_status() { - lcd_put_u8str(" "); + lcd_put_u8str(F(" ")); ammeter.read(); if (ammeter.current <= 0.999f) { lcd_put_u8str(ui16tostr3rj(uint16_t(ammeter.current * 1000 + 0.5f))); - lcd_put_u8str("mA"); + lcd_put_u8str(F("mA")); } else { lcd_put_u8str(ftostr12ns(ammeter.current)); - lcd_put_lchar('A'); + lcd_put_u8str(F("A")); } } #endif @@ -612,6 +623,36 @@ FORCE_INLINE void _draw_bed_status(const bool blink) { _draw_heater_status(H_BED, TERN0(HAS_LEVELING, blink && planner.leveling_active) ? '_' : LCD_STR_BEDTEMP[0], blink); } +#if HAS_CUTTER + + FORCE_INLINE void _draw_cutter_status() { + lcd_put_u8str(TERN(LASER_FEATURE, GET_TEXT_F(MSG_LASER), GET_TEXT_F(MSG_CUTTER))); + lcd_put_u8str(F(": ")); + + #if CUTTER_UNIT_IS(RPM) + lcd_put_u8str(ftostr61rj(float(cutter.unitPower) / 1000)); + lcd_put_u8str(F("K")); + #else + lcd_put_u8str(cutter_power2str(cutter.unitPower)); + #if CUTTER_UNIT_IS(PERCENT) + lcd_put_u8str(F("%")); + #endif + #endif + + lcd_put_u8str(F(" ")); + lcd_put_u8str(cutter.enabled() ? GET_TEXT_F(MSG_LCD_ON) : GET_TEXT_F(MSG_LCD_OFF)); + lcd_put_u8str(F(" ")); + + switch (cutter.cutter_mode) { + case CUTTER_MODE_STANDARD: lcd_put_u8str(F("S")); break; + case CUTTER_MODE_CONTINUOUS: lcd_put_u8str(F("C")); break; + case CUTTER_MODE_DYNAMIC: lcd_put_u8str(F("D")); break; + case CUTTER_MODE_ERROR: lcd_put_u8str(F("!")); break; + } + } + +#endif // HAS_CUTTER + #if ENABLED(LCD_PROGRESS_BAR) void MarlinUI::draw_progress_bar(const uint8_t percent) { @@ -654,7 +695,7 @@ void MarlinUI::draw_status_message(const bool blink) { lcd_put_u8str(ftostr12ns(filwidth.measured_mm)); lcd_put_u8str(F(" V")); lcd_put_u8str(i16tostr3rj(planner.volumetric_percent(parser.volumetric_enabled))); - lcd_put_lchar('%'); + lcd_put_u8str(F("%")); return; } @@ -673,7 +714,7 @@ void MarlinUI::draw_status_message(const bool blink) { lcd_put_u8str(status_message); // Fill the rest with spaces - while (slen < LCD_WIDTH) { lcd_put_lchar(' '); ++slen; } + while (slen < LCD_WIDTH) { lcd_put_u8str(F(" ")); ++slen; } } else { // String is larger than the available space in screen. @@ -687,11 +728,11 @@ void MarlinUI::draw_status_message(const bool blink) { // If the remaining string doesn't completely fill the screen if (rlen < LCD_WIDTH) { uint8_t chars = LCD_WIDTH - rlen; // Amount of space left in characters - lcd_put_lchar(' '); // Always at 1+ spaces left, draw a space + lcd_put_u8str(F(" ")); // Always at 1+ spaces left, draw a space if (--chars) { // Draw a second space if there's room - lcd_put_lchar(' '); + lcd_put_u8str(F(" ")); if (--chars) { // Draw a third space if there's room - lcd_put_lchar(' '); + lcd_put_u8str(F(" ")); if (--chars) lcd_put_u8str_max(status_message, chars); // Print a second copy of the message } @@ -712,10 +753,7 @@ void MarlinUI::draw_status_message(const bool blink) { lcd_put_u8str_max(status_message, LCD_WIDTH); // Fill the rest with spaces if there are missing spaces - while (slen < LCD_WIDTH) { - lcd_put_lchar(' '); - ++slen; - } + for (; slen < LCD_WIDTH; ++slen) lcd_put_u8str(F(" ")); #endif } @@ -732,7 +770,7 @@ void MarlinUI::draw_status_message(const bool blink) { lcd_moveto(pc, pr); lcd_put_u8str(F(TERN(IS_SD_PRINTING, "SD", "P:"))); lcd_put_u8str(TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(ui.get_progress_permyriad()), ui8tostr3rj(progress))); - lcd_put_lchar('%'); + lcd_put_u8str(F("%")); } } #endif @@ -828,6 +866,15 @@ void MarlinUI::draw_status_screen() { lcd_moveto(8, 0); _draw_bed_status(blink); #endif + + #elif HAS_CUTTER + + // + // Cutter Status + // + lcd_moveto(0, 0); + _draw_cutter_status(); + #endif #else // LCD_WIDTH >= 20 @@ -848,6 +895,15 @@ void MarlinUI::draw_status_screen() { lcd_moveto(10, 0); _draw_bed_status(blink); #endif + + #elif HAS_CUTTER + + // + // Cutter Status + // + lcd_moveto(0, 0); + _draw_cutter_status(); + #endif TERN_(HAS_COOLER, _draw_cooler_status('*', blink)); @@ -920,7 +976,7 @@ void MarlinUI::draw_status_screen() { else { const xy_pos_t lpos = current_position.asLogical(); _draw_axis_value(X_AXIS, ftostr4sign(lpos.x), blink); - lcd_put_lchar(' '); + lcd_put_u8str(F(" ")); _draw_axis_value(Y_AXIS, ftostr4sign(lpos.y), blink); } @@ -945,7 +1001,7 @@ void MarlinUI::draw_status_screen() { lcd_put_lchar(0, 2, LCD_STR_FEEDRATE[0]); lcd_put_u8str(i16tostr3rj(feedrate_percentage)); - lcd_put_lchar('%'); + lcd_put_u8str(F("%")); #if LCD_WIDTH >= 20 @@ -978,7 +1034,7 @@ void MarlinUI::draw_status_screen() { } lcd_put_lchar(c); lcd_put_u8str(i16tostr3rj(per)); - lcd_put_lchar('%'); + lcd_put_u8str(F("%")); #endif #endif @@ -1017,7 +1073,7 @@ void MarlinUI::draw_status_screen() { lcd_put_lchar(LCD_WIDTH - 9, 1, LCD_STR_FEEDRATE[0]); lcd_put_u8str(i16tostr3rj(feedrate_percentage)); - lcd_put_lchar('%'); + lcd_put_u8str(F("%")); // ========== Line 3 ========== @@ -1075,18 +1131,18 @@ void MarlinUI::draw_status_screen() { vlen = vstr ? utf8_strlen(vstr) : 0; if (style & SS_CENTER) { int8_t pad = (LCD_WIDTH - plen - vlen) / 2; - while (--pad >= 0) { lcd_put_lchar(' '); n--; } + while (--pad >= 0) { lcd_put_u8str(F(" ")); n--; } } if (plen) n = lcd_put_u8str(fstr, itemIndex, itemStringC, itemStringF, n); if (vlen) n -= lcd_put_u8str_max(vstr, n); - for (; n > 0; --n) lcd_put_lchar(' '); + for (; n > 0; --n) lcd_put_u8str(F(" ")); } // Draw a generic menu item with pre_char (if selected) and post_char void MenuItemBase::_draw(const bool sel, const uint8_t row, FSTR_P const ftpl, const char pre_char, const char post_char) { lcd_put_lchar(0, row, sel ? pre_char : ' '); uint8_t n = lcd_put_u8str(ftpl, itemIndex, itemStringC, itemStringF, LCD_WIDTH - 2); - for (; n; --n) lcd_put_lchar(' '); + for (; n; --n) lcd_put_u8str(F(" ")); lcd_put_lchar(post_char); } @@ -1096,8 +1152,8 @@ void MarlinUI::draw_status_screen() { lcd_put_lchar(0, row, sel ? LCD_STR_ARROW_RIGHT[0] : ' '); uint8_t n = lcd_put_u8str(ftpl, itemIndex, itemStringC, itemStringF, LCD_WIDTH - 2 - vlen); if (vlen) { - lcd_put_lchar(':'); - for (; n; --n) lcd_put_lchar(' '); + lcd_put_u8str(F(":")); + for (; n; --n) lcd_put_u8str(F(" ")); if (pgm) lcd_put_u8str_P(inStr); else lcd_put_u8str(inStr); } } @@ -1107,7 +1163,7 @@ void MarlinUI::draw_status_screen() { ui.encoder_direction_normal(); uint8_t n = lcd_put_u8str(0, 1, ftpl, itemIndex, itemStringC, itemStringF, LCD_WIDTH - 1); if (value) { - lcd_put_lchar(':'); n--; + lcd_put_u8str(F(":")); n--; const uint8_t len = utf8_strlen(value) + 1; // Plus one for a leading space const lcd_uint_t valrow = n < len ? 2 : 1; // Value on the next row if it won't fit lcd_put_lchar(LCD_WIDTH - len, valrow, ' '); // Right-justified, padded, leading space @@ -1134,7 +1190,7 @@ void MarlinUI::draw_status_screen() { lcd_put_lchar(0, row, sel ? LCD_STR_ARROW_RIGHT[0] : ' '); constexpr uint8_t maxlen = LCD_WIDTH - 2; uint8_t n = maxlen - lcd_put_u8str_max(ui.scrolled_filename(theCard, maxlen, row, sel), maxlen); - for (; n; --n) lcd_put_lchar(' '); + for (; n; --n) lcd_put_u8str(F(" ")); lcd_put_lchar(isDir ? LCD_STR_FOLDER[0] : ' '); } @@ -1466,9 +1522,9 @@ void MarlinUI::draw_status_screen() { */ lcd_put_lchar(_LCD_W_POS, 0, '('); lcd_put_u8str(ui8tostr3rj(x_plot)); - lcd_put_lchar(','); + lcd_put_u8str(F(",")); lcd_put_u8str(ui8tostr3rj(y_plot)); - lcd_put_lchar(')'); + lcd_put_u8str(F(")")); #if LCD_HEIGHT <= 3 // 16x2 or 20x2 display diff --git a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp index 029a04bf97c8..1418edf5d17a 100644 --- a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp @@ -523,17 +523,14 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const #if !HEATER_IDLE_HANDLER UNUSED(blink); #else - if (!blink && thermalManager.heater_idle[thermalManager.idle_index_for_id(heater_id)].timed_out) { - lcd_put_lchar(' '); - if (t2 >= 10) lcd_put_lchar(' '); - if (t2 >= 100) lcd_put_lchar(' '); - } + if (!blink && thermalManager.heater_idle[thermalManager.idle_index_for_id(heater_id)].timed_out) + lcd_put_u8str(F(" ")); else #endif lcd_put_u8str(i16tostr3left(t2)); - lcd_put_lchar(' '); - if (t2 < 10) lcd_put_lchar(' '); + lcd_put_u8str(F(" ")); + if (t2 < 10) lcd_put_u8str(F(" ")); if (t2) picBits |= ICON_TEMP1; else picBits &= ~ICON_TEMP1; @@ -545,7 +542,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const FORCE_INLINE void _draw_flowmeter_status() { lcd_moveto(5, 5); lcd_put_u8str(F("FLOW")); - lcd_moveto(7, 6); lcd_put_lchar('L'); + lcd_moveto(7, 6); lcd_put_u8str(F("L")); lcd_moveto(6, 7); lcd_put_u8str(ftostr11ns(cooler.flowrate)); if (cooler.flowrate) picBits |= ICON_FAN; @@ -564,7 +561,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const { lcd_put_u8str("mA"); lcd_moveto(10, 7); - lcd_put_lchar(' '); lcd_put_u8str(ui16tostr3rj(uint16_t(ammeter.current * 1000 + 0.5f))); + lcd_put_u8str(F(" ")); lcd_put_u8str(ui16tostr3rj(uint16_t(ammeter.current * 1000 + 0.5f))); } else { lcd_put_u8str(" A"); @@ -585,9 +582,9 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const #if CUTTER_UNIT_IS(RPM) lcd_moveto(16, 6); lcd_put_u8str(F("RPM")); lcd_moveto(15, 7); lcd_put_u8str(ftostr31ns(float(cutter.unitPower) / 1000)); - lcd_put_lchar('K'); + lcd_put_u8str(F("K")); #elif CUTTER_UNIT_IS(PERCENT) - lcd_moveto(17, 6); lcd_put_lchar('%'); + lcd_moveto(17, 6); lcd_put_u8str(F("%")); lcd_moveto(18, 7); lcd_put_u8str(cutter_power2str(cutter.unitPower)); #else lcd_moveto(17, 7); lcd_put_u8str(cutter_power2str(cutter.unitPower)); diff --git a/Marlin/src/lcd/dogm/lcdprint_u8g.cpp b/Marlin/src/lcd/dogm/lcdprint_u8g.cpp index 48b2e92a118d..74a49b095021 100644 --- a/Marlin/src/lcd/dogm/lcdprint_u8g.cpp +++ b/Marlin/src/lcd/dogm/lcdprint_u8g.cpp @@ -34,7 +34,7 @@ int lcd_put_lchar_max(const lchar_t &c, const pixel_len_t max_length) { return u8g_GetFontBBXWidth(u8g.getU8g()); } u8g_uint_t x = u8g.getPrintCol(), y = u8g.getPrintRow(), - ret = uxg_DrawWchar(u8g.getU8g(), x, y, c, max_length); + ret = uxg_DrawLchar(u8g.getU8g(), x, y, c, max_length); u8g.setPrintPos(x + ret, y); return ret; } diff --git a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp index b72a1ac9263b..1a86058b943c 100644 --- a/Marlin/src/lcd/dogm/marlinui_DOGM.cpp +++ b/Marlin/src/lcd/dogm/marlinui_DOGM.cpp @@ -372,9 +372,9 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop lcd_put_lchar(LCD_PIXEL_WIDTH - 11 * (MENU_FONT_WIDTH), y2, 'E'); lcd_put_lchar((char)('1' + extruder)); - lcd_put_lchar(' '); + lcd_put_u8str(F(" ")); lcd_put_u8str(i16tostr3rj(thermalManager.wholeDegHotend(extruder))); - lcd_put_lchar('/'); + lcd_put_u8str(F("/")); if (get_blink() || !thermalManager.heater_idle[extruder].timed_out) lcd_put_u8str(i16tostr3rj(thermalManager.degTargetHotend(extruder))); @@ -420,12 +420,12 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop vlen = vstr ? utf8_strlen(vstr) : 0; if (style & SS_CENTER) { int pad = (LCD_PIXEL_WIDTH - plen - vlen * MENU_FONT_WIDTH) / MENU_FONT_WIDTH / 2; - while (--pad >= 0) n -= lcd_put_lchar(' '); + while (--pad >= 0) n -= lcd_put_u8str(F(" ")); } if (plen) n = lcd_put_u8str(ftpl, itemIndex, itemStringC, itemStringF, n / (MENU_FONT_WIDTH)) * (MENU_FONT_WIDTH); if (vlen) n -= lcd_put_u8str_max(vstr, n); - while (n > MENU_FONT_WIDTH) n -= lcd_put_lchar(' '); + while (n > MENU_FONT_WIDTH) n -= lcd_put_u8str(F(" ")); } } @@ -433,9 +433,9 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop void MenuItemBase::_draw(const bool sel, const uint8_t row, FSTR_P const ftpl, const char, const char post_char) { if (mark_as_selected(row, sel)) { pixel_len_t n = lcd_put_u8str(ftpl, itemIndex, itemStringC, itemStringF, LCD_WIDTH - 1) * (MENU_FONT_WIDTH); - while (n > MENU_FONT_WIDTH) n -= lcd_put_lchar(' '); + while (n > MENU_FONT_WIDTH) n -= lcd_put_u8str(F(" ")); lcd_put_lchar(LCD_PIXEL_WIDTH - (MENU_FONT_WIDTH), row_y2, post_char); - lcd_put_lchar(' '); + lcd_put_u8str(F(" ")); } } @@ -448,8 +448,8 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop pixel_len_t n = lcd_put_u8str(ftpl, itemIndex, itemStringC, itemStringF, LCD_WIDTH - 2 - vallen * prop) * (MENU_FONT_WIDTH); if (vallen) { - lcd_put_lchar(':'); - while (n > MENU_FONT_WIDTH) n -= lcd_put_lchar(' '); + lcd_put_u8str(F(":")); + while (n > MENU_FONT_WIDTH) n -= lcd_put_u8str(F(" ")); lcd_moveto(LCD_PIXEL_WIDTH - _MAX((MENU_FONT_WIDTH) * vallen, pixelwidth + 2), row_y2); if (pgm) lcd_put_u8str_P(inStr); else lcd_put_u8str(inStr); } @@ -493,7 +493,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop // If a value is included, print a colon, then print the value right-justified if (value) { - lcd_put_lchar(':'); + lcd_put_u8str(F(":")); if (extra_row) { // Assume that value is numeric (with no descender) baseline += EDIT_FONT_ASCENT + 2; @@ -535,7 +535,7 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop if (isDir) lcd_put_lchar(LCD_STR_FOLDER[0]); const pixel_len_t pixw = maxlen * (MENU_FONT_WIDTH); pixel_len_t n = pixw - lcd_put_u8str_max(ui.scrolled_filename(theCard, maxlen, row, sel), pixw); - while (n > MENU_FONT_WIDTH) n -= lcd_put_lchar(' '); + while (n > MENU_FONT_WIDTH) n -= lcd_put_u8str(F(" ")); } } @@ -612,9 +612,9 @@ void MarlinUI::clear_lcd() { } // Automatically cleared by Picture Loop if (PAGE_CONTAINS(LCD_PIXEL_HEIGHT - (INFO_FONT_HEIGHT - 1), LCD_PIXEL_HEIGHT)) { lcd_put_lchar(5, LCD_PIXEL_HEIGHT, '('); u8g.print(x_plot); - lcd_put_lchar(','); + lcd_put_u8str(F(",")); u8g.print(y_plot); - lcd_put_lchar(')'); + lcd_put_u8str(F(")")); // Show the location value lcd_put_u8str_P(74, LCD_PIXEL_HEIGHT, Z_LBL); diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index 83f492e124c4..4283ab59cbde 100644 --- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -455,7 +455,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const void MarlinUI::drawPercent() { if (progress_string[0]) { lcd_put_u8str(progress_x_pos, EXTRAS_BASELINE, progress_string); - lcd_put_lchar('%'); + lcd_put_u8str(F("%")); } } #endif @@ -705,7 +705,7 @@ void MarlinUI::draw_status_screen() { lcd_put_u8str(STATUS_CUTTER_TEXT_X, STATUS_CUTTER_TEXT_Y, cutter_power2str(cutter.unitPower)); #elif CUTTER_UNIT_IS(RPM) lcd_put_u8str(STATUS_CUTTER_TEXT_X - 2, STATUS_CUTTER_TEXT_Y, ftostr61rj(float(cutter.unitPower) / 1000)); - lcd_put_lchar('K'); + lcd_put_u8str(F("K")); #else lcd_put_u8str(STATUS_CUTTER_TEXT_X, STATUS_CUTTER_TEXT_Y, cutter_power2str(cutter.unitPower)); #endif @@ -892,7 +892,7 @@ void MarlinUI::draw_status_screen() { set_font(FONT_STATUSMENU); lcd_put_u8str(12, EXTRAS_2_BASELINE, i16tostr3rj(feedrate_percentage)); - lcd_put_lchar('%'); + lcd_put_u8str(F("%")); // // Filament sensor display if SD is disabled @@ -900,7 +900,7 @@ void MarlinUI::draw_status_screen() { #if ENABLED(FILAMENT_LCD_DISPLAY) && DISABLED(SDSUPPORT) lcd_put_u8str(56, EXTRAS_2_BASELINE, wstring); lcd_put_u8str(102, EXTRAS_2_BASELINE, mstring); - lcd_put_lchar('%'); + lcd_put_u8str(F("%")); set_font(FONT_MENU); lcd_put_lchar(47, EXTRAS_2_BASELINE, LCD_STR_FILAM_DIA[0]); // lcd_put_u8str(F(LCD_STR_FILAM_DIA)); lcd_put_lchar(93, EXTRAS_2_BASELINE, LCD_STR_FILAM_MUL[0]); @@ -917,12 +917,12 @@ void MarlinUI::draw_status_screen() { // Alternate Status message and Filament display if (ELAPSED(millis(), next_filament_display)) { lcd_put_u8str(F(LCD_STR_FILAM_DIA)); - lcd_put_lchar(':'); + lcd_put_u8str(F(":")); lcd_put_u8str(wstring); lcd_put_u8str(F(" " LCD_STR_FILAM_MUL)); - lcd_put_lchar(':'); + lcd_put_u8str(F(":")); lcd_put_u8str(mstring); - lcd_put_lchar('%'); + lcd_put_u8str(F("%")); return; } #endif @@ -955,7 +955,7 @@ void MarlinUI::draw_status_message(const bool blink) { if (slen <= lcd_width) { // The string fits within the line. Print with no scrolling lcd_put_u8str(status_message); - while (slen < lcd_width) { lcd_put_lchar(' '); ++slen; } + while (slen < lcd_width) { lcd_put_u8str(F(" ")); ++slen; } } else { // String is longer than the available space @@ -973,14 +973,14 @@ void MarlinUI::draw_status_message(const bool blink) { // If the remaining string doesn't completely fill the screen if (rlen < lcd_width) { uint8_t chars = lcd_width - rlen; // Amount of space left in characters - lcd_put_lchar(' '); // Always at 1+ spaces left, draw a space + lcd_put_u8str(F(" ")); // Always at 1+ spaces left, draw a space if (--chars) { // Draw a second space if there's room - lcd_put_lchar(' '); + lcd_put_u8str(F(" ")); if (--chars) { // Draw a third space if there's room - lcd_put_lchar(' '); + lcd_put_u8str(F(" ")); if (--chars) { // Print a second copy of the message lcd_put_u8str_max(status_message, pixel_width - (rlen + 2) * (MENU_FONT_WIDTH)); - lcd_put_lchar(' '); + lcd_put_u8str(F(" ")); } } } @@ -995,7 +995,7 @@ void MarlinUI::draw_status_message(const bool blink) { lcd_put_u8str_max(status_message, pixel_width); // Fill the rest with spaces - for (; slen < lcd_width; ++slen) lcd_put_lchar(' '); + for (; slen < lcd_width; ++slen) lcd_put_u8str(F(" ")); #endif // !STATUS_MESSAGE_SCROLLING diff --git a/Marlin/src/lcd/dogm/u8g_fontutf8.cpp b/Marlin/src/lcd/dogm/u8g_fontutf8.cpp index d5e0e5bafff3..e9d15350963a 100644 --- a/Marlin/src/lcd/dogm/u8g_fontutf8.cpp +++ b/Marlin/src/lcd/dogm/u8g_fontutf8.cpp @@ -161,7 +161,7 @@ static int fontgroup_cb_draw_u8g(void *userdata, const font_t *fnt_current, cons * * Draw a UTF-8 string at the specified position */ -unsigned int uxg_DrawWchar(u8g_t *pu8g, unsigned int x, unsigned int y, const lchar_t &wc, pixel_len_t max_width) { +unsigned int uxg_DrawLchar(u8g_t *pu8g, unsigned int x, unsigned int y, const lchar_t &wc, pixel_len_t max_width) { struct _uxg_drawu8_data_t data; font_group_t *group = &g_fontgroup_root; const font_t *fnt_default = uxg_GetFont(pu8g); diff --git a/Marlin/src/lcd/dogm/u8g_fontutf8.h b/Marlin/src/lcd/dogm/u8g_fontutf8.h index 0109b6674cbe..660eb28ffeb3 100644 --- a/Marlin/src/lcd/dogm/u8g_fontutf8.h +++ b/Marlin/src/lcd/dogm/u8g_fontutf8.h @@ -26,7 +26,7 @@ typedef struct _uxg_fontinfo_t { int uxg_SetUtf8Fonts(const uxg_fontinfo_t * fntinfo, int number); // fntinfo is type of PROGMEM -unsigned int uxg_DrawWchar(u8g_t *pu8g, unsigned int x, unsigned int y, const lchar_t &ch, const pixel_len_t max_length); +unsigned int uxg_DrawLchar(u8g_t *pu8g, unsigned int x, unsigned int y, const lchar_t &ch, const pixel_len_t max_length); unsigned int uxg_DrawUtf8Str(u8g_t *pu8g, unsigned int x, unsigned int y, const char *utf8_msg, const pixel_len_t max_length); unsigned int uxg_DrawUtf8StrP(u8g_t *pu8g, unsigned int x, unsigned int y, PGM_P utf8_msg, const pixel_len_t max_length); diff --git a/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp b/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp index ab21c7be4a9c..560b30be0ad9 100644 --- a/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/ui_common.cpp @@ -213,7 +213,7 @@ void MarlinUI::draw_status_message(const bool blink) { lcd_put_u8str(status_message); // Fill the rest with spaces - while (slen < max_status_chars) { lcd_put_lchar(' '); ++slen; } + while (slen < max_status_chars) { lcd_put_u8str(F(" ")); ++slen; } } } else { @@ -227,10 +227,10 @@ void MarlinUI::draw_status_message(const bool blink) { // If the string doesn't completely fill the line... if (rlen < max_status_chars) { - lcd_put_lchar('.'); // Always at 1+ spaces left, draw a dot + lcd_put_u8str(F(".")); // Always at 1+ spaces left, draw a dot uint8_t chars = max_status_chars - rlen; // Amount of space left in characters if (--chars) { // Draw a second dot if there's space - lcd_put_lchar('.'); + lcd_put_u8str(F(".")); if (--chars) lcd_put_u8str_max(status_message, chars); // Print a second copy of the message } @@ -254,7 +254,7 @@ void MarlinUI::draw_status_message(const bool blink) { lcd_put_u8str_max(status_message, max_status_chars); // Fill the rest with spaces if there are missing spaces - while (slen < max_status_chars) { lcd_put_lchar(' '); ++slen; } + while (slen < max_status_chars) { lcd_put_u8str(F(" ")); ++slen; } } #endif diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index c888207ed123..8db5032bf3ec 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -332,6 +332,7 @@ namespace Language_en { LSTR MSG_COOLER = _UxGT("Laser Coolant"); LSTR MSG_COOLER_TOGGLE = _UxGT("Toggle Cooler"); LSTR MSG_FLOWMETER_SAFETY = _UxGT("Flow Safety"); + LSTR MSG_CUTTER = _UxGT("Cutter"); LSTR MSG_LASER = _UxGT("Laser"); LSTR MSG_FAN_SPEED = _UxGT("Fan Speed"); LSTR MSG_FAN_SPEED_N = _UxGT("Fan Speed ~"); diff --git a/Marlin/src/lcd/lcdprint.cpp b/Marlin/src/lcd/lcdprint.cpp index 7757379ac9d2..650824e553bc 100644 --- a/Marlin/src/lcd/lcdprint.cpp +++ b/Marlin/src/lcd/lcdprint.cpp @@ -52,7 +52,7 @@ lcd_uint_t lcd_put_u8str_P(PGM_P const ptpl, const int8_t ind, const char *cstr/ if (!wc) break; if (wc == '=' || wc == '~' || wc == '*') { if (ind >= 0) { - if (wc == '*') { lcd_put_lchar('E'); n--; } + if (wc == '*') { lcd_put_u8str(F("E")); n--; } if (n) { int8_t inum = ind + ((wc == '=') ? 0 : LCD_FIRST_TOOL); if (inum >= 10) { diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index c4a63dafc6ac..0e0051e65d6c 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -178,7 +178,7 @@ static void _lcd_level_bed_corners_get_next_position() { lcd_put_u8str(GET_TEXT_F(MSG_BED_TRAMMING_GOOD_POINTS)); IF_ENABLED(TFT_COLOR_UI, lcd_moveto(12, cy)); lcd_put_u8str(GOOD_POINTS_TO_STR(good_points)); - lcd_put_lchar('/'); + lcd_put_u8str(F("/")); lcd_put_u8str(GOOD_POINTS_TO_STR(nr_edge_points)); } diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 7ae199dfd6e9..e50cd69f6302 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -79,7 +79,7 @@ void menu_advanced_settings(); LIMIT(bar_percent, 0, 100); ui.encoderPosition = 0; MenuItem_static::draw(0, GET_TEXT_F(MSG_PROGRESS_BAR_TEST), SS_DEFAULT|SS_INVERT); - lcd_put_int((LCD_WIDTH) / 2 - 2, LCD_HEIGHT - 2, bar_percent); lcd_put_lchar('%'); + lcd_put_int((LCD_WIDTH) / 2 - 2, LCD_HEIGHT - 2, bar_percent); lcd_put_u8str(F("%")); lcd_moveto(0, LCD_HEIGHT - 1); ui.draw_progress_bar(bar_percent); } diff --git a/Marlin/src/lcd/menu/menu_password.cpp b/Marlin/src/lcd/menu/menu_password.cpp index d29b77311fd3..b50194d60dc8 100644 --- a/Marlin/src/lcd/menu/menu_password.cpp +++ b/Marlin/src/lcd/menu/menu_password.cpp @@ -61,10 +61,10 @@ void Password::menu_password_entry() { FSTR_P const label = GET_TEXT_F(MSG_ENTER_DIGIT); EDIT_ITEM_F(uint8, label, &editable.uint8, 0, 9, digit_entered); MENU_ITEM_ADDON_START(utf8_strlen(label) + 1); - lcd_put_lchar(' '); + lcd_put_u8str(F(" ")); lcd_put_lchar('1' + digit_no); SETCURSOR_X(LCD_WIDTH - 2); - lcd_put_lchar('>'); + lcd_put_u8str(F(">")); MENU_ITEM_ADDON_END(); ACTION_ITEM(MSG_START_OVER, start_over); diff --git a/Marlin/src/lcd/menu/menu_spindle_laser.cpp b/Marlin/src/lcd/menu/menu_spindle_laser.cpp index a6f99546f691..de16316987e6 100644 --- a/Marlin/src/lcd/menu/menu_spindle_laser.cpp +++ b/Marlin/src/lcd/menu/menu_spindle_laser.cpp @@ -79,7 +79,7 @@ EDIT_ITEM_FAST(CUTTER_MENU_PULSE_TYPE, MSG_LASER_PULSE_MS, &cutter.testPulse, LASER_TEST_PULSE_MIN, LASER_TEST_PULSE_MAX); ACTION_ITEM(MSG_LASER_FIRE_PULSE, cutter.test_fire_pulse); #if ENABLED(HAL_CAN_SET_PWM_FREQ) && SPINDLE_LASER_FREQUENCY - EDIT_ITEM_FAST(CUTTER_MENU_FREQUENCY_TYPE, MSG_CUTTER_FREQUENCY, &cutter.frequency, 2000, 80000, cutter.refresh_frequency); + EDIT_ITEM_FAST(CUTTER_MENU_FREQUENCY_TYPE, MSG_CUTTER_FREQUENCY, &cutter.frequency, 2000, 65535, cutter.refresh_frequency); #endif #endif END_MENU(); diff --git a/Marlin/src/lcd/menu/menu_tune.cpp b/Marlin/src/lcd/menu/menu_tune.cpp index 79d87bb6ca92..423af4e5a1eb 100644 --- a/Marlin/src/lcd/menu/menu_tune.cpp +++ b/Marlin/src/lcd/menu/menu_tune.cpp @@ -76,12 +76,12 @@ #if ENABLED(TFT_COLOR_UI) lcd_moveto(4, 3); lcd_put_u8str(GET_TEXT_F(MSG_BABYSTEP_TOTAL)); - lcd_put_lchar(':'); + lcd_put_u8str(F(":")); lcd_moveto(10, 3); #else lcd_moveto(0, TERN(HAS_MARLINUI_U8GLIB, LCD_PIXEL_HEIGHT - MENU_FONT_DESCENT, LCD_HEIGHT - 1)); lcd_put_u8str(GET_TEXT_F(MSG_BABYSTEP_TOTAL)); - lcd_put_lchar(':'); + lcd_put_u8str(F(":")); #endif lcd_put_u8str(BABYSTEP_TO_STR(mps * babystep.axis_total[BS_TOTAL_IND(axis)])); } diff --git a/buildroot/tests/BIGTREE_SKR_PRO b/buildroot/tests/BIGTREE_SKR_PRO index 2f1075c7ef22..3ffc9857a823 100755 --- a/buildroot/tests/BIGTREE_SKR_PRO +++ b/buildroot/tests/BIGTREE_SKR_PRO @@ -27,7 +27,7 @@ opt_set MOTHERBOARD BOARD_BTT_SKR_PRO_V1_1 SERIAL_PORT -1 \ SPINDLE_LASER_PWM_PIN HEATER_1_PIN SPINDLE_LASER_ENA_PIN HEATER_2_PIN \ TEMP_SENSOR_COOLER 1000 TEMP_COOLER_PIN PD13 opt_enable LASER_FEATURE LASER_SAFETY_TIMEOUT_MS REPRAP_DISCOUNT_SMART_CONTROLLER -exec_test $1 $2 "BigTreeTech SKR Pro | Laser (Percent) | Cooling | LCD" "$3" +exec_test $1 $2 "BigTreeTech SKR Pro | HD44780 | Laser (Percent) | Cooling | LCD" "$3" # clean up restore_configs diff --git a/buildroot/tests/mega2560 b/buildroot/tests/mega2560 index 333be2f0faae..18a6ea88c98b 100755 --- a/buildroot/tests/mega2560 +++ b/buildroot/tests/mega2560 @@ -268,12 +268,12 @@ opt_set MOTHERBOARD BOARD_RAMPS_14_EFB opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER \ SET_PROGRESS_MANUALLY SET_PROGRESS_PERCENT SET_REMAINING_TIME SET_INTERACTION_TIME M73_REPORT \ SHOW_PROGRESS_PERCENT SHOW_ELAPSED_TIME SHOW_REMAINING_TIME SHOW_INTERACTION_TIME PRINT_PROGRESS_SHOW_DECIMALS -exec_test $1 $2 "MEGA2560 RAMPS | 12864 | progress rotation" "$3" +exec_test $1 $2 "MEGA2560 RAMPS | 128x64 | progress rotation" "$3" opt_enable LIGHTWEIGHT_UI -exec_test $1 $2 "MEGA2560 RAMPS | 12864 LIGHTWEIGHT_UI | progress rotation" "$3" +exec_test $1 $2 "MEGA2560 RAMPS | 128x64 LIGHTWEIGHT_UI | progress rotation" "$3" opt_disable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER -exec_test $1 $2 "MEGA2560 RAMPS | 44780 | progress rotation" "$3" +exec_test $1 $2 "MEGA2560 RAMPS | HD44780 | progress rotation" "$3" # clean up restore_configs From 7d0f1dd17cbc0b2a34f720d5deaf83c8e8888def Mon Sep 17 00:00:00 2001 From: mikemerryguy <57319047+mikemerryguy@users.noreply.github.com> Date: Sat, 26 Nov 2022 20:14:05 -0500 Subject: [PATCH 157/243] =?UTF-8?q?=F0=9F=9A=B8=20Add=2050mm=20manual=20mo?= =?UTF-8?q?ve=20(#24884)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/language/language_an.h | 1 + Marlin/src/lcd/language/language_bg.h | 1 + Marlin/src/lcd/language/language_ca.h | 1 + Marlin/src/lcd/language/language_cz.h | 1 + Marlin/src/lcd/language/language_da.h | 1 + Marlin/src/lcd/language/language_de.h | 1 + Marlin/src/lcd/language/language_el.h | 1 + Marlin/src/lcd/language/language_el_gr.h | 1 + Marlin/src/lcd/language/language_en.h | 2 ++ Marlin/src/lcd/language/language_es.h | 1 + Marlin/src/lcd/language/language_eu.h | 1 + Marlin/src/lcd/language/language_fi.h | 1 + Marlin/src/lcd/language/language_fr.h | 2 ++ Marlin/src/lcd/language/language_gl.h | 1 + Marlin/src/lcd/language/language_hr.h | 1 + Marlin/src/lcd/language/language_hu.h | 2 ++ Marlin/src/lcd/language/language_it.h | 2 ++ Marlin/src/lcd/language/language_jp_kana.h | 1 + Marlin/src/lcd/language/language_zh_TW.h | 1 + Marlin/src/lcd/menu/menu_motion.cpp | 25 ++++++++++++++++--- .../src/pins/stm32f4/pins_MKS_MONSTER8_V2.h | 8 +++--- 21 files changed, 49 insertions(+), 7 deletions(-) diff --git a/Marlin/src/lcd/language/language_an.h b/Marlin/src/lcd/language/language_an.h index 37c90c34daf9..8e65f3801285 100644 --- a/Marlin/src/lcd/language/language_an.h +++ b/Marlin/src/lcd/language/language_an.h @@ -90,6 +90,7 @@ namespace Language_an { LSTR MSG_MOVE_01MM = _UxGT("Mover 0.1mm"); LSTR MSG_MOVE_1MM = _UxGT("Mover 1mm"); LSTR MSG_MOVE_10MM = _UxGT("Mover 10mm"); + LSTR MSG_MOVE_50MM = _UxGT("Mover 50mm"); LSTR MSG_MOVE_100MM = _UxGT("Mover 100mm"); LSTR MSG_SPEED = _UxGT("Velocidat"); LSTR MSG_BED_Z = _UxGT("Base Z"); diff --git a/Marlin/src/lcd/language/language_bg.h b/Marlin/src/lcd/language/language_bg.h index 038df3eccbb6..312ada7b10cd 100644 --- a/Marlin/src/lcd/language/language_bg.h +++ b/Marlin/src/lcd/language/language_bg.h @@ -79,6 +79,7 @@ namespace Language_bg { LSTR MSG_MOVE_01MM = _UxGT("Премести с 0.1mm"); LSTR MSG_MOVE_1MM = _UxGT("Премести с 1mm"); LSTR MSG_MOVE_10MM = _UxGT("Премести с 10mm"); + LSTR MSG_MOVE_50MM = _UxGT("Премести с 50mm"); LSTR MSG_MOVE_100MM = _UxGT("Премести с 100mm"); LSTR MSG_SPEED = _UxGT("Скорост"); LSTR MSG_BED_Z = _UxGT("Bed Z"); diff --git a/Marlin/src/lcd/language/language_ca.h b/Marlin/src/lcd/language/language_ca.h index 54b968ede241..d3a1c2eac1bb 100644 --- a/Marlin/src/lcd/language/language_ca.h +++ b/Marlin/src/lcd/language/language_ca.h @@ -90,6 +90,7 @@ namespace Language_ca { LSTR MSG_MOVE_01MM = _UxGT("Mou 0.1mm"); LSTR MSG_MOVE_1MM = _UxGT("Mou 1mm"); LSTR MSG_MOVE_10MM = _UxGT("Mou 10mm"); + LSTR MSG_MOVE_50MM = _UxGT("Mou 50mm"); LSTR MSG_MOVE_100MM = _UxGT("Mou 100mm"); LSTR MSG_SPEED = _UxGT("Velocitat"); LSTR MSG_BED_Z = _UxGT("Llit Z"); diff --git a/Marlin/src/lcd/language/language_cz.h b/Marlin/src/lcd/language/language_cz.h index 9c5bafc96ec5..50d490a6c2eb 100644 --- a/Marlin/src/lcd/language/language_cz.h +++ b/Marlin/src/lcd/language/language_cz.h @@ -240,6 +240,7 @@ namespace Language_cz { LSTR MSG_MOVE_01MM = _UxGT("Posunout o 0,1mm"); LSTR MSG_MOVE_1MM = _UxGT("Posunout o 1mm"); LSTR MSG_MOVE_10MM = _UxGT("Posunout o 10mm"); + LSTR MSG_MOVE_50MM = _UxGT("Posunout o 50mm"); LSTR MSG_MOVE_100MM = _UxGT("Posunout o 100mm"); LSTR MSG_SPEED = _UxGT("Rychlost"); LSTR MSG_BED_Z = _UxGT("Výška podl."); diff --git a/Marlin/src/lcd/language/language_da.h b/Marlin/src/lcd/language/language_da.h index b4afca9d99a8..4078c413d110 100644 --- a/Marlin/src/lcd/language/language_da.h +++ b/Marlin/src/lcd/language/language_da.h @@ -81,6 +81,7 @@ namespace Language_da { LSTR MSG_MOVE_01MM = _UxGT("Flyt 0.1mm"); LSTR MSG_MOVE_1MM = _UxGT("Flyt 1mm"); LSTR MSG_MOVE_10MM = _UxGT("Flyt 10mm"); + LSTR MSG_MOVE_50MM = _UxGT("Flyt 50mm"); LSTR MSG_MOVE_100MM = _UxGT("Flyt 100mm"); LSTR MSG_SPEED = _UxGT("Hastighed"); LSTR MSG_BED_Z = _UxGT("Plade Z"); diff --git a/Marlin/src/lcd/language/language_de.h b/Marlin/src/lcd/language/language_de.h index 9939ea3f4429..c2af37fc7777 100644 --- a/Marlin/src/lcd/language/language_de.h +++ b/Marlin/src/lcd/language/language_de.h @@ -301,6 +301,7 @@ namespace Language_de { LSTR MSG_MOVE_01MM = _UxGT(" 0,1 mm"); LSTR MSG_MOVE_1MM = _UxGT(" 1,0 mm"); LSTR MSG_MOVE_10MM = _UxGT(" 10,0 mm"); + LSTR MSG_MOVE_50MM = _UxGT(" 50,0 mm"); LSTR MSG_MOVE_100MM = _UxGT("100,0 mm"); LSTR MSG_MOVE_0001IN = _UxGT("0.001 in"); LSTR MSG_MOVE_001IN = _UxGT("0.010 in"); diff --git a/Marlin/src/lcd/language/language_el.h b/Marlin/src/lcd/language/language_el.h index 41b73ddc571d..2d7c42b2fa13 100644 --- a/Marlin/src/lcd/language/language_el.h +++ b/Marlin/src/lcd/language/language_el.h @@ -99,6 +99,7 @@ namespace Language_el { LSTR MSG_MOVE_01MM = _UxGT("Μετακίνηση 0,1 μμ"); LSTR MSG_MOVE_1MM = _UxGT("Μετακίνηση 1 μμ"); LSTR MSG_MOVE_10MM = _UxGT("Μετακίνηση 10 μμ"); + LSTR MSG_MOVE_50MM = _UxGT("Μετακίνηση 50 μμ"); LSTR MSG_MOVE_100MM = _UxGT("Μετακίνηση 100 μμ"); LSTR MSG_SPEED = _UxGT("Ταχύτητα"); LSTR MSG_BED_Z = _UxGT("Επ. Εκτύπωσης Z"); diff --git a/Marlin/src/lcd/language/language_el_gr.h b/Marlin/src/lcd/language/language_el_gr.h index 7306aab1235a..a76870d2a325 100644 --- a/Marlin/src/lcd/language/language_el_gr.h +++ b/Marlin/src/lcd/language/language_el_gr.h @@ -88,6 +88,7 @@ namespace Language_el_gr { LSTR MSG_MOVE_01MM = _UxGT("Μετακίνηση 0,1 μμ"); LSTR MSG_MOVE_1MM = _UxGT("Μετακίνηση 1 μμ"); LSTR MSG_MOVE_10MM = _UxGT("Μετακίνηση 10 μμ"); + LSTR MSG_MOVE_50MM = _UxGT("Μετακίνηση 50 μμ"); LSTR MSG_MOVE_100MM = _UxGT("Μετακίνηση 100 μμ"); LSTR MSG_SPEED = _UxGT("Ταχύτητα"); LSTR MSG_BED_Z = _UxGT("Κλίνη Z"); diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 8db5032bf3ec..2ecf2def1224 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -316,10 +316,12 @@ namespace Language_en { LSTR MSG_MOVE_01MM = _UxGT("Move 0.1mm"); LSTR MSG_MOVE_1MM = _UxGT("Move 1mm"); LSTR MSG_MOVE_10MM = _UxGT("Move 10mm"); + LSTR MSG_MOVE_50MM = _UxGT("Move 50mm"); LSTR MSG_MOVE_100MM = _UxGT("Move 100mm"); LSTR MSG_MOVE_0001IN = _UxGT("Move 0.001in"); LSTR MSG_MOVE_001IN = _UxGT("Move 0.01in"); LSTR MSG_MOVE_01IN = _UxGT("Move 0.1in"); + LSTR MSG_MOVE_05IN = _UxGT("Move 0.5in"); LSTR MSG_MOVE_1IN = _UxGT("Move 1.0in"); LSTR MSG_SPEED = _UxGT("Speed"); LSTR MSG_BED_Z = _UxGT("Bed Z"); diff --git a/Marlin/src/lcd/language/language_es.h b/Marlin/src/lcd/language/language_es.h index 5f88f8426d11..5422a8117ba1 100644 --- a/Marlin/src/lcd/language/language_es.h +++ b/Marlin/src/lcd/language/language_es.h @@ -234,6 +234,7 @@ namespace Language_es { LSTR MSG_MOVE_01MM = _UxGT("Mover 0.1mm"); LSTR MSG_MOVE_1MM = _UxGT("Mover 1mm"); LSTR MSG_MOVE_10MM = _UxGT("Mover 10mm"); + LSTR MSG_MOVE_50MM = _UxGT("Mover 50mm"); LSTR MSG_MOVE_100MM = _UxGT("Mover 100mm"); LSTR MSG_SPEED = _UxGT("Velocidad"); LSTR MSG_BED_Z = _UxGT("Cama Z"); diff --git a/Marlin/src/lcd/language/language_eu.h b/Marlin/src/lcd/language/language_eu.h index 210fdbdc168e..77c8dbe2d870 100644 --- a/Marlin/src/lcd/language/language_eu.h +++ b/Marlin/src/lcd/language/language_eu.h @@ -143,6 +143,7 @@ namespace Language_eu { LSTR MSG_MOVE_01MM = _UxGT("Mugitu 0.1mm"); LSTR MSG_MOVE_1MM = _UxGT("Mugitu 1mm"); LSTR MSG_MOVE_10MM = _UxGT("Mugitu 10mm"); + LSTR MSG_MOVE_50MM = _UxGT("Mugitu 50mm"); LSTR MSG_MOVE_100MM = _UxGT("Mugitu 100mm"); LSTR MSG_SPEED = _UxGT("Abiadura"); LSTR MSG_BED_Z = _UxGT("Z Ohea"); diff --git a/Marlin/src/lcd/language/language_fi.h b/Marlin/src/lcd/language/language_fi.h index ff1c23eee7e6..300da9b95652 100644 --- a/Marlin/src/lcd/language/language_fi.h +++ b/Marlin/src/lcd/language/language_fi.h @@ -76,6 +76,7 @@ namespace Language_fi { LSTR MSG_MOVE_01MM = _UxGT("Liikuta 0.1mm"); LSTR MSG_MOVE_1MM = _UxGT("Liikuta 1mm"); LSTR MSG_MOVE_10MM = _UxGT("Liikuta 10mm"); + LSTR MSG_MOVE_50MM = _UxGT("Liikuta 50mm"); LSTR MSG_MOVE_100MM = _UxGT("Liikuta 100mm"); LSTR MSG_SPEED = _UxGT("Nopeus"); LSTR MSG_NOZZLE = _UxGT("Suutin"); diff --git a/Marlin/src/lcd/language/language_fr.h b/Marlin/src/lcd/language/language_fr.h index 05e69a583ff5..ed4c7ca9af50 100644 --- a/Marlin/src/lcd/language/language_fr.h +++ b/Marlin/src/lcd/language/language_fr.h @@ -238,10 +238,12 @@ namespace Language_fr { LSTR MSG_MOVE_01MM = _UxGT("Déplacer 0.1mm"); LSTR MSG_MOVE_1MM = _UxGT("Déplacer 1mm"); LSTR MSG_MOVE_10MM = _UxGT("Déplacer 10mm"); + LSTR MSG_MOVE_50MM = _UxGT("Déplacer 50mm"); LSTR MSG_MOVE_100MM = _UxGT("Déplacer 100mm"); LSTR MSG_MOVE_0001IN = _UxGT("Déplacer 0.001\""); LSTR MSG_MOVE_001IN = _UxGT("Déplacer 0.01\""); LSTR MSG_MOVE_01IN = _UxGT("Déplacer 0.1\""); + LSTR MSG_MOVE_05IN = _UxGT("Déplacer 0.5\""); LSTR MSG_MOVE_1IN = _UxGT("Déplacer 1\""); LSTR MSG_SPEED = _UxGT("Vitesse"); LSTR MSG_BED_Z = _UxGT("Lit Z"); diff --git a/Marlin/src/lcd/language/language_gl.h b/Marlin/src/lcd/language/language_gl.h index 9ae64f080925..005c6cc5d025 100644 --- a/Marlin/src/lcd/language/language_gl.h +++ b/Marlin/src/lcd/language/language_gl.h @@ -231,6 +231,7 @@ namespace Language_gl { LSTR MSG_MOVE_01MM = _UxGT("Mover 0.1mm"); LSTR MSG_MOVE_1MM = _UxGT("Mover 1mm"); LSTR MSG_MOVE_10MM = _UxGT("Mover 10mm"); + LSTR MSG_MOVE_50MM = _UxGT("Mover 50mm"); LSTR MSG_MOVE_100MM = _UxGT("Mover 100mm"); LSTR MSG_SPEED = _UxGT("Velocidade"); LSTR MSG_BED_Z = _UxGT("Cama Z"); diff --git a/Marlin/src/lcd/language/language_hr.h b/Marlin/src/lcd/language/language_hr.h index 08ff6cc38c6f..7ca0f5405af1 100644 --- a/Marlin/src/lcd/language/language_hr.h +++ b/Marlin/src/lcd/language/language_hr.h @@ -86,6 +86,7 @@ namespace Language_hr { LSTR MSG_MOVE_01MM = _UxGT("Miči 0.1mm"); LSTR MSG_MOVE_1MM = _UxGT("Miči 1mm"); LSTR MSG_MOVE_10MM = _UxGT("Miči 10mm"); + LSTR MSG_MOVE_50MM = _UxGT("Miči 50mm"); LSTR MSG_MOVE_100MM = _UxGT("Miči 100mm"); LSTR MSG_SPEED = _UxGT("Brzina"); LSTR MSG_BED_Z = _UxGT("Bed Z"); diff --git a/Marlin/src/lcd/language/language_hu.h b/Marlin/src/lcd/language/language_hu.h index eebcb759e5e8..09fb71876f3f 100644 --- a/Marlin/src/lcd/language/language_hu.h +++ b/Marlin/src/lcd/language/language_hu.h @@ -264,10 +264,12 @@ namespace Language_hu { LSTR MSG_MOVE_01MM = _UxGT("Mozgás 0.1mm"); LSTR MSG_MOVE_1MM = _UxGT("Mozgás 1mm"); LSTR MSG_MOVE_10MM = _UxGT("Mozgás 10mm"); + LSTR MSG_MOVE_50MM = _UxGT("Mozgás 50mm"); LSTR MSG_MOVE_100MM = _UxGT("Mozgás 100mm"); LSTR MSG_MOVE_0001IN = _UxGT("Mozgás 0.025mm"); LSTR MSG_MOVE_001IN = _UxGT("Mozgás 0.254mm"); LSTR MSG_MOVE_01IN = _UxGT("Mozgás 2.54mm"); + LSTR MSG_MOVE_05IN = _UxGT("Mozgás 12.7mm"); LSTR MSG_MOVE_1IN = _UxGT("Mozgáá 25.4mm"); LSTR MSG_SPEED = _UxGT("Sebesség"); LSTR MSG_BED_Z = _UxGT("Z ágy"); diff --git a/Marlin/src/lcd/language/language_it.h b/Marlin/src/lcd/language/language_it.h index 1fcf07dbc79d..def1b9834317 100644 --- a/Marlin/src/lcd/language/language_it.h +++ b/Marlin/src/lcd/language/language_it.h @@ -313,10 +313,12 @@ namespace Language_it { LSTR MSG_MOVE_01MM = _UxGT("Muovi di 0.1mm"); LSTR MSG_MOVE_1MM = _UxGT("Muovi di 1mm"); LSTR MSG_MOVE_10MM = _UxGT("Muovi di 10mm"); + LSTR MSG_MOVE_50MM = _UxGT("Muovi di 50mm"); LSTR MSG_MOVE_100MM = _UxGT("Muovi di 100mm"); LSTR MSG_MOVE_0001IN = _UxGT("Muovi di 0.001\""); LSTR MSG_MOVE_001IN = _UxGT("Muovi di 0.01\""); LSTR MSG_MOVE_01IN = _UxGT("Muovi di 0.1\""); + LSTR MSG_MOVE_05IN = _UxGT("Muovi di 0.5\""); LSTR MSG_MOVE_1IN = _UxGT("Muovi di 1\""); LSTR MSG_SPEED = _UxGT("Velocità"); LSTR MSG_BED_Z = _UxGT("Piatto Z"); diff --git a/Marlin/src/lcd/language/language_jp_kana.h b/Marlin/src/lcd/language/language_jp_kana.h index bc8c9ba40ecb..2f75b887590e 100644 --- a/Marlin/src/lcd/language/language_jp_kana.h +++ b/Marlin/src/lcd/language/language_jp_kana.h @@ -99,6 +99,7 @@ namespace Language_jp_kana { LSTR MSG_MOVE_01MM = _UxGT("0.1mm イドウ"); // "Move 0.1mm" LSTR MSG_MOVE_1MM = _UxGT(" 1mm イドウ"); // "Move 1mm" LSTR MSG_MOVE_10MM = _UxGT(" 10mm イドウ"); // "Move 10mm" + LSTR MSG_MOVE_50MM = _UxGT(" 50mm イドウ"); // "Move 50mm" LSTR MSG_MOVE_100MM = _UxGT(" 100mm イドウ"); // "Move 100mm" LSTR MSG_SPEED = _UxGT("ソクド"); // "Speed" LSTR MSG_BED_Z = _UxGT("Zオフセット"); // "Bed Z" diff --git a/Marlin/src/lcd/language/language_zh_TW.h b/Marlin/src/lcd/language/language_zh_TW.h index 4eba832c4ffb..2aa3554fe80f 100644 --- a/Marlin/src/lcd/language/language_zh_TW.h +++ b/Marlin/src/lcd/language/language_zh_TW.h @@ -226,6 +226,7 @@ namespace Language_zh_TW { LSTR MSG_MOVE_01MM = _UxGT("移動 0.1 mm"); // "Move 0.1mm" LSTR MSG_MOVE_1MM = _UxGT("移動 1 mm"); // "Move 1mm" LSTR MSG_MOVE_10MM = _UxGT("移動 10 mm"); // "Move 10mm" + LSTR MSG_MOVE_50MM = _UxGT("移動 50 mm"); // "Move 50mm" LSTR MSG_MOVE_100MM = _UxGT("移動 100 mm"); // "Move 100mm" LSTR MSG_SPEED = _UxGT("速率"); // "Speed" LSTR MSG_BED_Z = _UxGT("熱床Z"); // "Bed Z" diff --git a/Marlin/src/lcd/menu/menu_motion.cpp b/Marlin/src/lcd/menu/menu_motion.cpp index 3c2917cb7184..4d8cc71553b3 100644 --- a/Marlin/src/lcd/menu/menu_motion.cpp +++ b/Marlin/src/lcd/menu/menu_motion.cpp @@ -28,7 +28,13 @@ #if HAS_MARLINUI_MENU -#define LARGE_AREA_TEST ((X_BED_SIZE) >= 1000 || TERN0(HAS_Y_AXIS, (Y_BED_SIZE) >= 1000) || TERN0(HAS_Z_AXIS, (Z_MAX_POS) >= 1000)) +#if ENABLED(TRULY_LARGE_AREA) + #define LARGE_AREA_TEST true +#elif ENABLED(SLIM_LCD_MENUS) + #define LARGE_AREA_TEST false +#else + #define LARGE_AREA_TEST ((X_BED_SIZE) >= 1000 || TERN0(HAS_Y_AXIS, (Y_BED_SIZE) >= 1000) || TERN0(HAS_Z_AXIS, (Z_MAX_POS) >= 1000)) +#endif #include "menu_item.h" #include "menu_addon.h" @@ -150,13 +156,19 @@ void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int BACK_ITEM(MSG_MOVE_AXIS); if (parser.using_inch_units()) { - if (LARGE_AREA_TEST) SUBMENU(MSG_MOVE_1IN, []{ _goto_manual_move(IN_TO_MM(1.000f)); }); + if (LARGE_AREA_TEST) { + SUBMENU(MSG_MOVE_1IN, []{ _goto_manual_move(IN_TO_MM(1.000f)); }); + SUBMENU(MSG_MOVE_05IN, []{ _goto_manual_move(IN_TO_MM(0.500f)); }); + } SUBMENU(MSG_MOVE_01IN, []{ _goto_manual_move(IN_TO_MM(0.100f)); }); SUBMENU(MSG_MOVE_001IN, []{ _goto_manual_move(IN_TO_MM(0.010f)); }); SUBMENU(MSG_MOVE_0001IN, []{ _goto_manual_move(IN_TO_MM(0.001f)); }); } else { - if (LARGE_AREA_TEST) SUBMENU(MSG_MOVE_100MM, []{ _goto_manual_move(100); }); + if (LARGE_AREA_TEST) { + SUBMENU(MSG_MOVE_100MM, []{ _goto_manual_move(100); }); + SUBMENU(MSG_MOVE_50MM, []{ _goto_manual_move(50); }); + } SUBMENU(MSG_MOVE_10MM, []{ _goto_manual_move(10); }); SUBMENU(MSG_MOVE_1MM, []{ _goto_manual_move( 1); }); SUBMENU(MSG_MOVE_01MM, []{ _goto_manual_move( 0.1f); }); @@ -356,6 +368,13 @@ void menu_motion() { GCODES_ITEM(MSG_MANUAL_STOW, F("M402")); #endif + // + // Probe Offset Wizard + // + #if ENABLED(PROBE_OFFSET_WIZARD) + SUBMENU(MSG_PROBE_WIZARD, goto_probe_offset_wizard); + #endif + // // Assisted Bed Tramming // diff --git a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h index 13e912d970e8..d70e935f0a29 100644 --- a/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h +++ b/Marlin/src/pins/stm32f4/pins_MKS_MONSTER8_V2.h @@ -53,11 +53,11 @@ // //#define WIFI_SERIAL 1// USART1 #if ENABLED(MKS_WIFI_MODULE) - #define WIFI_IO0_PIN PB14 // MKS ESP WIFI IO0 PIN - #define WIFI_IO1_PIN PB15 // MKS ESP WIFI IO1 PIN - #define WIFI_RESET_PIN PD14 // MKS ESP WIFI RESET PIN + #define WIFI_IO0_PIN PB14 // MKS ESP WIFI IO0 PIN + #define WIFI_IO1_PIN PB15 // MKS ESP WIFI IO1 PIN + #define WIFI_RESET_PIN PD14 // MKS ESP WIFI RESET PIN #endif -#define NEOPIXEL_PIN PC5 +#define NEOPIXEL_PIN PC5 #include "pins_MKS_MONSTER8_common.h" From c1684a1dbe3a64e82bb8380bd927c1ec7a7db927 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Sun, 27 Nov 2022 14:22:08 +1300 Subject: [PATCH 158/243] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20UBL=20menu=20compi?= =?UTF-8?q?le=20(#25020)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/menu/menu_ubl.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Marlin/src/lcd/menu/menu_ubl.cpp b/Marlin/src/lcd/menu/menu_ubl.cpp index f26e5b29846f..d6f42faa5558 100644 --- a/Marlin/src/lcd/menu/menu_ubl.cpp +++ b/Marlin/src/lcd/menu/menu_ubl.cpp @@ -35,6 +35,9 @@ #include "../../module/planner.h" #include "../../module/settings.h" #include "../../feature/bedlevel/bedlevel.h" +#if HAS_HOTEND + #include "../../module/temperature.h" +#endif static int16_t ubl_storage_slot = 0, custom_hotend_temp = 150, From b2b8407a7506860e3d885f7dcdc7cfd6a5ea280e Mon Sep 17 00:00:00 2001 From: Vasily Evseenko Date: Sun, 27 Nov 2022 04:26:40 +0300 Subject: [PATCH 159/243] =?UTF-8?q?=F0=9F=8D=BB=20Fix=20Z=20increase=20on?= =?UTF-8?q?=20toolchange=20without=20UBL=20(#22942)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/bedlevel/bedlevel.cpp | 1 + Marlin/src/module/tool_change.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Marlin/src/feature/bedlevel/bedlevel.cpp b/Marlin/src/feature/bedlevel/bedlevel.cpp index 1658b536d3ec..03b67745ec16 100644 --- a/Marlin/src/feature/bedlevel/bedlevel.cpp +++ b/Marlin/src/feature/bedlevel/bedlevel.cpp @@ -57,6 +57,7 @@ bool leveling_is_valid() { * Enable: Current position = "unleveled" physical position */ void set_bed_leveling_enabled(const bool enable/*=true*/) { + DEBUG_SECTION(log_sble, "set_bed_leveling_enabled", DEBUGGING(LEVELING)); const bool can_change = TERN1(AUTO_BED_LEVELING_BILINEAR, !enable || leveling_is_valid()); diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index a0939d155abb..7322098c0bb7 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -1157,8 +1157,8 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { const uint8_t old_tool = active_extruder; const bool can_move_away = !no_move && !idex_full_control; - #if HAS_LEVELING - // Set current position to the physical position + #if ENABLED(AUTO_BED_LEVELING_UBL) + // Workaround for UBL mesh boundary, possibly? TEMPORARY_BED_LEVELING_STATE(false); #endif From 6185b50dbedf7f564703ebdb9acc97e0a99388f1 Mon Sep 17 00:00:00 2001 From: Radek <46979052+radek8@users.noreply.github.com> Date: Sun, 27 Nov 2022 02:31:44 +0100 Subject: [PATCH 160/243] =?UTF-8?q?=F0=9F=90=9B=20Fix=20SKR=20mini=20E2=20?= =?UTF-8?q?V2=20+=20BTT=5FMINI=5F12864=5FV1=20(#24827)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/bigtreetech/BIGTREETECH-SKR-mini-E3/issues/686#issuecomment-1296545443 --- .../pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h | 43 ++++++++++++----- .../stm32f1/pins_BTT_SKR_MINI_E3_common.h | 48 ++++++++----------- 2 files changed, 50 insertions(+), 41 deletions(-) diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h index b5fddc4d7494..c0428279f0fe 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_V2_0.h @@ -21,7 +21,9 @@ */ #pragma once -#define SKR_MINI_E3_V2 +#ifndef BOARD_INFO_NAME + #define BOARD_INFO_NAME "BTT SKR Mini E3 V2.0" +#endif #define BOARD_CUSTOM_BUILD_FLAGS -DTONE_CHANNEL=4 -DTONE_TIMER=4 -DTIMER_TONE=4 @@ -29,33 +31,50 @@ #if NO_EEPROM_SELECTED #define I2C_EEPROM #define SOFT_I2C_EEPROM - #define MARLIN_EEPROM_SIZE 0x1000 // 4K - #define I2C_SDA_PIN PB7 - #define I2C_SCL_PIN PB6 + #define MARLIN_EEPROM_SIZE 0x1000 // 4K + #define I2C_SDA_PIN PB7 + #define I2C_SCL_PIN PB6 #undef NO_EEPROM_SELECTED #endif -#include "pins_BTT_SKR_MINI_E3_common.h" +#define FAN_PIN PC6 -#ifndef BOARD_INFO_NAME - #define BOARD_INFO_NAME "BTT SKR Mini E3 V2.0" -#endif +// +// USB connect control +// +#define USB_CONNECT_PIN PA14 + +/** + * SKR Mini E3 V2.0 + * ------ + * (BEEPER) PB5 | 1 2 | PA15 (BTN_ENC) + * (BTN_EN1) PA9 | 3 4 | RESET + * (BTN_EN2) PA10 5 6 | PB9 (LCD_D4) + * (LCD_RS) PB8 | 7 8 | PB15 (LCD_EN) + * GND | 9 10 | 5V + * ------ + * EXP1 + */ +#define EXP1_02_PIN PA15 +#define EXP1_08_PIN PB15 + +#include "pins_BTT_SKR_MINI_E3_common.h" // Release PA13/PA14 (led, usb control) from SWD pins #define DISABLE_DEBUG #ifndef NEOPIXEL_PIN - #define NEOPIXEL_PIN PA8 // LED driving pin + #define NEOPIXEL_PIN PA8 // LED driving pin #endif #ifndef PS_ON_PIN - #define PS_ON_PIN PC13 // Power Supply Control + #define PS_ON_PIN PC13 // Power Supply Control #endif -#define FAN1_PIN PC7 +#define FAN1_PIN PC7 #ifndef CONTROLLER_FAN_PIN - #define CONTROLLER_FAN_PIN FAN1_PIN + #define CONTROLLER_FAN_PIN FAN1_PIN #endif #if HAS_TMC_UART diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h index c4a89712652e..8ed09417f0df 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_MINI_E3_common.h @@ -100,38 +100,31 @@ #define HEATER_0_PIN PC8 // "HE" #define HEATER_BED_PIN PC9 // "HB" -#ifdef SKR_MINI_E3_V2 - #define FAN_PIN PC6 -#else +#ifndef FAN_PIN #define FAN_PIN PA8 // "FAN0" #endif // // USB connect control // -#ifdef SKR_MINI_E3_V2 - #define USB_CONNECT_PIN PA14 -#else +#ifndef USB_CONNECT_PIN #define USB_CONNECT_PIN PC13 #endif #define USB_CONNECT_INVERTING false /** - * SKR Mini E3 V1.0, V1.2 SKR Mini E3 V2.0 - * ------ ------ - * (BEEPER) PB5 | 1 2 | PB6 (BTN_ENC) (BEEPER) PB5 | 1 2 | PA15 (BTN_ENC) - * (BTN_EN1) PA9 | 3 4 | RESET (BTN_EN1) PA9 | 3 4 | RESET - * (BTN_EN2) PA10 5 6 | PB9 (LCD_D4) (BTN_EN2) PA10 5 6 | PB9 (LCD_D4) - * (LCD_RS) PB8 | 7 8 | PB7 (LCD_EN) (LCD_RS) PB8 | 7 8 | PB15 (LCD_EN) - * GND | 9 10 | 5V GND | 9 10 | 5V - * ------ ------ - * EXP1 EXP1 + * SKR Mini E3 V1.0, V1.2 + * ------ + * (BEEPER) PB5 | 1 2 | PB6 (BTN_ENC) + * (BTN_EN1) PA9 | 3 4 | RESET + * (BTN_EN2) PA10 5 6 | PB9 (LCD_D4) + * (LCD_RS) PB8 | 7 8 | PB7 (LCD_EN) + * GND | 9 10 | 5V + * ------ + * EXP1 */ -#ifdef SKR_MINI_E3_V2 - #define EXP1_02_PIN PA15 - #define EXP1_08_PIN PB15 -#else +#ifndef EXP1_02_PIN #define EXP1_02_PIN PB6 #define EXP1_08_PIN PB7 #endif @@ -269,8 +262,8 @@ * * --- ------ * RST | 1 | (MISO) |10 9 | SCK - * (RX2) PA2 | 2 | BTN_EN1 | 8 7 | (SS) - * (TX2) PA3 | 3 | BTN_EN2 | 6 5 | MOSI + * (RX2) PA3 | 2 | BTN_EN1 | 8 7 | (SS) + * (TX2) PA2 | 3 | BTN_EN2 | 6 5 | MOSI * GND | 4 | (CD) | 4 3 | (RST) * 5V | 5 | (GND) | 2 1 | (KILL) * --- ------ @@ -285,24 +278,21 @@ * EXP1-8 ----------- EXP2-6 EN2 * EXP1-7 ----------- EXP1-5 RED * EXP1-6 ----------- EXP2-8 EN1 - * EXP1-5 ----------- EXP1-6 LCD_RST - * EXP1-4 ----------- n/c + * EXP1-5 ----------- n/c + * EXP1-4 ----------- EXP1-6 RESET * EXP1-3 ----------- EXP1-8 LCD_CS * EXP1-2 ----------- EXP1-9 ENC * EXP1-1 ----------- EXP1-7 LCD_A0 * - * TFT-2 ----------- EXP2-9 SCK - * TFT-3 ----------- EXP2-5 MOSI + * TFT-2 ----------- EXP2-5 SCK + * TFT-3 ----------- EXP2-9 MOSI * * for backlight configuration see steps 2 (V2.1) and 3 in https://wiki.fysetc.com/Mini12864_Panel/ */ - #define LCD_PINS_RS EXP1_03_PIN // CS - #define LCD_PINS_ENABLE PA3 // MOSI #define LCD_BACKLIGHT_PIN -1 #define NEOPIXEL_PIN EXP1_07_PIN - #define LCD_CONTRAST 255 - #define LCD_RESET_PIN EXP1_05_PIN + #define LCD_CONTRAST 255 #define DOGLCD_CS EXP1_03_PIN #define DOGLCD_A0 EXP1_01_PIN From 360e03797f3ef35e34a0eb6902918235f5403047 Mon Sep 17 00:00:00 2001 From: Manuel McLure Date: Sat, 26 Nov 2022 18:30:59 -0800 Subject: [PATCH 161/243] =?UTF-8?q?=F0=9F=94=A7=20Merge=20TMC26X=20with=20?= =?UTF-8?q?TMC=20config=20(#24373)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 244 ++++++------------------- Marlin/src/core/drivers.h | 2 + Marlin/src/core/types.h | 2 + Marlin/src/inc/Conditionals_adv.h | 3 +- Marlin/src/inc/SanityCheck.h | 11 ++ Marlin/src/module/stepper/TMC26X.cpp | 2 +- Marlin/src/module/stepper/trinamic.cpp | 2 - 7 files changed, 74 insertions(+), 192 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 9a54b10b82b1..246664ff2a06 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -2669,167 +2669,33 @@ //#define FILAMENT_UNLOAD_ALL_EXTRUDERS // Allow M702 to unload all extruders above a minimum target temp (as set by M302) #endif -/** - * TMC26X Stepper Driver options - * - * The TMC26XStepper library is required for this stepper driver. - * https://github.com/trinamic/TMC26XStepper - * @section tmc/tmc26x - */ -#if HAS_DRIVER(TMC26X) - - #if AXIS_DRIVER_TYPE_X(TMC26X) - #define X_MAX_CURRENT 1000 // (mA) - #define X_SENSE_RESISTOR 91 // (mOhms) - #define X_MICROSTEPS 16 // Number of microsteps - #endif - - #if AXIS_DRIVER_TYPE_X2(TMC26X) - #define X2_MAX_CURRENT 1000 - #define X2_SENSE_RESISTOR 91 - #define X2_MICROSTEPS X_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_Y(TMC26X) - #define Y_MAX_CURRENT 1000 - #define Y_SENSE_RESISTOR 91 - #define Y_MICROSTEPS 16 - #endif - - #if AXIS_DRIVER_TYPE_Y2(TMC26X) - #define Y2_MAX_CURRENT 1000 - #define Y2_SENSE_RESISTOR 91 - #define Y2_MICROSTEPS Y_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_Z(TMC26X) - #define Z_MAX_CURRENT 1000 - #define Z_SENSE_RESISTOR 91 - #define Z_MICROSTEPS 16 - #endif - - #if AXIS_DRIVER_TYPE_Z2(TMC26X) - #define Z2_MAX_CURRENT 1000 - #define Z2_SENSE_RESISTOR 91 - #define Z2_MICROSTEPS Z_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_Z3(TMC26X) - #define Z3_MAX_CURRENT 1000 - #define Z3_SENSE_RESISTOR 91 - #define Z3_MICROSTEPS Z_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_Z4(TMC26X) - #define Z4_MAX_CURRENT 1000 - #define Z4_SENSE_RESISTOR 91 - #define Z4_MICROSTEPS Z_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_I(TMC26X) - #define I_MAX_CURRENT 1000 - #define I_SENSE_RESISTOR 91 - #define I_MICROSTEPS 16 - #endif - - #if AXIS_DRIVER_TYPE_J(TMC26X) - #define J_MAX_CURRENT 1000 - #define J_SENSE_RESISTOR 91 - #define J_MICROSTEPS 16 - #endif - - #if AXIS_DRIVER_TYPE_K(TMC26X) - #define K_MAX_CURRENT 1000 - #define K_SENSE_RESISTOR 91 - #define K_MICROSTEPS 16 - #endif - - #if AXIS_DRIVER_TYPE_U(TMC26X) - #define U_MAX_CURRENT 1000 - #define U_SENSE_RESISTOR 91 - #define U_MICROSTEPS 16 - #endif - - #if AXIS_DRIVER_TYPE_V(TMC26X) - #define V_MAX_CURRENT 1000 - #define V_SENSE_RESISTOR 91 - #define V_MICROSTEPS 16 - #endif - - #if AXIS_DRIVER_TYPE_W(TMC26X) - #define W_MAX_CURRENT 1000 - #define W_SENSE_RESISTOR 91 - #define W_MICROSTEPS 16 - #endif - - #if AXIS_DRIVER_TYPE_E0(TMC26X) - #define E0_MAX_CURRENT 1000 - #define E0_SENSE_RESISTOR 91 - #define E0_MICROSTEPS 16 - #endif - - #if AXIS_DRIVER_TYPE_E1(TMC26X) - #define E1_MAX_CURRENT 1000 - #define E1_SENSE_RESISTOR 91 - #define E1_MICROSTEPS E0_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_E2(TMC26X) - #define E2_MAX_CURRENT 1000 - #define E2_SENSE_RESISTOR 91 - #define E2_MICROSTEPS E0_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_E3(TMC26X) - #define E3_MAX_CURRENT 1000 - #define E3_SENSE_RESISTOR 91 - #define E3_MICROSTEPS E0_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_E4(TMC26X) - #define E4_MAX_CURRENT 1000 - #define E4_SENSE_RESISTOR 91 - #define E4_MICROSTEPS E0_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_E5(TMC26X) - #define E5_MAX_CURRENT 1000 - #define E5_SENSE_RESISTOR 91 - #define E5_MICROSTEPS E0_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_E6(TMC26X) - #define E6_MAX_CURRENT 1000 - #define E6_SENSE_RESISTOR 91 - #define E6_MICROSTEPS E0_MICROSTEPS - #endif - - #if AXIS_DRIVER_TYPE_E7(TMC26X) - #define E7_MAX_CURRENT 1000 - #define E7_SENSE_RESISTOR 91 - #define E7_MICROSTEPS E0_MICROSTEPS - #endif - -#endif // TMC26X +// @section tmc_smart /** - * To use TMC2130, TMC2160, TMC2660, TMC5130, TMC5160 stepper drivers in SPI mode - * connect your SPI pins to the hardware SPI interface on your board and define - * the required CS pins in your `pins_MYBOARD.h` file. (e.g., RAMPS 1.4 uses AUX3 - * pins `X_CS_PIN 53`, `Y_CS_PIN 49`, etc.). - * You may also use software SPI if you wish to use general purpose IO pins. + * Trinamic Smart Drivers + * + * To use TMC2130, TMC2160, TMC2660, TMC5130, TMC5160 stepper drivers in SPI mode: + * - Connect your SPI pins to the Hardware SPI interface on the board. + * Some boards have simple jumper connections! See your board's documentation. + * - Define the required Stepper CS pins in your `pins_MYBOARD.h` file. + * (See the RAMPS pins, for example.) + * - You can also use Software SPI with GPIO pins instead of Hardware SPI. * - * To use TMC2208 stepper UART-configurable stepper drivers connect #_SERIAL_TX_PIN - * to the driver side PDN_UART pin with a 1K resistor. - * To use the reading capabilities, also connect #_SERIAL_RX_PIN to PDN_UART without - * a resistor. - * The drivers can also be used with hardware serial. + * To use TMC220x stepper drivers with Serial UART: + * - Connect PDN_UART to the #_SERIAL_TX_PIN through a 1K resistor. + * For reading capabilities also connect PDN_UART to #_SERIAL_RX_PIN with no resistor. + * Some boards have simple jumper connections! See your board's documentation. + * - These drivers can also be used with Hardware Serial. + * + * The TMC26XStepper library is required for TMC26X stepper drivers. + * https://github.com/MarlinFirmware/TMC26XStepper + * + * The TMCStepper library is required for other TMC stepper drivers. + * https://github.com/teemuatlut/TMCStepper * - * TMCStepper library is required to use TMC stepper drivers. - * https://github.com/teemuatlut/TMCStepper * @section tmc/config */ -#if HAS_TRINAMIC_CONFIG +#if HAS_TRINAMIC_CONFIG || HAS_TMC26X #define HOLD_MULTIPLIER 0.5 // Scales down the holding current from run current @@ -2839,17 +2705,17 @@ */ #define INTERPOLATE true - #if AXIS_IS_TMC(X) + #if AXIS_IS_TMC_CONFIG(X) #define X_CURRENT 800 // (mA) RMS current. Multiply by 1.414 for peak current. #define X_CURRENT_HOME X_CURRENT // (mA) RMS current for sensorless homing #define X_MICROSTEPS 16 // 0..256 - #define X_RSENSE 0.11 + #define X_RSENSE 0.11 // Multiplied x1000 for TMC26X #define X_CHAIN_POS -1 // -1..0: Not chained. 1: MCU MOSI connected. 2: Next in chain, ... //#define X_INTERPOLATE true // Enable to override 'INTERPOLATE' for the X axis //#define X_HOLD_MULTIPLIER 0.5 // Enable to override 'HOLD_MULTIPLIER' for the X axis #endif - #if AXIS_IS_TMC(X2) + #if AXIS_IS_TMC_CONFIG(X2) #define X2_CURRENT 800 #define X2_CURRENT_HOME X2_CURRENT #define X2_MICROSTEPS X_MICROSTEPS @@ -2859,7 +2725,7 @@ //#define X2_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(Y) + #if AXIS_IS_TMC_CONFIG(Y) #define Y_CURRENT 800 #define Y_CURRENT_HOME Y_CURRENT #define Y_MICROSTEPS 16 @@ -2869,7 +2735,7 @@ //#define Y_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(Y2) + #if AXIS_IS_TMC_CONFIG(Y2) #define Y2_CURRENT 800 #define Y2_CURRENT_HOME Y2_CURRENT #define Y2_MICROSTEPS Y_MICROSTEPS @@ -2879,7 +2745,7 @@ //#define Y2_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(Z) + #if AXIS_IS_TMC_CONFIG(Z) #define Z_CURRENT 800 #define Z_CURRENT_HOME Z_CURRENT #define Z_MICROSTEPS 16 @@ -2889,7 +2755,7 @@ //#define Z_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(Z2) + #if AXIS_IS_TMC_CONFIG(Z2) #define Z2_CURRENT 800 #define Z2_CURRENT_HOME Z2_CURRENT #define Z2_MICROSTEPS Z_MICROSTEPS @@ -2899,7 +2765,7 @@ //#define Z2_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(Z3) + #if AXIS_IS_TMC_CONFIG(Z3) #define Z3_CURRENT 800 #define Z3_CURRENT_HOME Z3_CURRENT #define Z3_MICROSTEPS Z_MICROSTEPS @@ -2909,7 +2775,7 @@ //#define Z3_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(Z4) + #if AXIS_IS_TMC_CONFIG(Z4) #define Z4_CURRENT 800 #define Z4_CURRENT_HOME Z4_CURRENT #define Z4_MICROSTEPS Z_MICROSTEPS @@ -2919,7 +2785,7 @@ //#define Z4_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(I) + #if AXIS_IS_TMC_CONFIG(I) #define I_CURRENT 800 #define I_CURRENT_HOME I_CURRENT #define I_MICROSTEPS 16 @@ -2929,7 +2795,7 @@ //#define I_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(J) + #if AXIS_IS_TMC_CONFIG(J) #define J_CURRENT 800 #define J_CURRENT_HOME J_CURRENT #define J_MICROSTEPS 16 @@ -2939,7 +2805,7 @@ //#define J_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(K) + #if AXIS_IS_TMC_CONFIG(K) #define K_CURRENT 800 #define K_CURRENT_HOME K_CURRENT #define K_MICROSTEPS 16 @@ -2949,7 +2815,7 @@ //#define K_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(U) + #if AXIS_IS_TMC_CONFIG(U) #define U_CURRENT 800 #define U_CURRENT_HOME U_CURRENT #define U_MICROSTEPS 8 @@ -2959,7 +2825,7 @@ //#define U_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(V) + #if AXIS_IS_TMC_CONFIG(V) #define V_CURRENT 800 #define V_CURRENT_HOME V_CURRENT #define V_MICROSTEPS 8 @@ -2969,7 +2835,7 @@ //#define V_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(W) + #if AXIS_IS_TMC_CONFIG(W) #define W_CURRENT 800 #define W_CURRENT_HOME W_CURRENT #define W_MICROSTEPS 8 @@ -2979,7 +2845,7 @@ //#define W_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(E0) + #if AXIS_IS_TMC_CONFIG(E0) #define E0_CURRENT 800 #define E0_MICROSTEPS 16 #define E0_RSENSE 0.11 @@ -2988,7 +2854,7 @@ //#define E0_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(E1) + #if AXIS_IS_TMC_CONFIG(E1) #define E1_CURRENT 800 #define E1_MICROSTEPS E0_MICROSTEPS #define E1_RSENSE 0.11 @@ -2997,7 +2863,7 @@ //#define E1_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(E2) + #if AXIS_IS_TMC_CONFIG(E2) #define E2_CURRENT 800 #define E2_MICROSTEPS E0_MICROSTEPS #define E2_RSENSE 0.11 @@ -3006,7 +2872,7 @@ //#define E2_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(E3) + #if AXIS_IS_TMC_CONFIG(E3) #define E3_CURRENT 800 #define E3_MICROSTEPS E0_MICROSTEPS #define E3_RSENSE 0.11 @@ -3015,7 +2881,7 @@ //#define E3_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(E4) + #if AXIS_IS_TMC_CONFIG(E4) #define E4_CURRENT 800 #define E4_MICROSTEPS E0_MICROSTEPS #define E4_RSENSE 0.11 @@ -3024,7 +2890,7 @@ //#define E4_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(E5) + #if AXIS_IS_TMC_CONFIG(E5) #define E5_CURRENT 800 #define E5_MICROSTEPS E0_MICROSTEPS #define E5_RSENSE 0.11 @@ -3033,7 +2899,7 @@ //#define E5_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(E6) + #if AXIS_IS_TMC_CONFIG(E6) #define E6_CURRENT 800 #define E6_MICROSTEPS E0_MICROSTEPS #define E6_RSENSE 0.11 @@ -3042,7 +2908,7 @@ //#define E6_HOLD_MULTIPLIER 0.5 #endif - #if AXIS_IS_TMC(E7) + #if AXIS_IS_TMC_CONFIG(E7) #define E7_CURRENT 800 #define E7_MICROSTEPS E0_MICROSTEPS #define E7_RSENSE 0.11 @@ -3144,15 +3010,17 @@ * Use Trinamic's ultra quiet stepping mode. * When disabled, Marlin will use spreadCycle stepping mode. */ - #define STEALTHCHOP_XY - #define STEALTHCHOP_Z - #define STEALTHCHOP_I - #define STEALTHCHOP_J - #define STEALTHCHOP_K - #define STEALTHCHOP_U - #define STEALTHCHOP_V - #define STEALTHCHOP_W - #define STEALTHCHOP_E + #if HAS_STEALTHCHOP + #define STEALTHCHOP_XY + #define STEALTHCHOP_Z + #define STEALTHCHOP_I + #define STEALTHCHOP_J + #define STEALTHCHOP_K + #define STEALTHCHOP_U + #define STEALTHCHOP_V + #define STEALTHCHOP_W + #define STEALTHCHOP_E + #endif /** * Optimize spreadCycle chopper parameters by using predefined parameter sets @@ -3335,7 +3203,7 @@ */ #define TMC_ADV() { } -#endif // HAS_TRINAMIC_CONFIG +#endif // HAS_TRINAMIC_CONFIG || HAS_TMC26X // @section i2cbus diff --git a/Marlin/src/core/drivers.h b/Marlin/src/core/drivers.h index 8cf03d342a34..72a7d1f4b7eb 100644 --- a/Marlin/src/core/drivers.h +++ b/Marlin/src/core/drivers.h @@ -125,6 +125,8 @@ || AXIS_DRIVER_TYPE(A,TMC2660) \ || AXIS_DRIVER_TYPE(A,TMC5130) || AXIS_DRIVER_TYPE(A,TMC5160) ) +#define AXIS_IS_TMC_CONFIG(A) ( AXIS_IS_TMC(A) || AXIS_DRIVER_TYPE(A,TMC26X) ) + // Test for a driver that uses SPI - this allows checking whether a _CS_ pin // is considered sensitive #define AXIS_HAS_SPI(A) ( AXIS_DRIVER_TYPE(A,TMC2130) || AXIS_DRIVER_TYPE(A,TMC2160) \ diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index 4497ff49af43..0281dea08c3c 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -36,6 +36,8 @@ struct IF { typedef R type; }; template struct IF { typedef L type; }; +#define ALL_AXIS_NAMES X, X2, Y, Y2, Z, Z2, Z3, Z4, I, J, K, U, V, W, E0, E1, E2, E3, E4, E5, E6, E7 + #define NUM_AXIS_GANG(V...) GANG_N(NUM_AXES, V) #define NUM_AXIS_CODE(V...) CODE_N(NUM_AXES, V) #define NUM_AXIS_LIST(V...) LIST_N(NUM_AXES, V) diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index dd69e61c9275..d1b7a342d679 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -994,8 +994,8 @@ #undef CALIBRATION_MEASURE_IMIN #undef CALIBRATION_MEASURE_IMAX #if NUM_AXES < 3 - #undef Z_IDLE_HEIGHT #undef STEALTHCHOP_Z + #undef Z_IDLE_HEIGHT #undef Z_PROBE_SLED #undef Z_SAFE_HOMING #undef HOME_Z_FIRST @@ -1005,6 +1005,7 @@ #undef CNC_WORKSPACE_PLANES #if NUM_AXES < 2 #undef STEALTHCHOP_Y + #undef QUICK_HOME #endif #endif #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 2d8c7ca1c602..685411c20be6 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -681,6 +681,17 @@ constexpr float arm[] = AXIS_RELATIVE_MODES; static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _LOGICAL_AXES_STR "elements."); +// Consolidate TMC26X, validate migration (#24373) +#define _ISMAX_1(A) defined(A##_MAX_CURRENT) +#define _ISSNS_1(A) defined(A##_SENSE_RESISTOR) +#if DO(ISMAX,||,ALL_AXIS_NAMES) + #error "*_MAX_CURRENT is now set with *_CURRENT." +#elif DO(ISSNS,||,ALL_AXIS_NAMES) + #error "*_SENSE_RESISTOR (in Milli-Ohms) is now set with *_RSENSE (in Ohms), so you must divide values by 1000." +#endif +#undef _ISMAX_1 +#undef _ISSNS_1 + /** * Probe temp compensation requirements */ diff --git a/Marlin/src/module/stepper/TMC26X.cpp b/Marlin/src/module/stepper/TMC26X.cpp index 52d84f84101c..f46163ea2de2 100644 --- a/Marlin/src/module/stepper/TMC26X.cpp +++ b/Marlin/src/module/stepper/TMC26X.cpp @@ -34,7 +34,7 @@ #include "TMC26X.h" -#define _TMC26X_DEFINE(ST) TMC26XStepper stepper##ST(200, ST##_CS_PIN, ST##_STEP_PIN, ST##_DIR_PIN, ST##_MAX_CURRENT, ST##_SENSE_RESISTOR) +#define _TMC26X_DEFINE(ST) TMC26XStepper stepper##ST(200, ST##_CS_PIN, ST##_STEP_PIN, ST##_DIR_PIN, ST##_CURRENT, int(ST##_RSENSE * 1000)) #if AXIS_DRIVER_TYPE_X(TMC26X) _TMC26X_DEFINE(X); diff --git a/Marlin/src/module/stepper/trinamic.cpp b/Marlin/src/module/stepper/trinamic.cpp index bf36f83cd872..48ce020d3dca 100644 --- a/Marlin/src/module/stepper/trinamic.cpp +++ b/Marlin/src/module/stepper/trinamic.cpp @@ -1023,8 +1023,6 @@ void reset_trinamic_drivers() { // 2. For each axis in use, static_assert using a constexpr function, which counts the // number of matching/conflicting axis. If the value is not exactly 1, fail. -#define ALL_AXIS_NAMES X, X2, Y, Y2, Z, Z2, Z3, Z4, I, J, K, U, V, W, E0, E1, E2, E3, E4, E5, E6, E7 - #if ANY_AXIS_HAS(HW_SERIAL) // Hardware serial names are compared as strings, since actually resolving them cannot occur in a constexpr. // Using a fixed-length character array for the port name allows this to be constexpr compatible. From 3a28a1fd1d4139ddbf39cc6c53ee661a45b012b2 Mon Sep 17 00:00:00 2001 From: Marcio T Date: Sat, 26 Nov 2022 20:11:14 -0700 Subject: [PATCH 162/243] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20ADVANCE=5FK=20+=20?= =?UTF-8?q?DISTINCT=5FE=5FFACTORS=20sanity=20check=20(#25007)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/SanityCheck.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 685411c20be6..766b69fcb98c 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1353,7 +1353,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #if ENABLED(LIN_ADVANCE) #if DISTINCT_E > 1 constexpr float lak[] = ADVANCE_K; - static_assert(COUNT(lak) < DISTINCT_E, "The ADVANCE_K array has too many elements (i.e., more than " STRINGIFY(DISTINCT_E) ")."); + static_assert(COUNT(lak) <= DISTINCT_E, "The ADVANCE_K array has too many elements (i.e., more than " STRINGIFY(DISTINCT_E) ")."); #define _LIN_ASSERT(N) static_assert(N >= COUNT(lak) || WITHIN(lak[N], 0, 10), "ADVANCE_K values must be from 0 to 10 (Changed in LIN_ADVANCE v1.5, Marlin 1.1.9)."); REPEAT(DISTINCT_E, _LIN_ASSERT) #undef _LIN_ASSERT From 12017887f40a0a2cacf0728215fcfb631e10e383 Mon Sep 17 00:00:00 2001 From: studiodyne <42887851+studiodyne@users.noreply.github.com> Date: Sun, 27 Nov 2022 04:29:13 +0100 Subject: [PATCH 163/243] =?UTF-8?q?=F0=9F=90=9B=20Fix=20MILLISECONDS=5FPRE?= =?UTF-8?q?HEAT=5FTIME=20/=20mintemp=20(#24967)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/SanityCheck.h | 4 ++-- Marlin/src/module/temperature.cpp | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 766b69fcb98c..b2e4dc9de0f4 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -2330,8 +2330,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED < 5 #error "Thermistor 66 requires MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED ≥ 5." - #elif MILLISECONDS_PREHEAT_TIME < 30000 - #error "Thermistor 66 requires MILLISECONDS_PREHEAT_TIME ≥ 30000." + #elif MILLISECONDS_PREHEAT_TIME < 15000 + #error "Thermistor 66 requires MILLISECONDS_PREHEAT_TIME ≥ 15000, but 30000 or higher is recommended." #endif #undef _BAD_MINTEMP #endif diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 8742cf36dfb4..fb3953841b7c 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -2406,8 +2406,15 @@ void Temperature::updateTemperaturesFromRawValues() { if ((neg && r < temp_range[e].raw_max) || (pos && r > temp_range[e].raw_max)) max_temp_error((heater_id_t)e); + /** + // DEBUG PREHEATING TIME + SERIAL_ECHOLNPGM("\nExtruder = ", e, " Preheat On/Off = ", is_preheating(e)); + const float test_is_preheating = (preheat_end_time[HOTEND_INDEX] - millis()) * 0.001f; + if (test_is_preheating < 31) SERIAL_ECHOLNPGM("Extruder = ", e, " Preheat remaining time = ", test_is_preheating, "s", "\n"); + //*/ + const bool heater_on = temp_hotend[e].target > 0; - if (heater_on && ((neg && r > temp_range[e].raw_min) || (pos && r < temp_range[e].raw_min))) { + if (heater_on && !is_preheating(e) && ((neg && r > temp_range[e].raw_min) || (pos && r < temp_range[e].raw_min))) { if (TERN1(MULTI_MAX_CONSECUTIVE_LOW_TEMP_ERR, ++consecutive_low_temperature_error[e] >= MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED)) min_temp_error((heater_id_t)e); } From d2ece1e7137931085824d0bcf8f7732e7fcae1e3 Mon Sep 17 00:00:00 2001 From: Trivalik <3148279+trivalik@users.noreply.github.com> Date: Mon, 28 Nov 2022 02:06:44 +0100 Subject: [PATCH 164/243] =?UTF-8?q?=F0=9F=90=9B=20Fix=20missing=20va=5Fend?= =?UTF-8?q?=20in=20UnwPrintf=20(#25027)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/shared/backtrace/unwarm.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Marlin/src/HAL/shared/backtrace/unwarm.cpp b/Marlin/src/HAL/shared/backtrace/unwarm.cpp index adbcca69cc58..e72a02e487cd 100644 --- a/Marlin/src/HAL/shared/backtrace/unwarm.cpp +++ b/Marlin/src/HAL/shared/backtrace/unwarm.cpp @@ -33,8 +33,9 @@ void UnwPrintf(const char *format, ...) { va_list args; - va_start( args, format ); - vprintf(format, args ); + va_start(args, format); + vprintf(format, args); + va_end(args); } #endif From 57f6c93192c823049814c18ba48738d91ed1435f Mon Sep 17 00:00:00 2001 From: tombrazier <68918209+tombrazier@users.noreply.github.com> Date: Mon, 28 Nov 2022 03:38:15 +0000 Subject: [PATCH 165/243] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Input=20Shaping=20?= =?UTF-8?q?improvements=20(#24951)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 31 +- .../src/gcode/feature/input_shaping/M593.cpp | 21 +- Marlin/src/gcode/gcode.cpp | 2 +- Marlin/src/gcode/gcode.h | 4 +- Marlin/src/inc/Conditionals_adv.h | 18 +- Marlin/src/inc/SanityCheck.h | 14 +- Marlin/src/lcd/language/language_en.h | 8 +- Marlin/src/lcd/menu/menu_advanced.cpp | 34 +- Marlin/src/module/planner.cpp | 15 +- Marlin/src/module/planner.h | 6 +- Marlin/src/module/settings.cpp | 22 +- Marlin/src/module/stepper.cpp | 398 ++++++++++-------- Marlin/src/module/stepper.h | 264 +++++++----- buildroot/tests/mega2560 | 4 +- ini/features.ini | 2 +- 15 files changed, 472 insertions(+), 371 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 246664ff2a06..c168240e243d 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1062,12 +1062,14 @@ * * Zero Vibration (ZV) Input Shaping for X and/or Y movements. * - * This option uses a lot of SRAM for the step buffer, which is proportional - * to the largest step rate possible for any axis. If the build fails due to + * This option uses a lot of SRAM for the step buffer, which is related to the + * largest step rate possible for the shaped axes. If the build fails due to * low SRAM the buffer size may be reduced by setting smaller values for - * DEFAULT_AXIS_STEPS_PER_UNIT and/or DEFAULT_MAX_FEEDRATE. Runtime editing - * of max feedrate (M203) or resonant frequency (M593) may result feedrate - * being capped to prevent buffer overruns. + * DEFAULT_AXIS_STEPS_PER_UNIT and/or DEFAULT_MAX_FEEDRATE. Disabling + * ADAPTIVE_STEP_SMOOTHING and reducing the step rate for non-shaped axes may + * also reduce the buffer sizes. Runtime editing of max feedrate (M203) or + * resonant frequency (M593) may result in input shaping losing effectiveness + * during high speed movements to prevent buffer overruns. * * Tune with M593 D F: * @@ -1077,13 +1079,18 @@ * X<1> Set the given parameters only for the X axis. * Y<1> Set the given parameters only for the Y axis. */ -//#define INPUT_SHAPING -#if ENABLED(INPUT_SHAPING) - #define SHAPING_FREQ_X 40 // (Hz) The dominant resonant frequency of the X axis. - #define SHAPING_FREQ_Y 40 // (Hz) The dominant resonant frequency of the Y axis. - #define SHAPING_ZETA_X 0.3f // Damping ratio of the X axis (range: 0.0 = no damping to 1.0 = critical damping). - #define SHAPING_ZETA_Y 0.3f // Damping ratio of the Y axis (range: 0.0 = no damping to 1.0 = critical damping). - //#define SHAPING_MENU // Add a menu to the LCD to set shaping parameters. +//#define INPUT_SHAPING_X +//#define INPUT_SHAPING_Y +#if EITHER(INPUT_SHAPING_X, INPUT_SHAPING_Y) + #if ENABLED(INPUT_SHAPING_X) + #define SHAPING_FREQ_X 40 // (Hz) The default dominant resonant frequency on the X axis. + #define SHAPING_ZETA_X 0.15f // Damping ratio of the X axis (range: 0.0 = no damping to 1.0 = critical damping). + #endif + #if ENABLED(INPUT_SHAPING_Y) + #define SHAPING_FREQ_Y 40 // (Hz) The default dominant resonant frequency on the Y axis. + #define SHAPING_ZETA_Y 0.15f // Damping ratio of the Y axis (range: 0.0 = no damping to 1.0 = critical damping). + #endif + //#define SHAPING_MENU // Add a menu to the LCD to set shaping parameters. #endif #define AXIS_RELATIVE_MODES { false, false, false, false } diff --git a/Marlin/src/gcode/feature/input_shaping/M593.cpp b/Marlin/src/gcode/feature/input_shaping/M593.cpp index e1e99ca51b7a..040710f3e580 100644 --- a/Marlin/src/gcode/feature/input_shaping/M593.cpp +++ b/Marlin/src/gcode/feature/input_shaping/M593.cpp @@ -22,21 +22,21 @@ #include "../../../inc/MarlinConfig.h" -#if ENABLED(INPUT_SHAPING) +#if HAS_SHAPING #include "../../gcode.h" #include "../../../module/stepper.h" void GcodeSuite::M593_report(const bool forReplay/*=true*/) { report_heading_etc(forReplay, F("Input Shaping")); - #if HAS_SHAPING_X + #if ENABLED(INPUT_SHAPING_X) SERIAL_ECHOLNPGM(" M593 X" " F", stepper.get_shaping_frequency(X_AXIS), " D", stepper.get_shaping_damping_ratio(X_AXIS) ); #endif - #if HAS_SHAPING_Y - TERN_(HAS_SHAPING_X, report_echo_start(forReplay)); + #if ENABLED(INPUT_SHAPING_Y) + TERN_(INPUT_SHAPING_X, report_echo_start(forReplay)); SERIAL_ECHOLNPGM(" M593 Y" " F", stepper.get_shaping_frequency(Y_AXIS), " D", stepper.get_shaping_damping_ratio(Y_AXIS) @@ -55,10 +55,10 @@ void GcodeSuite::M593_report(const bool forReplay/*=true*/) { void GcodeSuite::M593() { if (!parser.seen_any()) return M593_report(); - const bool seen_X = TERN0(HAS_SHAPING_X, parser.seen_test('X')), - seen_Y = TERN0(HAS_SHAPING_Y, parser.seen_test('Y')), - for_X = seen_X || TERN0(HAS_SHAPING_X, (!seen_X && !seen_Y)), - for_Y = seen_Y || TERN0(HAS_SHAPING_Y, (!seen_X && !seen_Y)); + const bool seen_X = TERN0(INPUT_SHAPING_X, parser.seen_test('X')), + seen_Y = TERN0(INPUT_SHAPING_Y, parser.seen_test('Y')), + for_X = seen_X || TERN0(INPUT_SHAPING_X, (!seen_X && !seen_Y)), + for_Y = seen_Y || TERN0(INPUT_SHAPING_Y, (!seen_X && !seen_Y)); if (parser.seen('D')) { const float zeta = parser.value_float(); @@ -72,12 +72,13 @@ void GcodeSuite::M593() { if (parser.seen('F')) { const float freq = parser.value_float(); - if (freq > 0) { + constexpr float max_freq = float(uint32_t(STEPPER_TIMER_RATE) / 2) / shaping_time_t(-2); + if (freq == 0.0f || freq > max_freq) { if (for_X) stepper.set_shaping_frequency(X_AXIS, freq); if (for_Y) stepper.set_shaping_frequency(Y_AXIS, freq); } else - SERIAL_ECHO_MSG("?Frequency (F) must be greater than 0"); + SERIAL_ECHOLNPGM("?Frequency (F) must be greater than ", max_freq, " or 0 to disable"); } } diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index ff066ed67837..bb859d802641 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -933,7 +933,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 575: M575(); break; // M575: Set serial baudrate #endif - #if ENABLED(INPUT_SHAPING) + #if HAS_SHAPING case 593: M593(); break; // M593: Set Input Shaping parameters #endif diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 0ce8ab39025e..5d56e53dd5e0 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -259,7 +259,7 @@ * M554 - Get or set IP gateway. (Requires enabled Ethernet port) * M569 - Enable stealthChop on an axis. (Requires at least one _DRIVER_TYPE to be TMC2130/2160/2208/2209/5130/5160) * M575 - Change the serial baud rate. (Requires BAUD_RATE_GCODE) - * M593 - Get or set input shaping parameters. (Requires INPUT_SHAPING) + * M593 - Get or set input shaping parameters. (Requires INPUT_SHAPING_[XY]) * M600 - Pause for filament change: "M600 X Y Z E L". (Requires ADVANCED_PAUSE_FEATURE) * M603 - Configure filament change: "M603 T U L". (Requires ADVANCED_PAUSE_FEATURE) * M605 - Set Dual X-Carriage movement mode: "M605 S [X] [R]". (Requires DUAL_X_CARRIAGE) @@ -1081,7 +1081,7 @@ class GcodeSuite { static void M575(); #endif - #if ENABLED(INPUT_SHAPING) + #if HAS_SHAPING static void M593(); static void M593_report(const bool forReplay=true); #endif diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index d1b7a342d679..367f7f232460 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -1120,15 +1120,11 @@ #endif // Input shaping -#if ENABLED(INPUT_SHAPING) - #if !HAS_Y_AXIS - #undef SHAPING_FREQ_Y - #undef SHAPING_BUFFER_Y - #endif - #ifdef SHAPING_FREQ_X - #define HAS_SHAPING_X 1 - #endif - #ifdef SHAPING_FREQ_Y - #define HAS_SHAPING_Y 1 - #endif +#if !HAS_Y_AXIS + #undef INPUT_SHAPING_Y + #undef SHAPING_FREQ_Y + #undef SHAPING_BUFFER_Y +#endif +#if EITHER(INPUT_SHAPING_X, INPUT_SHAPING_Y) + #define HAS_SHAPING 1 #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index b2e4dc9de0f4..42f1409739ef 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -4271,14 +4271,14 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #endif // Check requirements for Input Shaping -#if ENABLED(INPUT_SHAPING) && defined(__AVR__) - #if HAS_SHAPING_X +#if HAS_SHAPING && defined(__AVR__) + #if ENABLED(INPUT_SHAPING_X) #if F_CPU > 16000000 static_assert((SHAPING_FREQ_X) * 2 * 0x10000 >= (STEPPER_TIMER_RATE), "SHAPING_FREQ_X is below the minimum (20) for AVR 20MHz."); #else static_assert((SHAPING_FREQ_X) * 2 * 0x10000 >= (STEPPER_TIMER_RATE), "SHAPING_FREQ_X is below the minimum (16) for AVR 16MHz."); #endif - #elif HAS_SHAPING_Y + #elif ENABLED(INPUT_SHAPING_Y) #if F_CPU > 16000000 static_assert((SHAPING_FREQ_Y) * 2 * 0x10000 >= (STEPPER_TIMER_RATE), "SHAPING_FREQ_Y is below the minimum (20) for AVR 20MHz."); #else @@ -4287,12 +4287,8 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); #endif #endif -#if ENABLED(INPUT_SHAPING) - #if ENABLED(DIRECT_STEPPING) - #error "INPUT_SHAPING cannot currently be used with DIRECT_STEPPING." - #elif ENABLED(LASER_FEATURE) - #error "INPUT_SHAPING cannot currently be used with LASER_FEATURE." - #endif +#if BOTH(HAS_SHAPING, DIRECT_STEPPING) + #error "INPUT_SHAPING_[XY] cannot currently be used with DIRECT_STEPPING." #endif // Misc. Cleanup diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 2ecf2def1224..45861a825235 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -403,10 +403,10 @@ namespace Language_en { LSTR MSG_A_RETRACT = _UxGT("Retract Accel"); LSTR MSG_A_TRAVEL = _UxGT("Travel Accel"); LSTR MSG_INPUT_SHAPING = _UxGT("Input Shaping"); - LSTR MSG_SHAPING_X_FREQ = STR_X _UxGT(" frequency"); - LSTR MSG_SHAPING_Y_FREQ = STR_Y _UxGT(" frequency"); - LSTR MSG_SHAPING_X_ZETA = STR_X _UxGT(" damping"); - LSTR MSG_SHAPING_Y_ZETA = STR_Y _UxGT(" damping"); + LSTR MSG_SHAPING_ENABLE = _UxGT("Enable @ shaping"); + LSTR MSG_SHAPING_DISABLE = _UxGT("Disable @ shaping"); + LSTR MSG_SHAPING_FREQ = _UxGT("@ frequency"); + LSTR MSG_SHAPING_ZETA = _UxGT("@ damping"); LSTR MSG_XY_FREQUENCY_LIMIT = _UxGT("XY Freq Limit"); LSTR MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Min FR Factor"); LSTR MSG_STEPS_PER_MM = _UxGT("Steps/mm"); diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 9d6d79efd741..875e74e8bb15 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -545,24 +545,28 @@ void menu_backlash(); START_MENU(); BACK_ITEM(MSG_ADVANCED_SETTINGS); - // M593 F Frequency - #if HAS_SHAPING_X + // M593 F Frequency and D Damping ratio + #if ENABLED(INPUT_SHAPING_X) editable.decimal = stepper.get_shaping_frequency(X_AXIS); - EDIT_ITEM_FAST(float61, MSG_SHAPING_X_FREQ, &editable.decimal, min_frequency, 200.0f, []{ stepper.set_shaping_frequency(X_AXIS, editable.decimal); }); + if (editable.decimal) { + ACTION_ITEM_N(X_AXIS, MSG_SHAPING_DISABLE, []{ stepper.set_shaping_frequency(X_AXIS, 0.0f); }); + EDIT_ITEM_FAST_N(float61, X_AXIS, MSG_SHAPING_FREQ, &editable.decimal, min_frequency, 200.0f, []{ stepper.set_shaping_frequency(X_AXIS, editable.decimal); }); + editable.decimal = stepper.get_shaping_damping_ratio(X_AXIS); + EDIT_ITEM_FAST_N(float42_52, X_AXIS, MSG_SHAPING_ZETA, &editable.decimal, 0.0f, 1.0f, []{ stepper.set_shaping_damping_ratio(X_AXIS, editable.decimal); }); + } + else + ACTION_ITEM_N(X_AXIS, MSG_SHAPING_ENABLE, []{ stepper.set_shaping_frequency(X_AXIS, SHAPING_FREQ_X); }); #endif - #if HAS_SHAPING_Y + #if ENABLED(INPUT_SHAPING_Y) editable.decimal = stepper.get_shaping_frequency(Y_AXIS); - EDIT_ITEM_FAST(float61, MSG_SHAPING_Y_FREQ, &editable.decimal, min_frequency, 200.0f, []{ stepper.set_shaping_frequency(Y_AXIS, editable.decimal); }); - #endif - - // M593 D Damping ratio - #if HAS_SHAPING_X - editable.decimal = stepper.get_shaping_damping_ratio(X_AXIS); - EDIT_ITEM_FAST(float42_52, MSG_SHAPING_X_ZETA, &editable.decimal, 0.0f, 1.0f, []{ stepper.set_shaping_damping_ratio(X_AXIS, editable.decimal); }); - #endif - #if HAS_SHAPING_Y - editable.decimal = stepper.get_shaping_damping_ratio(Y_AXIS); - EDIT_ITEM_FAST(float42_52, MSG_SHAPING_Y_ZETA, &editable.decimal, 0.0f, 1.0f, []{ stepper.set_shaping_damping_ratio(Y_AXIS, editable.decimal); }); + if (editable.decimal) { + ACTION_ITEM_N(Y_AXIS, MSG_SHAPING_DISABLE, []{ stepper.set_shaping_frequency(Y_AXIS, 0.0f); }); + EDIT_ITEM_FAST_N(float61, Y_AXIS, MSG_SHAPING_FREQ, &editable.decimal, min_frequency, 200.0f, []{ stepper.set_shaping_frequency(Y_AXIS, editable.decimal); }); + editable.decimal = stepper.get_shaping_damping_ratio(Y_AXIS); + EDIT_ITEM_FAST_N(float42_52, Y_AXIS, MSG_SHAPING_ZETA, &editable.decimal, 0.0f, 1.0f, []{ stepper.set_shaping_damping_ratio(Y_AXIS, editable.decimal); }); + } + else + ACTION_ITEM_N(Y_AXIS, MSG_SHAPING_ENABLE, []{ stepper.set_shaping_frequency(Y_AXIS, SHAPING_FREQ_Y); }); #endif END_MENU(); diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 0128d90f0fb5..ed85045098ba 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -1724,6 +1724,13 @@ float Planner::triggered_position_mm(const AxisEnum axis) { return result * mm_per_step[axis]; } +bool Planner::busy() { + return (has_blocks_queued() || cleaning_buffer_counter + || TERN0(EXTERNAL_CLOSED_LOOP_CONTROLLER, CLOSED_LOOP_WAITING()) + || TERN0(HAS_SHAPING, stepper.input_shaping_busy()) + ); +} + void Planner::finish_and_disable() { while (has_blocks_queued() || cleaning_buffer_counter) idle(); stepper.disable_all_steppers(); @@ -2483,14 +2490,6 @@ bool Planner::_populate_block( #endif // XY_FREQUENCY_LIMIT - #if ENABLED(INPUT_SHAPING) - const float top_freq = _MIN(float(0x7FFFFFFFL) - OPTARG(HAS_SHAPING_X, stepper.get_shaping_frequency(X_AXIS)) - OPTARG(HAS_SHAPING_Y, stepper.get_shaping_frequency(Y_AXIS))), - max_factor = (top_freq * float(shaping_dividends - 3) * 2.0f) / block->nominal_rate; - NOMORE(speed_factor, max_factor); - #endif - // Correct the speed if (speed_factor < 1.0f) { current_speed *= speed_factor; diff --git a/Marlin/src/module/planner.h b/Marlin/src/module/planner.h index 32b5a8795bcb..dcfdb1c28e6b 100644 --- a/Marlin/src/module/planner.h +++ b/Marlin/src/module/planner.h @@ -930,11 +930,7 @@ class Planner { static float triggered_position_mm(const AxisEnum axis); // Blocks are queued, or we're running out moves, or the closed loop controller is waiting - static bool busy() { - return (has_blocks_queued() || cleaning_buffer_counter - || TERN0(EXTERNAL_CLOSED_LOOP_CONTROLLER, CLOSED_LOOP_WAITING()) - ); - } + static bool busy(); // Block until all buffered steps are executed / cleaned static void synchronize(); diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 921b0d91cb2a..4ae4c19922d9 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -580,11 +580,11 @@ typedef struct SettingsDataStruct { // // Input Shaping // - #if HAS_SHAPING_X + #if ENABLED(INPUT_SHAPING_X) float shaping_x_frequency, // M593 X F shaping_x_zeta; // M593 X D #endif - #if HAS_SHAPING_Y + #if ENABLED(INPUT_SHAPING_Y) float shaping_y_frequency, // M593 Y F shaping_y_zeta; // M593 Y D #endif @@ -1617,12 +1617,12 @@ void MarlinSettings::postprocess() { // // Input Shaping /// - #if ENABLED(INPUT_SHAPING) - #if HAS_SHAPING_X + #if HAS_SHAPING + #if ENABLED(INPUT_SHAPING_X) EEPROM_WRITE(stepper.get_shaping_frequency(X_AXIS)); EEPROM_WRITE(stepper.get_shaping_damping_ratio(X_AXIS)); #endif - #if HAS_SHAPING_Y + #if ENABLED(INPUT_SHAPING_Y) EEPROM_WRITE(stepper.get_shaping_frequency(Y_AXIS)); EEPROM_WRITE(stepper.get_shaping_damping_ratio(Y_AXIS)); #endif @@ -2602,7 +2602,7 @@ void MarlinSettings::postprocess() { // // Input Shaping // - #if HAS_SHAPING_X + #if ENABLED(INPUT_SHAPING_X) { float _data[2]; EEPROM_READ(_data); @@ -2611,7 +2611,7 @@ void MarlinSettings::postprocess() { } #endif - #if HAS_SHAPING_Y + #if ENABLED(INPUT_SHAPING_Y) { float _data[2]; EEPROM_READ(_data); @@ -3389,12 +3389,12 @@ void MarlinSettings::reset() { // // Input Shaping // - #if ENABLED(INPUT_SHAPING) - #if HAS_SHAPING_X + #if HAS_SHAPING + #if ENABLED(INPUT_SHAPING_X) stepper.set_shaping_frequency(X_AXIS, SHAPING_FREQ_X); stepper.set_shaping_damping_ratio(X_AXIS, SHAPING_ZETA_X); #endif - #if HAS_SHAPING_Y + #if ENABLED(INPUT_SHAPING_Y) stepper.set_shaping_frequency(Y_AXIS, SHAPING_FREQ_Y); stepper.set_shaping_damping_ratio(Y_AXIS, SHAPING_ZETA_Y); #endif @@ -3650,7 +3650,7 @@ void MarlinSettings::reset() { // // Input Shaping // - TERN_(INPUT_SHAPING, gcode.M593_report(forReplay)); + TERN_(HAS_SHAPING, gcode.M593_report(forReplay)); // // Linear Advance diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 6cc40ccecee9..74e761dc6478 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -232,17 +232,25 @@ uint32_t Stepper::advance_divisor = 0, Stepper::la_advance_steps = 0; #endif -#if ENABLED(INPUT_SHAPING) - shaping_time_t DelayTimeManager::now = 0; - ParamDelayQueue Stepper::shaping_dividend_queue; - DelayQueue Stepper::shaping_queue; - #if HAS_SHAPING_X - shaping_time_t DelayTimeManager::delay_x; - ShapeParams Stepper::shaping_x; +#if HAS_SHAPING + shaping_time_t ShapingQueue::now = 0; + shaping_time_t ShapingQueue::times[shaping_echoes]; + shaping_echo_axis_t ShapingQueue::echo_axes[shaping_echoes]; + uint16_t ShapingQueue::tail = 0; + + #if ENABLED(INPUT_SHAPING_X) + shaping_time_t ShapingQueue::delay_x; + shaping_time_t ShapingQueue::peek_x_val = shaping_time_t(-1); + uint16_t ShapingQueue::head_x = 0; + uint16_t ShapingQueue::_free_count_x = shaping_echoes - 1; + ShapeParams Stepper::shaping_x; #endif - #if HAS_SHAPING_Y - shaping_time_t DelayTimeManager::delay_y; - ShapeParams Stepper::shaping_y; + #if ENABLED(INPUT_SHAPING_Y) + shaping_time_t ShapingQueue::delay_y; + shaping_time_t ShapingQueue::peek_y_val = shaping_time_t(-1); + uint16_t ShapingQueue::head_y = 0; + uint16_t ShapingQueue::_free_count_y = shaping_echoes - 1; + ShapeParams Stepper::shaping_y; #endif #endif @@ -1479,20 +1487,10 @@ void Stepper::isr() { // Enable ISRs to reduce USART processing latency hal.isr_on(); - #if ENABLED(INPUT_SHAPING) - // Speed limiting should ensure the buffers never get full. But if somehow they do, stutter rather than overflow. - if (!nextMainISR) { - TERN_(HAS_SHAPING_X, if (shaping_dividend_queue.free_count_x() == 0) nextMainISR = shaping_dividend_queue.peek_x() + 1); - TERN_(HAS_SHAPING_Y, if (shaping_dividend_queue.free_count_y() == 0) NOLESS(nextMainISR, shaping_dividend_queue.peek_y() + 1)); - TERN_(HAS_SHAPING_X, if (shaping_queue.free_count_x() < steps_per_isr) NOLESS(nextMainISR, shaping_queue.peek_x() + 1)); - TERN_(HAS_SHAPING_Y, if (shaping_queue.free_count_y() < steps_per_isr) NOLESS(nextMainISR, shaping_queue.peek_y() + 1)); - } - #endif + TERN_(HAS_SHAPING, shaping_isr()); // Do Shaper stepping, if needed if (!nextMainISR) pulse_phase_isr(); // 0 = Do coordinated axes Stepper pulses - TERN_(INPUT_SHAPING, shaping_isr()); // Do Shaper stepping, if needed - #if ENABLED(LIN_ADVANCE) if (!nextAdvanceISR) { // 0 = Do Linear Advance E Stepper pulses advance_isr(); @@ -1523,10 +1521,8 @@ void Stepper::isr() { 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 - OPTARG(HAS_SHAPING_X, shaping_dividend_queue.peek_x()) // Time until next input shaping dividend change for X - OPTARG(HAS_SHAPING_Y, shaping_dividend_queue.peek_y()) // Time until next input shaping dividend change for Y - OPTARG(HAS_SHAPING_X, shaping_queue.peek_x()) // Time until next input shaping echo for X - OPTARG(HAS_SHAPING_Y, shaping_queue.peek_y()) // Time until next input shaping echo for Y + OPTARG(INPUT_SHAPING_X, ShapingQueue::peek_x()) // Time until next input shaping echo for X + OPTARG(INPUT_SHAPING_Y, ShapingQueue::peek_y()) // Time until next input shaping echo for Y OPTARG(LIN_ADVANCE, nextAdvanceISR) // Come back early for Linear Advance? OPTARG(INTEGRATED_BABYSTEPPING, nextBabystepISR) // Come back early for Babystepping? ); @@ -1539,16 +1535,9 @@ void Stepper::isr() { // nextMainISR -= interval; - - TERN_(INPUT_SHAPING, DelayTimeManager::decrement_delays(interval)); - - #if ENABLED(LIN_ADVANCE) - if (nextAdvanceISR != LA_ADV_NEVER) nextAdvanceISR -= interval; - #endif - - #if ENABLED(INTEGRATED_BABYSTEPPING) - if (nextBabystepISR != BABYSTEP_NEVER) nextBabystepISR -= interval; - #endif + TERN_(HAS_SHAPING, ShapingQueue::decrement_delays(interval)); + TERN_(LIN_ADVANCE, if (nextAdvanceISR != LA_ADV_NEVER) nextAdvanceISR -= interval); + TERN_(INTEGRATED_BABYSTEPPING, if (nextBabystepISR != BABYSTEP_NEVER) nextBabystepISR -= interval); /** * This needs to avoid a race-condition caused by interleaving @@ -1636,11 +1625,16 @@ void Stepper::pulse_phase_isr() { abort_current_block = false; if (current_block) { discard_current_block(); - #if ENABLED(INPUT_SHAPING) - shaping_dividend_queue.purge(); - shaping_queue.purge(); - TERN_(HAS_SHAPING_X, delta_error.x = 0); - TERN_(HAS_SHAPING_Y, delta_error.y = 0); + #if HAS_SHAPING + ShapingQueue::purge(); + #if ENABLED(INPUT_SHAPING_X) + shaping_x.delta_error = 0; + shaping_x.last_block_end_pos = count_position.x; + #endif + #if ENABLED(INPUT_SHAPING_Y) + shaping_y.delta_error = 0; + shaping_y.last_block_end_pos = count_position.y; + #endif #endif } } @@ -1676,31 +1670,48 @@ void Stepper::pulse_phase_isr() { #define PULSE_PREP(AXIS) do{ \ delta_error[_AXIS(AXIS)] += advance_dividend[_AXIS(AXIS)]; \ step_needed[_AXIS(AXIS)] = (delta_error[_AXIS(AXIS)] >= 0); \ - if (step_needed[_AXIS(AXIS)]) { \ - count_position[_AXIS(AXIS)] += count_direction[_AXIS(AXIS)]; \ + if (step_needed[_AXIS(AXIS)]) \ delta_error[_AXIS(AXIS)] -= advance_divisor; \ - } \ }while(0) - #define PULSE_PREP_SHAPING(AXIS, DIVIDEND) do{ \ - delta_error[_AXIS(AXIS)] += (DIVIDEND); \ - if ((MAXDIR(AXIS) && delta_error[_AXIS(AXIS)] <= -0x30000000L) || (MINDIR(AXIS) && delta_error[_AXIS(AXIS)] >= 0x30000000L)) { \ - TBI(last_direction_bits, _AXIS(AXIS)); \ - DIR_WAIT_BEFORE(); \ - SET_STEP_DIR(AXIS); \ - DIR_WAIT_AFTER(); \ - } \ - step_needed[_AXIS(AXIS)] = (MAXDIR(AXIS) && delta_error[_AXIS(AXIS)] >= 0x10000000L) || \ - (MINDIR(AXIS) && delta_error[_AXIS(AXIS)] <= -0x10000000L); \ + // With input shaping, direction changes can happen with almost only + // AWAIT_LOW_PULSE() and DIR_WAIT_BEFORE() between steps. To work around + // the TMC2208 / TMC2225 shutdown bug (#16076), add a half step hysteresis + // in each direction. This results in the position being off by half an + // average half step during travel but correct at the end of each segment. + #if AXIS_DRIVER_TYPE_X(TMC2208) || AXIS_DRIVER_TYPE_X(TMC2208_STANDALONE) + #define HYSTERESIS_X 64 + #else + #define HYSTERESIS_X 0 + #endif + #if AXIS_DRIVER_TYPE_Y(TMC2208) || AXIS_DRIVER_TYPE_Y(TMC2208_STANDALONE) + #define HYSTERESIS_Y 64 + #else + #define HYSTERESIS_Y 0 + #endif + #define _HYSTERESIS(AXIS) HYSTERESIS_##AXIS + #define HYSTERESIS(AXIS) _HYSTERESIS(AXIS) + + #define PULSE_PREP_SHAPING(AXIS, DELTA_ERROR, DIVIDEND) do{ \ if (step_needed[_AXIS(AXIS)]) { \ - count_position[_AXIS(AXIS)] += count_direction[_AXIS(AXIS)]; \ - delta_error[_AXIS(AXIS)] += MAXDIR(AXIS) ? -0x20000000L : 0x20000000L; \ + DELTA_ERROR += (DIVIDEND); \ + if ((MAXDIR(AXIS) && DELTA_ERROR <= -(64 + HYSTERESIS(AXIS))) || (MINDIR(AXIS) && DELTA_ERROR >= (64 + HYSTERESIS(AXIS)))) { \ + { USING_TIMED_PULSE(); START_TIMED_PULSE(); AWAIT_LOW_PULSE(); } \ + TBI(last_direction_bits, _AXIS(AXIS)); \ + DIR_WAIT_BEFORE(); \ + SET_STEP_DIR(AXIS); \ + DIR_WAIT_AFTER(); \ + } \ + step_needed[_AXIS(AXIS)] = DELTA_ERROR <= -(64 + HYSTERESIS(AXIS)) || DELTA_ERROR >= (64 + HYSTERESIS(AXIS)); \ + if (step_needed[_AXIS(AXIS)]) \ + DELTA_ERROR += MAXDIR(AXIS) ? -128 : 128; \ } \ }while(0) // Start an active pulse if needed #define PULSE_START(AXIS) do{ \ if (step_needed[_AXIS(AXIS)]) { \ + count_position[_AXIS(AXIS)] += count_direction[_AXIS(AXIS)]; \ _APPLY_STEP(AXIS, !_INVERT_STEP_PIN(AXIS), 0); \ } \ }while(0) @@ -1819,22 +1830,12 @@ void Stepper::pulse_phase_isr() { #endif // DIRECT_STEPPING if (!is_page) { - TERN_(INPUT_SHAPING, shaping_queue.enqueue()); - // Determine if pulses are needed #if HAS_X_STEP - #if HAS_SHAPING_X - PULSE_PREP_SHAPING(X, advance_dividend.x); - #else - PULSE_PREP(X); - #endif + PULSE_PREP(X); #endif #if HAS_Y_STEP - #if HAS_SHAPING_Y - PULSE_PREP_SHAPING(Y, advance_dividend.y); - #else - PULSE_PREP(Y); - #endif + PULSE_PREP(Y); #endif #if HAS_Z_STEP PULSE_PREP(Z); @@ -1871,6 +1872,24 @@ void Stepper::pulse_phase_isr() { } #endif #endif + + #if HAS_SHAPING + // record an echo if a step is needed in the primary bresenham + const bool x_step = TERN0(INPUT_SHAPING_X, shaping_x.enabled && step_needed[X_AXIS]), + y_step = TERN0(INPUT_SHAPING_Y, shaping_y.enabled && step_needed[Y_AXIS]); + if (x_step || y_step) + ShapingQueue::enqueue(x_step, TERN0(INPUT_SHAPING_X, shaping_x.forward), y_step, TERN0(INPUT_SHAPING_Y, shaping_y.forward)); + + // do the first part of the secondary bresenham + #if ENABLED(INPUT_SHAPING_X) + if (shaping_x.enabled) + PULSE_PREP_SHAPING(X, shaping_x.delta_error, shaping_x.factor1 * (shaping_x.forward ? 1 : -1)); + #endif + #if ENABLED(INPUT_SHAPING_Y) + if (shaping_y.enabled) + PULSE_PREP_SHAPING(Y, shaping_y.delta_error, shaping_y.factor1 * (shaping_y.forward ? 1 : -1)); + #endif + #endif } #if ISR_MULTI_STEPS @@ -1910,7 +1929,10 @@ void Stepper::pulse_phase_isr() { #endif #if ENABLED(MIXING_EXTRUDER) - if (step_needed.e) E_STEP_WRITE(mixer.get_next_stepper(), !INVERT_E_STEP_PIN); + if (step_needed.e) { + count_position[E_AXIS] += count_direction[E_AXIS]; + E_STEP_WRITE(mixer.get_next_stepper(), !INVERT_E_STEP_PIN); + } #elif HAS_E0_STEP PULSE_START(E); #endif @@ -1965,55 +1987,59 @@ void Stepper::pulse_phase_isr() { } while (--events_to_do); } -#if ENABLED(INPUT_SHAPING) +#if HAS_SHAPING void Stepper::shaping_isr() { - xyze_bool_t step_needed{0}; + xy_bool_t step_needed{0}; + + // Clear the echoes that are ready to process. If the buffers are too full and risk overflo, also apply echoes early. + TERN_(INPUT_SHAPING_X, step_needed[X_AXIS] = !ShapingQueue::peek_x() || ShapingQueue::free_count_x() < steps_per_isr); + TERN_(INPUT_SHAPING_Y, step_needed[Y_AXIS] = !ShapingQueue::peek_y() || ShapingQueue::free_count_y() < steps_per_isr); + + if (bool(step_needed)) while (true) { + #if ENABLED(INPUT_SHAPING_X) + if (step_needed[X_AXIS]) { + const bool forward = ShapingQueue::dequeue_x(); + PULSE_PREP_SHAPING(X, shaping_x.delta_error, shaping_x.factor2 * (forward ? 1 : -1)); + PULSE_START(X); + } + #endif - const bool shapex = TERN0(HAS_SHAPING_X, !shaping_queue.peek_x()), - shapey = TERN0(HAS_SHAPING_Y, !shaping_queue.peek_y()); + #if ENABLED(INPUT_SHAPING_Y) + if (step_needed[Y_AXIS]) { + const bool forward = ShapingQueue::dequeue_y(); + PULSE_PREP_SHAPING(Y, shaping_y.delta_error, shaping_y.factor2 * (forward ? 1 : -1)); + PULSE_START(Y); + } + #endif - #if HAS_SHAPING_X - if (!shaping_dividend_queue.peek_x()) shaping_x.dividend = shaping_dividend_queue.dequeue_x(); - #endif - #if HAS_SHAPING_Y - if (!shaping_dividend_queue.peek_y()) shaping_y.dividend = shaping_dividend_queue.dequeue_y(); - #endif + TERN_(I2S_STEPPER_STREAM, i2s_push_sample()); - #if HAS_SHAPING_X - if (shapex) { - shaping_queue.dequeue_x(); - PULSE_PREP_SHAPING(X, shaping_x.dividend); - PULSE_START(X); + USING_TIMED_PULSE(); + if (bool(step_needed)) { + #if ISR_MULTI_STEPS + START_TIMED_PULSE(); + AWAIT_HIGH_PULSE(); + #endif + #if ENABLED(INPUT_SHAPING_X) + PULSE_STOP(X); + #endif + #if ENABLED(INPUT_SHAPING_Y) + PULSE_STOP(Y); + #endif } - #endif - #if HAS_SHAPING_Y - if (shapey) { - shaping_queue.dequeue_y(); - PULSE_PREP_SHAPING(Y, shaping_y.dividend); - PULSE_START(Y); - } - #endif + TERN_(INPUT_SHAPING_X, step_needed[X_AXIS] = !ShapingQueue::peek_x() || ShapingQueue::free_count_x() < steps_per_isr); + TERN_(INPUT_SHAPING_Y, step_needed[Y_AXIS] = !ShapingQueue::peek_y() || ShapingQueue::free_count_y() < steps_per_isr); - TERN_(I2S_STEPPER_STREAM, i2s_push_sample()); + if (!bool(step_needed)) break; - if (shapex || shapey) { - #if ISR_MULTI_STEPS - USING_TIMED_PULSE(); - START_TIMED_PULSE(); - AWAIT_HIGH_PULSE(); - #endif - #if HAS_SHAPING_X - if (shapex) PULSE_STOP(X); - #endif - #if HAS_SHAPING_Y - if (shapey) PULSE_STOP(Y); - #endif + START_TIMED_PULSE(); + AWAIT_LOW_PULSE(); } } -#endif // INPUT_SHAPING +#endif // HAS_SHAPING // Calculate timer interval, with all limits applied. uint32_t Stepper::calc_timer_interval(uint32_t step_rate) { @@ -2462,79 +2488,55 @@ uint32_t Stepper::block_phase_isr() { acceleration_time = deceleration_time = 0; #if ENABLED(ADAPTIVE_STEP_SMOOTHING) - uint8_t oversampling = 0; // Assume no axis smoothing (via oversampling) + oversampling_factor = 0; // Assume no axis smoothing (via oversampling) // Decide if axis smoothing is possible uint32_t max_rate = current_block->nominal_rate; // Get the step event rate while (max_rate < MIN_STEP_ISR_FREQUENCY) { // As long as more ISRs are possible... max_rate <<= 1; // Try to double the rate if (max_rate < MIN_STEP_ISR_FREQUENCY) // Don't exceed the estimated ISR limit - ++oversampling; // Increase the oversampling (used for left-shift) + ++oversampling_factor; // Increase the oversampling (used for left-shift) } - oversampling_factor = oversampling; // For all timer interval calculations - #else - constexpr uint8_t oversampling = 0; #endif // Based on the oversampling factor, do the calculations - step_event_count = current_block->step_event_count << oversampling; + step_event_count = current_block->step_event_count << oversampling_factor; // Initialize Bresenham delta errors to 1/2 - #if HAS_SHAPING_X - const int32_t old_delta_error_x = delta_error.x; - #endif - #if HAS_SHAPING_Y - const int32_t old_delta_error_y = delta_error.y; - #endif delta_error = TERN_(LIN_ADVANCE, la_delta_error =) -int32_t(step_event_count); // Calculate Bresenham dividends and divisors advance_dividend = (current_block->steps << 1).asLong(); advance_divisor = step_event_count << 1; - // for input shaped axes, advance_divisor is replaced with 0x40000000 - // and steps are repeated twice so dividends have to be scaled and halved - // and the dividend is directional, i.e. signed - TERN_(HAS_SHAPING_X, advance_dividend.x = (uint64_t(current_block->steps.x) << 29) / step_event_count); - TERN_(HAS_SHAPING_X, if (TEST(current_block->direction_bits, X_AXIS)) advance_dividend.x *= -1); - TERN_(HAS_SHAPING_X, if (!shaping_queue.empty_x()) SET_BIT_TO(current_block->direction_bits, X_AXIS, TEST(last_direction_bits, X_AXIS))); - TERN_(HAS_SHAPING_Y, advance_dividend.y = (uint64_t(current_block->steps.y) << 29) / step_event_count); - TERN_(HAS_SHAPING_Y, if (TEST(current_block->direction_bits, Y_AXIS)) advance_dividend.y *= -1); - TERN_(HAS_SHAPING_Y, if (!shaping_queue.empty_y()) SET_BIT_TO(current_block->direction_bits, Y_AXIS, TEST(last_direction_bits, Y_AXIS))); - - // The scaling operation above introduces rounding errors which must now be removed. - // For this segment, there will be step_event_count calls to the Bresenham logic and the same number of echoes. - // For each pair of calls to the Bresenham logic, delta_error will increase by advance_dividend modulo 0x20000000 - // so (e.g. for x) delta_error.x will end up changing by (advance_dividend.x * step_event_count) % 0x20000000. - // For a divisor which is a power of 2, modulo is the same as as a bitmask, i.e. - // (advance_dividend.x * step_event_count) & 0x1FFFFFFF. - // This segment's final change in delta_error should actually be zero so we need to increase delta_error by - // 0 - ((advance_dividend.x * step_event_count) & 0x1FFFFFFF) - // And this needs to be adjusted to the range -0x10000000 to 0x10000000. - // Adding and subtracting 0x10000000 inside the outside the modulo achieves this. - TERN_(HAS_SHAPING_X, delta_error.x = old_delta_error_x + 0x10000000L - ((0x10000000L + advance_dividend.x * step_event_count) & 0x1FFFFFFFUL)); - TERN_(HAS_SHAPING_Y, delta_error.y = old_delta_error_y + 0x10000000L - ((0x10000000L + advance_dividend.y * step_event_count) & 0x1FFFFFFFUL)); - - // when there is damping, the signal and its echo have different amplitudes - #if ENABLED(HAS_SHAPING_X) - const int32_t echo_x = shaping_x.factor * (advance_dividend.x >> 7); - #endif - #if ENABLED(HAS_SHAPING_Y) - const int32_t echo_y = shaping_y.factor * (advance_dividend.y >> 7); - #endif - - // plan the change of values for advance_dividend for the input shaping echoes - TERN_(INPUT_SHAPING, shaping_dividend_queue.enqueue(TERN0(HAS_SHAPING_X, echo_x), TERN0(HAS_SHAPING_Y, echo_y))); - - // apply the adjustment to the primary signal - TERN_(HAS_SHAPING_X, advance_dividend.x -= echo_x); - TERN_(HAS_SHAPING_Y, advance_dividend.y -= echo_y); + #if ENABLED(INPUT_SHAPING_X) + if (shaping_x.enabled) { + const int64_t steps = TEST(current_block->direction_bits, X_AXIS) ? -int64_t(current_block->steps.x) : int64_t(current_block->steps.x); + shaping_x.last_block_end_pos += steps; + + // If there are any remaining echos unprocessed, then direction change must + // be delayed and processed in PULSE_PREP_SHAPING. This will cause half a step + // to be missed, which will need recovering and this can be done through shaping_x.remainder. + shaping_x.forward = !TEST(current_block->direction_bits, X_AXIS); + if (!ShapingQueue::empty_x()) SET_BIT_TO(current_block->direction_bits, X_AXIS, TEST(last_direction_bits, X_AXIS)); + } + #endif + + // Y follows the same logic as X (but the comments aren't repeated) + #if ENABLED(INPUT_SHAPING_Y) + if (shaping_y.enabled) { + const int64_t steps = TEST(current_block->direction_bits, Y_AXIS) ? -int64_t(current_block->steps.y) : int64_t(current_block->steps.y); + shaping_y.last_block_end_pos += steps; + shaping_y.forward = !TEST(current_block->direction_bits, Y_AXIS); + if (!ShapingQueue::empty_y()) SET_BIT_TO(current_block->direction_bits, Y_AXIS, TEST(last_direction_bits, Y_AXIS)); + } + #endif // No step events completed so far step_events_completed = 0; // Compute the acceleration and deceleration points - accelerate_until = current_block->accelerate_until << oversampling; - decelerate_after = current_block->decelerate_after << oversampling; + accelerate_until = current_block->accelerate_until << oversampling_factor; + decelerate_after = current_block->decelerate_after << oversampling_factor; TERN_(MIXING_EXTRUDER, mixer.stepper_setup(current_block->b_color)); @@ -2548,7 +2550,7 @@ uint32_t Stepper::block_phase_isr() { #endif if (current_block->la_advance_rate) { // apply LA scaling and discount the effect of frequency scaling - la_dividend = (advance_dividend.e << current_block->la_scaling) << oversampling; + la_dividend = (advance_dividend.e << current_block->la_scaling) << oversampling_factor; } #endif @@ -2974,7 +2976,8 @@ void Stepper::init() { #endif } -#if ENABLED(INPUT_SHAPING) +#if HAS_SHAPING + /** * Calculate a fixed point factor to apply to the signal and its echo * when shaping an axis. @@ -2983,41 +2986,68 @@ void Stepper::init() { // from the damping ratio, get a factor that can be applied to advance_dividend for fixed point maths // for ZV, we use amplitudes 1/(1+K) and K/(1+K) where K = exp(-zeta * M_PI / sqrt(1.0f - zeta * zeta)) // which can be converted to 1:7 fixed point with an excellent fit with a 3rd order polynomial - float shaping_factor; - if (zeta <= 0.0f) shaping_factor = 64.0f; - else if (zeta >= 1.0f) shaping_factor = 0.0f; + float factor2; + if (zeta <= 0.0f) factor2 = 64.0f; + else if (zeta >= 1.0f) factor2 = 0.0f; else { - shaping_factor = 64.44056192 + -99.02008832 * zeta; + factor2 = 64.44056192 + -99.02008832 * zeta; const float zeta2 = zeta * zeta; - shaping_factor += -7.58095488 * zeta2; + factor2 += -7.58095488 * zeta2; const float zeta3 = zeta2 * zeta; - shaping_factor += 43.073216 * zeta3; + factor2 += 43.073216 * zeta3; + factor2 = floor(factor2); } const bool was_on = hal.isr_state(); hal.isr_off(); - TERN_(HAS_SHAPING_X, if (axis == X_AXIS) { shaping_x.factor = floor(shaping_factor); shaping_x.zeta = zeta; }) - TERN_(HAS_SHAPING_Y, if (axis == Y_AXIS) { shaping_y.factor = floor(shaping_factor); shaping_y.zeta = zeta; }) + TERN_(INPUT_SHAPING_X, if (axis == X_AXIS) { shaping_x.factor2 = factor2; shaping_x.factor1 = 128 - factor2; shaping_x.zeta = zeta; }) + TERN_(INPUT_SHAPING_Y, if (axis == Y_AXIS) { shaping_y.factor2 = factor2; shaping_y.factor1 = 128 - factor2; shaping_y.zeta = zeta; }) if (was_on) hal.isr_on(); } float Stepper::get_shaping_damping_ratio(const AxisEnum axis) { - TERN_(HAS_SHAPING_X, if (axis == X_AXIS) return shaping_x.zeta); - TERN_(HAS_SHAPING_Y, if (axis == Y_AXIS) return shaping_y.zeta); + TERN_(INPUT_SHAPING_X, if (axis == X_AXIS) return shaping_x.zeta); + TERN_(INPUT_SHAPING_Y, if (axis == Y_AXIS) return shaping_y.zeta); return -1; } void Stepper::set_shaping_frequency(const AxisEnum axis, const float freq) { - TERN_(HAS_SHAPING_X, if (axis == X_AXIS) { DelayTimeManager::set_delay(axis, float(uint32_t(STEPPER_TIMER_RATE) / 2) / freq); shaping_x.frequency = freq; }) - TERN_(HAS_SHAPING_Y, if (axis == Y_AXIS) { DelayTimeManager::set_delay(axis, float(uint32_t(STEPPER_TIMER_RATE) / 2) / freq); shaping_y.frequency = freq; }) + // enabling or disabling shaping whilst moving can result in lost steps + Planner::synchronize(); + + const bool was_on = hal.isr_state(); + hal.isr_off(); + + const shaping_time_t delay = freq ? float(uint32_t(STEPPER_TIMER_RATE) / 2) / freq : shaping_time_t(-1); + #if ENABLED(INPUT_SHAPING_X) + if (axis == X_AXIS) { + ShapingQueue::set_delay(X_AXIS, delay); + shaping_x.frequency = freq; + shaping_x.enabled = !!freq; + shaping_x.delta_error = 0; + shaping_x.last_block_end_pos = count_position.x; + } + #endif + #if ENABLED(INPUT_SHAPING_Y) + if (axis == Y_AXIS) { + ShapingQueue::set_delay(Y_AXIS, delay); + shaping_y.frequency = freq; + shaping_y.enabled = !!freq; + shaping_y.delta_error = 0; + shaping_y.last_block_end_pos = count_position.y; + } + #endif + + if (was_on) hal.isr_on(); } float Stepper::get_shaping_frequency(const AxisEnum axis) { - TERN_(HAS_SHAPING_X, if (axis == X_AXIS) return shaping_x.frequency); - TERN_(HAS_SHAPING_Y, if (axis == Y_AXIS) return shaping_y.frequency); + TERN_(INPUT_SHAPING_X, if (axis == X_AXIS) return shaping_x.frequency); + TERN_(INPUT_SHAPING_Y, if (axis == Y_AXIS) return shaping_y.frequency); return -1; } -#endif + +#endif // HAS_SHAPING /** * Set the stepper positions directly in steps @@ -3029,6 +3059,13 @@ void Stepper::init() { * derive the current XYZE position later on. */ void Stepper::_set_position(const abce_long_t &spos) { + #if ENABLED(INPUT_SHAPING_X) + const int32_t x_shaping_delta = count_position.x - shaping_x.last_block_end_pos; + #endif + #if ENABLED(INPUT_SHAPING_Y) + const int32_t y_shaping_delta = count_position.y - shaping_y.last_block_end_pos; + #endif + #if ANY(IS_CORE, MARKFORGED_XY, MARKFORGED_YX) #if CORE_IS_XY // corexy positioning @@ -3058,6 +3095,19 @@ void Stepper::_set_position(const abce_long_t &spos) { // default non-h-bot planning count_position = spos; #endif + + #if ENABLED(INPUT_SHAPING_X) + if (shaping_x.enabled) { + count_position.x += x_shaping_delta; + shaping_x.last_block_end_pos = spos.x; + } + #endif + #if ENABLED(INPUT_SHAPING_Y) + if (shaping_y.enabled) { + count_position.y += y_shaping_delta; + shaping_y.last_block_end_pos = spos.y; + } + #endif } /** @@ -3097,6 +3147,8 @@ void Stepper::set_axis_position(const AxisEnum a, const int32_t &v) { #endif count_position[a] = v; + TERN_(INPUT_SHAPING_X, if (a == X_AXIS) shaping_x.last_block_end_pos = v); + TERN_(INPUT_SHAPING_Y, if (a == Y_AXIS) shaping_y.last_block_end_pos = v); #ifdef __AVR__ // Reenable Stepper ISR diff --git a/Marlin/src/module/stepper.h b/Marlin/src/module/stepper.h index 5b634c52e476..f29bb346d1e3 100644 --- a/Marlin/src/module/stepper.h +++ b/Marlin/src/module/stepper.h @@ -75,8 +75,8 @@ */ #define TIMER_READ_ADD_AND_STORE_CYCLES 34UL - // The base ISR takes 792 cycles - #define ISR_BASE_CYCLES 792UL + // The base ISR + #define ISR_BASE_CYCLES 770UL // Linear advance base time is 64 cycles #if ENABLED(LIN_ADVANCE) @@ -92,21 +92,25 @@ #define ISR_S_CURVE_CYCLES 0UL #endif + // Input shaping base time + #if HAS_SHAPING + #define ISR_SHAPING_BASE_CYCLES 180UL + #else + #define ISR_SHAPING_BASE_CYCLES 0UL + #endif + // Stepper Loop base cycles #define ISR_LOOP_BASE_CYCLES 4UL - // To start the step pulse, in the worst case takes - #define ISR_START_STEPPER_CYCLES 13UL - // And each stepper (start + stop pulse) takes in worst case - #define ISR_STEPPER_CYCLES 16UL + #define ISR_STEPPER_CYCLES 100UL #else // Cycles to perform actions in START_TIMED_PULSE #define TIMER_READ_ADD_AND_STORE_CYCLES 13UL - // The base ISR takes 752 cycles - #define ISR_BASE_CYCLES 752UL + // The base ISR + #define ISR_BASE_CYCLES 1000UL // Linear advance base time is 32 cycles #if ENABLED(LIN_ADVANCE) @@ -122,12 +126,16 @@ #define ISR_S_CURVE_CYCLES 0UL #endif + // Input shaping base time + #if HAS_SHAPING + #define ISR_SHAPING_BASE_CYCLES 290UL + #else + #define ISR_SHAPING_BASE_CYCLES 0UL + #endif + // Stepper Loop base cycles #define ISR_LOOP_BASE_CYCLES 32UL - // To start the step pulse, in the worst case takes - #define ISR_START_STEPPER_CYCLES 57UL - // And each stepper (start + stop pulse) takes in worst case #define ISR_STEPPER_CYCLES 88UL @@ -202,8 +210,12 @@ #error "Expected at least one of MINIMUM_STEPPER_PULSE or MAXIMUM_STEPPER_RATE to be defined" #endif -// But the user could be enforcing a minimum time, so the loop time is -#define ISR_LOOP_CYCLES (ISR_LOOP_BASE_CYCLES + _MAX(MIN_STEPPER_PULSE_CYCLES, MIN_ISR_LOOP_CYCLES)) +// The loop takes the base time plus the time for all the bresenham logic for R pulses plus the time +// between pulses for (R-1) pulses. But the user could be enforcing a minimum time so the loop time is: +#define ISR_LOOP_CYCLES(R) ((ISR_LOOP_BASE_CYCLES + MIN_ISR_LOOP_CYCLES + MIN_STEPPER_PULSE_CYCLES) * (R - 1) + _MAX(MIN_ISR_LOOP_CYCLES, MIN_STEPPER_PULSE_CYCLES)) + +// Model input shaping as an extra loop call +#define ISR_SHAPING_LOOP_CYCLES(R) ((TERN0(HAS_SHAPING, ISR_LOOP_BASE_CYCLES) + TERN0(INPUT_SHAPING_X, ISR_X_STEPPER_CYCLES) + TERN0(INPUT_SHAPING_Y, ISR_Y_STEPPER_CYCLES)) * (R) + (MIN_ISR_LOOP_CYCLES) * (R - 1)) // If linear advance is enabled, then it is handled separately #if ENABLED(LIN_ADVANCE) @@ -228,7 +240,7 @@ #endif // Now estimate the total ISR execution time in cycles given a step per ISR multiplier -#define ISR_EXECUTION_CYCLES(R) (((ISR_BASE_CYCLES + ISR_S_CURVE_CYCLES + (ISR_LOOP_CYCLES) * (R) + ISR_LA_BASE_CYCLES + ISR_LA_LOOP_CYCLES)) / (R)) +#define ISR_EXECUTION_CYCLES(R) (((ISR_BASE_CYCLES + ISR_S_CURVE_CYCLES + ISR_SHAPING_BASE_CYCLES + ISR_LOOP_CYCLES(R) + ISR_SHAPING_LOOP_CYCLES(R) + ISR_LA_BASE_CYCLES + ISR_LA_LOOP_CYCLES)) / (R)) // The maximum allowable stepping frequency when doing x128-x1 stepping (in Hz) #define MAX_STEP_ISR_FREQUENCY_128X ((F_CPU) / ISR_EXECUTION_CYCLES(128)) @@ -312,116 +324,142 @@ constexpr ena_mask_t enable_overlap[] = { //static_assert(!any_enable_overlap(), "There is some overlap."); -#if ENABLED(INPUT_SHAPING) - - typedef IF::type shaping_time_t; +#if HAS_SHAPING // These constexpr are used to calculate the shaping queue buffer sizes constexpr xyze_float_t max_feedrate = DEFAULT_MAX_FEEDRATE; constexpr xyze_float_t steps_per_unit = DEFAULT_AXIS_STEPS_PER_UNIT; - constexpr float max_steprate = _MAX(LOGICAL_AXIS_LIST( - max_feedrate.e * steps_per_unit.e, - max_feedrate.x * steps_per_unit.x, - max_feedrate.y * steps_per_unit.y, - max_feedrate.z * steps_per_unit.z, - max_feedrate.i * steps_per_unit.i, - max_feedrate.j * steps_per_unit.j, - max_feedrate.k * steps_per_unit.k, - max_feedrate.u * steps_per_unit.u, - max_feedrate.v * steps_per_unit.v, - max_feedrate.w * steps_per_unit.w - )); - constexpr uint16_t shaping_dividends = max_steprate / _MIN(0x7FFFFFFFL OPTARG(HAS_SHAPING_X, SHAPING_FREQ_X) OPTARG(HAS_SHAPING_Y, SHAPING_FREQ_Y)) / 2 + 3; - constexpr uint16_t shaping_segments = max_steprate / (MIN_STEPS_PER_SEGMENT) / _MIN(0x7FFFFFFFL OPTARG(HAS_SHAPING_X, SHAPING_FREQ_X) OPTARG(HAS_SHAPING_Y, SHAPING_FREQ_Y)) / 2 + 3; - - class DelayTimeManager { - private: - static shaping_time_t now; - #ifdef HAS_SHAPING_X - static shaping_time_t delay_x; - #endif - #ifdef HAS_SHAPING_Y - static shaping_time_t delay_y; - #endif - public: - static void decrement_delays(const shaping_time_t interval) { now += interval; } - static void set_delay(const AxisEnum axis, const shaping_time_t delay) { - TERN_(HAS_SHAPING_X, if (axis == X_AXIS) delay_x = delay); - TERN_(HAS_SHAPING_Y, if (axis == Y_AXIS) delay_y = delay); - } - }; - - template - class DelayQueue : public DelayTimeManager { - protected: - shaping_time_t times[SIZE]; - uint16_t tail = 0 OPTARG(HAS_SHAPING_X, head_x = 0) OPTARG(HAS_SHAPING_Y, head_y = 0); + // MIN_STEP_ISR_FREQUENCY is known at compile time on AVRs and any reduction in SRAM is welcome + #ifdef __AVR__ + constexpr float max_isr_rate = _MAX( + LOGICAL_AXIS_LIST( + max_feedrate.e * steps_per_unit.e, + max_feedrate.x * steps_per_unit.x, + max_feedrate.y * steps_per_unit.y, + max_feedrate.z * steps_per_unit.z, + max_feedrate.i * steps_per_unit.i, + max_feedrate.j * steps_per_unit.j, + max_feedrate.k * steps_per_unit.k, + max_feedrate.u * steps_per_unit.u, + max_feedrate.v * steps_per_unit.v, + max_feedrate.w * steps_per_unit.w + ) + OPTARG(ADAPTIVE_STEP_SMOOTHING, MIN_STEP_ISR_FREQUENCY) + ); + constexpr float max_step_rate = _MIN(max_isr_rate, + TERN0(INPUT_SHAPING_X, max_feedrate.x * steps_per_unit.x) + + TERN0(INPUT_SHAPING_Y, max_feedrate.y * steps_per_unit.y) + ); + #else + constexpr float max_step_rate = TERN0(INPUT_SHAPING_X, max_feedrate.x * steps_per_unit.x) + + TERN0(INPUT_SHAPING_Y, max_feedrate.y * steps_per_unit.y); + #endif + constexpr uint16_t shaping_echoes = max_step_rate / _MIN(0x7FFFFFFFL OPTARG(INPUT_SHAPING_X, SHAPING_FREQ_X) OPTARG(INPUT_SHAPING_Y, SHAPING_FREQ_Y)) / 2 + 3; - public: - void enqueue() { - times[tail] = now; - if (++tail == SIZE) tail = 0; - } - #ifdef HAS_SHAPING_X - shaping_time_t peek_x() { - if (head_x != tail) return times[head_x] + delay_x - now; - else return shaping_time_t(-1); - } - void dequeue_x() { if (++head_x == SIZE) head_x = 0; } - bool empty_x() { return head_x == tail; } - uint16_t free_count_x() { return head_x > tail ? head_x - tail - 1 : head_x + SIZE - tail - 1; } - #endif - #ifdef HAS_SHAPING_Y - shaping_time_t peek_y() { - if (head_y != tail) return times[head_y] + delay_y - now; - else return shaping_time_t(-1); - } - void dequeue_y() { if (++head_y == SIZE) head_y = 0; } - bool empty_y() { return head_y == tail; } - uint16_t free_count_y() { return head_y > tail ? head_y - tail - 1 : head_y + SIZE - tail - 1; } - #endif - void purge() { auto temp = TERN_(HAS_SHAPING_X, head_x) = TERN_(HAS_SHAPING_Y, head_y) = tail; UNUSED(temp);} + typedef IF::type shaping_time_t; + enum shaping_echo_t { ECHO_NONE = 0, ECHO_FWD = 1, ECHO_BWD = 2 }; + struct shaping_echo_axis_t { + #if ENABLED(INPUT_SHAPING_X) + shaping_echo_t x:2; + #endif + #if ENABLED(INPUT_SHAPING_Y) + shaping_echo_t y:2; + #endif }; - class ParamDelayQueue : public DelayQueue { + class ShapingQueue { private: - #ifdef HAS_SHAPING_X - int32_t params_x[shaping_segments]; + static shaping_time_t now; + static shaping_time_t times[shaping_echoes]; + static shaping_echo_axis_t echo_axes[shaping_echoes]; + static uint16_t tail; + + #if ENABLED(INPUT_SHAPING_X) + static shaping_time_t delay_x; // = shaping_time_t(-1) to disable queueing + static shaping_time_t peek_x_val; + static uint16_t head_x; + static uint16_t _free_count_x; #endif - #ifdef HAS_SHAPING_Y - int32_t params_y[shaping_segments]; + #if ENABLED(INPUT_SHAPING_Y) + static shaping_time_t delay_y; // = shaping_time_t(-1) to disable queueing + static shaping_time_t peek_y_val; + static uint16_t head_y; + static uint16_t _free_count_y; #endif public: - void enqueue(const int32_t param_x, const int32_t param_y) { - TERN(HAS_SHAPING_X, params_x[DelayQueue::tail] = param_x, UNUSED(param_x)); - TERN(HAS_SHAPING_Y, params_y[DelayQueue::tail] = param_y, UNUSED(param_y)); - DelayQueue::enqueue(); + static void decrement_delays(const shaping_time_t interval) { + now += interval; + TERN_(INPUT_SHAPING_X, if (peek_x_val != shaping_time_t(-1)) peek_x_val -= interval); + TERN_(INPUT_SHAPING_Y, if (peek_y_val != shaping_time_t(-1)) peek_y_val -= interval); + } + static void set_delay(const AxisEnum axis, const shaping_time_t delay) { + TERN_(INPUT_SHAPING_X, if (axis == X_AXIS) delay_x = delay); + TERN_(INPUT_SHAPING_Y, if (axis == Y_AXIS) delay_y = delay); } - #ifdef HAS_SHAPING_X - const int32_t dequeue_x() { - const int32_t result = params_x[DelayQueue::head_x]; - DelayQueue::dequeue_x(); - return result; + static void enqueue(const bool x_step, const bool x_forward, const bool y_step, const bool y_forward) { + TERN_(INPUT_SHAPING_X, if (head_x == tail && x_step) peek_x_val = delay_x); + TERN_(INPUT_SHAPING_Y, if (head_y == tail && y_step) peek_y_val = delay_y); + times[tail] = now; + TERN_(INPUT_SHAPING_X, echo_axes[tail].x = x_step ? (x_forward ? ECHO_FWD : ECHO_BWD) : ECHO_NONE); + TERN_(INPUT_SHAPING_Y, echo_axes[tail].y = y_step ? (y_forward ? ECHO_FWD : ECHO_BWD) : ECHO_NONE); + if (++tail == shaping_echoes) tail = 0; + TERN_(INPUT_SHAPING_X, _free_count_x--); + TERN_(INPUT_SHAPING_Y, _free_count_y--); + TERN_(INPUT_SHAPING_X, if (echo_axes[head_x].x == ECHO_NONE) dequeue_x()); + TERN_(INPUT_SHAPING_Y, if (echo_axes[head_y].y == ECHO_NONE) dequeue_y()); + } + #if ENABLED(INPUT_SHAPING_X) + static shaping_time_t peek_x() { return peek_x_val; } + static bool dequeue_x() { + bool forward = echo_axes[head_x].x == ECHO_FWD; + do { + _free_count_x++; + if (++head_x == shaping_echoes) head_x = 0; + } while (head_x != tail && echo_axes[head_x].x == ECHO_NONE); + peek_x_val = head_x == tail ? shaping_time_t(-1) : times[head_x] + delay_x - now; + return forward; } + static bool empty_x() { return head_x == tail; } + static uint16_t free_count_x() { return _free_count_x; } #endif - #ifdef HAS_SHAPING_Y - const int32_t dequeue_y() { - const int32_t result = params_y[DelayQueue::head_y]; - DelayQueue::dequeue_y(); - return result; + #if ENABLED(INPUT_SHAPING_Y) + static shaping_time_t peek_y() { return peek_y_val; } + static bool dequeue_y() { + bool forward = echo_axes[head_y].y == ECHO_FWD; + do { + _free_count_y++; + if (++head_y == shaping_echoes) head_y = 0; + } while (head_y != tail && echo_axes[head_y].y == ECHO_NONE); + peek_y_val = head_y == tail ? shaping_time_t(-1) : times[head_y] + delay_y - now; + return forward; } + static bool empty_y() { return head_y == tail; } + static uint16_t free_count_y() { return _free_count_y; } #endif + static void purge() { + const auto st = shaping_time_t(-1); + #if ENABLED(INPUT_SHAPING_X) + head_x = tail; _free_count_x = shaping_echoes - 1; peek_x_val = st; + #endif + #if ENABLED(INPUT_SHAPING_Y) + head_y = tail; _free_count_y = shaping_echoes - 1; peek_y_val = st; + #endif + } }; struct ShapeParams { float frequency; float zeta; - uint8_t factor; - int32_t dividend; + bool enabled; + int16_t delta_error = 0; // delta_error for seconday bresenham mod 128 + uint8_t factor1; + uint8_t factor2; + bool forward; + int32_t last_block_end_pos = 0; }; -#endif // INPUT_SHAPING +#endif // HAS_SHAPING // // Stepper class definition @@ -527,13 +565,11 @@ class Stepper { static bool bezier_2nd_half; // If Bézier curve has been initialized or not #endif - #if ENABLED(INPUT_SHAPING) - static ParamDelayQueue shaping_dividend_queue; - static DelayQueue shaping_queue; - #if HAS_SHAPING_X + #if HAS_SHAPING + #if ENABLED(INPUT_SHAPING_X) static ShapeParams shaping_x; #endif - #if HAS_SHAPING_Y + #if ENABLED(INPUT_SHAPING_Y) static ShapeParams shaping_y; #endif #endif @@ -597,7 +633,7 @@ class Stepper { // The stepper block processing ISR phase static uint32_t block_phase_isr(); - #if ENABLED(INPUT_SHAPING) + #if HAS_SHAPING static void shaping_isr(); #endif @@ -620,6 +656,20 @@ class Stepper { // Check if the given block is busy or not - Must not be called from ISR contexts static bool is_block_busy(const block_t * const block); + #if HAS_SHAPING + // Check whether the stepper is processing any input shaping echoes + static bool input_shaping_busy() { + const bool was_on = hal.isr_state(); + hal.isr_off(); + + const bool result = TERN0(INPUT_SHAPING_X, !ShapingQueue::empty_x()) || TERN0(INPUT_SHAPING_Y, !ShapingQueue::empty_y()); + + if (was_on) hal.isr_on(); + + return result; + } + #endif + // Get the position of a stepper, in steps static int32_t position(const AxisEnum axis); @@ -754,7 +804,7 @@ class Stepper { set_directions(); } - #if ENABLED(INPUT_SHAPING) + #if HAS_SHAPING static void set_shaping_damping_ratio(const AxisEnum axis, const float zeta); static float get_shaping_damping_ratio(const AxisEnum axis); static void set_shaping_frequency(const AxisEnum axis, const float freq); diff --git a/buildroot/tests/mega2560 b/buildroot/tests/mega2560 index 18a6ea88c98b..4167c3e4bfc1 100755 --- a/buildroot/tests/mega2560 +++ b/buildroot/tests/mega2560 @@ -80,9 +80,9 @@ opt_set MOTHERBOARD BOARD_AZTEEG_X3_PRO MIXING_STEPPERS 5 LCD_LANGUAGE ru \ FIL_RUNOUT2_PIN 16 FIL_RUNOUT3_PIN 17 FIL_RUNOUT4_PIN 4 FIL_RUNOUT5_PIN 5 opt_enable MIXING_EXTRUDER GRADIENT_MIX GRADIENT_VTOOL CR10_STOCKDISPLAY \ USE_CONTROLLER_FAN CONTROLLER_FAN_EDITABLE CONTROLLER_FAN_IGNORE_Z \ - FILAMENT_RUNOUT_SENSOR ADVANCED_PAUSE_FEATURE NOZZLE_PARK_FEATURE INPUT_SHAPING + FILAMENT_RUNOUT_SENSOR ADVANCED_PAUSE_FEATURE NOZZLE_PARK_FEATURE INPUT_SHAPING_X INPUT_SHAPING_Y opt_disable DISABLE_INACTIVE_EXTRUDER -exec_test $1 $2 "Azteeg X3 | Mixing Extruder (x5) | Gradient Mix | Greek" "$3" +exec_test $1 $2 "Azteeg X3 | Mixing Extruder (x5) | Gradient Mix | Input Shaping | Greek" "$3" # # Test SPEAKER with BOARD_BQ_ZUM_MEGA_3D and BQ_LCD_SMART_CONTROLLER diff --git a/ini/features.ini b/ini/features.ini index 7c8fd2fd8f33..e376e2757e6e 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -187,7 +187,7 @@ HAS_DUPLICATION_MODE = src_filter=+ PHOTO_GCODE = src_filter=+ CONTROLLER_FAN_EDITABLE = src_filter=+ -INPUT_SHAPING = src_filter=+ +HAS_SHAPING = src_filter=+ GCODE_MACROS = src_filter=+ GRADIENT_MIX = src_filter=+ HAS_SAVED_POSITIONS = src_filter=+ + From 6f5ad55953b2029c1f92ff6554a14ca2b93c1b5d Mon Sep 17 00:00:00 2001 From: Chris Bagwell Date: Sun, 27 Nov 2022 21:40:11 -0600 Subject: [PATCH 166/243] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20More=20SCURVE=20cy?= =?UTF-8?q?cles=20on=20unoptimized=20cortex-m0=20(#24955)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/module/stepper.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Marlin/src/module/stepper.h b/Marlin/src/module/stepper.h index f29bb346d1e3..6d9814b4dfc3 100644 --- a/Marlin/src/module/stepper.h +++ b/Marlin/src/module/stepper.h @@ -87,7 +87,11 @@ // S curve interpolation adds 40 cycles #if ENABLED(S_CURVE_ACCELERATION) - #define ISR_S_CURVE_CYCLES 40UL + #ifdef STM32G0B1xx + #define ISR_S_CURVE_CYCLES 500UL + #else + #define ISR_S_CURVE_CYCLES 40UL + #endif #else #define ISR_S_CURVE_CYCLES 0UL #endif From 95019bf526c0f2db2fae10e8548271dd03a057c0 Mon Sep 17 00:00:00 2001 From: Taylor Talkington Date: Sun, 27 Nov 2022 22:41:27 -0500 Subject: [PATCH 167/243] =?UTF-8?q?=E2=9C=A8=20Ender-3=20V2=20DWIN=20for?= =?UTF-8?q?=20BTT=20Octopus=20V1.1=20(#24983)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/inc/Conditionals_adv.h | 2 +- .../pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 367f7f232460..bf1088afc898 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -1078,7 +1078,7 @@ */ #ifndef LCD_SERIAL_PORT #if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI || HAS_DGUS_LCD - #if MB(BTT_SKR_MINI_E3_V1_0, BTT_SKR_MINI_E3_V1_2, BTT_SKR_MINI_E3_V2_0, BTT_SKR_MINI_E3_V3_0, BTT_SKR_E3_TURBO) + #if MB(BTT_SKR_MINI_E3_V1_0, BTT_SKR_MINI_E3_V1_2, BTT_SKR_MINI_E3_V2_0, BTT_SKR_MINI_E3_V3_0, BTT_SKR_E3_TURBO, BTT_OCTOPUS_V1_1) #define LCD_SERIAL_PORT 1 #elif MB(CREALITY_V24S1_301, CREALITY_V24S1_301F4, CREALITY_V423, MKS_ROBIN) #define LCD_SERIAL_PORT 2 // Creality Ender3S1, MKS Robin diff --git a/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h b/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h index 35287050b891..4bf1073ae430 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h @@ -429,6 +429,30 @@ #define TFTGLCD_CS EXP2_03_PIN #endif +#elif HAS_DWIN_E3V2 || IS_DWIN_MARLINUI + /** + * ------ ------ --- + * | 1 2 | | 1 2 | 1 | + * | 3 4 | RX | 3 4 | TX | 2 | RX + * ENT 5 6 | BEEP ENT 5 6 | BEEP | 3 | TX + * B | 7 8 | A B | 7 8 | A | 4 | + * GND | 9 10 | VCC GND | 9 10 | VCC 5 | + * ------ ------ --- + * EXP1 DWIN TFT + * + * DWIN pins are labeled as printed on DWIN PCB. GND, VCC, A, B, ENT & BEEP can be connected in the same + * orientation as the existing plug/DWIN to EXP1. TX/RX need to be connected to the TFT port, with TX->RX, RX->TX. + */ + + #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING + #error "CAUTION! Ender-3 V2 display requires a custom cable. See 'pins_BTT_OCTOPUS_V1_common.h' for details. (Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning.)" + #endif + + #define BEEPER_PIN EXP1_06_PIN + #define BTN_EN1 EXP1_08_PIN + #define BTN_EN2 EXP1_07_PIN + #define BTN_ENC EXP1_05_PIN + #elif HAS_WIRED_LCD #define BEEPER_PIN EXP1_01_PIN From 0537e78572aa3e5aec8e3f444f826dbd5b0b8455 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 27 Nov 2022 23:23:00 -0600 Subject: [PATCH 168/243] =?UTF-8?q?=F0=9F=90=9B=20Fix=20G-code=20resend=20?= =?UTF-8?q?race=20condition?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As pointed out in #24972 by @silycr, but simplified. --- Marlin/src/gcode/queue.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index a390a46d8e31..c951fc633364 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -469,8 +469,11 @@ void GCodeQueue::get_serial_commands() { const long gcode_N = strtol(npos + 1, nullptr, 10); + // The line number must be in the correct sequence. if (gcode_N != serial.last_N + 1 && !M110) { - // In case of error on a serial port, don't prevent other serial port from making progress + // A request-for-resend line was already in transit so we got two - oops! + if (WITHIN(gcode_N, serial.last_N - 1, serial.last_N)) continue; + // A corrupted line or too high, indicating a lost line gcode_line_error(F(STR_ERR_LINE_NO), p); break; } @@ -480,13 +483,11 @@ void GCodeQueue::get_serial_commands() { uint8_t checksum = 0, count = uint8_t(apos - command); while (count) checksum ^= command[--count]; if (strtol(apos + 1, nullptr, 10) != checksum) { - // In case of error on a serial port, don't prevent other serial port from making progress gcode_line_error(F(STR_ERR_CHECKSUM_MISMATCH), p); break; } } else { - // In case of error on a serial port, don't prevent other serial port from making progress gcode_line_error(F(STR_ERR_NO_CHECKSUM), p); break; } From 5eb39d5277e11a29deaa47690f35b7170ba97447 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=88=E3=83=88=E3=82=82?= <85485984+ElectronicsArchiver@users.noreply.github.com> Date: Sun, 27 Nov 2022 23:52:06 -0500 Subject: [PATCH 169/243] =?UTF-8?q?=F0=9F=93=9D=20Formatted=20Team=20Overv?= =?UTF-8?q?iew=20(#25029)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 53 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index fb1e881dc58b..291f3fc4124f 100644 --- a/README.md +++ b/README.md @@ -83,16 +83,49 @@ Marlin is constantly improving thanks to a huge number of contributors from all Regular users can open and close their own issues, but only the administrators can do project-related things like add labels, merge changes, set milestones, and kick trolls. The current Marlin admin team consists of: - - Scott Lahteine [[@thinkyhead](https://github.com/thinkyhead)] - USA - Project Maintainer   [💸 Donate](https://www.thinkyhead.com/donate-to-marlin) - - Roxanne Neufeld [[@Roxy-3D](https://github.com/Roxy-3D)] - USA - - Keith Bennett [[@thisiskeithb](https://github.com/thisiskeithb)] - USA   [💸 Donate](https://github.com/sponsors/thisiskeithb) - - Peter Ellens [[@ellensp](https://github.com/ellensp)] - New Zealand   [💸 Donate](https://ko-fi.com/ellensp) - - Victor Oliveira [[@rhapsodyv](https://github.com/rhapsodyv)] - Brazil - - Chris Pepper [[@p3p](https://github.com/p3p)] - UK - - Jason Smith [[@sjasonsmith](https://github.com/sjasonsmith)] - USA - - Luu Lac [[@shitcreek](https://github.com/shitcreek)] - USA - - Bob Kuhn [[@Bob-the-Kuhn](https://github.com/Bob-the-Kuhn)] - USA - - Erik van der Zalm [[@ErikZalm](https://github.com/ErikZalm)] - Netherlands   [💸 Donate](https://flattr.com/submit/auto?user_id=ErikZalm&url=https://github.com/MarlinFirmware/Marlin&title=Marlin&language=&tags=github&category=software) + + + +
Project Maintainer
+ + 🇺🇸  **Scott Lahteine** +       [@thinkyhead](https://github.com/thinkyhead) +       [  Donate 💸  ](https://www.thinkyhead.com/donate-to-marlin) + + + + 🇺🇸  **Roxanne Neufeld** +       [@Roxy-3D](https://github.com/Roxy-3D) + + 🇺🇸  **Keith Bennett** +       [@thisiskeithb](https://github.com/thisiskeithb) +       [  Donate 💸  ](https://github.com/sponsors/thisiskeithb) + + 🇺🇸  **Jason Smith** +       [@sjasonsmith](https://github.com/sjasonsmith) + + + + 🇧🇷  **Victor Oliveira** +       [@rhapsodyv](https://github.com/rhapsodyv) + + 🇬🇧  **Chris Pepper** +       [@p3p](https://github.com/p3p) + +🇳🇿  **Peter Ellens** +       [@ellensp](https://github.com/ellensp) +       [  Donate 💸  ](https://ko-fi.com/ellensp) + + + + 🇺🇸  **Bob Kuhn** +       [@Bob-the-Kuhn](https://github.com/Bob-the-Kuhn) + + 🇳🇱  **Erik van der Zalm** +       [@ErikZalm](https://github.com/ErikZalm) +       [  Donate 💸  ](https://flattr.com/submit/auto?user_id=ErikZalm&url=https://github.com/MarlinFirmware/Marlin&title=Marlin&language=&tags=github&category=software) + +
## License From 51c1645ceb878a316b548095c68e42623dce16f6 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 12 Oct 2022 17:52:56 -0500 Subject: [PATCH 170/243] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Use?= =?UTF-8?q?=20spaces=20indent=20for=20Python?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/DUE/upload_extra_script.py | 16 +- .../scripts/STM32F103RC_MEEB_3DP.py | 20 +- .../PlatformIO/scripts/STM32F103RC_fysetc.py | 38 +- .../scripts/STM32F1_create_variant.py | 36 +- buildroot/share/scripts/config-labels.py | 280 ++++---- buildroot/share/scripts/gen-tft-image.py | 60 +- buildroot/share/scripts/upload.py | 628 +++++++++--------- 7 files changed, 539 insertions(+), 539 deletions(-) diff --git a/Marlin/src/HAL/DUE/upload_extra_script.py b/Marlin/src/HAL/DUE/upload_extra_script.py index 4f7a494512b2..ca12b3b54f43 100644 --- a/Marlin/src/HAL/DUE/upload_extra_script.py +++ b/Marlin/src/HAL/DUE/upload_extra_script.py @@ -6,14 +6,14 @@ # import pioutil if pioutil.is_pio_build(): - import platform - current_OS = platform.system() + import platform + current_OS = platform.system() - if current_OS == 'Windows': + if current_OS == 'Windows': - Import("env") + Import("env") - # Use bossac.exe on Windows - env.Replace( - UPLOADCMD="bossac --info --unlock --write --verify --reset --erase -U false --boot $SOURCE" - ) + # Use bossac.exe on Windows + env.Replace( + UPLOADCMD="bossac --info --unlock --write --verify --reset --erase -U false --boot $SOURCE" + ) diff --git a/buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py b/buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py index a69520f46d9c..4f2da9cdc0d0 100644 --- a/buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py +++ b/buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py @@ -4,16 +4,16 @@ import pioutil if pioutil.is_pio_build(): - Import("env", "projenv") + Import("env", "projenv") - flash_size = 0 - vect_tab_addr = 0 + flash_size = 0 + vect_tab_addr = 0 - for define in env['CPPDEFINES']: - if define[0] == "VECT_TAB_ADDR": - vect_tab_addr = define[1] - if define[0] == "STM32_FLASH_SIZE": - flash_size = define[1] + for define in env['CPPDEFINES']: + if define[0] == "VECT_TAB_ADDR": + vect_tab_addr = define[1] + if define[0] == "STM32_FLASH_SIZE": + flash_size = define[1] - print('Use the {0:s} address as the marlin app entry point.'.format(vect_tab_addr)) - print('Use the {0:d}KB flash version of stm32f103rct6 chip.'.format(flash_size)) + print('Use the {0:s} address as the marlin app entry point.'.format(vect_tab_addr)) + print('Use the {0:d}KB flash version of stm32f103rct6 chip.'.format(flash_size)) diff --git a/buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py b/buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py index 2cab2ce5c136..ecb0cc145c04 100644 --- a/buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py +++ b/buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py @@ -3,25 +3,25 @@ # import pioutil if pioutil.is_pio_build(): - from os.path import join - from os.path import expandvars - Import("env") + from os.path import join + from os.path import expandvars + Import("env") - # Custom HEX from ELF - env.AddPostAction( - join("$BUILD_DIR", "${PROGNAME}.elf"), - env.VerboseAction(" ".join([ - "$OBJCOPY", "-O ihex", "$TARGET", - "\"" + join("$BUILD_DIR", "${PROGNAME}.hex") + "\"", # Note: $BUILD_DIR is a full path - ]), "Building $TARGET")) + # Custom HEX from ELF + env.AddPostAction( + join("$BUILD_DIR", "${PROGNAME}.elf"), + env.VerboseAction(" ".join([ + "$OBJCOPY", "-O ihex", "$TARGET", + "\"" + join("$BUILD_DIR", "${PROGNAME}.hex") + "\"", # Note: $BUILD_DIR is a full path + ]), "Building $TARGET")) - # In-line command with arguments - UPLOAD_TOOL="stm32flash" - platform = env.PioPlatform() - if platform.get_package_dir("tool-stm32duino") != None: - UPLOAD_TOOL=expandvars("\"" + join(platform.get_package_dir("tool-stm32duino"),"stm32flash","stm32flash") + "\"") + # In-line command with arguments + UPLOAD_TOOL="stm32flash" + platform = env.PioPlatform() + if platform.get_package_dir("tool-stm32duino") != None: + UPLOAD_TOOL=expandvars("\"" + join(platform.get_package_dir("tool-stm32duino"),"stm32flash","stm32flash") + "\"") - env.Replace( - UPLOADER=UPLOAD_TOOL, - UPLOADCMD=expandvars(UPLOAD_TOOL + " -v -i rts,-dtr,dtr -R -b 115200 -g 0x8000000 -w \"" + join("$BUILD_DIR","${PROGNAME}.hex")+"\"" + " $UPLOAD_PORT") - ) + env.Replace( + UPLOADER=UPLOAD_TOOL, + UPLOADCMD=expandvars(UPLOAD_TOOL + " -v -i rts,-dtr,dtr -R -b 115200 -g 0x8000000 -w \"" + join("$BUILD_DIR","${PROGNAME}.hex")+"\"" + " $UPLOAD_PORT") + ) diff --git a/buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py b/buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py index 0eab7a8361a6..4189cb5899bc 100644 --- a/buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py +++ b/buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py @@ -3,29 +3,29 @@ # import pioutil if pioutil.is_pio_build(): - import shutil,marlin - from pathlib import Path + import shutil,marlin + from pathlib import Path - Import("env") - platform = env.PioPlatform() - board = env.BoardConfig() + Import("env") + platform = env.PioPlatform() + board = env.BoardConfig() - FRAMEWORK_DIR = Path(platform.get_package_dir("framework-arduinoststm32-maple")) - assert FRAMEWORK_DIR.is_dir() + FRAMEWORK_DIR = Path(platform.get_package_dir("framework-arduinoststm32-maple")) + assert FRAMEWORK_DIR.is_dir() - source_root = Path("buildroot/share/PlatformIO/variants") - assert source_root.is_dir() + source_root = Path("buildroot/share/PlatformIO/variants") + assert source_root.is_dir() - variant = board.get("build.variant") - variant_dir = FRAMEWORK_DIR / "STM32F1/variants" / variant + variant = board.get("build.variant") + variant_dir = FRAMEWORK_DIR / "STM32F1/variants" / variant - source_dir = source_root / variant - assert source_dir.is_dir() + source_dir = source_root / variant + assert source_dir.is_dir() - if variant_dir.is_dir(): - shutil.rmtree(variant_dir) + if variant_dir.is_dir(): + shutil.rmtree(variant_dir) - if not variant_dir.is_dir(): - variant_dir.mkdir() + if not variant_dir.is_dir(): + variant_dir.mkdir() - marlin.copytree(source_dir, variant_dir) + marlin.copytree(source_dir, variant_dir) diff --git a/buildroot/share/scripts/config-labels.py b/buildroot/share/scripts/config-labels.py index b721baf441fb..b571a434b7e1 100755 --- a/buildroot/share/scripts/config-labels.py +++ b/buildroot/share/scripts/config-labels.py @@ -47,150 +47,150 @@ #---------------------------------------------- def process_file(subdir: str, filename: str): #---------------------------------------------- - global filenum - filenum += 1 - - print(str(filenum) + ' ' + filename + ': ' + subdir) - - def_line = (def_macro_name + ' "' + subdir.replace('\\', '/') + '"') - - #------------------------ - # Read file - #------------------------ - lines = [] - infilepath = Path(input_examples_dir, subdir, filename) - try: - # UTF-8 because some files contain unicode chars - with infilepath.open('rt', encoding="utf-8") as infile: - lines = infile.readlines() - - except Exception as e: - print('Failed to read file: ' + str(e) ) - raise Exception - - lines = [line.rstrip('\r\n') for line in lines] - - #------------------------ - # Process lines - #------------------------ - file_modified = False - - # region state machine - # -1 = before pragma once; - # 0 = region to place define; - # 1 = past region to place define - region = -1 - - outlines = [] - for line in lines: - outline = line - - if (region == -1) and (def_macro_name in line): - outline = None - file_modified = True - - elif (region == -1) and ('pragma once' in line): - region = 0 - - elif (region == 0): - if (line.strip() == ''): - pass - elif (def_macro_name in line): - region = 1 - if line == def_line: # leave it as is - pass - else: - outline = def_line - file_modified = True - else: # some other string - outlines.append(def_line) - outlines.append('') - region = 1 - file_modified = True - - elif (region == 1): - if (def_macro_name in line): - outline = None - file_modified = True - else: - pass - - # end if - if outline is not None: - outlines.append(outline) - # end for - - #------------------------- - # Output file - #------------------------- - outdir = Path(output_examples_dir, subdir) - outfilepath = outdir / filename - - if file_modified: - # Note: no need to create output dirs, as the initial copy_tree - # will do that. - - print(' writing ' + str(outfilepath)) - try: - # Preserve unicode chars; Avoid CR-LF on Windows. - with outfilepath.open("w", encoding="utf-8", newline='\n') as outfile: - outfile.write("\n".join(outlines) + "\n") - - except Exception as e: - print('Failed to write file: ' + str(e) ) - raise Exception - else: - print(' no change for ' + str(outfilepath)) + global filenum + filenum += 1 + + print(str(filenum) + ' ' + filename + ': ' + subdir) + + def_line = (def_macro_name + ' "' + subdir.replace('\\', '/') + '"') + + #------------------------ + # Read file + #------------------------ + lines = [] + infilepath = Path(input_examples_dir, subdir, filename) + try: + # UTF-8 because some files contain unicode chars + with infilepath.open('rt', encoding="utf-8") as infile: + lines = infile.readlines() + + except Exception as e: + print('Failed to read file: ' + str(e) ) + raise Exception + + lines = [line.rstrip('\r\n') for line in lines] + + #------------------------ + # Process lines + #------------------------ + file_modified = False + + # region state machine + # -1 = before pragma once; + # 0 = region to place define; + # 1 = past region to place define + region = -1 + + outlines = [] + for line in lines: + outline = line + + if (region == -1) and (def_macro_name in line): + outline = None + file_modified = True + + elif (region == -1) and ('pragma once' in line): + region = 0 + + elif (region == 0): + if (line.strip() == ''): + pass + elif (def_macro_name in line): + region = 1 + if line == def_line: # leave it as is + pass + else: + outline = def_line + file_modified = True + else: # some other string + outlines.append(def_line) + outlines.append('') + region = 1 + file_modified = True + + elif (region == 1): + if (def_macro_name in line): + outline = None + file_modified = True + else: + pass + + # end if + if outline is not None: + outlines.append(outline) + # end for + + #------------------------- + # Output file + #------------------------- + outdir = Path(output_examples_dir, subdir) + outfilepath = outdir / filename + + if file_modified: + # Note: no need to create output dirs, as the initial copy_tree + # will do that. + + print(' writing ' + str(outfilepath)) + try: + # Preserve unicode chars; Avoid CR-LF on Windows. + with outfilepath.open("w", encoding="utf-8", newline='\n') as outfile: + outfile.write("\n".join(outlines) + "\n") + + except Exception as e: + print('Failed to write file: ' + str(e) ) + raise Exception + else: + print(' no change for ' + str(outfilepath)) #---------- def main(): #---------- - global filenum - global input_examples_dir - global output_examples_dir - filenum = 0 - - #-------------------------------- - # Check for requirements - #-------------------------------- - input_examples_dir = input_examples_dir.strip() - input_examples_dir = input_examples_dir.rstrip('\\/') - output_examples_dir = output_examples_dir.strip() - output_examples_dir = output_examples_dir.rstrip('\\/') - - for dir in (input_examples_dir, output_examples_dir): - if not Path(dir).exists(): - print('Directory not found: ' + dir) - sys.exit(1) - - #-------------------------------- - # Copy tree if necessary. - #-------------------------------- - # This includes files that are not otherwise included in the - # insertion of the define statement. - # - if different_out_dir: - print('Copying files to new directory: ' + output_examples_dir) - try: - copy_tree(input_examples_dir, output_examples_dir) - except Exception as e: - print('Failed to copy directory: ' + str(e) ) - raise Exception - - #----------------------------- - # Find and process files - #----------------------------- - len_input_examples_dir = 1 + len(input_examples_dir) - - for filename in files_to_mod: - input_path = Path(input_examples_dir) - filepathlist = input_path.rglob(filename) - - for filepath in filepathlist: - fulldirpath = str(filepath.parent) - subdir = fulldirpath[len_input_examples_dir:] - - process_file(subdir, filename) + global filenum + global input_examples_dir + global output_examples_dir + filenum = 0 + + #-------------------------------- + # Check for requirements + #-------------------------------- + input_examples_dir = input_examples_dir.strip() + input_examples_dir = input_examples_dir.rstrip('\\/') + output_examples_dir = output_examples_dir.strip() + output_examples_dir = output_examples_dir.rstrip('\\/') + + for dir in (input_examples_dir, output_examples_dir): + if not Path(dir).exists(): + print('Directory not found: ' + dir) + sys.exit(1) + + #-------------------------------- + # Copy tree if necessary. + #-------------------------------- + # This includes files that are not otherwise included in the + # insertion of the define statement. + # + if different_out_dir: + print('Copying files to new directory: ' + output_examples_dir) + try: + copy_tree(input_examples_dir, output_examples_dir) + except Exception as e: + print('Failed to copy directory: ' + str(e) ) + raise Exception + + #----------------------------- + # Find and process files + #----------------------------- + len_input_examples_dir = 1 + len(input_examples_dir) + + for filename in files_to_mod: + input_path = Path(input_examples_dir) + filepathlist = input_path.rglob(filename) + + for filepath in filepathlist: + fulldirpath = str(filepath.parent) + subdir = fulldirpath[len_input_examples_dir:] + + process_file(subdir, filename) #============== print('--- Starting config-labels ---') diff --git a/buildroot/share/scripts/gen-tft-image.py b/buildroot/share/scripts/gen-tft-image.py index 9b7d19493eca..f3786aef706c 100644 --- a/buildroot/share/scripts/gen-tft-image.py +++ b/buildroot/share/scripts/gen-tft-image.py @@ -26,38 +26,38 @@ from PIL import Image def image2bin(image, output_file): - if output_file.endswith(('.c', '.cpp')): - f = open(output_file, 'wt') - is_cpp = True - f.write("const uint16_t image[%d] = {\n" % (image.size[1] * image.size[0])) - else: - f = open(output_file, 'wb') - is_cpp = False - pixs = image.load() - for y in range(image.size[1]): - for x in range(image.size[0]): - R = pixs[x, y][0] >> 3 - G = pixs[x, y][1] >> 2 - B = pixs[x, y][2] >> 3 - rgb = (R << 11) | (G << 5) | B - if is_cpp: - strHex = '0x{0:04X}, '.format(rgb) - f.write(strHex) - else: - f.write(struct.pack("B", (rgb & 0xFF))) - f.write(struct.pack("B", (rgb >> 8) & 0xFF)) - if is_cpp: - f.write("\n") - if is_cpp: - f.write("};\n") - f.close() + if output_file.endswith(('.c', '.cpp')): + f = open(output_file, 'wt') + is_cpp = True + f.write("const uint16_t image[%d] = {\n" % (image.size[1] * image.size[0])) + else: + f = open(output_file, 'wb') + is_cpp = False + pixs = image.load() + for y in range(image.size[1]): + for x in range(image.size[0]): + R = pixs[x, y][0] >> 3 + G = pixs[x, y][1] >> 2 + B = pixs[x, y][2] >> 3 + rgb = (R << 11) | (G << 5) | B + if is_cpp: + strHex = '0x{0:04X}, '.format(rgb) + f.write(strHex) + else: + f.write(struct.pack("B", (rgb & 0xFF))) + f.write(struct.pack("B", (rgb >> 8) & 0xFF)) + if is_cpp: + f.write("\n") + if is_cpp: + f.write("};\n") + f.close() if len(sys.argv) <= 2: - print("Utility to export a image in Marlin TFT friendly format.") - print("It will dump a raw bin RGB565 image or create a CPP file with an array of 16 bit image pixels.") - print("Usage: gen-tft-image.py INPUT_IMAGE.(png|bmp|jpg) OUTPUT_FILE.(cpp|bin)") - print("Author: rhapsodyv") - exit(1) + print("Utility to export a image in Marlin TFT friendly format.") + print("It will dump a raw bin RGB565 image or create a CPP file with an array of 16 bit image pixels.") + print("Usage: gen-tft-image.py INPUT_IMAGE.(png|bmp|jpg) OUTPUT_FILE.(cpp|bin)") + print("Author: rhapsodyv") + exit(1) output_img = sys.argv[2] img = Image.open(sys.argv[1]) diff --git a/buildroot/share/scripts/upload.py b/buildroot/share/scripts/upload.py index ef042fcdedba..caa1fbae2303 100644 --- a/buildroot/share/scripts/upload.py +++ b/buildroot/share/scripts/upload.py @@ -25,320 +25,320 @@ #-----------------# def Upload(source, target, env): - #-------# - # Debug # - #-------# - Debug = False # Set to True to enable script debug - def debugPrint(data): - if Debug: print(f"[Debug]: {data}") - - #------------------# - # Marlin functions # - #------------------# - def _GetMarlinEnv(marlinEnv, feature): - if not marlinEnv: return None - return marlinEnv[feature] if feature in marlinEnv else None - - #----------------# - # Port functions # - #----------------# - def _GetUploadPort(env): - debugPrint('Autodetecting upload port...') - env.AutodetectUploadPort(env) - portName = env.subst('$UPLOAD_PORT') - if not portName: - raise Exception('Error detecting the upload port.') - debugPrint('OK') - return portName - - #-------------------------# - # Simple serial functions # - #-------------------------# - def _OpenPort(): - # Open serial port - if port.is_open: return - debugPrint('Opening upload port...') - port.open() - port.reset_input_buffer() - debugPrint('OK') - - def _ClosePort(): - # Open serial port - if port is None: return - if not port.is_open: return - debugPrint('Closing upload port...') - port.close() - debugPrint('OK') - - def _Send(data): - debugPrint(f'>> {data}') - strdata = bytearray(data, 'utf8') + b'\n' - port.write(strdata) - time.sleep(0.010) - - def _Recv(): - clean_responses = [] - responses = port.readlines() - for Resp in responses: - # Suppress invalid chars (coming from debug info) - try: - clean_response = Resp.decode('utf8').rstrip().lstrip() - clean_responses.append(clean_response) - debugPrint(f'<< {clean_response}') - except: - pass - return clean_responses - - #------------------# - # SDCard functions # - #------------------# - def _CheckSDCard(): - debugPrint('Checking SD card...') - _Send('M21') - Responses = _Recv() - if len(Responses) < 1 or not any('SD card ok' in r for r in Responses): - raise Exception('Error accessing SD card') - debugPrint('SD Card OK') - return True - - #----------------# - # File functions # - #----------------# - def _GetFirmwareFiles(UseLongFilenames): - debugPrint('Get firmware files...') - _Send(f"M20 F{'L' if UseLongFilenames else ''}") - Responses = _Recv() - if len(Responses) < 3 or not any('file list' in r for r in Responses): - raise Exception('Error getting firmware files') - debugPrint('OK') - return Responses - - def _FilterFirmwareFiles(FirmwareList, UseLongFilenames): - Firmwares = [] - for FWFile in FirmwareList: - # For long filenames take the 3rd column of the firmwares list - if UseLongFilenames: - Space = 0 - Space = FWFile.find(' ') - if Space >= 0: Space = FWFile.find(' ', Space + 1) - if Space >= 0: FWFile = FWFile[Space + 1:] - if not '/' in FWFile and '.BIN' in FWFile.upper(): - Firmwares.append(FWFile[:FWFile.upper().index('.BIN') + 4]) - return Firmwares - - def _RemoveFirmwareFile(FirmwareFile): - _Send(f'M30 /{FirmwareFile}') - Responses = _Recv() - Removed = len(Responses) >= 1 and any('File deleted' in r for r in Responses) - if not Removed: - raise Exception(f"Firmware file '{FirmwareFile}' not removed") - return Removed - - def _RollbackUpload(FirmwareFile): - if not rollback: return - print(f"Rollback: trying to delete firmware '{FirmwareFile}'...") - _OpenPort() - # Wait for SD card release - time.sleep(1) - # Remount SD card - _CheckSDCard() - print(' OK' if _RemoveFirmwareFile(FirmwareFile) else ' Error!') - _ClosePort() - - - #---------------------# - # Callback Entrypoint # - #---------------------# - port = None - protocol = None - filetransfer = None - rollback = False - - # Get Marlin evironment vars - MarlinEnv = env['MARLIN_FEATURES'] - marlin_pioenv = _GetMarlinEnv(MarlinEnv, 'PIOENV') - marlin_motherboard = _GetMarlinEnv(MarlinEnv, 'MOTHERBOARD') - marlin_board_info_name = _GetMarlinEnv(MarlinEnv, 'BOARD_INFO_NAME') - marlin_board_custom_build_flags = _GetMarlinEnv(MarlinEnv, 'BOARD_CUSTOM_BUILD_FLAGS') - marlin_firmware_bin = _GetMarlinEnv(MarlinEnv, 'FIRMWARE_BIN') - marlin_long_filename_host_support = _GetMarlinEnv(MarlinEnv, 'LONG_FILENAME_HOST_SUPPORT') is not None - marlin_longname_write = _GetMarlinEnv(MarlinEnv, 'LONG_FILENAME_WRITE_SUPPORT') is not None - marlin_custom_firmware_upload = _GetMarlinEnv(MarlinEnv, 'CUSTOM_FIRMWARE_UPLOAD') is not None - marlin_short_build_version = _GetMarlinEnv(MarlinEnv, 'SHORT_BUILD_VERSION') - marlin_string_config_h_author = _GetMarlinEnv(MarlinEnv, 'STRING_CONFIG_H_AUTHOR') - - # Get firmware upload params - upload_firmware_source_name = str(source[0]) # Source firmware filename - upload_speed = env['UPLOAD_SPEED'] if 'UPLOAD_SPEED' in env else 115200 - # baud rate of serial connection - upload_port = _GetUploadPort(env) # Serial port to use - - # Set local upload params - upload_firmware_target_name = os.path.basename(upload_firmware_source_name) - # Target firmware filename - upload_timeout = 1000 # Communication timout, lossy/slow connections need higher values - upload_blocksize = 512 # Transfer block size. 512 = Autodetect - upload_compression = True # Enable compression - upload_error_ratio = 0 # Simulated corruption ratio - upload_test = False # Benchmark the serial link without storing the file - upload_reset = True # Trigger a soft reset for firmware update after the upload - - # Set local upload params based on board type to change script behavior - # "upload_delete_old_bins": delete all *.bin files in the root of SD Card - upload_delete_old_bins = marlin_motherboard in ['BOARD_CREALITY_V4', 'BOARD_CREALITY_V4210', 'BOARD_CREALITY_V422', 'BOARD_CREALITY_V423', - 'BOARD_CREALITY_V427', 'BOARD_CREALITY_V431', 'BOARD_CREALITY_V452', 'BOARD_CREALITY_V453', - 'BOARD_CREALITY_V24S1'] - # "upload_random_name": generate a random 8.3 firmware filename to upload - upload_random_filename = marlin_motherboard in ['BOARD_CREALITY_V4', 'BOARD_CREALITY_V4210', 'BOARD_CREALITY_V422', 'BOARD_CREALITY_V423', - 'BOARD_CREALITY_V427', 'BOARD_CREALITY_V431', 'BOARD_CREALITY_V452', 'BOARD_CREALITY_V453', - 'BOARD_CREALITY_V24S1'] and not marlin_long_filename_host_support - - try: - - # Start upload job - print(f"Uploading firmware '{os.path.basename(upload_firmware_target_name)}' to '{marlin_motherboard}' via '{upload_port}'") - - # Dump some debug info - if Debug: - print('Upload using:') - print('---- Marlin -----------------------------------') - print(f' PIOENV : {marlin_pioenv}') - print(f' SHORT_BUILD_VERSION : {marlin_short_build_version}') - print(f' STRING_CONFIG_H_AUTHOR : {marlin_string_config_h_author}') - print(f' MOTHERBOARD : {marlin_motherboard}') - print(f' BOARD_INFO_NAME : {marlin_board_info_name}') - print(f' CUSTOM_BUILD_FLAGS : {marlin_board_custom_build_flags}') - print(f' FIRMWARE_BIN : {marlin_firmware_bin}') - print(f' LONG_FILENAME_HOST_SUPPORT : {marlin_long_filename_host_support}') - print(f' LONG_FILENAME_WRITE_SUPPORT : {marlin_longname_write}') - print(f' CUSTOM_FIRMWARE_UPLOAD : {marlin_custom_firmware_upload}') - print('---- Upload parameters ------------------------') - print(f' Source : {upload_firmware_source_name}') - print(f' Target : {upload_firmware_target_name}') - print(f' Port : {upload_port} @ {upload_speed} baudrate') - print(f' Timeout : {upload_timeout}') - print(f' Block size : {upload_blocksize}') - print(f' Compression : {upload_compression}') - print(f' Error ratio : {upload_error_ratio}') - print(f' Test : {upload_test}') - print(f' Reset : {upload_reset}') - print('-----------------------------------------------') - - # Custom implementations based on board parameters - # Generate a new 8.3 random filename - if upload_random_filename: - upload_firmware_target_name = f"fw-{''.join(random.choices('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', k=5))}.BIN" - print(f"Board {marlin_motherboard}: Overriding firmware filename to '{upload_firmware_target_name}'") - - # Delete all *.bin files on the root of SD Card (if flagged) - if upload_delete_old_bins: - # CUSTOM_FIRMWARE_UPLOAD is needed for this feature - if not marlin_custom_firmware_upload: - raise Exception(f"CUSTOM_FIRMWARE_UPLOAD must be enabled in 'Configuration_adv.h' for '{marlin_motherboard}'") - - # Init & Open serial port - port = serial.Serial(upload_port, baudrate = upload_speed, write_timeout = 0, timeout = 0.1) - _OpenPort() - - # Check SD card status - _CheckSDCard() - - # Get firmware files - FirmwareFiles = _GetFirmwareFiles(marlin_long_filename_host_support) - if Debug: - for FirmwareFile in FirmwareFiles: - print(f'Found: {FirmwareFile}') - - # Get all 1st level firmware files (to remove) - OldFirmwareFiles = _FilterFirmwareFiles(FirmwareFiles[1:len(FirmwareFiles)-2], marlin_long_filename_host_support) # Skip header and footers of list - if len(OldFirmwareFiles) == 0: - print('No old firmware files to delete') - else: - print(f"Remove {len(OldFirmwareFiles)} old firmware file{'s' if len(OldFirmwareFiles) != 1 else ''}:") - for OldFirmwareFile in OldFirmwareFiles: - print(f" -Removing- '{OldFirmwareFile}'...") - print(' OK' if _RemoveFirmwareFile(OldFirmwareFile) else ' Error!') - - # Close serial - _ClosePort() - - # Cleanup completed - debugPrint('Cleanup completed') - - # WARNING! The serial port must be closed here because the serial transfer that follow needs it! - - # Upload firmware file - debugPrint(f"Copy '{upload_firmware_source_name}' --> '{upload_firmware_target_name}'") - protocol = MarlinBinaryProtocol.Protocol(upload_port, upload_speed, upload_blocksize, float(upload_error_ratio), int(upload_timeout)) - #echologger = MarlinBinaryProtocol.EchoProtocol(protocol) - protocol.connect() - # Mark the rollback (delete broken transfer) from this point on - rollback = True - filetransfer = MarlinBinaryProtocol.FileTransferProtocol(protocol) - transferOK = filetransfer.copy(upload_firmware_source_name, upload_firmware_target_name, upload_compression, upload_test) - protocol.disconnect() - - # Notify upload completed - protocol.send_ascii('M117 Firmware uploaded' if transferOK else 'M117 Firmware upload failed') - - # Remount SD card - print('Wait for SD card release...') - time.sleep(1) - print('Remount SD card') - protocol.send_ascii('M21') - - # Transfer failed? - if not transferOK: - protocol.shutdown() - _RollbackUpload(upload_firmware_target_name) - else: - # Trigger firmware update - if upload_reset: - print('Trigger firmware update...') - protocol.send_ascii('M997', True) - protocol.shutdown() - - print('Firmware update completed' if transferOK else 'Firmware update failed') - return 0 if transferOK else -1 - - except KeyboardInterrupt: - print('Aborted by user') - if filetransfer: filetransfer.abort() - if protocol: - protocol.disconnect() - protocol.shutdown() - _RollbackUpload(upload_firmware_target_name) - _ClosePort() - raise - - except serial.SerialException as se: - # This exception is raised only for send_ascii data (not for binary transfer) - print(f'Serial excepion: {se}, transfer aborted') - if protocol: - protocol.disconnect() - protocol.shutdown() - _RollbackUpload(upload_firmware_target_name) - _ClosePort() - raise Exception(se) - - except MarlinBinaryProtocol.FatalError: - print('Too many retries, transfer aborted') - if protocol: - protocol.disconnect() - protocol.shutdown() - _RollbackUpload(upload_firmware_target_name) - _ClosePort() - raise - - except Exception as ex: - print(f"\nException: {ex}, transfer aborted") - if protocol: - protocol.disconnect() - protocol.shutdown() - _RollbackUpload(upload_firmware_target_name) - _ClosePort() - print('Firmware not updated') - raise + #-------# + # Debug # + #-------# + Debug = False # Set to True to enable script debug + def debugPrint(data): + if Debug: print(f"[Debug]: {data}") + + #------------------# + # Marlin functions # + #------------------# + def _GetMarlinEnv(marlinEnv, feature): + if not marlinEnv: return None + return marlinEnv[feature] if feature in marlinEnv else None + + #----------------# + # Port functions # + #----------------# + def _GetUploadPort(env): + debugPrint('Autodetecting upload port...') + env.AutodetectUploadPort(env) + portName = env.subst('$UPLOAD_PORT') + if not portName: + raise Exception('Error detecting the upload port.') + debugPrint('OK') + return portName + + #-------------------------# + # Simple serial functions # + #-------------------------# + def _OpenPort(): + # Open serial port + if port.is_open: return + debugPrint('Opening upload port...') + port.open() + port.reset_input_buffer() + debugPrint('OK') + + def _ClosePort(): + # Open serial port + if port is None: return + if not port.is_open: return + debugPrint('Closing upload port...') + port.close() + debugPrint('OK') + + def _Send(data): + debugPrint(f'>> {data}') + strdata = bytearray(data, 'utf8') + b'\n' + port.write(strdata) + time.sleep(0.010) + + def _Recv(): + clean_responses = [] + responses = port.readlines() + for Resp in responses: + # Suppress invalid chars (coming from debug info) + try: + clean_response = Resp.decode('utf8').rstrip().lstrip() + clean_responses.append(clean_response) + debugPrint(f'<< {clean_response}') + except: + pass + return clean_responses + + #------------------# + # SDCard functions # + #------------------# + def _CheckSDCard(): + debugPrint('Checking SD card...') + _Send('M21') + Responses = _Recv() + if len(Responses) < 1 or not any('SD card ok' in r for r in Responses): + raise Exception('Error accessing SD card') + debugPrint('SD Card OK') + return True + + #----------------# + # File functions # + #----------------# + def _GetFirmwareFiles(UseLongFilenames): + debugPrint('Get firmware files...') + _Send(f"M20 F{'L' if UseLongFilenames else ''}") + Responses = _Recv() + if len(Responses) < 3 or not any('file list' in r for r in Responses): + raise Exception('Error getting firmware files') + debugPrint('OK') + return Responses + + def _FilterFirmwareFiles(FirmwareList, UseLongFilenames): + Firmwares = [] + for FWFile in FirmwareList: + # For long filenames take the 3rd column of the firmwares list + if UseLongFilenames: + Space = 0 + Space = FWFile.find(' ') + if Space >= 0: Space = FWFile.find(' ', Space + 1) + if Space >= 0: FWFile = FWFile[Space + 1:] + if not '/' in FWFile and '.BIN' in FWFile.upper(): + Firmwares.append(FWFile[:FWFile.upper().index('.BIN') + 4]) + return Firmwares + + def _RemoveFirmwareFile(FirmwareFile): + _Send(f'M30 /{FirmwareFile}') + Responses = _Recv() + Removed = len(Responses) >= 1 and any('File deleted' in r for r in Responses) + if not Removed: + raise Exception(f"Firmware file '{FirmwareFile}' not removed") + return Removed + + def _RollbackUpload(FirmwareFile): + if not rollback: return + print(f"Rollback: trying to delete firmware '{FirmwareFile}'...") + _OpenPort() + # Wait for SD card release + time.sleep(1) + # Remount SD card + _CheckSDCard() + print(' OK' if _RemoveFirmwareFile(FirmwareFile) else ' Error!') + _ClosePort() + + + #---------------------# + # Callback Entrypoint # + #---------------------# + port = None + protocol = None + filetransfer = None + rollback = False + + # Get Marlin evironment vars + MarlinEnv = env['MARLIN_FEATURES'] + marlin_pioenv = _GetMarlinEnv(MarlinEnv, 'PIOENV') + marlin_motherboard = _GetMarlinEnv(MarlinEnv, 'MOTHERBOARD') + marlin_board_info_name = _GetMarlinEnv(MarlinEnv, 'BOARD_INFO_NAME') + marlin_board_custom_build_flags = _GetMarlinEnv(MarlinEnv, 'BOARD_CUSTOM_BUILD_FLAGS') + marlin_firmware_bin = _GetMarlinEnv(MarlinEnv, 'FIRMWARE_BIN') + marlin_long_filename_host_support = _GetMarlinEnv(MarlinEnv, 'LONG_FILENAME_HOST_SUPPORT') is not None + marlin_longname_write = _GetMarlinEnv(MarlinEnv, 'LONG_FILENAME_WRITE_SUPPORT') is not None + marlin_custom_firmware_upload = _GetMarlinEnv(MarlinEnv, 'CUSTOM_FIRMWARE_UPLOAD') is not None + marlin_short_build_version = _GetMarlinEnv(MarlinEnv, 'SHORT_BUILD_VERSION') + marlin_string_config_h_author = _GetMarlinEnv(MarlinEnv, 'STRING_CONFIG_H_AUTHOR') + + # Get firmware upload params + upload_firmware_source_name = str(source[0]) # Source firmware filename + upload_speed = env['UPLOAD_SPEED'] if 'UPLOAD_SPEED' in env else 115200 + # baud rate of serial connection + upload_port = _GetUploadPort(env) # Serial port to use + + # Set local upload params + upload_firmware_target_name = os.path.basename(upload_firmware_source_name) + # Target firmware filename + upload_timeout = 1000 # Communication timout, lossy/slow connections need higher values + upload_blocksize = 512 # Transfer block size. 512 = Autodetect + upload_compression = True # Enable compression + upload_error_ratio = 0 # Simulated corruption ratio + upload_test = False # Benchmark the serial link without storing the file + upload_reset = True # Trigger a soft reset for firmware update after the upload + + # Set local upload params based on board type to change script behavior + # "upload_delete_old_bins": delete all *.bin files in the root of SD Card + upload_delete_old_bins = marlin_motherboard in ['BOARD_CREALITY_V4', 'BOARD_CREALITY_V4210', 'BOARD_CREALITY_V422', 'BOARD_CREALITY_V423', + 'BOARD_CREALITY_V427', 'BOARD_CREALITY_V431', 'BOARD_CREALITY_V452', 'BOARD_CREALITY_V453', + 'BOARD_CREALITY_V24S1'] + # "upload_random_name": generate a random 8.3 firmware filename to upload + upload_random_filename = marlin_motherboard in ['BOARD_CREALITY_V4', 'BOARD_CREALITY_V4210', 'BOARD_CREALITY_V422', 'BOARD_CREALITY_V423', + 'BOARD_CREALITY_V427', 'BOARD_CREALITY_V431', 'BOARD_CREALITY_V452', 'BOARD_CREALITY_V453', + 'BOARD_CREALITY_V24S1'] and not marlin_long_filename_host_support + + try: + + # Start upload job + print(f"Uploading firmware '{os.path.basename(upload_firmware_target_name)}' to '{marlin_motherboard}' via '{upload_port}'") + + # Dump some debug info + if Debug: + print('Upload using:') + print('---- Marlin -----------------------------------') + print(f' PIOENV : {marlin_pioenv}') + print(f' SHORT_BUILD_VERSION : {marlin_short_build_version}') + print(f' STRING_CONFIG_H_AUTHOR : {marlin_string_config_h_author}') + print(f' MOTHERBOARD : {marlin_motherboard}') + print(f' BOARD_INFO_NAME : {marlin_board_info_name}') + print(f' CUSTOM_BUILD_FLAGS : {marlin_board_custom_build_flags}') + print(f' FIRMWARE_BIN : {marlin_firmware_bin}') + print(f' LONG_FILENAME_HOST_SUPPORT : {marlin_long_filename_host_support}') + print(f' LONG_FILENAME_WRITE_SUPPORT : {marlin_longname_write}') + print(f' CUSTOM_FIRMWARE_UPLOAD : {marlin_custom_firmware_upload}') + print('---- Upload parameters ------------------------') + print(f' Source : {upload_firmware_source_name}') + print(f' Target : {upload_firmware_target_name}') + print(f' Port : {upload_port} @ {upload_speed} baudrate') + print(f' Timeout : {upload_timeout}') + print(f' Block size : {upload_blocksize}') + print(f' Compression : {upload_compression}') + print(f' Error ratio : {upload_error_ratio}') + print(f' Test : {upload_test}') + print(f' Reset : {upload_reset}') + print('-----------------------------------------------') + + # Custom implementations based on board parameters + # Generate a new 8.3 random filename + if upload_random_filename: + upload_firmware_target_name = f"fw-{''.join(random.choices('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', k=5))}.BIN" + print(f"Board {marlin_motherboard}: Overriding firmware filename to '{upload_firmware_target_name}'") + + # Delete all *.bin files on the root of SD Card (if flagged) + if upload_delete_old_bins: + # CUSTOM_FIRMWARE_UPLOAD is needed for this feature + if not marlin_custom_firmware_upload: + raise Exception(f"CUSTOM_FIRMWARE_UPLOAD must be enabled in 'Configuration_adv.h' for '{marlin_motherboard}'") + + # Init & Open serial port + port = serial.Serial(upload_port, baudrate = upload_speed, write_timeout = 0, timeout = 0.1) + _OpenPort() + + # Check SD card status + _CheckSDCard() + + # Get firmware files + FirmwareFiles = _GetFirmwareFiles(marlin_long_filename_host_support) + if Debug: + for FirmwareFile in FirmwareFiles: + print(f'Found: {FirmwareFile}') + + # Get all 1st level firmware files (to remove) + OldFirmwareFiles = _FilterFirmwareFiles(FirmwareFiles[1:len(FirmwareFiles)-2], marlin_long_filename_host_support) # Skip header and footers of list + if len(OldFirmwareFiles) == 0: + print('No old firmware files to delete') + else: + print(f"Remove {len(OldFirmwareFiles)} old firmware file{'s' if len(OldFirmwareFiles) != 1 else ''}:") + for OldFirmwareFile in OldFirmwareFiles: + print(f" -Removing- '{OldFirmwareFile}'...") + print(' OK' if _RemoveFirmwareFile(OldFirmwareFile) else ' Error!') + + # Close serial + _ClosePort() + + # Cleanup completed + debugPrint('Cleanup completed') + + # WARNING! The serial port must be closed here because the serial transfer that follow needs it! + + # Upload firmware file + debugPrint(f"Copy '{upload_firmware_source_name}' --> '{upload_firmware_target_name}'") + protocol = MarlinBinaryProtocol.Protocol(upload_port, upload_speed, upload_blocksize, float(upload_error_ratio), int(upload_timeout)) + #echologger = MarlinBinaryProtocol.EchoProtocol(protocol) + protocol.connect() + # Mark the rollback (delete broken transfer) from this point on + rollback = True + filetransfer = MarlinBinaryProtocol.FileTransferProtocol(protocol) + transferOK = filetransfer.copy(upload_firmware_source_name, upload_firmware_target_name, upload_compression, upload_test) + protocol.disconnect() + + # Notify upload completed + protocol.send_ascii('M117 Firmware uploaded' if transferOK else 'M117 Firmware upload failed') + + # Remount SD card + print('Wait for SD card release...') + time.sleep(1) + print('Remount SD card') + protocol.send_ascii('M21') + + # Transfer failed? + if not transferOK: + protocol.shutdown() + _RollbackUpload(upload_firmware_target_name) + else: + # Trigger firmware update + if upload_reset: + print('Trigger firmware update...') + protocol.send_ascii('M997', True) + protocol.shutdown() + + print('Firmware update completed' if transferOK else 'Firmware update failed') + return 0 if transferOK else -1 + + except KeyboardInterrupt: + print('Aborted by user') + if filetransfer: filetransfer.abort() + if protocol: + protocol.disconnect() + protocol.shutdown() + _RollbackUpload(upload_firmware_target_name) + _ClosePort() + raise + + except serial.SerialException as se: + # This exception is raised only for send_ascii data (not for binary transfer) + print(f'Serial excepion: {se}, transfer aborted') + if protocol: + protocol.disconnect() + protocol.shutdown() + _RollbackUpload(upload_firmware_target_name) + _ClosePort() + raise Exception(se) + + except MarlinBinaryProtocol.FatalError: + print('Too many retries, transfer aborted') + if protocol: + protocol.disconnect() + protocol.shutdown() + _RollbackUpload(upload_firmware_target_name) + _ClosePort() + raise + + except Exception as ex: + print(f"\nException: {ex}, transfer aborted") + if protocol: + protocol.disconnect() + protocol.shutdown() + _RollbackUpload(upload_firmware_target_name) + _ClosePort() + print('Firmware not updated') + raise # Attach custom upload callback env.Replace(UPLOADCMD=Upload) From db3865520f2626bac5abd6cfd81a1cfbd44cbdab Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 1 Dec 2022 23:39:17 -0600 Subject: [PATCH 171/243] =?UTF-8?q?=F0=9F=8E=A8=20Misc.=20cleanup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/feature/bltouch.cpp | 2 -- Marlin/src/feature/pause.cpp | 8 ++------ buildroot/share/scripts/upload.py | 4 +--- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/Marlin/src/feature/bltouch.cpp b/Marlin/src/feature/bltouch.cpp index 10d3131aedcb..fe56341a47ec 100644 --- a/Marlin/src/feature/bltouch.cpp +++ b/Marlin/src/feature/bltouch.cpp @@ -38,8 +38,6 @@ bool BLTouch::od_5v_mode; // Initialized by settings.load, 0 = Open Drai #include "../module/servo.h" #include "../module/probe.h" -void stop(); - #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) #include "../core/debug_out.h" diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index 1c2ea59d4daf..91d25d718775 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -472,9 +472,7 @@ bool pause_print(const_float_t retract, const xyz_pos_t &park_point, const bool if (unload_length) unload_filament(unload_length, show_lcd, PAUSE_MODE_CHANGE_FILAMENT); - #if ENABLED(DUAL_X_CARRIAGE) - set_duplication_enabled(saved_ext_dup_mode, saved_ext); - #endif + TERN_(DUAL_X_CARRIAGE, set_duplication_enabled(saved_ext_dup_mode, saved_ext)); // Disable the Extruder for manual change disable_active_extruder(); @@ -580,9 +578,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep } idle_no_sleep(); } - #if ENABLED(DUAL_X_CARRIAGE) - set_duplication_enabled(saved_ext_dup_mode, saved_ext); - #endif + TERN_(DUAL_X_CARRIAGE, set_duplication_enabled(saved_ext_dup_mode, saved_ext)); } /** diff --git a/buildroot/share/scripts/upload.py b/buildroot/share/scripts/upload.py index caa1fbae2303..af15a825906e 100644 --- a/buildroot/share/scripts/upload.py +++ b/buildroot/share/scripts/upload.py @@ -189,9 +189,7 @@ def _RollbackUpload(FirmwareFile): 'BOARD_CREALITY_V427', 'BOARD_CREALITY_V431', 'BOARD_CREALITY_V452', 'BOARD_CREALITY_V453', 'BOARD_CREALITY_V24S1'] # "upload_random_name": generate a random 8.3 firmware filename to upload - upload_random_filename = marlin_motherboard in ['BOARD_CREALITY_V4', 'BOARD_CREALITY_V4210', 'BOARD_CREALITY_V422', 'BOARD_CREALITY_V423', - 'BOARD_CREALITY_V427', 'BOARD_CREALITY_V431', 'BOARD_CREALITY_V452', 'BOARD_CREALITY_V453', - 'BOARD_CREALITY_V24S1'] and not marlin_long_filename_host_support + upload_random_filename = upload_delete_old_bins and not marlin_long_filename_host_support try: From 96b8c28376fbefa92ebd71119bda1db66daa20ea Mon Sep 17 00:00:00 2001 From: kisslorand <50251547+kisslorand@users.noreply.github.com> Date: Fri, 2 Dec 2022 08:19:34 +0200 Subject: [PATCH 172/243] =?UTF-8?q?=F0=9F=9A=B8=20G30=20move=20to=20logica?= =?UTF-8?q?l=20XY=20(#24953)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/types.h | 6 +++--- Marlin/src/gcode/probe/G30.cpp | 23 +++++++++++++---------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index 0281dea08c3c..61c182448e45 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -309,9 +309,9 @@ typedef abce_float_t abce_pos_t; void toLogical(xy_pos_t &raw); void toLogical(xyz_pos_t &raw); void toLogical(xyze_pos_t &raw); -void toNative(xy_pos_t &raw); -void toNative(xyz_pos_t &raw); -void toNative(xyze_pos_t &raw); +void toNative(xy_pos_t &lpos); +void toNative(xyz_pos_t &lpos); +void toNative(xyze_pos_t &lpos); // // Paired XY coordinates, counters, flags, etc. diff --git a/Marlin/src/gcode/probe/G30.cpp b/Marlin/src/gcode/probe/G30.cpp index e474ffe9d689..6893d4bec284 100644 --- a/Marlin/src/gcode/probe/G30.cpp +++ b/Marlin/src/gcode/probe/G30.cpp @@ -58,16 +58,13 @@ void GcodeSuite::G30() { tool_change(0); #endif - const xy_pos_t pos = { parser.linearval('X', current_position.x + probe.offset_xy.x), - parser.linearval('Y', current_position.y + probe.offset_xy.y) }; + // Convert the given logical position to native position + const xy_pos_t pos = { + parser.seenval('X') ? RAW_X_POSITION(parser.value_linear_units()) : current_position.x, + parser.seenval('Y') ? RAW_Y_POSITION(parser.value_linear_units()) : current_position.y + }; - if (!probe.can_reach(pos)) { - #if ENABLED(DWIN_LCD_PROUI) - SERIAL_ECHOLNF(GET_EN_TEXT_F(MSG_ZPROBE_OUT)); - LCD_MESSAGE(MSG_ZPROBE_OUT); - #endif - } - else { + if (probe.can_reach(pos)) { // Disable leveling so the planner won't mess with us TERN_(HAS_LEVELING, set_bed_leveling_enabled(false)); @@ -83,7 +80,7 @@ void GcodeSuite::G30() { const float measured_z = probe.probe_at_point(pos, raise_after, 1); TERN_(HAS_PTC, ptc.set_enabled(true)); if (!isnan(measured_z)) { - SERIAL_ECHOLNPGM("Bed X: ", pos.x, " Y: ", pos.y, " Z: ", measured_z); + SERIAL_ECHOLNPGM("Bed X: ", pos.asLogical().x, " Y: ", pos.asLogical().y, " Z: ", measured_z); #if EITHER(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) char msg[31], str_1[6], str_2[6], str_3[6]; sprintf_P(msg, PSTR("X:%s, Y:%s, Z:%s"), @@ -102,6 +99,12 @@ void GcodeSuite::G30() { report_current_position(); } + else { + #if ENABLED(DWIN_LCD_PROUI) + SERIAL_ECHOLNF(GET_EN_TEXT_F(MSG_ZPROBE_OUT)); + LCD_MESSAGE(MSG_ZPROBE_OUT); + #endif + } // Restore the active tool TERN_(HAS_MULTI_HOTEND, tool_change(old_tool_index)); From 26edeefeb9ee79e6e2c992a192d8465a5a24bbfb Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Sun, 4 Dec 2022 14:05:22 +1300 Subject: [PATCH 173/243] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20MSG=5FMOVE=5FN=5FM?= =?UTF-8?q?M=20substitution=20(#25043)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/language/language_el.h | 2 +- Marlin/src/lcd/language/language_el_gr.h | 2 +- Marlin/src/lcd/language/language_ru.h | 2 +- Marlin/src/lcd/language/language_uk.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Marlin/src/lcd/language/language_el.h b/Marlin/src/lcd/language/language_el.h index 2d7c42b2fa13..57af804147c5 100644 --- a/Marlin/src/lcd/language/language_el.h +++ b/Marlin/src/lcd/language/language_el.h @@ -95,7 +95,7 @@ namespace Language_el { LSTR MSG_MOVE_N = _UxGT("Μετακίνηση @"); LSTR MSG_MOVE_E = _UxGT("Εξωθητής"); LSTR MSG_MOVE_EN = _UxGT("Εξωθητής *"); - LSTR MSG_MOVE_N_MM = _UxGT("Μετακίνηση %s μμ"); + LSTR MSG_MOVE_N_MM = _UxGT("Μετακίνηση $μμ"); LSTR MSG_MOVE_01MM = _UxGT("Μετακίνηση 0,1 μμ"); LSTR MSG_MOVE_1MM = _UxGT("Μετακίνηση 1 μμ"); LSTR MSG_MOVE_10MM = _UxGT("Μετακίνηση 10 μμ"); diff --git a/Marlin/src/lcd/language/language_el_gr.h b/Marlin/src/lcd/language/language_el_gr.h index a76870d2a325..08f647f705bb 100644 --- a/Marlin/src/lcd/language/language_el_gr.h +++ b/Marlin/src/lcd/language/language_el_gr.h @@ -84,7 +84,7 @@ namespace Language_el_gr { LSTR MSG_MOVE_N = _UxGT("Μετακίνηση @"); LSTR MSG_MOVE_E = _UxGT("Εξωθητήρας"); LSTR MSG_MOVE_EN = _UxGT("Εξωθητήρας *"); - LSTR MSG_MOVE_N_MM = _UxGT("Μετακίνηση %s μμ"); + LSTR MSG_MOVE_N_MM = _UxGT("Μετακίνηση $μμ"); LSTR MSG_MOVE_01MM = _UxGT("Μετακίνηση 0,1 μμ"); LSTR MSG_MOVE_1MM = _UxGT("Μετακίνηση 1 μμ"); LSTR MSG_MOVE_10MM = _UxGT("Μετακίνηση 10 μμ"); diff --git a/Marlin/src/lcd/language/language_ru.h b/Marlin/src/lcd/language/language_ru.h index c9b4683bb20d..ec9ddfa7f63c 100644 --- a/Marlin/src/lcd/language/language_ru.h +++ b/Marlin/src/lcd/language/language_ru.h @@ -336,7 +336,7 @@ namespace Language_ru { LSTR MSG_MOVE_E = _UxGT("Экструдер"); LSTR MSG_MOVE_EN = _UxGT("Экструдер *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Сопло не нагрето"); - LSTR MSG_MOVE_N_MM = _UxGT("Движение %sмм"); + LSTR MSG_MOVE_N_MM = _UxGT("Движение $мм"); LSTR MSG_MOVE_01MM = _UxGT("Движение 0.1мм"); LSTR MSG_MOVE_1MM = _UxGT("Движение 1мм"); LSTR MSG_MOVE_10MM = _UxGT("Движение 10мм"); diff --git a/Marlin/src/lcd/language/language_uk.h b/Marlin/src/lcd/language/language_uk.h index ccdcb21ddf38..6b4ebc79cd1e 100644 --- a/Marlin/src/lcd/language/language_uk.h +++ b/Marlin/src/lcd/language/language_uk.h @@ -337,7 +337,7 @@ namespace Language_uk { LSTR MSG_MOVE_E = _UxGT("Екструдер"); LSTR MSG_MOVE_EN = _UxGT("Екструдер *"); LSTR MSG_HOTEND_TOO_COLD = _UxGT("Сопло дуже холодне"); - LSTR MSG_MOVE_N_MM = _UxGT("Рух %sмм"); + LSTR MSG_MOVE_N_MM = _UxGT("Рух $мм"); LSTR MSG_MOVE_01MM = _UxGT("Рух 0.1мм"); LSTR MSG_MOVE_1MM = _UxGT("Рух 1мм"); LSTR MSG_MOVE_10MM = _UxGT("Рух 10мм"); From eb125c95b68af813a05a732273be62e6dd2e23af Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Sun, 4 Dec 2022 14:09:02 +1300 Subject: [PATCH 174/243] =?UTF-8?q?=F0=9F=94=A8=20Update=20renamed.ini=20(?= =?UTF-8?q?#25042)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ini/renamed.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ini/renamed.ini b/ini/renamed.ini index 5785bfac67e3..fa154f3a0f04 100644 --- a/ini/renamed.ini +++ b/ini/renamed.ini @@ -57,10 +57,10 @@ extends = renamed # Renamed to STM32F103VE_GTM32_maple extends = renamed -[env:mks_robin_nano_35] +[env:mks_robin_nano35] # Renamed to mks_robin_nano_v1v2 extends = renamed -[env:mks_robin_nano_35_maple] +[env:mks_robin_nano35_maple] # Renamed to mks_robin_nano_v1v2_maple extends = renamed From 0fadb56150aedf4759b5d5a959506c9ef7854443 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 3 Dec 2022 19:18:03 -0600 Subject: [PATCH 175/243] =?UTF-8?q?=F0=9F=8E=A8=20Trailing=20whitespace?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h | 4 +- README.md | 40 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h b/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h index 4bf1073ae430..b3d97ae059e4 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_OCTOPUS_V1_common.h @@ -435,8 +435,8 @@ * | 1 2 | | 1 2 | 1 | * | 3 4 | RX | 3 4 | TX | 2 | RX * ENT 5 6 | BEEP ENT 5 6 | BEEP | 3 | TX - * B | 7 8 | A B | 7 8 | A | 4 | - * GND | 9 10 | VCC GND | 9 10 | VCC 5 | + * B | 7 8 | A B | 7 8 | A | 4 | + * GND | 9 10 | VCC GND | 9 10 | VCC 5 | * ------ ------ --- * EXP1 DWIN TFT * diff --git a/README.md b/README.md index 291f3fc4124f..1e3a161aafc5 100644 --- a/README.md +++ b/README.md @@ -87,42 +87,42 @@ Regular users can open and close their own issues, but only the administrators c Project Maintainer - 🇺🇸  **Scott Lahteine** -       [@thinkyhead](https://github.com/thinkyhead) + 🇺🇸  **Scott Lahteine** +       [@thinkyhead](https://github.com/thinkyhead)       [  Donate 💸  ](https://www.thinkyhead.com/donate-to-marlin) - 🇺🇸  **Roxanne Neufeld** -       [@Roxy-3D](https://github.com/Roxy-3D) - - 🇺🇸  **Keith Bennett** -       [@thisiskeithb](https://github.com/thisiskeithb) + 🇺🇸  **Roxanne Neufeld** +       [@Roxy-3D](https://github.com/Roxy-3D) + + 🇺🇸  **Keith Bennett** +       [@thisiskeithb](https://github.com/thisiskeithb)       [  Donate 💸  ](https://github.com/sponsors/thisiskeithb) - - 🇺🇸  **Jason Smith** + + 🇺🇸  **Jason Smith**       [@sjasonsmith](https://github.com/sjasonsmith) - 🇧🇷  **Victor Oliveira** + 🇧🇷  **Victor Oliveira**       [@rhapsodyv](https://github.com/rhapsodyv) - - 🇬🇧  **Chris Pepper** + + 🇬🇧  **Chris Pepper**       [@p3p](https://github.com/p3p) - -🇳🇿  **Peter Ellens** -       [@ellensp](https://github.com/ellensp) + +🇳🇿  **Peter Ellens** +       [@ellensp](https://github.com/ellensp)       [  Donate 💸  ](https://ko-fi.com/ellensp) - 🇺🇸  **Bob Kuhn** + 🇺🇸  **Bob Kuhn**       [@Bob-the-Kuhn](https://github.com/Bob-the-Kuhn) - - 🇳🇱  **Erik van der Zalm** -       [@ErikZalm](https://github.com/ErikZalm) -       [  Donate 💸  ](https://flattr.com/submit/auto?user_id=ErikZalm&url=https://github.com/MarlinFirmware/Marlin&title=Marlin&language=&tags=github&category=software) + + 🇳🇱  **Erik van der Zalm** +       [@ErikZalm](https://github.com/ErikZalm) +       [  Donate 💸  ](https://flattr.com/submit/auto?user_id=ErikZalm&url=https://github.com/MarlinFirmware/Marlin&title=Marlin&language=&tags=github&category=software) From c3090bd4e8df8c9eb3f32e31e0a8e37e92242681 Mon Sep 17 00:00:00 2001 From: Taylor Talkington Date: Sat, 3 Dec 2022 20:20:19 -0500 Subject: [PATCH 176/243] =?UTF-8?q?=F0=9F=A9=B9=20Ender=203v2=20DWIN=20Mar?= =?UTF-8?q?linUI=20Fixup=20(#24984)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/e3v2/common/dwin_api.cpp | 2 +- Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/lcd/e3v2/common/dwin_api.cpp b/Marlin/src/lcd/e3v2/common/dwin_api.cpp index 79998219a95e..f3abaf25c96b 100644 --- a/Marlin/src/lcd/e3v2/common/dwin_api.cpp +++ b/Marlin/src/lcd/e3v2/common/dwin_api.cpp @@ -234,7 +234,7 @@ void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis, // *string: The string // rlimit: To limit the drawn string length void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const char * const string, uint16_t rlimit/*=0xFFFF*/) { - #if NONE(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI) + #if NONE(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI, IS_DWIN_MARLINUI) DWIN_Draw_Rectangle(1, bColor, x, y, x + (fontWidth(size) * strlen_P(string)), y + fontHeight(size)); #endif constexpr uint8_t widthAdjust = 0; diff --git a/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp b/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp index 0bd1b2ff2af2..73de275f9c62 100644 --- a/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp @@ -453,7 +453,7 @@ void MarlinUI::draw_status_screen() { DWIN_Draw_String( false, font16x32, Percent_Color, Color_Bg_Black, pb_left + (pb_width - dwin_string.length * 16) / 2, - pb_top + (pb_height - 32) / 2, + pb_top + (pb_height - 32) / 2 - 1, S(dwin_string.string()) ); #endif From df2a2488a8911e50d4840e17e9ae91bd05bd369b Mon Sep 17 00:00:00 2001 From: tombrazier <68918209+tombrazier@users.noreply.github.com> Date: Sun, 4 Dec 2022 02:14:31 +0000 Subject: [PATCH 177/243] =?UTF-8?q?=F0=9F=90=9B=20Fix=20TMC5160=20+=20Inpu?= =?UTF-8?q?t=20Shaping=20overcurrent=20(#25050)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/module/stepper.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 74e761dc6478..46b21a20b68c 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -1679,12 +1679,14 @@ void Stepper::pulse_phase_isr() { // the TMC2208 / TMC2225 shutdown bug (#16076), add a half step hysteresis // in each direction. This results in the position being off by half an // average half step during travel but correct at the end of each segment. - #if AXIS_DRIVER_TYPE_X(TMC2208) || AXIS_DRIVER_TYPE_X(TMC2208_STANDALONE) + #if AXIS_DRIVER_TYPE_X(TMC2208) || AXIS_DRIVER_TYPE_X(TMC2208_STANDALONE) || \ + AXIS_DRIVER_TYPE_X(TMC5160) || AXIS_DRIVER_TYPE_X(TMC5160_STANDALONE) #define HYSTERESIS_X 64 #else #define HYSTERESIS_X 0 #endif - #if AXIS_DRIVER_TYPE_Y(TMC2208) || AXIS_DRIVER_TYPE_Y(TMC2208_STANDALONE) + #if AXIS_DRIVER_TYPE_Y(TMC2208) || AXIS_DRIVER_TYPE_Y(TMC2208_STANDALONE) || \ + AXIS_DRIVER_TYPE_Y(TMC5160) || AXIS_DRIVER_TYPE_Y(TMC5160_STANDALONE) #define HYSTERESIS_Y 64 #else #define HYSTERESIS_Y 0 From 071dae0c288e75c26f6779b830af1e6153682854 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 3 Dec 2022 20:19:18 -0600 Subject: [PATCH 178/243] =?UTF-8?q?=F0=9F=94=A8=20Fix=20CI=20Test=20clean?= =?UTF-8?q?=20step?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildroot/share/PlatformIO/scripts/pioutil.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildroot/share/PlatformIO/scripts/pioutil.py b/buildroot/share/PlatformIO/scripts/pioutil.py index 5ae28a62f393..cc3db33df48a 100644 --- a/buildroot/share/PlatformIO/scripts/pioutil.py +++ b/buildroot/share/PlatformIO/scripts/pioutil.py @@ -6,7 +6,7 @@ def is_pio_build(): from SCons.Script import DefaultEnvironment env = DefaultEnvironment() - return not env.IsIntegrationDump() + return not env.IsIntegrationDump() and not env.IsCleanTarget() def get_pio_version(): from platformio import util From 3c550e0f1910927fa691f2e62a18cebb6ddd58fd Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 3 Dec 2022 20:49:46 -0600 Subject: [PATCH 179/243] =?UTF-8?q?=F0=9F=8E=A8=20Misc.=20cleanup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/calibrate/M48.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/gcode/calibrate/M48.cpp b/Marlin/src/gcode/calibrate/M48.cpp index 8b6ea0bf1fae..825f3713f45c 100644 --- a/Marlin/src/gcode/calibrate/M48.cpp +++ b/Marlin/src/gcode/calibrate/M48.cpp @@ -112,7 +112,7 @@ void GcodeSuite::M48() { set_bed_leveling_enabled(false); #endif - TERN_(HAS_PTC, ptc.set_enabled(!parser.seen('C') || parser.value_bool())); + TERN_(HAS_PTC, ptc.set_enabled(parser.boolval('C', true)); // Work with reasonable feedrates remember_feedrate_scaling_off(); From 686ce0c0e220c73b32a1d29ae3d48c6b336b024f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 4 Dec 2022 15:35:45 -0600 Subject: [PATCH 180/243] =?UTF-8?q?=F0=9F=94=A8=20Fix=20CI=20Test=20clean?= =?UTF-8?q?=20step=20(2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildroot/share/PlatformIO/scripts/pioutil.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/buildroot/share/PlatformIO/scripts/pioutil.py b/buildroot/share/PlatformIO/scripts/pioutil.py index cc3db33df48a..18e6dba92889 100644 --- a/buildroot/share/PlatformIO/scripts/pioutil.py +++ b/buildroot/share/PlatformIO/scripts/pioutil.py @@ -6,7 +6,8 @@ def is_pio_build(): from SCons.Script import DefaultEnvironment env = DefaultEnvironment() - return not env.IsIntegrationDump() and not env.IsCleanTarget() + if "IsCleanTarget" in dir(env) and env.IsCleanTarget(): return False + return not env.IsIntegrationDump() def get_pio_version(): from platformio import util From ecdf07f0555ce0d71ac3fd1fcd9efd07c14209ad Mon Sep 17 00:00:00 2001 From: kisslorand <50251547+kisslorand@users.noreply.github.com> Date: Mon, 5 Dec 2022 00:04:11 +0200 Subject: [PATCH 181/243] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20Fix=20missing=20)?= =?UTF-8?q?=20(#25055)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/calibrate/M48.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/gcode/calibrate/M48.cpp b/Marlin/src/gcode/calibrate/M48.cpp index 825f3713f45c..bfb3b640078b 100644 --- a/Marlin/src/gcode/calibrate/M48.cpp +++ b/Marlin/src/gcode/calibrate/M48.cpp @@ -112,7 +112,7 @@ void GcodeSuite::M48() { set_bed_leveling_enabled(false); #endif - TERN_(HAS_PTC, ptc.set_enabled(parser.boolval('C', true)); + TERN_(HAS_PTC, ptc.set_enabled(parser.boolval('C', true))); // Work with reasonable feedrates remember_feedrate_scaling_off(); From 86a10dc459056cfb49055758e3fed0e0825043ae Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Mon, 5 Dec 2022 16:38:23 +1300 Subject: [PATCH 182/243] =?UTF-8?q?=F0=9F=90=9B=20Fix=20Fast=20PWM=20on=20?= =?UTF-8?q?AVR=20(#25030)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Followup to #25005 --- Marlin/src/HAL/AVR/fast_pwm.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Marlin/src/HAL/AVR/fast_pwm.cpp b/Marlin/src/HAL/AVR/fast_pwm.cpp index e440315e0032..d361aaab38f3 100644 --- a/Marlin/src/HAL/AVR/fast_pwm.cpp +++ b/Marlin/src/HAL/AVR/fast_pwm.cpp @@ -146,11 +146,11 @@ void MarlinHAL::set_pwm_frequency(const pin_t pin, const uint16_t f_desired) { LIMIT(res_pc_temp, 1U, maxtop); // Calculate frequencies of test prescaler and resolution values - const int f_diff = ABS(f - int(f_desired)), - f_fast_temp = (F_CPU) / (p * (1 + res_fast_temp)), - f_fast_diff = ABS(f_fast_temp - int(f_desired)), - f_pc_temp = (F_CPU) / (2 * p * res_pc_temp), - f_pc_diff = ABS(f_pc_temp - int(f_desired)); + const uint16_t f_fast_temp = (F_CPU) / (p * (1 + res_fast_temp)), + f_pc_temp = (F_CPU) / (2 * p * res_pc_temp); + const int f_diff = _MAX(f, f_desired) - _MIN(f, f_desired), + f_fast_diff = _MAX(f_fast_temp, f_desired) - _MIN(f_fast_temp, f_desired), + f_pc_diff = _MAX(f_pc_temp, f_desired) - _MIN(f_pc_temp, f_desired); if (f_fast_diff < f_diff && f_fast_diff <= f_pc_diff) { // FAST values are closest to desired f // Set the Wave Generation Mode to FAST PWM From 273728602109e208c1ca32d2ac7dad59dcc1307a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 5 Dec 2022 11:01:08 -0600 Subject: [PATCH 183/243] =?UTF-8?q?=F0=9F=93=9D=20Update=20config=20commen?= =?UTF-8?q?ts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 7f625c04f85e..462bfff65b4d 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -909,8 +909,6 @@ #define DELTA_CALIBRATION_DEFAULT_POINTS 4 #endif - // NOTE: All values for DELTA_* values MUST be floating point, so always have a decimal point in them - #if EITHER(DELTA_AUTO_CALIBRATION, DELTA_CALIBRATION_MENU) // Step size for paper-test probing #define PROBE_MANUALLY_STEP 0.05 // (mm) @@ -1918,17 +1916,21 @@ #endif #if ANY(MESH_BED_LEVELING, AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_UBL) - // Gradually reduce leveling correction until a set height is reached, - // at which point movement will be level to the machine's XY plane. - // The height can be set with M420 Z + /** + * Gradually reduce leveling correction until a set height is reached, + * at which point movement will be level to the machine's XY plane. + * The height can be set with M420 Z + */ #define ENABLE_LEVELING_FADE_HEIGHT #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) #define DEFAULT_LEVELING_FADE_HEIGHT 10.0 // (mm) Default fade height. #endif - // For Cartesian machines, instead of dividing moves on mesh boundaries, - // split up moves into short segments like a Delta. This follows the - // contours of the bed more closely than edge-to-edge straight moves. + /** + * For Cartesian machines, instead of dividing moves on mesh boundaries, + * split up moves into short segments like a Delta. This follows the + * contours of the bed more closely than edge-to-edge straight moves. + */ #define SEGMENT_LEVELED_MOVES #define LEVELED_SEGMENT_LENGTH 5.0 // (mm) Length of all segments (except the last one) From 5a97ffc41415481d0e285c3478e582cbdd467bad Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 7 Dec 2022 12:18:09 -0600 Subject: [PATCH 184/243] =?UTF-8?q?=F0=9F=94=A8=20Return=20error=20on=20mf?= =?UTF-8?q?test=20exit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildroot/bin/mftest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildroot/bin/mftest b/buildroot/bin/mftest index 8a4f3afd4f3e..e4132f02a75c 100755 --- a/buildroot/bin/mftest +++ b/buildroot/bin/mftest @@ -202,7 +202,7 @@ if ((AUTO_BUILD)); then echo "Building environment $TARGET for board $MB ($BNUM)..." ; echo pio run $SILENT_FLAG -e $TARGET fi - exit 0 + exit $? fi # From c86f20010d916ba5a09f7c4320a37f5cdfc75f48 Mon Sep 17 00:00:00 2001 From: Sebastien BLAISOT Date: Wed, 7 Dec 2022 22:49:38 +0100 Subject: [PATCH 185/243] =?UTF-8?q?=E2=9C=A8=20M150=20S=20default=20index?= =?UTF-8?q?=20(#23066)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/Configuration.h | 1 + Marlin/src/gcode/feature/leds/M150.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 462bfff65b4d..37df8c0c57d5 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -3305,6 +3305,7 @@ #define NEOPIXEL2_PIXELS 15 // Number of LEDs in the second strip #define NEOPIXEL2_BRIGHTNESS 127 // Initial brightness (0-255) #define NEOPIXEL2_STARTUP_TEST // Cycle through colors at startup + #define NEOPIXEL_M150_DEFAULT -1 // Default strip for M150 without 'S'. Use -1 to set all by default. #else //#define NEOPIXEL2_INSERIES // Default behavior is NeoPixel 2 in parallel #endif diff --git a/Marlin/src/gcode/feature/leds/M150.cpp b/Marlin/src/gcode/feature/leds/M150.cpp index 77c58411a37a..43062c3f752a 100644 --- a/Marlin/src/gcode/feature/leds/M150.cpp +++ b/Marlin/src/gcode/feature/leds/M150.cpp @@ -61,7 +61,12 @@ void GcodeSuite::M150() { #if ENABLED(NEOPIXEL_LED) const pixel_index_t index = parser.intval('I', -1); #if ENABLED(NEOPIXEL2_SEPARATE) - int8_t brightness = neo.brightness(), unit = parser.intval('S', -1); + #ifndef NEOPIXEL_M150_DEFAULT + #define NEOPIXEL_M150_DEFAULT -1 + #elif NEOPIXEL_M150_DEFAULT > 1 + #error "NEOPIXEL_M150_DEFAULT must be -1, 0, or 1." + #endif + int8_t brightness = neo.brightness(), unit = parser.intval('S', NEOPIXEL_M150_DEFAULT); switch (unit) { case -1: neo2.neoindex = index; // fall-thru case 0: neo.neoindex = index; old_color = parser.seen('K') ? neo.pixel_color(index >= 0 ? index : 0) : 0; break; From 0efeedf26274b7a66e21899ab99a5dd70e8ae657 Mon Sep 17 00:00:00 2001 From: EvilGremlin <22657714+EvilGremlin@users.noreply.github.com> Date: Thu, 8 Dec 2022 01:08:53 +0300 Subject: [PATCH 186/243] =?UTF-8?q?=F0=9F=9A=B8=20Progress=20display=20fol?= =?UTF-8?q?lowup=20(#24879)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 18 +-- Marlin/src/gcode/lcd/M73.cpp | 28 ++--- Marlin/src/lcd/HD44780/marlinui_HD44780.cpp | 20 +-- Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp | 82 ++++++++----- Marlin/src/lcd/dogm/status_screen_DOGM.cpp | 115 ++++++------------ .../lcd/e3v2/marlinui/ui_status_480x272.cpp | 2 + Marlin/src/libs/numtostr.cpp | 6 - 7 files changed, 123 insertions(+), 148 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index c168240e243d..db8bf75b5aa2 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1476,24 +1476,26 @@ #endif // HAS_DISPLAY || DWIN_LCD_PROUI -// Add the G-code 'M73' to set / report the current job progress +// Add 'M73' to set print job progress, overrides Marlin's built-in estimate //#define SET_PROGRESS_MANUALLY #if ENABLED(SET_PROGRESS_MANUALLY) - //#define SET_PROGRESS_PERCENT // Add 'P' parameter to set percentage done, otherwise use Marlin's estimate - //#define SET_REMAINING_TIME // Add 'R' parameter to set remaining time, otherwise use Marlin's estimate + #define SET_PROGRESS_PERCENT // Add 'P' parameter to set percentage done + #define SET_REMAINING_TIME // Add 'R' parameter to set remaining time //#define SET_INTERACTION_TIME // Add 'C' parameter to set time until next filament change or other user interaction - #if ENABLED(SET_INTERACTION_TIME) - #define SHOW_INTERACTION_TIME // Display time until next user interaction ('C' = filament change) + //#define M73_REPORT // Report M73 values to host + #if BOTH(M73_REPORT, SDSUPPORT) + #define M73_REPORT_SD_ONLY // Report only when printing from SD #endif - //#define M73_REPORT // Report progress to host with 'M73' #endif -// LCD Print Progress options, multiple can be rotated depending on screen layout +// LCD Print Progress options. Multiple times may be displayed in turn. #if HAS_DISPLAY && EITHER(SDSUPPORT, SET_PROGRESS_MANUALLY) #define SHOW_PROGRESS_PERCENT // Show print progress percentage (doesn't affect progress bar) #define SHOW_ELAPSED_TIME // Display elapsed printing time (prefix 'E') //#define SHOW_REMAINING_TIME // Display estimated time to completion (prefix 'R') - + #if ENABLED(SET_INTERACTION_TIME) + #define SHOW_INTERACTION_TIME // Display time until next user interaction ('C' = filament change) + #endif //#define PRINT_PROGRESS_SHOW_DECIMALS // Show/report progress with decimal digits, not all UIs support this #if EITHER(HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL) diff --git a/Marlin/src/gcode/lcd/M73.cpp b/Marlin/src/gcode/lcd/M73.cpp index 77d93019acaf..02d44ca00be8 100644 --- a/Marlin/src/gcode/lcd/M73.cpp +++ b/Marlin/src/gcode/lcd/M73.cpp @@ -33,10 +33,6 @@ #include "../../lcd/e3v2/proui/dwin.h" #endif -#if ENABLED(M73_REPORT) - #define M73_REPORT_PRUSA -#endif - /** * M73: Set percentage complete (for display on LCD) * @@ -46,10 +42,9 @@ * M73 C12 ; Set next interaction countdown to 12 minutes * M73 ; Report current values * - * Use a shorter-than-Průša report format: - * M73 Percent done: ---%; Time left: -----m; Change: -----m; + * M73 Progress: ---%; Time left: -----m; Change: -----m; * - * When PRINT_PROGRESS_SHOW_DECIMALS is enabled - reports percent with 100 / 23.4 / 3.45 format + * When PRINT_PROGRESS_SHOW_DECIMALS is enabled - reports percent with 100% / 23.4% / 3.45% format * */ void GcodeSuite::M73() { @@ -79,19 +74,20 @@ void GcodeSuite::M73() { #endif #if ENABLED(M73_REPORT) - { - SERIAL_ECHO_MSG( - TERN(M73_REPORT_PRUSA, "M73 Percent done: ", "Progress: ") - , TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(ui.get_progress_permyriad()), ui.get_progress_percent()) + if (TERN1(M73_REPORT_SD_ONLY, IS_SD_PRINTING())) { + SERIAL_ECHO_START(); + SERIAL_ECHOPGM(" M73"); + #if ENABLED(SET_PROGRESS_PERCENT) + SERIAL_ECHOPGM(" Progress: ", TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(ui.get_progress_permyriad()), ui.get_progress_percent()), "%;"); + #endif #if ENABLED(SET_REMAINING_TIME) - , TERN(M73_REPORT_PRUSA, "; Print time remaining in mins: ", "%; Time left: "), ui.remaining_time / 60 + SERIAL_ECHOPGM(" Time left: ", ui.remaining_time / 60, "m;"); #endif #if ENABLED(SET_INTERACTION_TIME) - , TERN(M73_REPORT_PRUSA, "; Change in mins: ", "m; Change: "), ui.interaction_time / 60 + SERIAL_ECHOPGM(" Change: ", ui.interaction_time / 60, "m;"); #endif - , TERN(M73_REPORT_PRUSA, ";", "m") - ); - } + SERIAL_EOL(); + } #endif } diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index ffbca8def607..9445198a22c1 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -760,7 +760,7 @@ void MarlinUI::draw_status_message(const bool blink) { #if HAS_PRINT_PROGRESS #define TPOFFSET (LCD_WIDTH - 1) static uint8_t timepos = TPOFFSET - 6; - static char buffer[14]; + static char buffer[8]; static lcd_uint_t pc, pr; #if ENABLED(SHOW_PROGRESS_PERCENT) @@ -776,9 +776,10 @@ void MarlinUI::draw_status_message(const bool blink) { #endif #if ENABLED(SHOW_REMAINING_TIME) void MarlinUI::drawRemain() { - const duration_t remaint = ui.get_remaining_time(); if (printJobOngoing()) { + const duration_t remaint = ui.get_remaining_time(); timepos = TPOFFSET - remaint.toDigital(buffer); + TERN_(NOT(LCD_INFO_SCREEN_STYLE), lcd_put_lchar(timepos - 1, 2, 0x20);) lcd_put_lchar(TERN(LCD_INFO_SCREEN_STYLE, 11, timepos), 2, 'R'); lcd_put_u8str(buffer); } @@ -789,6 +790,7 @@ void MarlinUI::draw_status_message(const bool blink) { const duration_t interactt = ui.interaction_time; if (printingIsActive() && interactt.value) { timepos = TPOFFSET - interactt.toDigital(buffer); + TERN_(NOT(LCD_INFO_SCREEN_STYLE), lcd_put_lchar(timepos - 1, 2, 0x20);) lcd_put_lchar(TERN(LCD_INFO_SCREEN_STYLE, 11, timepos), 2, 'C'); lcd_put_u8str(buffer); } @@ -796,11 +798,11 @@ void MarlinUI::draw_status_message(const bool blink) { #endif #if ENABLED(SHOW_ELAPSED_TIME) void MarlinUI::drawElapsed() { - const duration_t elapsedt = print_job_timer.duration(); if (printJobOngoing()) { + const duration_t elapsedt = print_job_timer.duration(); timepos = TPOFFSET - elapsedt.toDigital(buffer); + TERN_(NOT(LCD_INFO_SCREEN_STYLE), lcd_put_lchar(timepos - 1, 2, 0x20);) lcd_put_lchar(TERN(LCD_INFO_SCREEN_STYLE, 11, timepos), 2, 'E'); - //lcd_put_lchar(timepos, 2, LCD_STR_CLOCK[0]); lcd_put_u8str(buffer); } } @@ -919,7 +921,7 @@ void MarlinUI::draw_status_screen() { #if LCD_WIDTH < 20 #if HAS_PRINT_PROGRESS - pc = 0, pr = 2; + pc = 0; pr = 2; rotate_progress(); #endif @@ -1006,14 +1008,14 @@ void MarlinUI::draw_status_screen() { #if LCD_WIDTH >= 20 #if HAS_PRINT_PROGRESS - pc = timepos - 7, pr = 2; + pc = 6; pr = 2; rotate_progress(); #else char c; uint16_t per; #if HAS_FAN0 if (true - #if EXTRUDERS && ENABLED(ADAPTIVE_FAN_SLOWING) + #if BOTH(HAS_EXTRUDERS, ADAPTIVE_FAN_SLOWING) && (blink || thermalManager.fan_speed_scaler[0] < 128) #endif ) { @@ -1087,7 +1089,7 @@ void MarlinUI::draw_status_screen() { _draw_bed_status(blink); #elif HAS_PRINT_PROGRESS #define DREW_PRINT_PROGRESS 1 - pc = 0, pr = 2; + pc = 0; pr = 2; rotate_progress(); #endif @@ -1095,7 +1097,7 @@ void MarlinUI::draw_status_screen() { // All progress strings // #if HAS_PRINT_PROGRESS && !DREW_PRINT_PROGRESS - pc = LCD_WIDTH - 9, pr = 2; + pc = LCD_WIDTH - 9; pr = 2; rotate_progress(); #endif #endif // LCD_INFO_SCREEN_STYLE 1 diff --git a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp index 1418edf5d17a..e4f9e4eafc08 100644 --- a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp @@ -596,23 +596,58 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const #endif // HAS_CUTTER -#if HAS_PRINT_PROGRESS - - FORCE_INLINE void _draw_print_progress() { - if (!PanelDetected) return; - const uint8_t progress = ui._get_progress(); - #if ENABLED(SDSUPPORT) - lcd_put_u8str(F("SD")); - #elif ENABLED(SET_PROGRESS_PERCENT) - lcd_put_u8str(F("P:")); - #endif - if (progress) - lcd.print(ui8tostr3rj(progress)); - else - lcd_put_u8str(F("---")); - lcd.write('%'); - } +#if HAS_PRINT_PROGRESS // UNTESTED!!! + #define TPOFFSET (LCD_WIDTH - 1) + static uint8_t timepos = TPOFFSET - 6; + + #if ENABLED(SHOW_PROGRESS_PERCENT) + void MarlinUI::drawPercent() { + const uint8_t progress = ui.get_progress_percent(); + if (progress) { + lcd_moveto(0, 2); + lcd_put_u8str(F(TERN(IS_SD_PRINTING, "SD", "P:"))); + lcd.print(TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(ui.get_progress_permyriad()), ui8tostr3rj(progress))); + lcd.write('%'); + } + } + #endif + #if ENABLED(SHOW_REMAINING_TIME) + void MarlinUI::drawRemain() { + if (printJobOngoing()) { + const duration_t remaint = ui.get_remaining_time(); + char buffer[10]; + timepos = TPOFFSET - remaint.toDigital(buffer); + lcd_moveto(timepos, 1); + lcd.write('R'); + lcd.print(buffer); + } + } + #endif + #if ENABLED(SHOW_INTERACTION_TIME) + void MarlinUI::drawInter() { + const duration_t interactt = ui.interaction_time; + if (printingIsActive() && interactt.value) { + char buffer[10]; + timepos = TPOFFSET - interactt.toDigital(buffer); + lcd_moveto(timepos, 1); + lcd.write('C'); + lcd.print(buffer); + } + } + #endif + #if ENABLED(SHOW_ELAPSED_TIME) + void MarlinUI::drawElapsed() { + if (printJobOngoing()) { + const duration_t elapsedt = print_job_timer.duration(); + char buffer[10]; + timepos = TPOFFSET - elapsedt.toDigital(buffer); + lcd_moveto(timepos, 1); + lcd.write('E'); + lcd.print(buffer); + } + } + #endif #endif // HAS_PRINT_PROGRESS #if ENABLED(LCD_PROGRESS_BAR) @@ -796,23 +831,12 @@ void MarlinUI::draw_status_screen() { #endif // - // Line 2 - feedrate, , time + // Line 2 - feedrate, progress %, progress time // lcd_moveto(0, 1); lcd_put_u8str(F("FR")); lcd.print(i16tostr3rj(feedrate_percentage)); lcd.write('%'); - - #if BOTH(SDSUPPORT, HAS_PRINT_PROGRESS) - lcd_moveto(LCD_WIDTH / 2 - 3, 1); - _draw_print_progress(); - #endif - - char buffer[10]; - duration_t elapsed = print_job_timer.duration(); - uint8_t len = elapsed.toDigital(buffer); - - lcd_moveto((LCD_WIDTH - 1) - len, 1); - lcd.write(LCD_STR_CLOCK[0]); lcd.print(buffer); + ui.rotate_progress(); // UNTESTED!!! // // Line 3 - progressbar diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index 4283ab59cbde..d0910c44ba5d 100644 --- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -445,50 +445,44 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const // Prepare strings for progress display #if HAS_PRINT_PROGRESS - #define _PRGR_INFO_X(len) (LCD_PIXEL_WIDTH - (len) * (MENU_FONT_WIDTH)) - #define PCENTERED 1 // center percent value over progress bar, else align to the right - static uint8_t lastProgress = 0xFF; - static u8g_uint_t progress_bar_solid_width = 0; + static MarlinUI::progress_t progress = 0; + static char bufferc[13]; + + static void prepare_time_string(const duration_t &time, char prefix) { + char str[9]; + memset(&bufferc[2], 0x20, 5); // partialy fill with spaces to avoid artifacts and terminator + bufferc[0] = prefix; + bufferc[1] = ':'; + int str_length = time.toDigital(str, time.value >= 60*60*24L); + strcpy(&bufferc[sizeof(bufferc) - str_length - 1], str); + } + #if ENABLED(SHOW_PROGRESS_PERCENT) - static char progress_string[5]; - static u8g_uint_t progress_x_pos; void MarlinUI::drawPercent() { - if (progress_string[0]) { - lcd_put_u8str(progress_x_pos, EXTRAS_BASELINE, progress_string); - lcd_put_u8str(F("%")); + if (progress != 0) { + #define PCENTERED 1 // center percent value over progress bar, else align to the right + #define PPOS TERN(PCENTERED, 4, 0) + #define PLEN TERN(PRINT_PROGRESS_SHOW_DECIMALS, 4, 3) + memset(&bufferc, 0x20, 12); + memcpy(&bufferc[PPOS], TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(progress), ui8tostr3rj(progress / (PROGRESS_SCALE))), PLEN); + bufferc[PPOS+PLEN] = '%'; } } #endif #if ENABLED(SHOW_REMAINING_TIME) - static char remaining_string[10]; - static u8g_uint_t remaining_x_pos = 0; void MarlinUI::drawRemain() { - if (printJobOngoing()){ - lcd_put_u8str(PROGRESS_BAR_X, EXTRAS_BASELINE, F("R:")); - lcd_put_u8str(remaining_x_pos, EXTRAS_BASELINE, remaining_string); - } - } + if (printJobOngoing() && get_remaining_time() != 0) + prepare_time_string(get_remaining_time(), 'R'); } #endif #if ENABLED(SHOW_INTERACTION_TIME) - static char interaction_string[10]; - static u8g_uint_t interaction_x_pos = 0; void MarlinUI::drawInter() { - if (printingIsActive() && interaction_string[0]) { - lcd_put_u8str(PROGRESS_BAR_X, EXTRAS_BASELINE, F("C:")); - lcd_put_u8str(interaction_x_pos, EXTRAS_BASELINE, interaction_string); - } - } + if (printingIsActive() && interaction_time) + prepare_time_string(interaction_time, 'C'); } #endif #if ENABLED(SHOW_ELAPSED_TIME) - static char elapsed_string[10]; - static u8g_uint_t elapsed_x_pos = 0; - static uint8_t lastElapsed; void MarlinUI::drawElapsed() { - if (printJobOngoing()) { - lcd_put_u8str(PROGRESS_BAR_X, EXTRAS_BASELINE, F("E:")); - lcd_put_u8str(elapsed_x_pos, EXTRAS_BASELINE, elapsed_string); - } - } + if (printJobOngoing()) + prepare_time_string(print_job_timer.duration(), 'E'); } #endif #endif // HAS_PRINT_PROGRESS @@ -514,6 +508,8 @@ void MarlinUI::draw_status_screen() { const bool show_e_total = TERN0(LCD_SHOW_E_TOTAL, printingIsActive()); + static u8g_uint_t progress_bar_solid_width = 0; + // At the first page, generate new display values if (first_page) { #if ANIM_HBCC @@ -551,59 +547,16 @@ void MarlinUI::draw_status_screen() { strcpy(mstring, i16tostr3rj(planner.volumetric_percent(parser.volumetric_enabled))); #endif - // Progress / elapsed / estimation updates and string formatting to avoid float math on each LCD draw + // Progress update to avoid float math on each LCD draw #if HAS_PRINT_PROGRESS - const progress_t progress = TERN(HAS_PRINT_PROGRESS_PERMYRIAD, get_progress_permyriad, get_progress_percent)(); - duration_t elapsedt = print_job_timer.duration(); - const uint8_t p = progress & 0xFF, ev = elapsedt.value & 0xFF; + progress = TERN(HAS_PRINT_PROGRESS_PERMYRIAD, get_progress_permyriad, get_progress_percent)(); + + static uint8_t lastProgress = 0xFF; + const uint8_t p = progress & 0xFF; if (p != lastProgress) { lastProgress = p; - progress_bar_solid_width = u8g_uint_t((PROGRESS_BAR_WIDTH - 2) * (progress / (PROGRESS_SCALE)) * 0.01f); - - #if ENABLED(SHOW_PROGRESS_PERCENT) - if (progress == 0) - progress_string[0] = '\0'; - else - strcpy(progress_string, TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(progress), ui8tostr3rj(progress / (PROGRESS_SCALE)))); - progress_x_pos = TERN(PCENTERED, 77, _PRGR_INFO_X(strlen(progress_string) + 1)); - #endif } - - #if ENABLED(SHOW_INTERACTION_TIME) - if (!(interaction_time)) { - interaction_string[0] = '\0'; - interaction_x_pos = _PRGR_INFO_X(0); - } - else { - const duration_t interactt = ui.interaction_time; - interactt.toDigital(interaction_string, interactt.value >= 60*60*24L); - interaction_x_pos = _PRGR_INFO_X(strlen(interaction_string)); - } - #endif - - #if ENABLED(SHOW_ELAPSED_TIME) - if (ev != lastElapsed) { - lastElapsed = ev; - const uint8_t len = elapsedt.toDigital(elapsed_string, elapsedt.value >= 60*60*24L); - elapsed_x_pos = _PRGR_INFO_X(len); - } - #endif - - #if ENABLED(SHOW_REMAINING_TIME) - if (!(ev & 0x3)) { - uint32_t timeval = get_remaining_time(); - if (!timeval) { - remaining_string[0] = '\0'; - remaining_x_pos = _PRGR_INFO_X(0); - } - else { - const duration_t remaint = timeval; - const uint8_t len = remaint.toDigital(remaining_string, remaint.value >= 60*60*24L); - remaining_x_pos = _PRGR_INFO_X(len); - } - } - #endif #endif } @@ -796,8 +749,10 @@ void MarlinUI::draw_status_screen() { u8g.drawBox(PROGRESS_BAR_X + 1, PROGRESS_BAR_Y + 1, progress_bar_solid_width, 2); // Progress strings - if (PAGE_CONTAINS(EXTRAS_BASELINE - INFO_FONT_ASCENT, EXTRAS_BASELINE - 1)) + if (PAGE_CONTAINS(EXTRAS_BASELINE - INFO_FONT_ASCENT, EXTRAS_BASELINE - 1)){ ui.rotate_progress(); + lcd_put_u8str(PROGRESS_BAR_X, EXTRAS_BASELINE, bufferc); + } #endif // diff --git a/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp b/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp index 73de275f9c62..73f4386011e8 100644 --- a/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp @@ -366,6 +366,8 @@ void MarlinUI::draw_status_screen() { ); } + // TODO! + // // Elapsed time // diff --git a/Marlin/src/libs/numtostr.cpp b/Marlin/src/libs/numtostr.cpp index 594255aea81e..cd50bffffe1f 100644 --- a/Marlin/src/libs/numtostr.cpp +++ b/Marlin/src/libs/numtostr.cpp @@ -84,12 +84,6 @@ const char* i8tostr3rj(const int8_t x) { conv[6] = DIGIMOD(xx, 10); return &conv[3]; } - else if (xx % 100 == 0) { - conv[4] = ' '; - conv[5] = RJDIGIT(xx, 1000); - conv[6] = DIGIMOD(xx, 100); - return &conv[4]; - } else { conv[3] = DIGIMOD(xx, 100); conv[4] = '.'; From 86a3362bf6830fea77c15aa1b139847569372671 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Sun, 11 Dec 2022 04:00:51 +1300 Subject: [PATCH 187/243] =?UTF-8?q?=F0=9F=93=8C=20Pins=20updates=20for=20L?= =?UTF-8?q?onger=20LK5,=20etc.=20(#25012)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/src/pins/pins_postprocess.h | 2 + Marlin/src/pins/ramps/pins_3DRAG.h | 27 ++---- Marlin/src/pins/ramps/pins_K8600.h | 31 ++---- Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h | 94 +++++++++++++------ Marlin/src/pins/ramps/pins_ORTUR_4.h | 16 +--- Marlin/src/pins/ramps/pins_RAMPS.h | 36 +++++-- Marlin/src/pins/ramps/pins_ZRIB_V20.h | 28 ++---- Marlin/src/pins/sanguino/pins_AZTEEG_X1.h | 2 + Marlin/src/pins/sanguino/pins_MELZI.h | 4 +- .../src/pins/sanguino/pins_MELZI_CREALITY.h | 23 ++--- Marlin/src/pins/sanguino/pins_MELZI_MALYAN.h | 24 ++--- Marlin/src/pins/sanguino/pins_MELZI_TRONXY.h | 41 ++++---- .../src/pins/sanguino/pins_SANGUINOLOLU_11.h | 36 +++---- .../src/pins/sanguino/pins_SANGUINOLOLU_12.h | 12 +++ Marlin/src/pins/sanguino/pins_STB_11.h | 4 + 15 files changed, 194 insertions(+), 186 deletions(-) diff --git a/Marlin/src/pins/pins_postprocess.h b/Marlin/src/pins/pins_postprocess.h index 1e5265b5966e..5b5cbcd2147a 100644 --- a/Marlin/src/pins/pins_postprocess.h +++ b/Marlin/src/pins/pins_postprocess.h @@ -715,6 +715,8 @@ #undef FIL_RUNOUT2_PIN #endif +#undef LCD_PINS_DEFINED + #ifndef LCD_PINS_D4 #define LCD_PINS_D4 -1 #endif diff --git a/Marlin/src/pins/ramps/pins_3DRAG.h b/Marlin/src/pins/ramps/pins_3DRAG.h index 6f5b775af9ce..1e9d53a6cb58 100644 --- a/Marlin/src/pins/ramps/pins_3DRAG.h +++ b/Marlin/src/pins/ramps/pins_3DRAG.h @@ -66,6 +66,8 @@ #define MOSFET_C_PIN 9 #define MOSFET_D_PIN 12 +#define HEATER_2_PIN 6 + // // Misc. Functions // @@ -122,16 +124,6 @@ #endif #endif -#include "pins_RAMPS.h" - -// -// Heaters / Fans -// -#define HEATER_2_PIN 6 - -#undef SD_DETECT_PIN -#define SD_DETECT_PIN 53 - // // LCD / Controller // @@ -139,12 +131,6 @@ #undef BEEPER_PIN // TODO: Remap EXP1/2 based on adapter - #undef LCD_PINS_RS - #undef LCD_PINS_ENABLE - #undef LCD_PINS_D4 - #undef LCD_PINS_D5 - #undef LCD_PINS_D6 - #undef LCD_PINS_D7 #define LCD_PINS_RS 27 #define LCD_PINS_ENABLE 29 #define LCD_PINS_D4 37 @@ -153,13 +139,12 @@ #define LCD_PINS_D7 31 // Buttons - #undef BTN_EN1 - #undef BTN_EN2 - #undef BTN_ENC #define BTN_EN1 16 #define BTN_EN2 17 #define BTN_ENC 23 + #define LCD_PINS_DEFINED + #else #define BEEPER_PIN 33 @@ -171,3 +156,7 @@ #define BOARD_ST7920_DELAY_2 188 #define BOARD_ST7920_DELAY_3 0 #endif + +#define SD_DETECT_PIN 53 + +#include "pins_RAMPS.h" diff --git a/Marlin/src/pins/ramps/pins_K8600.h b/Marlin/src/pins/ramps/pins_K8600.h index a9613e8eb27f..e4468a609882 100644 --- a/Marlin/src/pins/ramps/pins_K8600.h +++ b/Marlin/src/pins/ramps/pins_K8600.h @@ -37,8 +37,7 @@ // #define X_MIN_PIN 3 #define Y_MAX_PIN 14 -#define Z_MAX_PIN 18 -#define Z_MIN_PIN -1 +#define Z_STOP_PIN 18 // // Steppers @@ -48,6 +47,7 @@ // // Heaters / Fans // +#define HEATER_BED_PIN -1 #define FAN_PIN 8 // @@ -56,28 +56,11 @@ #define SDSS 25 #define CASE_LIGHT_PIN 7 -// -// Other RAMPS pins -// -#include "pins_RAMPS.h" - -// -// Heaters / Fans -// -#undef HEATER_BED_PIN - // // LCD / Controller // #if HAS_WIRED_LCD && IS_NEWPANEL - #undef BEEPER_PIN - #undef LCD_PINS_RS - #undef LCD_PINS_ENABLE - #undef LCD_PINS_D4 - #undef LCD_PINS_D5 - #undef LCD_PINS_D6 - #undef LCD_PINS_D7 #define LCD_PINS_RS 27 #define LCD_PINS_ENABLE 29 #define LCD_PINS_D4 37 @@ -86,15 +69,19 @@ #define LCD_PINS_D7 31 // Buttons - #undef BTN_EN1 - #undef BTN_EN2 - #undef BTN_ENC #define BTN_EN1 17 #define BTN_EN2 16 #define BTN_ENC 23 + #define LCD_PINS_DEFINED + #else #define BEEPER_PIN 33 #endif + +// +// Other RAMPS pins +// +#include "pins_RAMPS.h" diff --git a/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h b/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h index af1d33c83c60..51f9cd80381c 100644 --- a/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h +++ b/Marlin/src/pins/ramps/pins_LONGER3D_LKx_PRO.h @@ -33,56 +33,68 @@ #endif #if SERIAL_PORT == 1 || SERIAL_PORT_2 == 1 || SERIAL_PORT_3 == 1 - #warning "Serial 1 is originally reserved to DGUS LCD." + #warning "Serial 1 is originally reserved for DGUS LCD." #endif #if SERIAL_PORT == 2 || SERIAL_PORT_2 == 2 || SERIAL_PORT_3 == 2 || LCD_SERIAL_PORT == 2 #warning "Serial 2 has no connector. Hardware changes may be required to use it." #endif #if SERIAL_PORT == 3 || SERIAL_PORT_2 == 3 || SERIAL_PORT_3 == 3 || LCD_SERIAL_PORT == 3 - #define CHANGE_Y_LIMIT_PINS - #warning "Serial 3 is originally reserved to Y limit switches. Hardware changes are required to use it." + #warning "Serial 3 is originally reserved for Y limit switches. Hardware changes are required to use it." + #define Y_STOP_PIN 37 + #if MB(LONGER3D_LKx_PRO) + #define Z_STOP_PIN 35 + #endif #endif -// Custom flags and defines for the build -//#define BOARD_CUSTOM_BUILD_FLAGS -D__FOO__ - #define BOARD_INFO_NAME "LGT KIT V1.0" +#if ENABLED(LONGER_LK5) + #define DEFAULT_MACHINE_NAME "LONGER LK5" +#else + #define DEFAULT_MACHINE_NAME "LONGER 3D Printer" +#endif // // Servos // -#if !MB(LONGER3D_LK1_PRO) +#if MB(LONGER3D_LKx_PRO) #define SERVO0_PIN 7 #endif -#define SERVO1_PIN -1 -#define SERVO2_PIN -1 -#define SERVO3_PIN -1 +#define SERVO1_PIN -1 +#define SERVO2_PIN -1 +#define SERVO3_PIN -1 // // Limit Switches // -#define X_STOP_PIN 3 - -#ifdef CHANGE_Y_LIMIT_PINS - #define Y_STOP_PIN 37 +#if ENABLED(LONGER_LK5) + #define X_MIN_PIN 3 + #define X_MAX_PIN 2 #else - #define Y_MIN_PIN 14 - #define Y_MAX_PIN 15 + #define X_STOP_PIN 3 #endif -#if !MB(LONGER3D_LK1_PRO) - #ifdef CHANGE_Y_LIMIT_PINS - #define Z_STOP_PIN 35 +#if !ANY_PIN(Y_MIN, Y_MAX, Y_STOP) + #if ENABLED(LONGER_LK5) + #define Y_STOP_PIN 14 #else + #define Y_MIN_PIN 14 + #define Y_MAX_PIN 15 + #endif +#endif + +#if !ANY_PIN(Z_MIN, Z_MAX, Z_STOP) + #if MB(LONGER3D_LKx_PRO) #define Z_MIN_PIN 35 - #define Z_MAX_PIN 37 + #else + #define Z_MIN_PIN 11 #endif -#else - #define Z_MIN_PIN 11 #define Z_MAX_PIN 37 #endif -#undef CHANGE_Y_LIMIT_PINS +// +// Z Probe (when not Z_MIN_PIN) +// +#define Z_MIN_PROBE_PIN -1 // // Steppers - No E1 pins @@ -92,11 +104,6 @@ #define E1_ENABLE_PIN -1 #define E1_CS_PIN -1 -// -// Z Probe (when not Z_MIN_PIN) -// -#define Z_MIN_PROBE_PIN -1 - // // Temperature Sensors // @@ -115,7 +122,36 @@ #define SD_DETECT_PIN 49 #define FIL_RUNOUT_PIN 2 +// ------------------ ---------------- --------------- ------------- +// Aux-1 | D19 D18 GND 5V | J21 | D4 D5 D6 GND | J17 | D11 GND 24V | J18 | D7 GND 5V | +// ------------------ ---------------- --------------- ------------- + +#if BOTH(CR10_STOCKDISPLAY, LONGER_LK5) + /** CR-10 Stock Display + * ------ + * GND | 9 10 | 5V + * LCD_PINS_RS D5 | 7 8 | D4 LCD_PINS_ENABLE + * BTN_EN2 D19 | 5 6 D6 LCD_PINS_D4 + * BTN_EN1 D18 | 3 4 | GND + * BEEPER_PIN D11 | 1 2 | D15 BTN_ENC + * ------ + * Connected via provided custom cable to: + * Aux-1, J21, J17 and Y-Max. + */ + #define LCD_PINS_RS 5 + #define LCD_PINS_ENABLE 4 + #define LCD_PINS_D4 6 + #define BTN_EN1 18 + #define BTN_EN2 19 + #define BTN_ENC 15 + #define BEEPER_PIN 11 + + #define SDCARD_CONNECTION ONBOARD + + #define LCD_PINS_DEFINED +#endif + // // Other RAMPS 1.3 pins // -#include "pins_RAMPS_13.h" // ... RAMPS +#include "pins_RAMPS_13.h" // ... pins_RAMPS.h diff --git a/Marlin/src/pins/ramps/pins_ORTUR_4.h b/Marlin/src/pins/ramps/pins_ORTUR_4.h index bc86c1a8c66a..e47bae191520 100644 --- a/Marlin/src/pins/ramps/pins_ORTUR_4.h +++ b/Marlin/src/pins/ramps/pins_ORTUR_4.h @@ -75,31 +75,25 @@ #define E0_SERIAL_RX_PIN 65 #endif -#include "pins_RAMPS.h" - // // LCD / Controller // #if IS_RRD_FG_SC - #undef BEEPER_PIN #define BEEPER_PIN 35 - #undef LCD_PINS_RS - #undef LCD_PINS_ENABLE - #undef LCD_PINS_D4 #define LCD_PINS_RS 27 #define LCD_PINS_ENABLE 23 #define LCD_PINS_D4 37 - #undef LCD_SDSS - #undef SD_DETECT_PIN #define LCD_SDSS 53 #define SD_DETECT_PIN 49 - #undef BTN_EN1 - #undef BTN_EN2 - #undef BTN_ENC #define BTN_EN1 29 #define BTN_EN2 25 #define BTN_ENC 16 + + #define LCD_PINS_DEFINED + #endif + +#include "pins_RAMPS.h" diff --git a/Marlin/src/pins/ramps/pins_RAMPS.h b/Marlin/src/pins/ramps/pins_RAMPS.h index 7b0ae64cfcf0..4e4ca6058389 100644 --- a/Marlin/src/pins/ramps/pins_RAMPS.h +++ b/Marlin/src/pins/ramps/pins_RAMPS.h @@ -585,7 +585,7 @@ // LCDs and Controllers // ////////////////////////// -#if HAS_WIRED_LCD +#if HAS_WIRED_LCD && DISABLED(LCD_PINS_DEFINED) //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270 @@ -715,7 +715,9 @@ #define BTN_EN1 AUX2_05_PIN #define BTN_EN2 AUX2_03_PIN #define BTN_ENC AUX2_04_PIN - #define SD_DETECT_PIN AUX2_08_PIN + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN AUX2_08_PIN + #endif #elif ENABLED(LCD_I2C_PANELOLU2) @@ -732,7 +734,9 @@ #define BTN_ENC -1 #define LCD_SDSS SDSS - #define SD_DETECT_PIN EXP2_07_PIN + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #endif #elif EITHER(VIKI2, miniVIKI) @@ -748,7 +752,9 @@ #define BTN_EN2 7 #define BTN_ENC AUX4_08_PIN - #define SD_DETECT_PIN -1 // Pin 49 for display SD interface, 72 for easy adapter board + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN -1 // Pin 49 for display SD interface, 72 for easy adapter board + #endif #define KILL_PIN EXP2_03_PIN #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) @@ -764,7 +770,9 @@ #define BTN_ENC EXP2_03_PIN #define LCD_SDSS SDSS - #define SD_DETECT_PIN EXP2_07_PIN + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #endif #define KILL_PIN EXP2_08_PIN #elif EITHER(MKS_MINI_12864, FYSETC_MINI_12864) @@ -833,7 +841,9 @@ #define BTN_EN2 AUX2_04_PIN #define BTN_ENC AUX2_03_PIN - #define SD_DETECT_PIN AUX3_02_PIN + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN AUX3_02_PIN + #endif #define KILL_PIN AUX2_05_PIN #elif ENABLED(ZONESTAR_LCD) @@ -848,7 +858,9 @@ #define BEEPER_PIN EXP1_01_PIN - #define SD_DETECT_PIN EXP2_07_PIN + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #endif #define KILL_PIN EXP2_08_PIN #define BTN_EN1 EXP2_05_PIN @@ -857,7 +869,9 @@ #elif IS_TFTGLCD_PANEL - #define SD_DETECT_PIN EXP2_07_PIN + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #endif #else @@ -876,7 +890,7 @@ #endif #endif // IS_NEWPANEL -#endif // HAS_WIRED_LCD +#endif // HAS_WIRED_LCD && !LCD_PINS_DEFINED #if IS_RRW_KEYPAD && !HAS_ADC_BUTTONS #define SHIFT_OUT_PIN AUX2_06_PIN @@ -933,7 +947,9 @@ #define BEEPER_PIN EXP1_01_PIN - #define SD_DETECT_PIN EXP2_07_PIN + #ifndef SD_DETECT_PIN + #define SD_DETECT_PIN EXP2_07_PIN + #endif #define CLCD_MOD_RESET EXP2_05_PIN #define CLCD_SPI_CS EXP2_03_PIN diff --git a/Marlin/src/pins/ramps/pins_ZRIB_V20.h b/Marlin/src/pins/ramps/pins_ZRIB_V20.h index 3078b9f77bbe..3e236e36ba99 100644 --- a/Marlin/src/pins/ramps/pins_ZRIB_V20.h +++ b/Marlin/src/pins/ramps/pins_ZRIB_V20.h @@ -26,7 +26,9 @@ * V2 and V3 Boards only differ in USB controller, nothing affecting the pins. */ -#include "pins_MKS_GEN_13.h" // ... RAMPS +#ifndef FILWIDTH_PIN + #define FILWIDTH_PIN 11 // Analog Input +#endif // // Auto fans @@ -44,27 +46,7 @@ #define E3_AUTO_FAN_PIN 6 #endif -#ifndef FILWIDTH_PIN - #define FILWIDTH_PIN 11 // Analog Input -#endif - #if ENABLED(ZONESTAR_LCD) - #undef LCD_PINS_RS - #undef LCD_PINS_ENABLE - #undef LCD_PINS_D4 - #undef LCD_PINS_D5 - #undef LCD_PINS_D6 - #undef LCD_PINS_D7 - #undef ADC_KEYPAD_PIN - #undef BEEPER_PIN - - #undef SHIFT_OUT_PIN - #undef SHIFT_CLK_PIN - #undef SHIFT_LD_PIN - #undef BTN_EN1 - #undef BTN_EN2 - #undef BTN_ENC - #define LCD_PINS_RS 16 #define LCD_PINS_ENABLE 17 #define LCD_PINS_D4 23 @@ -73,4 +55,8 @@ #define LCD_PINS_D7 29 #define ADC_KEYPAD_PIN 10 // Analog Input #define BEEPER_PIN 37 + + #define LCD_PINS_DEFINED #endif + +#include "pins_MKS_GEN_13.h" // ... RAMPS diff --git a/Marlin/src/pins/sanguino/pins_AZTEEG_X1.h b/Marlin/src/pins/sanguino/pins_AZTEEG_X1.h index 3edb14ec413f..4c721da00038 100644 --- a/Marlin/src/pins/sanguino/pins_AZTEEG_X1.h +++ b/Marlin/src/pins/sanguino/pins_AZTEEG_X1.h @@ -27,4 +27,6 @@ #define BOARD_INFO_NAME "Azteeg X1" +#define FAN_PIN 4 + #include "pins_SANGUINOLOLU_12.h" // ... SANGUINOLOLU_11 diff --git a/Marlin/src/pins/sanguino/pins_MELZI.h b/Marlin/src/pins/sanguino/pins_MELZI.h index e24636c8e03c..cfd859f2b621 100644 --- a/Marlin/src/pins/sanguino/pins_MELZI.h +++ b/Marlin/src/pins/sanguino/pins_MELZI.h @@ -29,7 +29,9 @@ #define BOARD_INFO_NAME "Melzi" #endif -#define IS_MELZI 1 +#ifndef FAN_PIN + #define FAN_PIN 4 +#endif // Alter timing for graphical display #if IS_U8GLIB_ST7920 diff --git a/Marlin/src/pins/sanguino/pins_MELZI_CREALITY.h b/Marlin/src/pins/sanguino/pins_MELZI_CREALITY.h index 83aa5317f939..76478dd1a07e 100644 --- a/Marlin/src/pins/sanguino/pins_MELZI_CREALITY.h +++ b/Marlin/src/pins/sanguino/pins_MELZI_CREALITY.h @@ -42,24 +42,19 @@ #define BOARD_ST7920_DELAY_3 125 #endif -#include "pins_MELZI.h" // ... SANGUINOLOLU_12 ... SANGUINOLOLU_11 - // // For the stock CR-10 enable CR10_STOCKDISPLAY in Configuration.h // -#undef LCD_SDSS -#undef LED_PIN -#undef LCD_PINS_RS -#undef LCD_PINS_ENABLE -#undef LCD_PINS_D4 -#undef LCD_PINS_D5 -#undef LCD_PINS_D6 -#undef LCD_PINS_D7 +#if ENABLED(CR10_STOCKDISPLAY) + #define LCD_SDSS 31 // Smart Controller SD card reader (rather than the Melzi) + #define LCD_PINS_RS 28 // ST9720 CS + #define LCD_PINS_ENABLE 17 // ST9720 DAT + #define LCD_PINS_D4 30 // ST9720 CLK -#define LCD_SDSS 31 // Smart Controller SD card reader (rather than the Melzi) -#define LCD_PINS_RS 28 // ST9720 CS -#define LCD_PINS_ENABLE 17 // ST9720 DAT -#define LCD_PINS_D4 30 // ST9720 CLK + #define LCD_PINS_DEFINED +#endif + +#include "pins_MELZI.h" // ... SANGUINOLOLU_12 ... SANGUINOLOLU_11 #if ENABLED(BLTOUCH) #ifndef SERVO0_PIN diff --git a/Marlin/src/pins/sanguino/pins_MELZI_MALYAN.h b/Marlin/src/pins/sanguino/pins_MELZI_MALYAN.h index a0421dcf5cc6..d6f36cc6f541 100644 --- a/Marlin/src/pins/sanguino/pins_MELZI_MALYAN.h +++ b/Marlin/src/pins/sanguino/pins_MELZI_MALYAN.h @@ -27,19 +27,15 @@ #define BOARD_INFO_NAME "Melzi (Malyan)" -#include "pins_MELZI.h" // ... SANGUINOLOLU_12 ... SANGUINOLOLU_11 +#if ENABLED(CR10_STOCKDISPLAY) + #define LCD_PINS_RS 17 // ST9720 CS + #define LCD_PINS_ENABLE 16 // ST9720 DAT + #define LCD_PINS_D4 11 // ST9720 CLK + #define BTN_EN1 30 + #define BTN_EN2 29 + #define BTN_ENC 28 -#undef LCD_SDSS -#undef LCD_PINS_RS -#undef LCD_PINS_ENABLE -#undef LCD_PINS_D4 -#undef BTN_EN1 -#undef BTN_EN2 -#undef BTN_ENC + #define LCD_PINS_DEFINED +#endif -#define LCD_PINS_RS 17 // ST9720 CS -#define LCD_PINS_ENABLE 16 // ST9720 DAT -#define LCD_PINS_D4 11 // ST9720 CLK -#define BTN_EN1 30 -#define BTN_EN2 29 -#define BTN_ENC 28 +#include "pins_MELZI.h" // ... SANGUINOLOLU_12 ... SANGUINOLOLU_11 diff --git a/Marlin/src/pins/sanguino/pins_MELZI_TRONXY.h b/Marlin/src/pins/sanguino/pins_MELZI_TRONXY.h index 3f7b36765f34..19649a4ea526 100644 --- a/Marlin/src/pins/sanguino/pins_MELZI_TRONXY.h +++ b/Marlin/src/pins/sanguino/pins_MELZI_TRONXY.h @@ -27,6 +27,24 @@ #define BOARD_INFO_NAME "Melzi (Tronxy)" +#define Z_ENABLE_PIN 14 + +#define LCD_SDSS -1 + +#if ENABLED(CR10_STOCKDISPLAY) + #define LCD_PINS_RS 30 + #define LCD_PINS_ENABLE 28 + #define LCD_PINS_D4 16 + #define LCD_PINS_D5 17 + #define LCD_PINS_D6 27 + #define LCD_PINS_D7 29 + #define BTN_EN1 10 + #define BTN_EN2 11 + #define BTN_ENC 26 + + #define LCD_PINS_DEFINED +#endif + // Alter timing for graphical display #if IS_U8GLIB_ST7920 #define BOARD_ST7920_DELAY_1 0 @@ -35,26 +53,3 @@ #endif #include "pins_MELZI.h" // ... SANGUINOLOLU_12 ... SANGUINOLOLU_11 - -#undef Z_ENABLE_PIN -#undef LCD_PINS_RS -#undef LCD_PINS_ENABLE -#undef LCD_PINS_D4 -#undef LCD_PINS_D5 -#undef LCD_PINS_D6 -#undef LCD_PINS_D7 -#undef BTN_EN1 -#undef BTN_EN2 -#undef BTN_ENC -#undef LCD_SDSS - -#define Z_ENABLE_PIN 14 -#define LCD_PINS_RS 30 -#define LCD_PINS_ENABLE 28 -#define LCD_PINS_D4 16 -#define LCD_PINS_D5 17 -#define LCD_PINS_D6 27 -#define LCD_PINS_D7 29 -#define BTN_EN1 10 -#define BTN_EN2 11 -#define BTN_ENC 26 diff --git a/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_11.h b/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_11.h index 5fe0d3842dd4..3b6297ba4d1c 100644 --- a/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_11.h +++ b/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_11.h @@ -90,30 +90,18 @@ // #define HEATER_0_PIN 13 // (extruder) -#if ENABLED(SANGUINOLOLU_V_1_2) - - #define HEATER_BED_PIN 12 // (bed) - #define X_ENABLE_PIN 14 - #define Y_ENABLE_PIN 14 - #define Z_ENABLE_PIN 26 - #define E0_ENABLE_PIN 14 - - #if !defined(FAN_PIN) && ENABLED(LCD_I2C_PANELOLU2) - #define FAN_PIN 4 // Uses Transistor1 (PWM) on Panelolu2's Sanguino Adapter Board to drive the fan - #endif - -#else +#ifndef FAN_PIN + #define FAN_PIN 4 // Works for Panelolu2 too +#endif +#if DISABLED(SANGUINOLOLU_V_1_2) #define HEATER_BED_PIN 14 // (bed) #define X_ENABLE_PIN 4 #define Y_ENABLE_PIN 4 - #define Z_ENABLE_PIN 4 + #ifndef Z_ENABLE_PIN + #define Z_ENABLE_PIN 4 + #endif #define E0_ENABLE_PIN 4 - -#endif - -#if !defined(FAN_PIN) && (MB(AZTEEG_X1, STB_11) || IS_MELZI) - #define FAN_PIN 4 // Works for Panelolu2 too #endif // @@ -151,7 +139,7 @@ // // LCD / Controller // -#if HAS_WIRED_LCD +#if HAS_WIRED_LCD && DISABLED(LCD_PINS_DEFINED) #define SD_DETECT_PIN -1 @@ -245,7 +233,9 @@ #if IS_MELZI #define BTN_ENC 29 - #define LCD_SDSS 30 // Panelolu2 SD card reader rather than the Melzi + #ifndef LCD_SDSS + #define LCD_SDSS 30 // Panelolu2 SD card reader rather than the Melzi + #endif #else #define BTN_ENC 30 #endif @@ -253,7 +243,9 @@ #else // !LCD_FOR_MELZI && !ZONESTAR_LCD && !LCD_I2C_PANELOLU2 #define BTN_ENC 16 - #define LCD_SDSS 28 // Smart Controller SD card reader rather than the Melzi + #ifndef LCD_SDSS + #define LCD_SDSS 28 // Smart Controller SD card reader rather than the Melzi + #endif #endif diff --git a/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_12.h b/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_12.h index c5c8b4f57e57..ec7621e28f3e 100644 --- a/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_12.h +++ b/Marlin/src/pins/sanguino/pins_SANGUINOLOLU_12.h @@ -38,5 +38,17 @@ #define BOARD_INFO_NAME "Sanguinololu 1.2" #endif +#define HEATER_BED_PIN 12 // (bed) +#define X_ENABLE_PIN 14 +#define Y_ENABLE_PIN 14 +#ifndef Z_ENABLE_PIN + #define Z_ENABLE_PIN 26 +#endif +#define E0_ENABLE_PIN 14 + +#if !defined(FAN_PIN) && ENABLED(LCD_I2C_PANELOLU2) + #define FAN_PIN 4 // Uses Transistor1 (PWM) on Panelolu2's Sanguino Adapter Board to drive the fan +#endif + #define SANGUINOLOLU_V_1_2 #include "pins_SANGUINOLOLU_11.h" diff --git a/Marlin/src/pins/sanguino/pins_STB_11.h b/Marlin/src/pins/sanguino/pins_STB_11.h index ea36211f3bc9..ad0919e99e69 100644 --- a/Marlin/src/pins/sanguino/pins_STB_11.h +++ b/Marlin/src/pins/sanguino/pins_STB_11.h @@ -27,4 +27,8 @@ #define BOARD_INFO_NAME "STB V1.1" +#ifndef FAN_PIN + #define FAN_PIN 4 // Works for Panelolu2 too +#endif + #include "pins_SANGUINOLOLU_12.h" // ... SANGUINOLOLU_11 From 79b88471f00e3a8a7e5ee8ed440c6e40059b4815 Mon Sep 17 00:00:00 2001 From: Vovodroid Date: Sat, 10 Dec 2022 17:03:54 +0200 Subject: [PATCH 188/243] =?UTF-8?q?=E2=9C=A8=20Two=20controller=20fans=20(?= =?UTF-8?q?#24995)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 1 + Marlin/src/feature/controllerfan.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index db8bf75b5aa2..75226fb88a34 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -538,6 +538,7 @@ //#define USE_CONTROLLER_FAN #if ENABLED(USE_CONTROLLER_FAN) //#define CONTROLLER_FAN_PIN -1 // Set a custom pin for the controller fan + //#define CONTROLLER_FAN2_PIN -1 // Set a custom pin for second controller fan //#define CONTROLLER_FAN_USE_Z_ONLY // With this option only the Z axis is considered //#define CONTROLLER_FAN_IGNORE_Z // Ignore Z stepper. Useful when stepper timeout is disabled. #define CONTROLLERFAN_SPEED_MIN 0 // (0-255) Minimum speed. (If set below this value the fan is turned off.) diff --git a/Marlin/src/feature/controllerfan.cpp b/Marlin/src/feature/controllerfan.cpp index 2f25832cdc2d..cc22c642bd2a 100644 --- a/Marlin/src/feature/controllerfan.cpp +++ b/Marlin/src/feature/controllerfan.cpp @@ -40,6 +40,9 @@ uint8_t ControllerFan::speed; void ControllerFan::setup() { SET_OUTPUT(CONTROLLER_FAN_PIN); + #ifdef CONTROLLER_FAN2_PIN + SET_OUTPUT(CONTROLLER_FAN2_PIN); + #endif init(); } @@ -95,6 +98,13 @@ void ControllerFan::update() { hal.set_pwm_duty(pin_t(CONTROLLER_FAN_PIN), speed); else WRITE(CONTROLLER_FAN_PIN, speed > 0); + + #ifdef CONTROLLER_FAN2_PIN + if (PWM_PIN(CONTROLLER_FAN2_PIN)) + hal.set_pwm_duty(pin_t(CONTROLLER_FAN2_PIN), speed); + else + WRITE(CONTROLLER_FAN2_PIN, speed > 0); + #endif #endif } } From eae339b8dcd43797cc285605826a23370e28165e Mon Sep 17 00:00:00 2001 From: tombrazier <68918209+tombrazier@users.noreply.github.com> Date: Sat, 10 Dec 2022 17:28:48 +0000 Subject: [PATCH 189/243] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Better=20IS=20buff?= =?UTF-8?q?er=20size=20calc=20(#25035)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 27 +++++++-------- Marlin/src/inc/SanityCheck.h | 17 +++++++--- Marlin/src/module/settings.cpp | 2 -- Marlin/src/module/stepper.h | 60 +++++++++++++++------------------- 4 files changed, 53 insertions(+), 53 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 75226fb88a34..18fe3d71429c 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1063,14 +1063,13 @@ * * Zero Vibration (ZV) Input Shaping for X and/or Y movements. * - * This option uses a lot of SRAM for the step buffer, which is related to the - * largest step rate possible for the shaped axes. If the build fails due to - * low SRAM the buffer size may be reduced by setting smaller values for - * DEFAULT_AXIS_STEPS_PER_UNIT and/or DEFAULT_MAX_FEEDRATE. Disabling - * ADAPTIVE_STEP_SMOOTHING and reducing the step rate for non-shaped axes may - * also reduce the buffer sizes. Runtime editing of max feedrate (M203) or - * resonant frequency (M593) may result in input shaping losing effectiveness - * during high speed movements to prevent buffer overruns. + * This option uses a lot of SRAM for the step buffer. The buffer size is + * calculated automatically from SHAPING_FREQ_[XY], DEFAULT_AXIS_STEPS_PER_UNIT, + * DEFAULT_MAX_FEEDRATE and ADAPTIVE_STEP_SMOOTHING. The default calculation can + * be overridden by setting SHAPING_MIN_FREQ and/or SHAPING_MAX_FEEDRATE. + * The higher the frequency and the lower the feedrate, the smaller the buffer. + * If the buffer is too small at runtime, input shaping will have reduced + * effectiveness during high speed movements. * * Tune with M593 D F: * @@ -1084,14 +1083,16 @@ //#define INPUT_SHAPING_Y #if EITHER(INPUT_SHAPING_X, INPUT_SHAPING_Y) #if ENABLED(INPUT_SHAPING_X) - #define SHAPING_FREQ_X 40 // (Hz) The default dominant resonant frequency on the X axis. - #define SHAPING_ZETA_X 0.15f // Damping ratio of the X axis (range: 0.0 = no damping to 1.0 = critical damping). + #define SHAPING_FREQ_X 40 // (Hz) The default dominant resonant frequency on the X axis. + #define SHAPING_ZETA_X 0.15f // Damping ratio of the X axis (range: 0.0 = no damping to 1.0 = critical damping). #endif #if ENABLED(INPUT_SHAPING_Y) - #define SHAPING_FREQ_Y 40 // (Hz) The default dominant resonant frequency on the Y axis. - #define SHAPING_ZETA_Y 0.15f // Damping ratio of the Y axis (range: 0.0 = no damping to 1.0 = critical damping). + #define SHAPING_FREQ_Y 40 // (Hz) The default dominant resonant frequency on the Y axis. + #define SHAPING_ZETA_Y 0.15f // Damping ratio of the Y axis (range: 0.0 = no damping to 1.0 = critical damping). #endif - //#define SHAPING_MENU // Add a menu to the LCD to set shaping parameters. + //#define SHAPING_MIN_FREQ 20 // By default the minimum of the shaping frequencies. Override to affect SRAM usage. + //#define SHAPING_MAX_STEPRATE 10000 // By default the maximum total step rate of the shaped axes. Override to affect SRAM usage. + //#define SHAPING_MENU // Add a menu to the LCD to set shaping parameters. #endif #define AXIS_RELATIVE_MODES { false, false, false, false } diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 42f1409739ef..802506f1633a 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -4272,17 +4272,24 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive."); // Check requirements for Input Shaping #if HAS_SHAPING && defined(__AVR__) + #ifdef SHAPING_MIN_FREQ + static_assert((SHAPING_MIN_FREQ) > 0, "SHAPING_MIN_FREQ must be > 0."); + #else + TERN_(INPUT_SHAPING_X, static_assert((SHAPING_FREQ_X) > 0, "SHAPING_FREQ_X must be > 0 or SHAPING_MIN_FREQ must be set.")); + TERN_(INPUT_SHAPING_Y, static_assert((SHAPING_FREQ_Y) > 0, "SHAPING_FREQ_Y must be > 0 or SHAPING_MIN_FREQ must be set.")); + #endif #if ENABLED(INPUT_SHAPING_X) #if F_CPU > 16000000 - static_assert((SHAPING_FREQ_X) * 2 * 0x10000 >= (STEPPER_TIMER_RATE), "SHAPING_FREQ_X is below the minimum (20) for AVR 20MHz."); + static_assert((SHAPING_FREQ_X) == 0 || (SHAPING_FREQ_X) * 2 * 0x10000 >= (STEPPER_TIMER_RATE), "SHAPING_FREQ_X is below the minimum (20) for AVR 20MHz."); #else - static_assert((SHAPING_FREQ_X) * 2 * 0x10000 >= (STEPPER_TIMER_RATE), "SHAPING_FREQ_X is below the minimum (16) for AVR 16MHz."); + static_assert((SHAPING_FREQ_X) == 0 || (SHAPING_FREQ_X) * 2 * 0x10000 >= (STEPPER_TIMER_RATE), "SHAPING_FREQ_X is below the minimum (16) for AVR 16MHz."); #endif - #elif ENABLED(INPUT_SHAPING_Y) + #endif + #if ENABLED(INPUT_SHAPING_Y) #if F_CPU > 16000000 - static_assert((SHAPING_FREQ_Y) * 2 * 0x10000 >= (STEPPER_TIMER_RATE), "SHAPING_FREQ_Y is below the minimum (20) for AVR 20MHz."); + static_assert((SHAPING_FREQ_Y) == 0 || (SHAPING_FREQ_Y) * 2 * 0x10000 >= (STEPPER_TIMER_RATE), "SHAPING_FREQ_Y is below the minimum (20) for AVR 20MHz."); #else - static_assert((SHAPING_FREQ_Y) * 2 * 0x10000 >= (STEPPER_TIMER_RATE), "SHAPING_FREQ_Y is below the minimum (16) for AVR 16MHz."); + static_assert((SHAPING_FREQ_Y) == 0 || (SHAPING_FREQ_Y) * 2 * 0x10000 >= (STEPPER_TIMER_RATE), "SHAPING_FREQ_Y is below the minimum (16) for AVR 16MHz."); #endif #endif #endif diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 4ae4c19922d9..de38cf23770c 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -193,8 +193,6 @@ typedef struct { bool NUM_AXIS_LIST(X:1, Y:1, Z:1, I:1, J:1, K:1, U:1, V:1, // Defaults for reset / fill in on load static const uint32_t _DMA[] PROGMEM = DEFAULT_MAX_ACCELERATION; -static const float _DASU[] PROGMEM = DEFAULT_AXIS_STEPS_PER_UNIT; -static const feedRate_t _DMF[] PROGMEM = DEFAULT_MAX_FEEDRATE; /** * Current EEPROM Layout diff --git a/Marlin/src/module/stepper.h b/Marlin/src/module/stepper.h index 6d9814b4dfc3..e92d478dc6be 100644 --- a/Marlin/src/module/stepper.h +++ b/Marlin/src/module/stepper.h @@ -326,49 +326,43 @@ constexpr ena_mask_t enable_overlap[] = { #endif }; +constexpr float _DASU[] = DEFAULT_AXIS_STEPS_PER_UNIT; +constexpr feedRate_t _DMF[] = DEFAULT_MAX_FEEDRATE; + //static_assert(!any_enable_overlap(), "There is some overlap."); #if HAS_SHAPING - // These constexpr are used to calculate the shaping queue buffer sizes - constexpr xyze_float_t max_feedrate = DEFAULT_MAX_FEEDRATE; - constexpr xyze_float_t steps_per_unit = DEFAULT_AXIS_STEPS_PER_UNIT; - // MIN_STEP_ISR_FREQUENCY is known at compile time on AVRs and any reduction in SRAM is welcome - #ifdef __AVR__ - constexpr float max_isr_rate = _MAX( - LOGICAL_AXIS_LIST( - max_feedrate.e * steps_per_unit.e, - max_feedrate.x * steps_per_unit.x, - max_feedrate.y * steps_per_unit.y, - max_feedrate.z * steps_per_unit.z, - max_feedrate.i * steps_per_unit.i, - max_feedrate.j * steps_per_unit.j, - max_feedrate.k * steps_per_unit.k, - max_feedrate.u * steps_per_unit.u, - max_feedrate.v * steps_per_unit.v, - max_feedrate.w * steps_per_unit.w - ) - OPTARG(ADAPTIVE_STEP_SMOOTHING, MIN_STEP_ISR_FREQUENCY) - ); - constexpr float max_step_rate = _MIN(max_isr_rate, - TERN0(INPUT_SHAPING_X, max_feedrate.x * steps_per_unit.x) + - TERN0(INPUT_SHAPING_Y, max_feedrate.y * steps_per_unit.y) - ); + #ifdef SHAPING_MAX_STEPRATE + constexpr float max_step_rate = SHAPING_MAX_STEPRATE; #else - constexpr float max_step_rate = TERN0(INPUT_SHAPING_X, max_feedrate.x * steps_per_unit.x) + - TERN0(INPUT_SHAPING_Y, max_feedrate.y * steps_per_unit.y); + constexpr float max_shaped_rate = TERN0(INPUT_SHAPING_X, _DMF[X_AXIS] * _DASU[X_AXIS]) + + TERN0(INPUT_SHAPING_Y, _DMF[Y_AXIS] * _DASU[Y_AXIS]); + #if defined(__AVR__) || !defined(ADAPTIVE_STEP_SMOOTHING) + // MIN_STEP_ISR_FREQUENCY is known at compile time on AVRs and any reduction in SRAM is welcome + template constexpr float max_isr_rate() { + return _MAX(_DMF[INDEX - 1] * _DASU[INDEX - 1], max_isr_rate()); + } + template<> constexpr float max_isr_rate<0>() { + return TERN0(ADAPTIVE_STEP_SMOOTHING, MIN_STEP_ISR_FREQUENCY); + } + constexpr float max_step_rate = _MIN(max_isr_rate(), max_shaped_rate); + #else + constexpr float max_step_rate = max_shaped_rate; + #endif #endif - constexpr uint16_t shaping_echoes = max_step_rate / _MIN(0x7FFFFFFFL OPTARG(INPUT_SHAPING_X, SHAPING_FREQ_X) OPTARG(INPUT_SHAPING_Y, SHAPING_FREQ_Y)) / 2 + 3; + + #ifndef SHAPING_MIN_FREQ + #define SHAPING_MIN_FREQ _MIN(0x7FFFFFFFL OPTARG(INPUT_SHAPING_X, SHAPING_FREQ_X) OPTARG(INPUT_SHAPING_Y, SHAPING_FREQ_Y)) + #endif + constexpr uint16_t shaping_min_freq = SHAPING_MIN_FREQ, + shaping_echoes = max_step_rate / shaping_min_freq / 2 + 3; typedef IF::type shaping_time_t; enum shaping_echo_t { ECHO_NONE = 0, ECHO_FWD = 1, ECHO_BWD = 2 }; struct shaping_echo_axis_t { - #if ENABLED(INPUT_SHAPING_X) - shaping_echo_t x:2; - #endif - #if ENABLED(INPUT_SHAPING_Y) - shaping_echo_t y:2; - #endif + TERN_(INPUT_SHAPING_X, shaping_echo_t x:2); + TERN_(INPUT_SHAPING_Y, shaping_echo_t y:2); }; class ShapingQueue { From 408a53bcdd5b5c5781596c2ba9e435cfe4525c74 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Sun, 11 Dec 2022 06:44:09 +1300 Subject: [PATCH 190/243] =?UTF-8?q?=F0=9F=94=A8=20No=20env:mega1280=20for?= =?UTF-8?q?=20MIGHTYBOARD=5FREVE=20(#25080)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/pins/pins.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/pins/pins.h b/Marlin/src/pins/pins.h index ef73b3c8c001..9d54273afe0f 100644 --- a/Marlin/src/pins/pins.h +++ b/Marlin/src/pins/pins.h @@ -234,7 +234,7 @@ #elif MB(CNCONTROLS_15) #include "mega/pins_CNCONTROLS_15.h" // ATmega2560, ATmega1280 env:mega2560 env:mega1280 #elif MB(MIGHTYBOARD_REVE) - #include "mega/pins_MIGHTYBOARD_REVE.h" // ATmega2560, ATmega1280 env:mega2560ext env:mega1280 env:MightyBoard1280 env:MightyBoard2560 + #include "mega/pins_MIGHTYBOARD_REVE.h" // ATmega2560, ATmega1280 env:mega2560ext env:MightyBoard1280 env:MightyBoard2560 #elif MB(CHEAPTRONIC) #include "mega/pins_CHEAPTRONIC.h" // ATmega2560 env:mega2560 #elif MB(CHEAPTRONIC_V2) From 3ad684b10bc8a7c6631dda4e6615238499289013 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 11 Dec 2022 12:56:45 -0600 Subject: [PATCH 191/243] =?UTF-8?q?=F0=9F=94=A8=20Updated=20'mfconfig=20in?= =?UTF-8?q?it'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildroot/share/git/mfconfig | 13 +- buildroot/share/scripts/config-labels.py | 198 ----------------------- 2 files changed, 11 insertions(+), 200 deletions(-) delete mode 100755 buildroot/share/scripts/config-labels.py diff --git a/buildroot/share/git/mfconfig b/buildroot/share/git/mfconfig index b379317d9866..852885944621 100755 --- a/buildroot/share/git/mfconfig +++ b/buildroot/share/git/mfconfig @@ -140,8 +140,17 @@ if [[ $ACTION == "init" ]]; then cp -R "$TEMP/config" . find config -type f \! -name "Configuration*" -exec rm "{}" \; + addpathlabels() { + find config -name "Conf*.h" -print0 | while read -d $'\0' fn ; do + fldr=$(dirname "$fn") + blank_line=$(awk '/^\s*$/ {print NR; exit}' "$fn") + $SED -i~ "${blank_line}i\\\n#define CONFIG_EXAMPLES_DIR \"$fldr\"\\ " "$fn" + rm -f "$fn~" + done + } + echo "- Adding path labels to all configs..." - config-labels.py >/dev/null 2>&1 + addpathlabels git add . >/dev/null && git commit -m "Examples Customizations" >/dev/null @@ -149,7 +158,7 @@ if [[ $ACTION == "init" ]]; then cp -R "$TEMP/config" . # Apply labels again! - config-labels.py >/dev/null 2>&1 + addpathlabels git add . >/dev/null && git commit -m "Examples Extras" >/dev/null diff --git a/buildroot/share/scripts/config-labels.py b/buildroot/share/scripts/config-labels.py deleted file mode 100755 index b571a434b7e1..000000000000 --- a/buildroot/share/scripts/config-labels.py +++ /dev/null @@ -1,198 +0,0 @@ -#!/usr/bin/env python3 -# -# for python3.5 or higher -#----------------------------------- -# Within Marlin project MarlinFirmware/Configurations, this program visits all folders -# under .../config/examples/*, processing each Configuration.h, Configuration_adv.h, -# _Bootscreen.h, and _Statusscreen.h, to insert: -# #define CONFIG_EXAMPLES_DIR "examples/